A computer-implemented hierarchical optimization method for real-time balancing of power production and power consumption in a localized smart energy management system comprising a plurality of controllable loads, at least one intermittent energy source, and a selectively connectable dispatchable energy source, the method comprising:
- in a first, upper layer of hierarchical optimization:
- providing forecasts of long-term demand profiles for the plurality of controllable loads and providing forecasts of long-term power generation profiles for the at least one intermittent energy source, wherein the long-term demand profile and power generation profile are forecasted over a first planning interval;
- solving in a first solver module associated with the first, upper layer of hierarchical optimization a first constrained optimization problem with the provided forecasts of long-term demand profiles and power generation profiles as inputs, thereby generating a coarse-grained predicted schedule comprising a plurality of checkpoints distributed with a coarse temporal resolution determined by a first timescale over the first planning interval, each checkpoint having associated thereto a value of at least one control variable for controlling the plurality of loads and/or a power transfer to the plurality of loads from the selectively connectable dispatchable energy source and/or a power transfer from the at least one intermittent energy source over the first planning interval and with the coarse temporal resolution determined by the first timescale;
- extracting, from the coarse-grained predicted schedule, coarse-grained power reference curves for an overall power consumption by the plurality of controllable loads and for the power transfer to the plurality of loads from the selectively connectable dispatchable energy source;
- and
- outputting to a second, lower layer of hierarchical optimization, a portion of each of the power reference curves for the overall power consumption by the plurality of controllable loads and for the power transfer to the plurality of loads from the selectively connectable dispatchable energy source;
- and
- in the second, lower layer of hierarchical optimization:
- providing, to the second, lower layer of hierarchical optimization, multiple successive forecasts of short-term power generation profiles for the at least one intermittent energy source over a second planning interval shorter than the first planning interval;
- detecting, within the second planning interval, short-term imbalances between the generated power by the at least one intermittent energy source and power demand by the plurality of loads with a fine temporal resolution determined by a second timescale over the second planning interval, the fine temporal resolution being at least a factor of ten smaller than the coarse temporal resolution;
- solving in a second solver module associated with the second, lower layer of hierarchical optimization a second constrained optimization problem with the provided forecasts of short-term power generation profiles, the portions of the coarse-grained power reference curves for the overall power consumption by the plurality of controllable loads and for the power transfer to the plurality of loads from the selectively connectable dispatchable energy source as inputs, thereby iteratively, upon receiving a new forecast of a short-term power generation profile for at least one intermittent energy source, refining the coarse-grained schedule over the second planning interval and thereby generating a fine-grained refined schedule comprising a plurality of checkpoints distributed with the fine temporal resolution determined by the second timescale over the second planning interval, each checkpoint having associated thereto a value of at least one control variable for controlling the plurality of loads and/or the power transfer to the plurality of loads from the selectively connectable dispatchable energy source over the second planning interval and with the fine temporal resolution determined by the second timescale, and
- compensating, with the fine temporal resolution, detected short-term imbalances by transmitting for each checkpoint of the refined schedule the value of the at least one control variable associated thereto to the one or more loads and/or to a switch for selectively connecting the dispatchable energy source.