Skip to content

Generic constraints

A generic constraint is a linear rule that you define yourself: a weighted sum of model quantities, such as storages, flows, generation and deficits, that must respect a floor, a cap, an equality or a band. Optionally, it has a penalized slack that relaxes it instead of making the problem infeasible.

A language for your own rules

The constraint is written as an expression over a catalogue of model variables (storages, flows, generation, line flows, deficits and others), with coefficients that can be numbers or named parameters.

The shape follows from the limits

A lower limit alone is a floor; an upper limit alone, a cap; two identical limits, an equality; two different limits, a band. There is no separate field to choose the shape.

Relaxing the rule has a price

With the slack enabled, the constraint is relaxed at a cost per unit of violation instead of making the stage problem infeasible. Without a slack, the constraint cannot be relaxed.

A weighted sum of model quantities must respect the limits you define penalized slack penalized slack cost grows with the violation cost grows with the violation allowed values floor cap weighted sum of quantities (per stage and block) The shape follows from which limits are present floor lower limit only cap upper limit only equality identical limits band two different limits
Figure: a generic constraint and its optional penalized slack. Schematic illustration, not to scale.
  • Value of the expression, in each active stage and block unit of the quantities (MW, m³/s, MWh, hm³)
  • Constraint slack, when enabled same unit as the row

The model chooses the values of the quantities in the expression so that it respects the limits. The slack is used only when the limit cannot be met otherwise, and each unit of violation is charged at the declared cost.

  • The constraints, in generic_constraints.json: each has an identifier, a name, the linear expression and the slack configuration, which is required on every constraint.
  • Where each constraint is active and its limits, in generic_constraint_bounds.parquet: one row per constraint, stage and, optionally, block.
  • Optionally, named scalar parameters, in generic_parameters.json, which expressions and limits reference as @name.
  • For each enabled slack, the penalty (greater than zero) and the penalty basis.

The bounds file is the activation grid: there is no other activation flag. A constraint is active at a stage and block if, and only if, a row exists for it there. A null block in the row applies to all blocks of the stage. The limits can come from the row itself, from the expression (for example a constant on the right-hand side), or from both, which add up at the same endpoint. A constraint whose limits come only from the expression, with no row in the grid, is rejected at validation.

The slack is declared once per constraint and applies to every row the grid produces. A one-sided limit has one slack column; a two-sided limit (band or equality) has two, one for each direction, at the same cost per unit. In the results, the violation of a two-sided row is reported as the signed net of the two.

The penalty basis says what one unit of violation is and, therefore, how the penalty becomes a cost:

  • Per hour. For a row whose quantity is a rate (MW, m³/s): the penalty is a price per unit and per hour, multiplied by the hours the row covers.
  • Per unit. For a row whose quantity is an amount (MWh, hm³): the penalty is a price per unit, whatever the duration of the stage.

The basis is declared, never inferred from the expression: choose it by the unit of the row, not by the variables it contains.

The model writes the resolved echo: the fully resolved form of every constraint built, one row per constraint, stage, block and term. The simulation writes, in simulation/violations/generic/, the slack cost of each row at the same cost per unit used in the problem. The cost of generic-constraint violations also appears as a column of the per-stage cost breakdown.