Capacity Limits
Process formulation
Unless stated otherwise, all formulations shown for Link apply analogously to Process by replacing with and Link-* with Process-* in the constraint names.
Upper and Lower Bounds
If the nominal capacity of a components is also the subject of optimisation (e.g. with decision variable for generators), limits on the installable capacity may also be introduced (e.g. and ):
| Constraint | Dual Variable | Name |
|---|---|---|
n.generators.mu_lower | Generator-ext-p_nom-lower | |
n.generators.mu_upper | Generator-ext-p_nom-upper | |
n.links.mu_lower | Link-ext-p_nom-lower | |
n.links.mu_upper | Link-ext-p_nom-upper | |
n.processes.mu_lower | Process-ext-p_nom-lower | |
n.processes.mu_upper | Process-ext-p_nom-upper | |
n.{lines,transformers}.mu_lower | {Line,Transformer}-ext-s_nom-lower | |
n.{lines, transformers}.mu_upper | {Line,Transformer}-ext-s_nom-upper | |
n.stores.mu_lower | Store-ext-e_nom-lower | |
n.stores.mu_upper | Store-ext-e_nom-upper | |
n.storage_units.mu_lower | StorageUnit-ext-p_nom-lower |
These constraints are set in the function define_nominal_constraints_for_extendables.
Committable and Extendable Components
When components are both committable (committable=True) and extendable (e.g. p_nom_extendable=True), the optimizer co-optimizes both capacity expansion and operational unit commitment. The challenge is that the upper bound on dispatch becomes nonlinear: (the product of binary status and continuous capacity ). To maintain a Mixed-Integer Linear Programme (MILP), PyPSA uses a big-M formulation that replaces this nonlinear constraint with two linear constraints:
GeneratorLinkProcess
| Constraint | Name |
|---|---|
Generator-com-ext-p-upper-bigM | |
Generator-com-ext-p-upper-cap | |
Generator-com-ext-p-lower | |
Generator-com-ext-p-lower-nonneg |
| Constraint | Name |
|---|---|
Link-com-ext-p-upper-bigM | |
Link-com-ext-p-upper-cap | |
Link-com-ext-p-lower | |
Link-com-ext-p-lower-nonneg |
| Constraint | Name |
|---|---|
Process-com-ext-p-upper-bigM | |
Process-com-ext-p-upper-cap | |
Process-com-ext-p-lower | |
Process-com-ext-p-lower-nonneg |
where is a sufficiently large constant (the "big-M") and , , are the maximum per-unit dispatch limits (p_max_pu, default 1). When the status , the big-M constraint forces dispatch to zero. When , the lower bound becomes (minimum part-load) and the upper bound is (capacity limit).
Big-M Parameter Configuration
The big-M constant must be large enough to not constrain the optimization, but not so large as to cause numerical issues. PyPSA automatically infers an appropriate value based on the network's peak load:
where is the load at bus and time . The factor of 10 provides a safety margin.
The big-M value can be manually overridden using the committable_big_m parameter:
n.optimize(committable_big_m=value)Big-M Size Warning
If the optimized capacity , or exceeds the big-M value, PyPSA will issue a warning. In this case, increase the big-M value manually to ensure the formulation remains valid.
Ramp Constraints for Extendable Committable Components
For components that are both committable and extendable with ramp limits, a big-M formulation is used to handle the interaction between ramp limits and the commitment status. Four constraints are added — two for ramping up (during normal operation and during start-up) and two for ramping down (during normal operation and during shut-down):
GeneratorLinkProcess
| Constraint | Name |
|---|---|
Generator-p-ramp_limit_up-run-bigM | |
Generator-p-ramp_limit_up-start-bigM | |
Generator-p-ramp_limit_down-run-bigM | |
Generator-p-ramp_limit_down-shut-bigM |
| Constraint | Name |
|---|---|
Link-p-ramp_limit_up-run-bigM | |
Link-p-ramp_limit_up-start-bigM | |
Link-p-ramp_limit_down-run-bigM | |
Link-p-ramp_limit_down-shut-bigM |
| Constraint | Name |
|---|---|
Process-p-ramp_limit_up-run-bigM | |
Process-p-ramp_limit_up-start-bigM | |
Process-p-ramp_limit_down-run-bigM | |
Process-p-ramp_limit_down-shut-bigM |
When the unit was running in the previous timestep (), the big-M term vanishes and the normal ramp-up limit applies. When , the big-M relaxes the constraint, allowing unrestricted ramp-up. The start-up ramp limit is enforced only during start-up events (). The same logic applies symmetrically to ramp-down and shut-down constraints.
These constraints are defined in the function define_ramp_limit_constraints().
Mapping of symbols to component attributes
GeneratorLink
| Symbol | Attribute | Type |
|---|---|---|
n.generators_t.p | Decision variable | |
n.generators.p_nom_opt | Decision variable | |
n.generators_t.status | Decision variable | |
n.generators_t.start_up | Decision variable | |
n.generators_t.shut_down | Decision variable | |
auto-inferred or committable_big_m parameter | Parameter | |
n.generators.ramp_limit_up | Parameter | |
n.generators.ramp_limit_down | Parameter | |
n.generators.ramp_limit_start_up | Parameter | |
n.generators.ramp_limit_shut_down | Parameter |
| Symbol | Attribute | Type |
|---|---|---|
n.links_t.p | Decision variable | |
n.links.p_nom_opt | Decision variable | |
n.links_t.status | Decision variable | |
n.links_t.start_up | Decision variable | |
n.links_t.shut_down | Decision variable | |
auto-inferred or committable_big_m parameter | Parameter | |
n.links.ramp_limit_up | Parameter | |
n.links.ramp_limit_down | Parameter | |
n.links.ramp_limit_start_up | Parameter | |
n.links.ramp_limit_shut_down | Parameter |
Modularity Constraints
The capacity expansion can be further constrained to be a multiple (e.g. ) of a modular capacity (e.g. ) to represent fixed block sizes of added components (e.g. fixed block size of a nuclear power plant or a fixed capacity of a new circuit).
If {p,s,e}_nom_mod>0, the nominal capacity is given by:
| Constraint | Dual Variable | Name |
|---|---|---|
| N/A | Generator-p_nom_modularity | |
| N/A | Link-p_nom_modularity | |
| N/A | Process-p_nom_modularity | |
| N/A | {Line,Transformer}-s_nom_modularity | |
| N/A | Store-e_nom_modularity | |
| N/A | StorageUnit-p_nom_modularity |
These constraints are set in the function define_modular_constraints().
Modular and Committable Components
When extendable components additionally have modular capacities activated (p_nom_mod > 0) and are committable (committable=True), the formulation differs from the big-M approach above. Instead of a binary on/off status variable, the status variable becomes an integer representing the number of committed modules inside the component.
Module-Level Commitment Formulation
For modular committable components, two integer variables are introduced:
- : Number of modules built (determines total capacity)
- : Number of modules committed at time (determines operational state)
The capacity is constrained to be a multiple of the module size:
GeneratorLink
| Constraint | Name |
|---|---|
Generator-p_nom_modularity | |
Generator-status-p_nom-variable-upper |
| Constraint | Name |
|---|---|
Link-p_nom_modularity | |
Link-status-p_nom-variable-upper |
The dispatch constraints enforce that power output respects the number of committed modules:
GeneratorLink
| Constraint | Name |
|---|---|
Generator-com-mod-p-lower | |
Generator-com-mod-p-upper |
| Constraint | Name |
|---|---|
Link-com-mod-p-lower | |
Link-com-mod-p-upper |
Note that the minimum and maximum part-load parameters ( and ) apply per committed module, not to the total capacity.
Start-up and Shut-down for Modular Components
Start-up and shut-down variables track changes in the number of committed modules:
GeneratorLink
| Constraint | Name |
|---|---|
Generator-com-transition-start-up | |
Generator-com-transition-shut-down |
| Constraint | Name |
|---|---|
Link-com-transition-start-up | |
Link-com-transition-shut-down |
The start-up and shut-down cost terms in the objective function are multiplied by the number of modules being started or stopped.
Initial status affects start-up costs
The status before the first snapshot is reconstructed from up_time_before (default 1) and down_time_before. A fixed modular unit that was on runs all its installed modules. For an extendable modular unit, the number of modules is a variable, so one module is assumed to be already committed. For example, if the optimizer invests in 5 modules and commits all 5 in the first timestep, only 4 start-up events are counted (). To charge start-up costs for all modules, set up_time_before=0. This also applies to the non-modular (big-M) committable formulation.
These constraints are defined in the function define_operational_constraints_for_committables().
Mapping of symbols to component attributes
GeneratorLink
| Symbol | Attribute | Type |
|---|---|---|
n.generators_t.p | Decision variable | |
n.generators.p_nom_opt | Decision variable | |
n.model.variables['Generator-n_mod'] | Decision variable | |
n.generators_t.status | Decision variable (integer) | |
n.generators_t.start_up | Decision variable (integer) | |
n.generators_t.shut_down | Decision variable (integer) | |
n.generators.p_nom_mod | Parameter | |
n.generators_t.p_min_pu | Parameter | |
n.generators_t.p_max_pu | Parameter |
| Symbol | Attribute | Type |
|---|---|---|
n.links_t.p | Decision variable | |
n.links.p_nom_opt | Decision variable | |
n.model.variables['Link-n_mod'] | Decision variable | |
n.links_t.status | Decision variable (integer) | |
n.links_t.start_up | Decision variable (integer) | |
n.links_t.shut_down | Decision variable (integer) | |
n.links.p_nom_mod | Parameter | |
n.links_t.p_min_pu | Parameter | |
n.links_t.p_max_pu | Parameter |
Compatibility of Capacity Expansion with Unit Commitment Features
The following table summarizes which unit commitment features are compatible with the two formulations:
| Feature | Committable + Extendable (Big-M) | Modular + Committable |
|---|---|---|
| Start-up costs | ✓ | ✓ |
| Shut-down costs | ✓ | ✓ |
Minimum part-load (p_min_pu) | ✓ | ✓ (per module)¹ |
Ramp limits (ramp_limit_up/down) | ✓ | ✓² |
| Stand-by costs | ✓ | ✓ |
Minimum up time (min_up_time) | ✓ | ✗ |
Minimum down time (min_down_time) | ✓ | ✓ |
Up time before (up_time_before) | ✓ | ✗ |
Down time before (down_time_before) | ✓ | ✗ |
¹ For modular components, p_min_pu and p_max_pu apply to each committed module. The minimum/maximum power is calculated as p_min_pu × p_nom_mod × status where status is the number of committed modules.
² For modular + committable components, ramp limits apply to each committed module, like the part-load constraints. The ramp-up constraint is p_t - p_{t-1} ≤ ramp_limit_up × p_nom_mod × status_{t-1} + ramp_limit_start_up × p_nom_mod × (status_t - status_{t-1}), where status is the number of committed modules. This holds for fixed and extendable modular committable components alike.
Fixed Capacity
Additionally, the nominal capacity can be fixed to a certain value for generators, for links, for processes, for lines and transformers, and for stores, and for storage units. In this case, the nominal capacity is given by:
| Constraint | Dual Variable | Name |
|---|---|---|
only in n.model | Generator-p_nom_set | |
only in n.model | Link-p_nom_set | |
only in n.model | Process-p_nom_set | |
only in n.model | {Line,Transformer}-s_nom_set | |
only in n.model | Store-e_nom_set | |
only in n.model | StorageUnit-p_nom_set |
These constraints are set in the function define_fixed_nominal_constraints().
Why not just set p_nom_extendable=False?
Using p_nom_extendable=False means the capacity is fixed and not optimized. However, sometimes we need to fix the capacity to a specific value while still keeping track of the dual variables associated with capacity constraints. Setting {p,s,e}_nom_set allows for this while maintaining p_nom_extendable=True.
Mapping of symbols to component attributes
GeneratorLinkProcessLineTransformerStoreStorage Unit
| Symbol | Attribute | Type |
|---|---|---|
n.generators.p_nom_opt | Decision variable | |
| not stored | Decision variable | |
n.generators.p_nom_min | Parameter | |
n.generators.p_nom_max | Parameter | |
n.generators.p_nom_mod | Parameter | |
n.generators.p_nom_set | Parameter |
| Symbol | Attribute | Type |
|---|---|---|
n.links.p_nom_opt | Decision variable | |
| not stored | Decision variable | |
n.links.p_nom_min | Parameter | |
n.links.p_nom_max | Parameter | |
n.links.p_nom_mod | Parameter | |
n.links.p_nom_set | Parameter |
| Symbol | Attribute | Type |
|---|---|---|
n.processes.p_nom_opt | Decision variable | |
| not stored | Decision variable | |
n.processes.p_nom_min | Parameter | |
n.processes.p_nom_max | Parameter | |
n.processes.p_nom_mod | Parameter | |
n.processes.p_nom_set | Parameter |
| Symbol | Attribute | Type |
|---|---|---|
n.lines.s_nom_opt | Decision variable | |
| not stored | Decision variable | |
n.lines.s_nom_min | Parameter | |
n.lines.s_nom_max | Parameter | |
n.lines.s_nom_mod | Parameter | |
n.lines.s_nom_set | Parameter |
| Symbol | Attribute | Type |
|---|---|---|
n.transformers.s_nom_opt | Decision variable | |
| not stored | Decision variable | |
n.transformers.s_nom_min | Parameter | |
n.transformers.s_nom_max | Parameter | |
n.transformers.s_nom_mod | Parameter | |
n.transformers.s_nom_set | Parameter |
| Symbol | Attribute | Type |
|---|---|---|
n.stores.e_nom_opt | Decision variable | |
| not stored | Decision variable | |
n.stores.e_nom_min | Parameter | |
n.stores.e_nom_max | Parameter | |
n.stores.e_nom_mod | Parameter | |
n.stores.e_nom_set | Parameter |
| Symbol | Attribute | Type |
|---|---|---|
n.storage_units.p_nom_opt | Decision variable | |
| not stored | Decision variable | |
n.storage_units.p_nom_min | Parameter | |
n.storage_units.p_nom_max | Parameter | |
n.storage_units.p_nom_mod | Parameter | |
n.storage_units.p_nom_set | Parameter |
Examples
Modular Capacity Expansion
Models discrete capacity additions with integer constraints on investment decisions considering predefined unit sizes.
Committable and Extendable Components
Co-optimize capacity expansion and unit commitment using big-M linearization. Demonstrates continuous capacity decisions with start-up/shut-down costs, ramp limits, and minimum load constraints.
Modular and Committable Components
Model discrete capacity blocks with unit commitment where status represents the number of committed modules. Shows modular gas turbines, HVDC links, and multi-module operational dynamics.
2026-11-30
2025-10-09