Global Constraints
Global constraints apply to more than one component at once and are stored under a unique name in n.global_constraints. Several pre-defined types of global constraints are available (type).
For instance, for defining emission limits, transmission expansion limits, or technology capacity expansion limits using the sense and constant attributes.
By default, global constraints span across all investment periods. For models with multiple investment periods, global constraints can be limited to affect only single investment period (e.g. an emission limit for a specific year) by specifying the in the attribute investment_period. The shadow price of each global constraint is stored in the attribute mu. Flow-based rows store theirs per snapshot in mu_ram instead.
Naming Convention
Global constraints carry the name scheme GlobalConstraint-{name} in the Linopy model. All flow_based rows share the one constraint GlobalConstraint-ram, indexed by name. Their net positions and the balance of the net positions are FlowBased-net_position and FlowBased-balance.
Primary Energy
The primary energy constraints (type="primary_energy") are used to limit byproducts of primary energy consumption of a carrier (e.g. CO2 emissions) in generators, storage units and stores. They depend on the generator efficiency and carrier-specific attributes (e.g. co2_emissions).
Suppose there is a global constraint defined for CO2 emissions (carrier_attribute) with sense "<=" (sense) and a limit (constant). Emissions can come from generators whose energy carriers have CO2 emissions, and from stores and storage units whose storage medium releases or absorbs CO2 when it is converted. A store or storage unit contributes the net energy withdrawn from it (discharging minus charging): its energy level at the start () minus its level at the end () of the counted snapshots, plus its net inflow . This follows from the sum of the storage energy balance over the counted snapshots and includes standing losses. For a constraint with an investment_period, the start level is the level that the storage carries into that period. With investment periods, the level change and the net inflow of each period are weighted by the years of the period. The level term is zero for storage that is cyclic within the counted snapshots.
If the specific emissions of carrier is (n.carriers.co2_emissions) and the generator with carrier at node and snapshot has efficiency then the CO2 constraint is
The first sum is over generators; the second sum is over stores; the third over storage units; the fourth over stores and storage units. The shadow price would represent the CO2 price in this case.
This global constraint is added in the function define_primary_energy_limit().
Mapping symbols to component attributes
| Symbol | Attribute | Type |
|---|---|---|
n.generators_t.p | Decision Variable | |
n.stores_t.e | Decision Variable | |
n.storage_units_t.soc | Decision Variable | |
n.{stores,storage_units}_t.spill | Decision Variable | |
n.global_constraints.mu | Dual Variable | |
n.snapshot_weightings.generators | Parameter | |
n.snapshot_weightings.stores | Parameter | |
n.{stores,storage_units}_t.inflow | Parameter | |
n.generators.efficiency | Parameter | |
n.carriers.co2_emissions | Parameter | |
n.global_constraints.constant | Parameter |
Operational Limit
The operational constraints can limit the net production of a carrier taking
into account generator, storage units and stores (type="operational_limit").
For example, this can be used to limit the usage of gas in the system to a
certain amount (constant in MWh). With sense "<=" (sense), the
constraint would be given by
The first sum is over generators; the second sum is over stores; the third over storage units; the fourth over stores and storage units. Structurally, it is similar to the primary energy limit, but without the consideration of specific emissions and efficiencies. The shadow price (in currency/MWh) would represent the reduction in system costs if the operational limit were relaxed by one unit.
This global constraint is added in the function define_operational_limit().
Mapping symbols to component attributes
| Symbol | Attribute | Type |
|---|---|---|
n.generators_t.p | Decision Variable | |
n.stores_t.e | Decision Variable | |
n.storage_units_t.soc | Decision Variable | |
n.{stores,storage_units}_t.spill | Decision Variable | |
n.global_constraints.mu | Dual Variable | |
n.snapshot_weightings.generators | Parameter | |
n.snapshot_weightings.stores | Parameter | |
n.{stores,storage_units}_t.inflow | Parameter | |
n.global_constraints.constant | Parameter |
Volume Limit on Transmission Expansion
This global constraint can be used to limit the expansion volume in MWkm of transmission lines and links (type="transmission_volume_expansion_limit"). The carrier_attribute specifies the subset of carriers to consider. These can be individual carriers or concatenated by commas, e.g. "AC", "DC", "AC,DC", or a Link carrier such as "H2 pipeline". With sense="<=", the constraint is defined as
where is the set of lines and links with the specified carriers, is the maximum allowed volume expansion in MWkm, is the distance of line or link in km and is the capacity of line or link in MW. The shadow price represents the marginal benefit of expanding the transmission capacity in currency/MWkm/a.
This global constraint is added in the function define_transmission_volume_expansion_limit().
Mapping symbols to component attributes
| Symbol | Attribute | Type |
|---|---|---|
n.{lines,links}.p_nom_opt | Decision Variable | |
n.global_constraints.mu | Dual Variable | |
n.{lines,links}.length | Parameter | |
n.global_constraints.constant | Parameter |
Cost Limit on Transmission Expansion
This global constraint can be used to limit the total investment cost in currency/a of transmission lines and links (type="transmission_expansion_cost_limit"). The carrier_attribute specifies the subset of carriers to consider. These can be individual carriers or concatenated by commas, e.g. "AC", "DC", "AC,DC", or a Link carrier such as "H2 pipeline". With sense="<=", the constraint is defined as
where is the set of lines and links with the specified carriers, is the capital cost of line or link in currency/MW/a, is the capacity of line or link in MW and is the maximum allowed cost of line expansion in currency/a. The shadow price represents how much the total system cost could be reduced if the spending limit was increased by one currency/a.
This global constraint is added in the function define_transmission_expansion_cost_limit().
Mapping symbols to component attributes
| Symbol | Attribute | Type |
|---|---|---|
n.{lines,links}.p_nom_opt | Decision Variable | |
n.global_constraints.mu | Dual Variable | |
n.{lines,links}.capital_cost | Parameter | |
n.global_constraints.constant | Parameter |
Expansion Limit
This global constraint can be used to limit the total capacity of components of a carrier (type=tech_capacity_expansion_limit). This global constraint can be specific to an investment period by setting the investment_period attribute and specific to a bus by setting the bus attribute. This constraint is mainly used for networks with multiple investment periods, where land usage and building rate restrictions need to be applied for a range of active components of a particular carrier (carrier_attribute) in a certain region.
Warning
Currently, only the capacities of extendable components are considered, i.e. generators, storage units and stores with extendable=True. The capacities of non-extendable components are not considered in this constraint.
For example, the capacities of all onshore wind generators (carrier_attribute="onshore wind") at a certain bus (bus="DE") should be smaller (sense="<=") than a hypothetical technical potential of 200 GW for onshore wind in the specific region (constant=200e3). Then the technology capacity expansion constraint across all active components is given by
where are the investment periods, are all extendable generators of the specified carrier, is the build year of an asset with lifetime . In this example, the shadow price would represent the marginal benefit of expanding the capacity of onshore wind in currency/MW/a.
In general, the constraint would iterate over all investment variables for generators , lines and transformers , links , stores and storage units for the specified carrier and bus. For components connecting two buses, the bus selection is done by bus0.
This global constraint is added in the function define_tech_capacity_expansion_limit().
Mapping symbols to component attributes
| Symbol | Attribute | Type |
|---|---|---|
n.generators.p_nom_opt | Decision Variable | |
n.storage_units.p_nom_opt | Decision Variable | |
n.stores.e_nom_opt | Decision Variable | |
n.links.p_nom_opt | Decision Variable | |
n.{lines,transformers}.s_nom_opt | Decision Variable | |
n.global_constraints.mu | Dual Variable | |
n.{<component>}.build_year | Parameter | |
n.{<component>}.lifetime | Parameter | |
| , | n.investment_periods | Parameter |
n.global_constraints.constant | Parameter |
Growth Limit per Carrier
This carrier-specific constraint type implements absolute and relative growth limits per carrier which constrains new installed capacities for each investment period. It can be defined by providing the attributes n.carriers.max_growth and n.carriers.max_relative_growth.
Suppose the absolute growth limit for a specific carrier is (max_growth) and the relative growth limit is (max_relative_growth). With the growth limit constraint, for each investment period , the new installed capacity of all components with carrier is limited by:
where represents the sum of all newly built nominal capacities of extendable components with carrier in period . The relative growth limit allows the new capacity in period to be proportional to the capacity added in the previous period .
This constraint only applies to networks with multiple investment periods and only considers components that are newly activated in each period. For the constraint to take effect, at least one of the attributes max_growth or max_relative_growth must be set to a finite value for the carrier.
Warning
The relative and abolute growth limits are additive, i.e. the absolute growth limit applies in addition to the relative growth limit.
In general, the constraint would iterate over all investment variables for generators , lines and transformers , links , stores and storage units for the specified carrier. For components connecting two buses, the bus selection is done by bus0.
This global constraint is added in the function define_growth_limit() and carries the name Carrier-growth_limit.
Mapping symbols to component attributes
| Symbol | Attribute | Type |
|---|---|---|
n.generators.p_nom_opt | Decision Variable | |
n.storage_units.p_nom_opt | Decision Variable | |
n.stores.e_nom_opt | Decision Variable | |
n.links.p_nom_opt | Decision Variable | |
n.{lines,transformers}.s_nom_opt | Decision Variable | |
n.carriers.max_relative_growth | Parameter | |
n.carriers.max_growth | Parameter |
Flow-Based Market Coupling
Flow-based market coupling (FBMC) replaces the transmission grid constraints between market zones by a compact set of linear constraints on the zones' net positions. Instead of resolving every node and line, the market treats each zone as a copper plate and trades against a few linear limits that capture how zonal exchanges load the critical grid elements. This is the capacity-allocation method used in parts of the European day-ahead market, notably the Core region.4 For an introduction to the method and its parameters, see Van den Bergh et al. (2016)[^vandenbergh] and Schönheit et al. (2021)[^schonheit]. The domain of feasible net positions is stored as global constraints of type="flow_based", see the component page.
The net-position variable is FlowBased-net_position, the domain half-spaces are GlobalConstraint-ram, and the zero-sum balance is FlowBased-balance; see also the example notebook.
Net position
The net position of a market zone at snapshot is the power it feeds into the flow-based region. It is added as a decision variable and injected directly into the nodal balance of its zone bus,
so it equals the bus's net injection and is read from n.buses_t.p after solving. The output n.buses_t.net_position holds the generation minus load of each zone bus (0 for other buses), which is the net position itself unless corridor links are present (see below).
Domain constraints
Each critical network element (CNEC) is one global constraint row, a monitored grid constraint such as a line under a given outage. It contributes one half-space that bounds a weighted sum of net positions by its remaining available margin , the headroom left on that element for cross-zonal trade:
The sensitivities are the zonal power transfer distribution factors (attributes ptdf_<zone>, see the component page); both they and the RAM (ram) may be static or vary by snapshot, and the constraint broadcasts over either way. A row with an investment_period only applies in that period's snapshots, and a row with a NaN ram is dropped in that snapshot. The shadow price is written to n.global_constraints_t.mu_ram. A zero-sum balance closes the copper plate across the zones of each domain ,
By default all zones form one domain. Rows that name their domain, e.g. Core and Nordic, give one balance per named domain. A link between two domains then acts as an AHC corridor in each. The rows of one domain see neither the zones nor the hubs of the other ( and are 0 there), so the EvFB and AHC formulas below give the same column.
The net-position variable is added in define_flow_based_variables() and these constraints in define_flow_based_constraints(); the net-position injection is added in define_nodal_balance_constraints() via flow_based_balance_terms().
Controllable link flows (AHC and EvFB)
A domain column may name a Link instead of a zone Bus. This extends the domain to controllable corridors, such as HVDC links;[^estermann] PyPSA tells the two cases apart by the link's ends:
- Advanced hybrid coupling (AHC): one end is a zone, the other a bus outside the flow-based region.
- Evolved flow-based (EvFB): both ends are flow-based zones.
The link stays in the nodal balances of its buses like any other link, so a zone's net position now includes the corridor inflow,
with the link flow (Link-p, in the bus0 -> bus1 direction) and the link's incidence at ( at bus0, at bus1, else ). Each link adds a term to every CNEC:
The link column is the sensitivity of CNEC to the link flow with all zone net positions held fixed: the loading the corridor causes beyond what its zones' PTDFs already explain. Let be the sensitivity of CNEC to an injection at the node where link lands in zone (its hub sensitivity). Then
which is for an AHC link into zone , and for an EvFB link from to . If the corridor lands where the zone's GSK puts its power anyway, the column is zero. The zero-sum balance is unchanged, , because the corridor imports are already inside the net positions.
Two equivalent net-position conventions
Published domains use one of two conventions for corridors. Both describe the same feasible set and give the same CNEC flows; they only split each flow differently between the zone terms and the link terms.
- PyPSA: the net position includes the corridor flow. The zone PTDF already spreads that flow as if the GSK placed it, so the link column keeps only the correction from the GSK to the landing node. ERAA publishes its AHC columns in this form (
PTDF*_AHC = PTDF_AHC - PTDF_SZ). - Virtual hub: the net position is generation minus load, . Each corridor end acts as a hub with its raw hub sensitivity , and the hub flows join the zero-sum balance. The Core methodology,4 JAO and TSO files use this form, and so do ERAA's EvFB columns.
The conversion is one rule: what PyPSA adds to the net positions, it takes out of the link column,
| PyPSA | Virtual hub | |
|---|---|---|
| zone net position | (n.buses_t.p) | (n.buses_t.net_position) |
| AHC column, | ||
| EvFB column, | ||
| zero-sum balance |
PyPSA uses the first form because the link then needs no special treatment in the nodal balance. After solving, n.buses_t.net_position reports the virtual-hub net position of each zone bus, i.e. n.buses_t.p without the flows of its corridor links.
These terms are built in define_flow_based_constraints().
Mapping symbols to component attributes
| Symbol | Attribute | Type |
|---|---|---|
n.buses_t.p (variable FlowBased-net_position) | Decision Variable | |
n.buses_t.net_position | Output | |
n.links_t.p0 | Decision Variable | |
n.global_constraints_t.mu_ram | Dual Variable | |
n.c.global_constraints.zonal_ptdf | Parameter | |
n.global_constraints.ram, n.global_constraints_t.ram | Parameter | |
| hub sensitivity of a published corridor column | Data | |
n.links.efficiency | Parameter |
[^vandenbergh]: K. Van den Bergh, J. Boury and E. Delarue (2016), The Flow-Based Market Coupling in Central Western Europe: Concepts and definitions, The Electricity Journal, 29(1), 24-29, doi:10.1016/j.tej.2015.12.004. [^schonheit]: D. Schönheit, M. Kenis, L. Lorenz, D. Möst, E. Delarue and K. Bruninx (2021), Toward a fundamental understanding of flow-based market coupling for cross-border electricity trading, Advances in Applied Energy, 2, 100027, doi:10.1016/j.adapen.2021.100027. [^estermann]: A. Estermann, M. Schrade and L. Anderson (eds.) (2025), European Electricity Market Coupling: A Practitioner's Guide, Springer, doi:10.1007/978-3-031-86315-8. 4.
ACER (2019), Day-ahead capacity calculation methodology of the Core capacity calculation region, in accordance with Commission Regulation (EU) 2015/1222 (CACM).
2026-11-13
2025-10-09