The config schema¶
flex-pse is config-driven. A whole model, its time horizon, property packages, costing, plants, units, operating logic and fixed variables, can be written as one version-controlled JSON file, the spec, and built from it. Building in Python stays fully supported, and the two meet in a loop:
code ──emit_model──► spec (JSON) ──build_model──► model
▲ │
└──────────── same model, compared ───────────────┘
emit_model() reads the spec a live model was, or
could have been, built from. build_model() turns a
spec back into a model. A model that survives the loop unchanged is fully
described by its file: it can be reviewed, diffed, rebuilt somewhere else and
changed without touching code. Round-trip a model walks
through the loop end to end.
The spec¶
A spec (FlowsheetSpec) is a header (the
schema_version, the model name, and the fix policy described below) and one
flat list of elements. Each element has a kind. The rules:
Names are full component paths. A unit named
"waterfacility.tank"is built asmodel.waterfacility.tank, so its parent, the plant"waterfacility", must be an element too.Elements refer to each other by name. A connection goes to
"waterfacility.plant.inlet"; astatuselement names the unit"plant.ro"(every member of an indexed unit) or"plant.ro[0]"(one).File order is irrelevant. The build sorts elements by kind, depth and name. Shuffling the list builds the same model, component for component.
So this scrambled spec is valid. It is the frozen API example, with the objective listed before the units it optimizes and the plant after the units inside it:
{
"schema_version": "0.1.1",
"name": "waterfacility",
"elements": [
{"kind": "unit", "name": "waterfacility.plant",
"unit_model_class": "ConstantEnergyIntensityModel",
"construction_options": {"energy_intensity": {"value": 0.5, "units": "kWh/m^3"}}},
{"kind": "objective", "name": "objective", "expression": "cost"},
{"kind": "unit", "name": "waterfacility.tank", "unit_model_class": "Tank",
"connections": [{"port": "outlet", "to": "waterfacility.plant.inlet"}]},
{"kind": "costing", "name": "costing", "tariff_source": "tariff.json",
"dr": {"events_source": "dr_events.json"}},
{"kind": "plant", "name": "waterfacility"},
{"kind": "time", "start_date": "2025-01-01", "end_date": "2025-01-30",
"time_step": "15 min"},
{"kind": "property_package", "name": "properties",
"property_class": "SimpleAqueousFlow"}
]
}
A quantity with units is data, not code: {"value": 0.5, "units": "kWh/m^3"},
or the string "15 min" for the time step. Units are written as Pyomo prints
them, with ** changed to ^.
Assembly order¶
build_model runs nine stages in a fixed order
(STAGES): declare, topology, degradation, surrogates,
ramping, logic, state, extensions, costing. Each kind belongs to one
stage, and is either mutable (it can be changed on a built model) or not:
Kind |
Stage |
Mutable |
|---|---|---|
|
declare |
no |
|
declare |
no |
|
declare |
no |
|
topology |
no |
|
topology |
no |
|
topology |
no |
|
topology |
no |
|
degradation |
no |
|
surrogates |
yes |
|
ramping |
no |
|
logic |
no |
|
logic |
no |
|
logic |
no |
|
logic |
no |
|
logic |
no |
|
logic |
no |
|
logic |
no |
|
state |
yes |
|
state |
yes |
|
state |
yes |
|
extensions |
no |
|
costing |
no |
Within the logic stage, kinds build in LOGIC_ORDER:
status first, because startup, conditional and parallel logic hang off a
status binary, and logic between units last. Degradation builds before
surrogates, so a surrogate element can replace the wear relations it registers.
Costing is processed last
because cost_process aggregates whatever is registered when it runs: every
power term a unit, a surrogate or an extension registers has to exist by then.
Mutable and immutable kinds¶
A kind is mutable when changing it on a solved, costed model leaves the
costing and the objective valid. Swapping a surrogate replaces a relation in
place, and fixing, unfixing or dispatching a variable changes only its value or
fixed flag. apply_spec() applies mutable elements to a
built model, and refuses an immutable one before changing anything.
Everything else changes the model’s structure, so it is changed in the spec and
rebuilt. Swapping a unit, for example, means editing its unit_model_class and
calling build_model again. flex-pse never deletes a component from a built
model, since anything that captured it would keep a stale reference.
A new element kind is classified the same way: it gets a stage and a mutability
flag in KINDS.
Data¶
Short lists sit inline. A long one, such as a year of prices, a dispatch series or a fixed demand profile, can live beside the spec:
{"kind": "fix", "variable": "plant.product.outlet_state.flow_vol_phase[*,Liq]",
"value": {"$source": "data/demand.json.gz"}}
A $source also works anywhere in a unit’s construction_options. A $source path is relative to the spec file and names a .json or gzipped
.json.gz file. emit_model(data_dir=..., inline_limit=2000) writes every list
longer than inline_limit this way, and relative_to= writes paths relative to
where the spec will be saved.
A unit that takes several property packages receives them as
{"$package": "biogas"} construction options, which name a property_package
element.
Fixing variables¶
A fix element names any variable by its path from the model root and
gives its values. An unfix element frees one, such as a parameter a unit
fixes by default:
{"kind": "fix", "variable": "plant.battery.charge[0]", "value": 5.0},
{"kind": "fix", "variable": "plant.pretreatment[*].status", "value": 1},
{"kind": "fix", "variable": "plant.intake.flow_in", "value": [120, 120, 95, 80], "units": "m^3/hr"},
{"kind": "unfix", "variable": "plant.ro[*].recovery"}
Paths are Pyomo ComponentUID strings. plant.x is a whole variable,
plant.x[3] one point, plant.ro[*].x the variable on every member of ro,
and plant.u.flow_vol_phase[*,Liq] every time point of the Liq phase. A
path that matches nothing is an error that suggests the closest variable names;
a path that matches a Param is an error too, since parameters are set, not
fixed.
Values come in four forms: one number for every matched point; a list with
one number per time point (or per entry of at); a {time index: value}
mapping; or a $source file holding a list or mapping. at restricts the fix
to some time indices. units converts the values into each variable’s own
units. The time index is the variable’s first index, when that is the
TimeBlock’s.
Conflicts are errors. Since file order is irrelevant, there is no “the later
fix wins”. Two fix or dispatch elements that set one point to different
values, or a fix and an unfix of the same point, stop the build and name the
elements involved. Two elements writing the same value are fine.
Bounds and domain. Pyomo itself only logs a warning when a variable is fixed
outside its bounds, or a binary to 0.5. The state stage checks every value
first, and what happens next is the policy: the element’s on_violation,
or the spec’s fix_on_violation when the element sets none.
Policy |
Outside bounds |
Outside domain (e.g. a binary to 0.5) |
Valid points |
|---|---|---|---|
|
Error |
Error |
Not fixed: nothing in the stage is applied |
|
Fixed anyway, with a |
Error |
Fixed |
|
Left free, with a |
Left free, with a |
Fixed |
A bound check passes within an absolute tolerance: the element’s tolerance,
or the spec’s fix_tolerance (1e-9). A skipped point is left free for the
solver, never clamped to its bound, since a clamped value is one nobody wrote.
The state stage is all or nothing: every fix, unfix and dispatch is planned and
checked before any of them changes the model. Every warned or skipped point is
also logged at WARNING, and listed in the model’s _flex_fix_report
(FixReport).
"warn" and "skip" let a run go on with commands that differ from what the
spec says. A spec that drives equipment with nobody reading the log should keep
the default "error", or escalate the warning so it stops the run:
warnings.simplefilter("error", FlexFixWarning).
emit_model writes .fix() and .unfix() calls made in code as these
elements. A variable fixed to one value over the whole horizon becomes one
number, the same fix on every member of an indexed unit becomes one [*]
element, and a fix on some time points uses at. Bounds changed in code
(setlb, setub) can’t be written yet and raise a FlexEmitWarning.
Logic, ramps and extensions¶
Each flexops.logic helper (except relax and unrelax, which are solve
strategy) has one element kind: status, startup_shutdown, dwell, bypass,
ramp, startup_delay, conditional, parallel_group and degradation. An element names
its unit and never sits inside it. The spec checks that every unit named exists
and that nothing is set twice on the same unit. Two status rules are checked
when the model is built, since only the unit knows them: logic needing an on/off
status must find one on the unit (a battery with unit_commitment.status builds
its own), and a status element may not target a unit whose
allows_status_element is False (Tank, BatteryModel).
An extension element names a user function, as "package.module:function" or
an entry point in the flexpse.extensions group, with JSON options. Decorating a
function with @flexops.extension makes calling it record the element. Logic
helpers called inside an extension record nothing, because rebuilding re-runs
the extension. An objective with "expression": "extension" means an extension
adds the objective. A spec that uses an extension builds only where its package
is installed.
What emit_model checks¶
emit_model rebuilds the spec it wrote and compares the two models. Anything the
spec can’t express yet, such as a constraint added by hand, an objective no
extension made, or a surrogate object built without a spec, raises a
FlexEmitWarning that names it. Nothing is dropped silently. Things that would
change the model if left out (an option with no spec form, indexed members
configured differently, an arc no {i} template fits) raise a
FlexConfigError.
Surrogates¶
A SurrogateSpec, carried by a surrogate
element, names a predefined surrogate class, one of
SurrogateType’s members, and an opaque data
mapping in the shape that class defines. The class (flexops.surrogates)
validates data and builds the Pyomo relationship. A type not yet implemented
raises NotImplementedError when the model is built (quadratic,
exponential and neural_network are reserved names, see
flexops.surrogates).
arima is implemented by ArimaSurrogate
and fitted by ArimaRegressor.
Every surrogate element carries the same envelope, whichever type it is and whether a fit, a live model or a person wrote it:
surrogate_typepicks the class that defines and validates the rest.configholds everything the surrogate needs besides its fitted values: variables and units, structure, options, and any state. Its shape belongs to the class (see flexops.surrogates).config_versionis the version of that type’s config format. A class migrates older versions of its own config when the surrogate is built.parametersmaps each fitted value, by the name the built block registers, to{"value": ..., "fixed": true|false}. A value is a number or a list (nested lists for a matrix).fixedcovers the whole parameter, defaults totrue, and is always written on emit. A free parameter may leave outvalueto start from the class’s documented initial guess. The names must match the class’s parameters exactly, so a typo is an error rather than a silently fixed coefficient.provenanceis free-form fit metadata.
The multilinear class
(MultilinearSurrogate) is a constant
plus a sum of coefficient * (product of distinct declared inputs). Each entry
of terms is a *-separated product of names from input_variables, each at
most once. The parameters are intercept, the constant term, plus one per
term, named by the term.
{
"kind": "surrogate",
"unit": "plant.pump",
"surrogate_type": "multilinear",
"config_version": 1,
"config": {
"input_variables": {"flow_out": "m^3/hr", "outlet_state.pressure": "Pa"},
"output_variables": {"power_electrical": "kW"},
"terms": ["flow_out", "outlet_state.pressure", "flow_out*outlet_state.pressure"]
},
"parameters": {
"intercept": {"value": 5.0, "fixed": true},
"flow_out": {"value": 0.42, "fixed": true},
"outlet_state.pressure": {"value": 1.1e-5, "fixed": true},
"flow_out*outlet_state.pressure": {"value": 2.3e-6, "fixed": true}
}
}
An arima surrogate puts its order, deterministic term, options and
pre-horizon history in config, and names its coefficients intercept (or
drift), ar.L1, ma.L1 and exog.<input>. Naming each exogenous
coefficient after its input keeps the pair together even if a JSON tool
reorders input_variables. Here one coefficient is left free for estimation:
{
"kind": "surrogate",
"unit": "plant.ro",
"relation": "power_electrical_relation",
"surrogate_type": "arima",
"config_version": 1,
"config": {
"order": [1, 0, 1],
"deterministic": "intercept",
"input_variables": {"permeate": "m^3/hr"},
"output_variables": {"power_electrical": "kW"},
"history": {
"start_date": "2025-01-01T00:00:00",
"time_step_seconds": 3600.0,
"eta_values": [1.0],
"eps_values": [0.0]
}
},
"parameters": {
"intercept": {"value": 2.0, "fixed": true},
"ar.L1": {"value": 0.5, "fixed": false},
"ma.L1": {"value": 0.2, "fixed": true},
"exog.permeate": {"value": 0.8, "fixed": true}
}
}
A constant_intensity surrogate swaps no relation. It sets the unit’s own
energy_intensity, its one parameter:
{
"kind": "surrogate",
"unit": "plant.pump",
"surrogate_type": "constant_intensity",
"parameters": {"energy_intensity": {"value": 0.9, "fixed": true}}
}
A unit can carry several surrogates, one element per relation. An RO skid can
have one on split_definition and another on power_electrical_relation.
Building, applying or emitting a surrogate logs which of its parameters are
free, at INFO when any are and at DEBUG when all are fixed.
The declared units are the basis the relationship was fitted in. Each input
converts from the model’s units into its declared ones before the coefficient
multiplies it, and the result converts into the target’s units. A dimensionally
incompatible declaration raises a FlexConfigError instead of silently
rescaling.
Only relationships a unit registered with
register_relation() can be swapped:
every constant-intensity energy relation, an RO skid’s split_definition, a
tank’s level_definition. Conservation constraints are never registered, so
they can never be swapped. iter_swapped_relations()
reports which registered relations have been swapped.
Versioning¶
Every spec carries a mandatory schema_version, a semantic version string
(SCHEMA_VERSION). On load, a missing, malformed
or too-new version raises a FlexConfigError, and an older one steps through
MIGRATIONS before validation. Pydantic models in
flexcore.config.spec are the schema authority and reject undocumented keys.
Schema 0.2.0 replaced each surrogate element’s data with config and
parameters. A 0.1.1 file still loads: every coefficient the old build
created becomes a fixed parameter at the value the old build gave it, so the
migrated spec builds the same model. A saved standalone surrogate spec can be
upgraded with migrate_surrogate_spec().
Changes to one surrogate type’s config don’t change the schema version; that
type bumps its own config_version instead.
Their exported JSON Schema is checked in under src/flexcore/config/schemas/,
so schema changes show up in review and other tools can validate against it.
Changing the default fix policy is a breaking change and needs a new version.
Version 0.1.1 renames the BatteryModel capacity option and Var to
energy_capacity; a 0.1.0 spec is rewritten on load, except for extension
functions, which are user code.
The FlexParameterize and FlexOps seam¶
The spec is also the contract between FlexParameterize and FlexOps.
FlexParameterize changes a live FlexOps model in place, and
emit_model() writes that model out as a spec that
rebuilds it.
Field reference¶
Field |
Type |
Default |
Description |
|---|---|---|---|
schema_version |
str |
required |
Semantic schema version of this spec, an X.Y.Z string; mandatory, no default. |
name |
str |
required |
Name of the Pyomo ConcreteModel. |
solver |
str | None |
None |
Optional solver name; None lets the facade pick. |
elements |
list |
required |
Every element of the flowsheet; order is irrelevant. |
fix_on_violation |
Literal |
‘error’ |
Default bounds/domain policy for every fix element that doesn’t set its own. |
fix_tolerance |
float |
1e-09 |
Default absolute tolerance for the fix bounds check. |
Field |
Type |
Default |
Description |
|---|---|---|---|
start_date |
str |
required |
Inclusive ISO-8601 start of the horizon. |
end_date |
str |
required |
Exclusive ISO-8601 end of the horizon. |
time_step |
str |
required |
Time-step as a units-carrying expression string, e.g. ‘15 min’; parsed at build time. |
kind |
Literal |
required |
Field |
Type |
Default |
Description |
|---|---|---|---|
property_class |
str |
required |
Name of a flexops property-package class, e.g. ‘SimpleAqueousFlow’ or ‘SimpleGasFlow’. |
options |
dict |
PydanticUndefined |
Keyword options passed to the property-package constructor, e.g. {‘has_pressure’: true}. |
kind |
Literal |
required |
|
name |
str |
required |
Name of the package on the model. |
Field |
Type |
Default |
Description |
|---|---|---|---|
kind |
Literal |
required |
|
name |
str |
required |
Name of the costing block on the model. |
tariff_source |
str | list[str] | dict[str, str] | None |
None |
Where the EECO tariff comes from: one file or tag, a list of them to merge, or a mapping of EECO utility (‘electric’/’gas’) to file to merge and also assign each file to a utility. Omit to price every carrier from energy_prices instead. |
energy_prices |
dict[str, flexcore.config.spec.SourcedPrice] | None |
None |
Optional native prices keyed by carrier or fuel name (‘electrical’, or a fuel such as ‘natural_gas’). A carrier priced here is billed at that price instead of through the tariff, so a run with every carrier priced needs no tariff at all. Each price is flat over the horizon or given per time point. |
export_prices |
dict[str, flexcore.config.spec.SourcedPrice] | None |
None |
Optional prices paid for exports, keyed like energy_prices (‘electrical’ or a fuel name). Each key needs a matching energy_prices entry and must not exceed it at any time point. A carrier left out credits exports at its import price. |
decomposition_type |
str | None |
None |
Optional EECO decomposition of net electrical power and fuel usage into imports and exports on the tariff path (e.g. ‘linear’), so the tariff’s export charges apply. Passed straight to EECO. |
currency |
str |
‘USD’ |
Currency basis to use when no tariff is given; a tariff’s own currency basis always wins. |
dr |
flexcore.config.schema.DRConfig | None |
None |
Optional demand-response container (containers-only in v0). |
consumption_estimate |
dict[typing.Literal[‘electric’, ‘gas’], float] | None |
None |
Estimated total consumption over the horizon, keyed by EECO utility (‘electric’/’gas’; kWh / m^3). EECO needs it to price any tier other than a flat top tier. |
fixed_operating_cost |
float |
0.0 |
Fixed operating cost over the horizon, in the currency basis in force (a tariff’s own, else ‘currency’): non-tariff costs such as maintenance, labor, and chemicals. Distinct from the tariff’s own fixed charge (which EECO includes in the electricity cost). |
prorate_monthly_charges |
bool |
True |
Prorate a tariff’s monthly-assessed demand charge and fixed (customer) charge to the horizon length when the horizon is shorter than the calendar month it starts in. False bills the full monthly charges. |
lifetime_years |
float |
20.0 |
Plant lifetime in years (> 0), used with the effective rate to form the capital recovery factor that annualizes capital cost. |
discount_rate |
float |
0.08 |
Annual discount rate (fraction, e.g. 0.08 = 8%). Used alone as the effective rate when interest_rate is unset; otherwise it deflates interest_rate into a real effective rate. An effective rate of 0 falls back to straight-line 1/lifetime. |
interest_rate |
float | None |
None |
Optional annual cost of capital (fraction, e.g. 0.06). When given, the capital recovery factor uses the effective rate (1 + interest_rate) / (1 + discount_rate) - 1. Omit to use discount_rate alone. |
Field |
Type |
Default |
Description |
|---|---|---|---|
kind |
Literal |
required |
|
name |
str |
required |
Dotted path of the network on the model. |
Field |
Type |
Default |
Description |
|---|---|---|---|
kind |
Literal |
required |
|
name |
str |
required |
Dotted path of the plant on the model. |
Field |
Type |
Default |
Description |
|---|---|---|---|
kind |
Literal |
required |
|
name |
str |
required |
Dotted path of the set on the model. |
values |
list |
required |
The set’s members, in order; non-empty and unique. |
Field |
Type |
Default |
Description |
|---|---|---|---|
kind |
Literal |
required |
|
name |
str |
required |
Dotted path of the unit on the model. |
unit_model_class |
str |
required |
Name of the flexops unit-model class to construct. |
construction_options |
dict |
PydanticUndefined |
Keyword options passed to the unit-model constructor. A value {‘$package’: name} passes the named property_package element. |
property_package |
str | None |
‘auto’ |
Name of a property_package element. ‘auto’ means the model’s only one (an error if it has several); null gives the unit none. |
costing_package |
str | None |
‘auto’ |
Name of a costing element. ‘auto’ means the model’s only one; null leaves the unit uncosted. |
index |
str | None |
None |
Name of a set element; the unit is built once per member. |
connections |
list |
PydanticUndefined |
Arcs leaving this unit. Each arc is written once, on its source unit. |
io_variables |
list |
PydanticUndefined |
Declared process input/output variables of the unit. |
unit_commitment |
flexcore.config.schema.UnitCommitmentConfig | None |
None |
Per-unit unit-commitment configuration. Unset (null) leaves the unit model’s own default in force. |
Field |
Type |
Default |
Description |
|---|---|---|---|
port |
str |
required |
Port on the owning unit, e.g. ‘outlet’. |
to |
str |
required |
Destination as ‘<unit element name>.<port path>’; may contain ‘{i}’ for an indexed connection. |
name |
str | None |
None |
Name of the arc on the model; omitted: derived from the endpoints. |
doc |
str | None |
None |
Optional arc description. |
index |
str | None |
None |
Name of a set element to index the arc over; omitted: the owning unit’s index, if it has one. |
directed |
bool |
True |
False builds an undirected arc between the two ports. |
Field |
Type |
Default |
Description |
|---|---|---|---|
surrogate_type |
SurrogateType |
required |
Which predefined surrogate class this relationship is. The class (flexops.surrogates) validates config and parameters and builds the relationship; a class not yet implemented raises NotImplementedError when the model is built, not when the config is validated. |
config_version |
int |
1 |
Version of this surrogate type’s config format. Each surrogate class migrates older versions of its own config when it is built. Always written on emit. |
config |
dict |
PydanticUndefined |
Everything the surrogate needs besides its parameters (variables and units, structure, options, state such as an ARIMA history), in the shape surrogate_type’s class defines and validates. Opaque to the schema; see the flexops.surrogates reference page for each class’s config. |
parameters |
dict |
PydanticUndefined |
The surrogate’s fitted values, keyed by the names its class registers (for example ‘intercept’, ‘ar.L1’, ‘exog.feed’). The names must match the class’s parameters exactly. |
provenance |
dict |
PydanticUndefined |
Free-form fit metadata (metrics, data window, versions). |
kind |
Literal |
required |
|
unit |
str |
required |
Name of the unit element it applies to. |
relation |
str |
‘power_electrical_relation’ |
Name of the unit’s relation to replace. |
name |
str | None |
None |
Optional label; not used to build anything. |
Field |
Type |
Default |
Description |
|---|---|---|---|
kind |
Literal |
required |
|
unit |
str |
required |
Name of the unit element, or ‘name[i]’ for one member of an indexed unit. |
variable |
str |
required |
Path of the time-indexed variable relative to the unit, e.g. ‘flow_in’. |
ramp_up |
float | None |
None |
Largest increase per step, in units. |
ramp_down |
float | None |
None |
Largest decrease per step, in units. |
units |
str |
required |
Units of ramp_up and ramp_down, e.g. ‘kW/h’. |
window |
int |
1 |
Number of steps the ramp is measured across. |
component_name |
str | None |
None |
Stem of the built component names; omitted: ‘<variable>_ramp’. |
name |
str | None |
None |
Optional label; not used to build anything. |
Field |
Type |
Default |
Description |
|---|---|---|---|
kind |
Literal |
required |
|
unit |
str |
required |
Name of the unit element, or ‘name[i]’ for one member of an indexed unit. |
variable |
str |
required |
Path of the time-indexed variable relative to the unit, e.g. ‘flow_in’. |
min_output |
float | flexcore.config.spec.Quantity |
required |
Output when on, lower limit: a number or a quantity. |
max_output |
float | flexcore.config.spec.Quantity |
required |
Output when on, upper limit: a number or a quantity. |
name |
str | None |
None |
Optional label; not used to build anything. |
Field |
Type |
Default |
Description |
|---|---|---|---|
kind |
Literal |
required |
|
unit |
str |
required |
Name of the unit element, or ‘name[i]’ for one member of an indexed unit. |
min_up |
int |
1 |
Minimum steps on after a startup. |
min_down |
int |
1 |
Minimum steps off after a shutdown. |
name |
str | None |
None |
Optional label; not used to build anything. |
Field |
Type |
Default |
Description |
|---|---|---|---|
kind |
Literal |
required |
|
unit |
str |
required |
Name of the unit element, or ‘name[i]’ for one member of an indexed unit. |
variable |
str |
required |
Path of the time-indexed variable relative to the unit, e.g. ‘flow_in’. |
k |
int |
required |
Block length in steps. |
name |
str | None |
None |
Optional label; not used to build anything. |
Field |
Type |
Default |
Description |
|---|---|---|---|
kind |
Literal |
required |
|
unit |
str |
required |
Name of the unit element, or ‘name[i]’ for one member of an indexed unit. |
variable |
str |
required |
Path of the time-indexed variable relative to the unit, e.g. ‘flow_in’. |
max |
float | flexcore.config.spec.Quantity |
required |
Upper limit on the bypassed flow: a number or a quantity. |
name |
str | None |
None |
Optional label; not used to build anything. |
Field |
Type |
Default |
Description |
|---|---|---|---|
kind |
Literal |
required |
|
unit |
str |
required |
Name of the unit element, or ‘name[i]’ for one member of an indexed unit. |
upstream |
str |
required |
Name of the unit element that must run first. |
k |
int |
required |
Steps the unit lags behind the upstream unit. |
initially_on |
bool |
True |
Whether the upstream unit counts as already warmed up at the start of the horizon. |
name |
str | None |
None |
Optional label; not used to build anything. |
Field |
Type |
Default |
Description |
|---|---|---|---|
kind |
Literal |
required |
|
unit |
str |
required |
Name of the unit element, or ‘name[i]’ for one member of an indexed unit. |
implies |
str |
required |
Name of the unit element whose state follows. |
state |
Literal |
‘on’ |
State of the implied unit while this one is on. |
name |
str | None |
None |
Optional label; not used to build anything. |
Field |
Type |
Default |
Description |
|---|---|---|---|
kind |
Literal |
required |
|
units |
list |
required |
Unit element names, in priority order. |
variables |
list |
PydanticUndefined |
Variables ordered the same way across the group. |
order_status |
bool |
True |
Whether to order the units’ status binaries. |
name |
str | None |
None |
Optional label; not used to build anything. |
Field |
Type |
Default |
Description |
|---|---|---|---|
kind |
Literal |
required |
|
unit |
str |
required |
Name of the unit element it applies to. |
variable |
str |
required |
Name of the time-indexed variable on the unit. |
values |
list[float] | dict[str, float] | flexcore.config.spec.SourceRef |
required |
One value per time point as a list, a mapping of time index to value, or a $source reference to a file holding either. |
fix |
bool |
True |
Whether to fix the variable to the values (removing its degrees of freedom). |
name |
str | None |
None |
Optional label; not used to build anything. |
Field |
Type |
Default |
Description |
|---|---|---|---|
kind |
Literal |
required |
|
name |
str | None |
None |
Optional id, used in error messages. |
variable |
str |
required |
Pyomo ComponentUID path from the model root, e.g. ‘plant.pump.flow_in’, ‘plant.pump.flow_in[3]’, ‘plant.ro[*].status’ or ‘plant.u.flow_vol_phase[,Liq]’. A star () matches every index in that position. |
value |
float | list[float] | dict[str, float] | flexcore.config.spec.SourceRef |
required |
One number for every matched point; a list with one number per time point (or per entry of at); a {time index: value} mapping; or a $source file holding either. |
units |
str | None |
None |
Units of value; omitted means each variable’s own units. |
at |
list[int] | None |
None |
Only fix these time indices; omitted means every matched point. |
on_violation |
Optional |
None |
What to do when a value is outside the variable’s bounds or domain: ‘error’ raises and fixes nothing; ‘warn’ fixes out-of-bounds points anyway and warns; ‘skip’ leaves violating points unfixed, fixes the rest, and warns. Omitted means the spec’s fix_on_violation. |
tolerance |
float | None |
None |
Absolute tolerance for the bounds check, in the variable’s units. Omitted means the spec’s fix_tolerance. |
Field |
Type |
Default |
Description |
|---|---|---|---|
kind |
Literal |
required |
|
name |
str | None |
None |
Optional id, used in error messages. |
variable |
str |
required |
ComponentUID path from the model root, as for fix. |
Field |
Type |
Default |
Description |
|---|---|---|---|
kind |
Literal |
required |
|
name |
str |
required |
Name of this call; unique among extensions. |
entry_point |
str |
required |
‘package.module:function’, or the name of an entry point in the ‘flexpse.extensions’ group. |
options |
dict |
PydanticUndefined |
Keyword options passed to the function. |
Field |
Type |
Default |
Description |
|---|---|---|---|
kind |
Literal |
required |
|
name |
str |
‘objective’ |
Name on the model. |
expression |
Literal |
‘cost’ |
‘cost’ optimizes a costing element’s cost; ‘extension’ means an extension adds the objective. |
costing_package |
str |
‘auto’ |
Name of the costing element whose cost is optimized; ‘auto’ means the model’s only one. |
sense |
Literal |
‘minimize’ |
Direction of optimization. |
Field |
Type |
Default |
Description |
|---|---|---|---|
surrogate_type |
SurrogateType |
required |
Which predefined surrogate class this relationship is. The class (flexops.surrogates) validates config and parameters and builds the relationship; a class not yet implemented raises NotImplementedError when the model is built, not when the config is validated. |
config_version |
int |
1 |
Version of this surrogate type’s config format. Each surrogate class migrates older versions of its own config when it is built. Always written on emit. |
config |
dict |
PydanticUndefined |
Everything the surrogate needs besides its parameters (variables and units, structure, options, state such as an ARIMA history), in the shape surrogate_type’s class defines and validates. Opaque to the schema; see the flexops.surrogates reference page for each class’s config. |
parameters |
dict |
PydanticUndefined |
The surrogate’s fitted values, keyed by the names its class registers (for example ‘intercept’, ‘ar.L1’, ‘exog.feed’). The names must match the class’s parameters exactly. |
provenance |
dict |
PydanticUndefined |
Free-form fit metadata (metrics, data window, versions). |