1. A system for electricity and heat load balancing within a community of energy nodes, the system comprising: a central control device configured to solve an optimization problem over a planning horizon and to run an allocation algorithm; and a plurality of local agent devices configured to communicate with the central control device, each of the local agent devices being associated with and configured to receive input variables or parameters from a respective one of the energy nodes, each of the energy nodes having electricity generation equipment, electrical heat-generating equipment, power transmission equipment, electricity storage equipment and thermal storage equipment, at least one of the local agent devices being configured to operate the respective electrical heat-generating equipment based on an allocation instruction received from the central control device, wherein the central control device is configured to receive status information from each of the local agent devices and use the status information in the allocation algorithm to determine an amount of energy to be converted from electricity to heat by the respective electrical heat-generating equipment of at least one of the energy nodes, so as to provide the allocation instruction to the at least one of the energy nodes.