Operation window
Note
Experimental (#128). The API of this page serves two packages under development, a weekly stochastic dual dynamic programming of the seasonal stocks and a myopic operation driven by usage values, and may change until they settle: a future-cost variable with cuts on the end states, a persistent driver of the window, and more switchable series are planned.
pommes.solver.build_operation_window() builds the pommes operation
model on a contiguous window of hours of one operation year, capacities
fixed to a design, with the stocks at the bounds of the window as
states: the storage levels and the remaining annual production budgets
enter the window as parameters whose duals are the marginal values of the
stored energy and of the budget, and leave it as free variables. It is the
stage problem of an operating policy that does not foresee the rest of the
year, and the brick that a decomposition of the year into weeks solves at
each stage.
The window model
The window is built by pommes.model.build_model.build_model() from the
dataset of the planning problem, sliced and rescaled:
the dataset is sliced to one
year_op, one operating condition if the dataset has them, and a contiguous run ofhourlabels;every
*annuity_cost*parameter is set to zero and every*fixed_cost*parameter is multiplied by the share of the year the window covers (OperationWindow.share), so that a window pays its share of the fixed costs and nothing of the investments;operation_year_durationis set to the duration of the window, so that the normalisation of the operational costs is one and the objective is the cost of the window itself. The discount factor and the operation-year weight of the year (pommes.utils.objective_year_weight()) are kept, a constant factor over the windows of a year; the weight of the operating condition is set to one, the expectation over conditions being the caller’s business;the planning decisions (
Catalogue.fixed_in_subproblem, see Architecture) are kept and pinned by equality rowsbenders_fix_*, as inpommes.solver.benders.build_subproblem();OperationWindow.set_capacities()rewrites their right-hand side.pommes.solver.operation_window.capacities_from_solution()reads them off a solved planning model or its solution dataset;the pure planning constraints (
Catalogue.dropped_from_subproblem) are removed, and so are the annual couplings (Catalogue.annual_couplings) that the dataset left a row to: the carbon goal, the yearly import and export ceilings, the yearly ceilings of combined technologies and production groups, the conservation of flexible demand over the year. They are listed inOperationWindow.dropped_constraints; the yearly ceiling of a budgeted technology, which has no row, is not. A yearly import or export ceiling of zero survives as a zero bound on the hourly variable (rowswindow_zero_<parameter>); a finite positive one is reported as unenforced in the log;ramp constraints across the window boundary are not written: the first hour of a window ramps freely;
with
penalty_cost, the adequacy rows receive the elastic slacks of Benders (pommes.solver.benders._add_elastic_slacks()), so that a window short of energy is feasible at a price.
States
Two optional parameters of the dataset, both nan by default so that
build_model() is unchanged without them,
open the stocks at the bounds of the horizon:
storage_initial_level[area, storage_tech, year_op, operating_condition]A storage with a finite value is opened instead of cycling over the year (
pommes.model.storage.storage_windowed()). Its level before the first hour is the variableoperation_storage_initial_level, pinned to the parameter by the rowoperation_storage_initial_level_def; the level recursion of the other hours isoperation_storage_level_window_def(a shift, not a roll) and that of the first houroperation_storage_level_initial_def. The level at the last hour is free within the energy capacity.conversion_initial_production_budget[area, conversion_tech, year_op, operating_condition]A technology with a finite value carries its annual ceiling as a budget state (
pommes.model.conversion.conversion_budgeted()):operation_conversion_production_budget_inis pinned to the parameter byoperation_conversion_production_budget_in_def, the production of the window is drawn from it (operation_conversion_production_budget_def) andoperation_conversion_production_budget_out >= 0is what remains. The yearly cap row is not written for a budgeted technology.
build_operation_window() sets both for every storage and for every
technology with a finite conversion_max_yearly_production. The window
then exposes the states:
OperationWindow.set_state()writes the right-hand sides of the pinning rows (STATE_IN_CONSTRAINTS, the public names of the state groups; each row is thestate_inof its state in the catalogue, and a catalogued state the window does not expose raisesNotImplementedError), one array per state group;OperationWindow.state_duals()reads their duals after a solve. The dual of a storage row is the derivative of the window cost with respect to the initial level: minus the dual is the water value of that storage, in the objective units of the window;OperationWindow.state_out_values()reads the end states (STATE_OUT_VARIABLES: the storage level at the last hour, the budget left) andOperationWindow.fix_state_out()pins them, for a decomposition that hands a trajectory down.
Switching the hourly series
Switching the operating condition of a window is not only a right-hand-side
update: the availabilities multiply the pinned capacity variables, so they
are matrix coefficients. OperationWindow.set_time_series() rewrites in
place, on the linopy model, the rows and coefficients that the hourly series
of another dataset or condition enter, following
pommes.solver.operation_window.TIME_SERIES_RULES:
demandas the right-hand side of the adequacy rows;conversion_availabilityas the coefficient of the pinned capacity in the power-limit rows and the must-run equality rows;the import emission factors in the carbon rows;
the flexible-demand series in their rows.
Any other parameter with an hour or operating_condition dimension
that differs between the two datasets – costs and prices, which are
objective coefficients, time_step_duration – is refused by name, as is
a change of the mask a rule shapes: build a new window for those. One
window model per stage thus serves every operating condition of a dataset
whose conditions differ by their series only.
The TimeSeriesUpdate returned
holds the same change in linopy labels and replays it on a persistent
solver object built from the model
(TimeSeriesUpdate.apply(), through the update_row_rhs and
update_coefficients methods of every backend of
pommes.solver.persistent), so that the solver model of a window is
built once and patched between solves.
Relation to the sub-periods
The decomposition by Sub-periods of the Benders page
(pommes.model.subperiods.split_into_subperiods(), #145) also cuts the
operation years into weeks with the storage levels at their bounds as
coupling variables, but it keeps the whole year in one planning problem:
the bound levels are planning variables of the master, and the weeks are
subproblems with perfect foresight of the master’s trajectory. The
operation window is the opposite reading of the same cut: capacities and
the trajectory are given, one week is solved on its own, and what the
window returns – its cost, its end states and the duals of its start
states – is for the caller to turn into a policy.