Mixed integer linear programming math¶
Pre-defined extra math to apply mixed integer linear programming math on top of the base mathematical formulation.
This math is only applied if referenced in the config.init.extra_math list as "milp".
A guide to math documentation¶
If a math component's initial conditions are met (the first if statement), it will be applied to a model.
For each objective, constraint and global expression, a number of sub-conditions then apply (the subsequent, indented if statements) to decide on the specific expression to apply at a given iteration of the component dimensions.
In the expressions, terms in bold font are decision variables and terms in italic font are parameters.
The decision variables and parameters are listed at the end of the page; they also refer back to the global expressions / constraints in which they are used.
Those parameters which are defined over time (timesteps) in the expressions can be defined by a user as a single, time invariant value, or as a timeseries that is loaded from file or dataframe.
Note
For every math component in the documentation, we include the YAML snippet that was used to generate the math in a separate tab.
Download the mixed integer linear programming math formulation as a YAML file
Subject to¶
area_use_minimum¶
NEW Set the lower bound on a technology's area use for any technology with a non-zero lower bound, with or without integer capacity purchasing.
description: "NEW\nSet the lower bound on a technology's area use for any technology
with a non-zero lower bound, with or without integer capacity purchasing."
equations:
- where: NOT purchased_units
expression: area_use >= area_use_min
- where: purchased_units
expression: area_use >= area_use_min * purchased_units
foreach:
- nodes
- techs
where: area_use_min
async_flow_in_milp¶
NEW Set a technology's ability to have inflow in the same timestep that it has outflow, for any technology using the asynchronous flow binary switch.
Uses
description: "NEW\nSet a technology's ability to have inflow in the same timestep
that it has outflow, for any technology using the asynchronous flow binary switch."
equations:
- expression: sum(flow_in, over=carriers) <= (1 - async_flow_switch) * bigM
foreach:
- nodes
- techs
- timesteps
where: async_flow_switch
async_flow_out_milp¶
NEW Set a technology's ability to have outflow in the same timestep that it has inflow, for any technology using the asynchronous flow binary switch.
Uses
description: "NEW\nSet a technology's ability to have outflow in the same timestep
that it has inflow, for any technology using the asynchronous flow binary switch."
equations:
- expression: sum(flow_out, over=carriers) <= async_flow_switch * bigM
foreach:
- nodes
- techs
- timesteps
where: async_flow_switch
available_flow_cap_binary¶
NEW Limit flow capacity to zero if the technology is not operating in a given timestep.
available_flow_cap_continuous¶
NEW
Limit flow capacity to the value of the flow_cap decision variable when the technology is operating in a given timestep.
available_flow_cap_max_binary_continuous_switch¶
NEW
Force flow capacity to equal the value of the flow_cap decision variable if the technology is operating in a given timestep, zero otherwise.
description: "NEW\nForce flow capacity to equal the value of the `flow_cap` decision
variable if the technology is operating in a given timestep, zero otherwise."
equations:
- expression: available_flow_cap >= flow_cap + ((operating_units -
purchased_units) * flow_cap_max)
foreach:
- nodes
- techs
- carriers
- timesteps
where: available_flow_cap
flow_capacity_max_purchase_milp¶
NEW Set the upper bound on a technology's flow capacity, for any technology with integer capacity purchasing.
description: "NEW\nSet the upper bound on a technology's flow capacity, for any
technology with integer capacity purchasing."
equations:
- where: flow_cap_max
expression: flow_cap <= flow_cap_max * purchased_units
- where: NOT flow_cap_max
expression: flow_cap <= bigM * purchased_units
foreach:
- nodes
- techs
- carriers
where: purchased_units
flow_capacity_minimum¶
NEW Set the lower bound on a technology's flow capacity, for any technology with a non-zero lower bound, with or without integer capacity purchasing.
description: "NEW\nSet the lower bound on a technology's flow capacity, for any
technology with a non-zero lower bound, with or without integer capacity purchasing."
equations:
- where: NOT purchased_units
expression: flow_cap >= flow_cap_min
- where: purchased_units
expression: flow_cap >= flow_cap_min * purchased_units
foreach:
- nodes
- techs
- carriers
where: flow_cap_min
flow_capacity_systemwide_min¶
UPDATED Set a lower bound on flow capacity of a technology across all nodes in which the technology exists.
description: "UPDATED\nSet a lower bound on flow capacity of a technology across
all nodes in which the technology exists."
equations:
- where: any(purchased_units, over=nodes)
expression: sum(flow_cap, over=nodes) >= flow_cap_min_systemwide *
sum(purchased_units, over=nodes)
- where: NOT any(purchased_units, over=nodes)
expression: sum(flow_cap, over=nodes) >= flow_cap_min_systemwide
foreach:
- techs
- carriers
where: flow_cap_min_systemwide
flow_capacity_units_milp¶
NEW Fix the flow capacity of any technology using integer units to define its capacity.
flow_in_max¶
UPDATED Set the upper bound of a continuous technology's inflow.
flow_in_max_milp¶
NEW Set the upper bound of a technology's ability to consume carriers, for any technology using integer units to define its capacity.
description: "NEW\nSet the upper bound of a technology's ability to consume carriers,
for any technology using integer units to define its capacity."
equations:
- expression: flow_in <= operating_units * timestep_resolution *
flow_cap_per_unit
foreach:
- nodes
- techs
- carriers
- timesteps
where: flow_in AND operating_units AND flow_cap_per_unit
flow_out_max¶
UPDATED Set the upper bound of a continuous technology's outflow.
flow_out_max_milp¶
NEW Set the upper bound of a technology's ability to produce carriers, for any technology using integer units to define its capacity.
description: "NEW\nSet the upper bound of a technology's ability to produce carriers,
for any technology using integer units to define its capacity."
equations:
- expression: flow_out <= operating_units * timestep_resolution *
flow_cap_per_unit * flow_out_parasitic_eff
foreach:
- nodes
- techs
- carriers
- timesteps
where: flow_out AND operating_units AND flow_cap_per_unit
flow_out_min¶
UPDATED Set the lower bound of a continuous technology's outflow.
flow_out_min_milp¶
NEW Set the lower bound of a technology's ability to produce carriers, for any technology using integer units to define its capacity.
description: "NEW\nSet the lower bound of a technology's ability to produce carriers,
for any technology using integer units to define its capacity."
equations:
- where: flow_cap_per_unit
expression: flow_out >= operating_units * timestep_resolution *
flow_cap_per_unit * flow_out_min_relative
- where: available_flow_cap
expression: flow_out >= available_flow_cap * timestep_resolution *
flow_out_min_relative
foreach:
- nodes
- techs
- carriers
- timesteps
where: flow_out AND operating_units AND flow_out_min_relative
source_capacity_minimum¶
NEW Set the lower bound on a technology's source capacity for any supply technology with a non-zero lower bound, with or without integer capacity purchasing.
description: "NEW\nSet the lower bound on a technology's source capacity for any
supply technology with a non-zero lower bound, with or without integer capacity
purchasing."
equations:
- where: NOT purchased_units
expression: source_cap >= source_cap_min
- where: purchased_units
expression: source_cap >= source_cap_min * purchased_units
foreach:
- nodes
- techs
where: base_tech==supply AND source_cap_min
storage_capacity_max_purchase_milp¶
NEW Set the upper bound on a technology's storage capacity, for any technology with integer capacity purchasing.
storage_capacity_minimum¶
NEW Set the lower bound on a technology's storage capacity for any technology with a non-zero lower bound, with or without integer capacity purchasing.
description: "NEW\nSet the lower bound on a technology's storage capacity for any
technology with a non-zero lower bound, with or without integer capacity purchasing."
equations:
- where: NOT purchased_units
expression: storage_cap >= storage_cap_min
- where: purchased_units
expression: storage_cap >= storage_cap_min * purchased_units
foreach:
- nodes
- techs
where: storage_cap_min
storage_capacity_units_milp¶
NEW Fix the storage capacity of any technology using integer units to define its capacity.
unit_capacity_max_systemwide_milp¶
NEW Set the upper bound on the total number of units of a technology that can be purchased across all nodes where the technology can exist, for any technology using integer units to define its capacity.
description: "NEW\nSet the upper bound on the total number of units of a technology
that can be purchased across all nodes where the technology can exist, for any technology
using integer units to define its capacity."
equations:
- expression: sum(purchased_units, over=nodes) <= purchased_units_max_systemwide
foreach:
- techs
where: purchased_units AND purchased_units_max_systemwide
unit_capacity_min_systemwide_milp¶
NEW Set the lower bound on the total number of units of a technology that can be purchased across all nodes where the technology can exist, for any technology using integer units to define its capacity.
description: "NEW\nSet the lower bound on the total number of units of a technology
that can be purchased across all nodes where the technology can exist, for any technology
using integer units to define its capacity."
equations:
- expression: sum(purchased_units, over=nodes) >= purchased_units_min_systemwide
foreach:
- techs
where: purchased_units AND purchased_units_max_systemwide
unit_commitment_milp¶
NEW Set the upper bound of the number of integer units of technology that can exist, for any technology using integer units to define its capacity.
description: "NEW\nSet the upper bound of the number of integer units of technology
that can exist, for any technology using integer units to define its capacity."
equations:
- expression: operating_units <= purchased_units
foreach:
- nodes
- techs
- timesteps
where: operating_units AND purchased_units
Where¶
cost_investment¶
UPDATED The installation costs of a technology, including those linked to the nameplate capacity, land use, storage size, and binary/integer unit purchase.
Unit: cost
Default: 0
title: Total investment costs
description: "UPDATED\nThe installation costs of a technology, including those linked
to the nameplate capacity, land use, storage size, and binary/integer unit purchase."
equations:
- expression: sum(cost_investment_flow_cap, over=carriers) +
cost_investment_storage_cap + cost_investment_source_cap +
cost_investment_area_use + cost_investment_purchase
foreach:
- nodes
- techs
- costs
where: cost_investment_flow_cap OR cost_investment_storage_cap OR
cost_investment_source_cap OR cost_investment_area_use OR
cost_investment_purchase
unit: cost
default: 0
cost_investment_purchase¶
NEW The investment costs associated with the binary purchase of a technology.
Used in
Unit: cost
Default: 0
title: Binary purchase investment costs
description: "NEW\nThe investment costs associated with the binary purchase of a
technology."
equations:
- where: base_tech==transmission
expression: (cost_purchase + cost_purchase_per_distance * distance) *
purchased_units * 0.5
- where: NOT base_tech==transmission
expression: cost_purchase * purchased_units
foreach:
- nodes
- techs
- costs
where: cost_purchase AND purchased_units
unit: cost
default: 0
order: -1
Decision Variables¶
area_use¶
UPDATED The area in space utilised directly (e.g., solar PV panels) or indirectly (e.g., biofuel crops) by a technology. Minimum is set to 0 and handled in a distinct constraint to handle the integer purchase variable.
Used in
Unit: area
Default: 0
title: Area utilisation
description: "UPDATED\nThe area in space utilised directly (e.g., solar PV panels)
or indirectly (e.g., biofuel crops) by a technology. Minimum is set to 0 and handled
in a distinct constraint to handle the integer purchase variable."
foreach:
- nodes
- techs
where: (area_use_min OR area_use_max OR area_use_per_flow_cap OR
sink_unit==per_area OR source_unit==per_area)
unit: area
default: 0
bounds:
max: area_use_max
min: 0
async_flow_switch¶
NEW
Binary switch to force asynchronous outflow/consumption of technologies with both flow_in and flow_out defined. This ensures that a technology with carrier flow efficiencies < 100% cannot produce and consume a flow simultaneously to remove unwanted carrier from the system.
Uses
Unit: integer
Default: 0
title: Asynchronous carrier flow switch
description: "NEW\nBinary switch to force asynchronous outflow/consumption of technologies
with both `flow_in` and `flow_out` defined. This ensures that a technology with
carrier flow efficiencies < 100% cannot produce and consume a flow simultaneously
to remove unwanted carrier from the system."
foreach:
- nodes
- techs
- timesteps
where: force_async_flow==True
unit: integer
default: 0
domain: integer
bounds:
max: 1
min: 0
available_flow_cap¶
NEW
Flow capacity that will be set to zero if the technology is not operating in a given timestep and will be set to the value of the decision variable flow_cap otherwise. This is useful when you want to set a minimum flow capacity for any technology investment, but also want to allow the model to decide the capacity. It is expected to only be used when purchased_units_max == 1, i.e., the purchased_units decision variable is binary. If purchased_units_max > 1, you may get strange results and should instead use the less flexible flow_cap_per_unit.
Used in
Unit: power
Default: 0
title: Available carrier flow capacity
description: "NEW\nFlow capacity that will be set to zero if the technology is not
operating in a given timestep and will be set to the value of the decision variable
`flow_cap` otherwise. This is useful when you want to set a minimum flow capacity
for any technology investment, but also want to allow the model to decide the capacity.
It is expected to only be used when `purchased_units_max == 1`, i.e., the `purchased_units`
decision variable is binary. If `purchased_units_max > 1`, you may get strange results
and should instead use the less flexible `flow_cap_per_unit`."
foreach:
- nodes
- techs
- carriers
- timesteps
where: integer_dispatch==True AND flow_cap_max AND NOT flow_cap_per_unit
unit: power
default: 0
bounds:
min: 0
flow_cap¶
UPDATED A technology's flow capacity, also known as its nominal or nameplate capacity. Minimum is set to 0 and handled in a distinct constraint to handle the integer purchase variable.
Used in
Uses
Unit: power
Default: 0
title: Technology flow (a.k.a. nominal) capacity
description: "UPDATED\nA technology's flow capacity, also known as its nominal or
nameplate capacity. Minimum is set to 0 and handled in a distinct constraint to
handle the integer purchase variable."
foreach:
- nodes
- techs
- carriers
unit: power
default: 0
bounds:
max: flow_cap_max
min: 0
operating_units¶
NEW Integer number of a technology that is operating in each timestep, for any technology set to require integer capacity purchasing.
Used in
Unit: integer
Default: 0
title: Number of operating units
description: "NEW\nInteger number of a technology that is operating in each timestep,
for any technology set to require integer capacity purchasing."
foreach:
- nodes
- techs
- timesteps
where: integer_dispatch==True AND cap_method==integer
unit: integer
default: 0
domain: integer
bounds:
min: 0
purchased_units¶
NEW
Integer number of a technology that has been purchased, for any technology set to require integer capacity purchasing. This is used to allow installation of fixed capacity units of technologies ( if flow_cap_max == flow_cap_min) and/or to set a fixed cost for a technology, irrespective of its installed capacity. On top of a fixed technology cost, a continuous cost for the quantity of installed capacity can still be applied.
Since technology capacity is no longer a continuous decision variable, it is possible for these technologies to have a lower bound set on outflow/consumption which will only be enforced in those timesteps that the technology is operating. Otherwise, the same lower bound forces the technology to produce/consume that minimum amount of carrier in every timestep.
Used in
- area_use_minimum
- available_flow_cap_max_binary_continuous_switch
- cost_investment_purchase
- flow_capacity_max_purchase_milp
- flow_capacity_minimum
- flow_capacity_systemwide_min
- flow_capacity_units_milp
- source_capacity_minimum
- storage_capacity_max_purchase_milp
- storage_capacity_minimum
- storage_capacity_units_milp
- unit_capacity_max_systemwide_milp
- unit_capacity_min_systemwide_milp
- unit_commitment_milp
Unit: integer
Default: 0
title: Number of purchased units
description: "NEW\nInteger number of a technology that has been purchased, for any
technology set to require integer capacity purchasing. This is used to allow installation
of fixed capacity units of technologies ( if `flow_cap_max` == `flow_cap_min`) and/or
to set a fixed cost for a technology, irrespective of its installed capacity. On
top of a fixed technology cost, a continuous cost for the quantity of installed
capacity can still be applied.\nSince technology capacity is no longer a continuous
decision variable, it is possible for these technologies to have a lower bound set
on outflow/consumption which will only be enforced in those timesteps that the technology
is operating. Otherwise, the same lower bound forces the technology to produce/consume
that minimum amount of carrier in *every* timestep."
foreach:
- nodes
- techs
where: cap_method==integer
unit: integer
default: 0
domain: integer
bounds:
max: purchased_units_max
min: purchased_units_min
source_cap¶
UPDATED
The upper limit on a flow that can be consumed from outside the system boundaries by a supply technology in each timestep. Minimum is set to 0 and handled in a distinct constraint to handle the integer purchase variable.
Used in
Uses
Unit: power
Default: 0
title: Source flow capacity
description: "UPDATED\nThe upper limit on a flow that can be consumed from outside
the system boundaries by a `supply` technology in each timestep. Minimum is set
to 0 and handled in a distinct constraint to handle the integer purchase variable."
foreach:
- nodes
- techs
where: base_tech==supply
unit: power
default: 0
bounds:
max: source_cap_max
min: 0
storage_cap¶
UPDATED The upper limit on a carrier that can be stored by a technology in any timestep. Minimum is set to 0 and handled in a distinct constraint to handle the integer purchase variable.
Unit: energy
Default: 0
title: Stored carrier capacity
description: "UPDATED\nThe upper limit on a carrier that can be stored by a technology
in any timestep. Minimum is set to 0 and handled in a distinct constraint to handle
the integer purchase variable."
foreach:
- nodes
- techs
where: include_storage==True OR base_tech==storage
unit: energy
default: 0
bounds:
max: storage_cap_max
min: 0
Parameters¶
area_use_max¶
If set to a finite value, limits the upper bound of the area_use decision variable to this value.
Used in
Unit: \(\text{area}\)
Default: inf
area_use_min¶
Limits the lower bound of the area_use decision variable to this value.
Used in
Unit: \(\text{area}\)
Default: 0
area_use_per_flow_cap¶
If set, forces area_use to follow flow_cap with the given numerical ratio (e.g. setting to 1.5 means that area_use == 1.5 * flow_cap).
Used in
Unit: \(\frac{\text{area}}{\text{power}}\)
Default: nan
bigM¶
BigM is a large value used to define certain optimisation problems. See https://en.wikipedia.org/wiki/Big_M_method for more information. This value should be larger than the largest values that any decision variables can take, but should not be too large (i.e., do not set it greater than 3 orders of magnitude above the numeric range of the model). If too large, numerical problems may arise in the optimisation.
Unit: unitless
Default: 1000000.0
cost_purchase¶
Cost applied to the variable purchased_units. Requires the parameter cap_method to be integer.
Used in
Unit: \(\frac{\text{cost}}{\text{unit}}\)
Default: 0
cost_purchase_per_distance¶
Cost applied if the binary variable purchased is 1 or per unit of the integer variable units. Requires the parameter cap_method to be integer.
Used in
Unit: \(\frac{\text{cost}}{\text{unit}\times\text{distance}}\)
Default: 0
distance¶
Used for ..._per_distance constraints. If not defined, it will be automatically derived from latitude/longitude of nodes in a link.
Used in
Unit: distance.
Default: 1.0
flow_cap_max¶
Limits flow_cap to a maximum.
Used in
Unit: power.
Default: inf
flow_cap_min¶
Limits flow_cap to a minimum. NOTE: this will force flow_cap to a minimum value unless cap_method is set to integer. If cap_method=integer, this will be scaled by the number of integer units of a technology purchased.
Used in
Unit: power or \(\frac{\text{power}}{\text{unit}}\)
Default: 0
flow_cap_min_systemwide¶
Limits the sum of flow_cap over all nodes in the model to a minimum. NOTE: this will force the sum of flow_cap to a minimum value unless cap_method is set to integer.
Used in
Unit: power.
Default: 0
flow_cap_per_unit¶
Set the capacity of each integer unit of a technology purchased, if cap_method is integer.
Used in
Unit: \(\frac{\text{power}}{\text{unit}}\)
Default: inf
flow_out_min_relative¶
Set to a value between 0 and 1 to force minimum flow_out as a fraction of the technology rated capacity. If non-zero and cap_method is continuous, this will force the technology to operate above its minimum value at every timestep.
Used in
Unit: unitless.
Default: 0
flow_out_parasitic_eff¶
Additional losses as flow gets transferred from the plant to the carrier, e.g. due to plant parasitic consumption. Set as value between 1 (no loss) and 0 (all lost).
Used in
Unit: unitless.
Default: 1.0
purchased_units_max¶
Limits the upper bound of units purchased if cap_method is integer. If set to 1, will effectively set the purchased_units to a binary decision variable.
Used in
Unit: integer.
Default: inf
purchased_units_max_systemwide¶
sets the upper bound of the sum across all nodes of the decision variable units for a particular technology.
Unit: integer.
Default: inf
purchased_units_min¶
Limits the lower bound of units purchased if cap_method is integer.
Used in
Unit: integer.
Default: 0
source_cap_max¶
Upper limit on source_cap decision variable.
Used in
Unit: power.
Default: inf
source_cap_min¶
Lower limit on source_cap decision variable.
Used in
Unit: power.
Default: 0
storage_cap_max¶
Limit upper bound of storage_cap decision variable.
Unit: energy.
Default: inf
storage_cap_min¶
Limit lower bound of storage_cap decision variable.
Used in
Unit: energy.
Default: 0
storage_cap_per_unit¶
Set the storage capacity of each integer unit of a technology purchased.
Used in
Unit: \(\frac{\text{energy}}{\text{unit}}\)
Default: inf
timestep_resolution¶
Unit: hours.
Default: 1
Lookup Arrays¶
base_tech¶
Should be the name of one of the abstract base classes, from which some initial parameter defaults will be derived and with which certain base math will be triggered.
Default: nan
Type: string
cap_method¶
One of 'continuous' (LP model) or 'integer' (integer/binary unit capacity).
Used in
Default: continuous
Type: string
carrier_in¶
Carrier(s) consumed by this technology. Only transmission, conversion, storage, and demand technologies can define this parameter
Used in
Default: False
Type: bool
carrier_out¶
Carrier(s) produced by this technology. Only transmission, conversion, storage, and supply technologies can define this parameter
Used in
Default: False
Type: bool
force_async_flow¶
If True, non-zero flow_out and flow_in cannot both occur in the same timestep.
Used in
Default: False
Type: bool
include_storage¶
When true, math will be triggered to allow discontinuous carrier inflow and outflows across timesteps.
Used in
Default: False
Type: bool
integer_dispatch¶
When true, will limit per-timestep out/inflows relative to the number of units of a technology that are in operation.
Requires cap_method=integer.
Used in
Default: False
Type: bool
sink_unit¶
Sets the unit of Sink to either absolute (unit: energy), per_area (unit: energy/area), or per_cap (unit: energy/power). per_area uses the area_use decision variable to scale the sink while per_cap uses the flow_cap decision variable.
Used in
Default: absolute
Type: string
source_unit¶
Sets the unit of Source to either absolute (unit: energy), per_area (unit: energy/area), or per_cap (unit: energy/power). per_area uses the area_use decision variable to scale the source while per_cap uses the flow_cap decision variable.
Used in
Default: absolute
Type: string