TimeBlockData¶
- class flexops.core.time_block.TimeBlockData(component)¶
A discrete, bounded time horizon at a configurable resolution.
Holds the ordered integer time set (time_index), the elapsed-time Param (time,
i*dt), the unit-carrying step size (dt), datetime↔index utilities, and the rolling-horizon hooks (register_initial_state, window) thatflexscheduledrives. Time points are interval starts: pointiis the timestampstart_date + i * dt;end_dateis the exclusive horizon end and is not itself a time point.A single
TimeBlockspans at mostmax_length(default one calendar month); longer studies are composed from multipleTimeBlockblocks by the rolling-horizon driver or the design-mode wrapper.Example
>>> from pyomo.environ import units as pyunits >>> m = pyo.ConcreteModel() >>> m.time_block = TimeBlock( ... start_date="2025-01-01", end_date="2025-01-31", ... time_step=15 * pyunits.min, ... )
- property datetime_index: DatetimeIndex¶
timestamps of every time point.
- Type:
- property horizon¶
Total horizon length as a unit-carrying expression,
n_points * dt.
- index_of(timestamp) int¶
Return the time-point index for a timestamp.
- Parameters:
timestamp – A
pd.Timestamp,datetime, or ISO-8601 string that must fall exactly on a grid point.- Returns:
The integer time-point index.
- Raises:
FlexConfigError – If
timestampis off-grid or outside the horizon.
- property initial_state_params: tuple¶
the registered rolling-horizon initial states (fixed scalar Vars or mutable Params).
- Type:
- register_initial_state(param) None¶
Register a fixed scalar Var or mutable Param as initial state.
A fixed scalar
Var(as built bydeclare_process_parameter()) is preferred: a sweep can set it and a scenario can unfix it and solve for it in place. MutableParams are still accepted.- Parameters:
param – A fixed scalar Pyomo
Varor a mutableParam(e.g. tank level, battery SOC, on/off status) that the rolling-horizon driver sets between windows.- Raises:
FlexConfigError – If
paramis neither; if it is an indexed or unfixedVar; or if it is aParamdeclared withmutable=False.
- timestamp_of(i: int) Timestamp¶
Return the timestamp for a time-point index.
- Parameters:
i – A time-point index.
- Returns:
The corresponding
pd.Timestamp.- Raises:
FlexConfigError – If
iis outside[0, n_points).
- window(start: int, length: int) TimeWindow¶
Return metadata for a contiguous slice of the horizon.
- Parameters:
start – First time-point index of the window.
length – Requested number of time points; clipped if the window would run past the horizon.
- Returns:
The window metadata.
- Raises:
FlexConfigError – If
startis outside[0, n_points).