# Structure of OSeMOSYS¶

In OSeMOSYS, like usually in linear programs, sets, parameters and variables are defined. In this section, the sets, parameters and variables existing in OSeMOSYS are listed and briefly described. Illustrative examples on how to assign values for each of these will be given in the following Sections.

## Sets¶

The ‘sets’ define the physical structure of a model, usually independent from the specific scenarios which will be run. They define the time domain and time split, the spatial coverage, the technologies and energy vectors to be considered, etc. For instance, when a variable is defined as a function of the set ‘YEAR’ it will be indicated as variablename[y] at it will be computed for every year listed in the set. The sets of OSeMOSYS are presented in the Table below.

Name Description Index
YEAR It represents the time frame of the model, it contains all the years to be considered in the study. y
TECHNOLOGY It includes any element of the energy system that changes a commodity from one form to another, uses it or supplies it. All system components are set up as a ‘technology’ in OSeMOSYS. As the model is an abstraction, the modeller is free to interpret the role of a technology at will, where relevant. It may for example represent a single real technology (such as a power plant) or can represent a heavily aggregated collection of technologies (such as the stock of several million light bulbs), or may even simply be a ‘dummy technology’, perhaps used for accounting purposes. t
TIMESLICE It represents the time split of each modelled year, therefore the time resolution of the model. Common to several energy systems modelling tools (incl. MESSAGE / MARKAL / TIMES), the annual demand is ‘sliced’ into representative fractions of the year. It is necessary to assess times of the year when demand is high separately from times when demand is low, for fuels that are expensive to store. In order to reduce the computation time, these ‘slices’ are often grouped. Thus, the annual demand may be split into aggregate seasons where demand levels are similar (such as ‘summer, winter and intermediate’). Those seasons may be subdivided into aggregate ‘day types’ (such as workdays and weekends), and the day further sub divided (such as into day and night) depending on the level of demand. l
FUEL It includes any energy vector, energy service or proxies entering or exiting technologies. These can be aggregate groups, individual flows or artificially separated, depending on the requirements of the analysis. f
EMISSION It includes any kind of emission potentially deriving from the operation of the defined technologies. Typical examples would include atmospheric emissions of greenhouse gasses, such as CO2. e
MODE_OF_OPERATION It defines the number of modes of operation that the technologies can have. If a technology can have various input or output fuels and it can choose the mix (i.e. any linear combination) of these input or output fuels, each mix can be accounted as a separate mode of operation. For example, a CHP plant may produce heat in one mode of operation and electricity in another. m
REGION It sets the regions to be modelled, e.g. different countries. For each of them, the supply-demand balances for all the energy vectors are ensured, including trades with other regions. In some occasions it might be computationally more convenient to model different countries within the same region and differentiate them simply by creating ad hoc fuels and technologies for each of them. r
SEASON It gives indication (by successive numerical values) of how many seasons (e.g. winter, intermediate, summer) are accounted for and in which order. This set is needed if storage facilities are included in the model. ls
DAYTYPE It gives indication (by successive numerical values) of how many day types (e.g. workday, weekend) are accounted for and in which order. This set is needed if storage facilities are included in the model. ld
DAILYTIMEBRACKET It gives indication (by successive numerical values) of how many parts the day is split into (e.g. night, morning, afternoon, evening) and in which order these parts are sorted. This set is needed if storage facilities are included in the model. lh
STORAGE It includes storage facilities in the model. s

## Parameters¶

The parameters are the user-defined numerical inputs to the model. While usually the structure of a model, therefore the sets, remains fixed across scenarios, it is common practice to change the values of some parameters when running different scenarios and/or sensitivity analyses. As will be clear in the following, each parameter is a function of the elements in one or more sets. For instance, CapitalCost[r,t,y] indicates that the capital cost is a function of the region (r), the technology (t) and the year (y)  . A list and brief description of the parameters declared in the master version of OSeMOSYS is given in the Table below.

### Global parameters¶

Name Description
YearSplit[l,y] Duration of a modelled time slice, expressed as a fraction of the year. The sum of each entry over one modelled year should equal 1.
DiscountRate[r] Region specific value for the discount rate, expressed in decimals (e.g. 0.05)
DaySplit[lh,y] Length of one DailyTimeBracket in one specific day as a fraction of the year (e.g., when distinguishing between days and night: 12h/(24h*365d)).
Conversionls[l,ls] Binary parameter linking one TimeSlice to a certain Season. It has value 0 if the TimeSlice does not pertain to the specific season, 1 if it does.
Conversionld[ld,l] Binary parameter linking one TimeSlice to a certain DayType. It has value 0 if the TimeSlice does not pertain to the specific DayType, 1 if it does.
Conversionlh[lh,l] Binary parameter linking one TimeSlice to a certain DaylyTimeBracket. It has value 0 if the TimeSlice does not pertain to the specific DaylyTimeBracket, 1 if it does.
DaysInDayType[ls,ld,y] Number of days for each day type, within one week (natural number, ranging from 1 to 7)
TradeRoute[r,rr,f,y] Binary parameter defining the links between region r and region rr, to enable or disable trading of a specific commodity. It has value 1 when two regions are linked, 0 otherwise
DepreciationMethod[r] Binary parameter defining the type of depreciation to be applied. It has value 1 for sinking fund depreciation, value 2 for straight-line depreciation.

### Demands¶

Name Description
SpecifiedAnnualDemand[r,f,y] Total specified demand for the year, linked to a specific ‘time of use’ during the year.
SpecifiedDemandProfile[r,f,l,y] Annual fraction of energy-service or commodity demand that is required in each time slice. For each year, all the defined SpecifiedDemandProfile input values should sum up to 1.
AccumulatedAnnualDemand[r,f,y] Accumulated Demand for a certain commodity in one specific year. It cannot be defined for a commodity if its SpecifiedAnnualDemand for the same year is already defined and vice versa.

### Performance¶

Name Description
CapacityToActivityUnit[r,t] Conversion factor relating the energy that would be produced when one unit of capacity is fully used in one year.
CapacityFactor[r,t,l,y] Capacity available per each TimeSlice expressed as a fraction of the total installed capacity, with values ranging from 0 to 1. It gives the possibility to account for forced outages.
AvailabilityFactor[r,t,y] Maximum time a technology can run in the whole year, as a fraction of the year ranging from 0 to 1. It gives the possibility to account for planned outages.
OperationalLife[r,t] Useful lifetime of a technology, expressed in years.
ResidualCapacity[r,t,y] Remained capacity available from before the modelling period.
InputActivityRatio[r,t,f,m,y] Rate of use of a commodity by a technology, as a ratio of the rate of activity.
OutputActivityRatio[r,t,f,m,y] Rate of commodity output from a technology, as a ratio of the rate of activity.

### Technology costs¶

Name Description
CapitalCost[r,t,y] Capital investment cost of a technology, per unit of capacity.
VariableCost[r,t,m,y] Cost of a technology for a given mode of operation (Variable O&M cost), per unit of activity.
FixedCost[r,t,y] Fixed O&M cost of a technology, per unit of capacity.

### Storage¶

Name Description
TechnologyToStorage[r,t,s,m] Binary parameter linking a technology to the storage facility it charges. It has value 1 if the technology and the storage facility are linked, 0 otherwise.
TechnologyFromStorage[r,t,s,m] Binary parameter linking a storage facility to the technology it feeds. It has value 1 if the technology and the storage facility are linked, 0 otherwise.
StorageLevelStart[r,s] Level of storage at the beginning of first modelled year, in units of activity.
StorageMaxChargeRate[r,s] Maximum charging rate for the storage, in units of activity per year.
StorageMaxDischargeRate[r,s] Maximum discharging rate for the storage, in units of activity per year.
MinStorageCharge[r,s,y] It sets a lower bound to the amount of energy stored, as a fraction of the maximum, with a number reanging between 0 and 1. The storage facility cannot be emptied below this level.
OperationalLifeStorage[r,s] Useful lifetime of the storage facility.
CapitalCostStorage[r,s,y] Investment costs of storage additions, defined per unit of storage capacity.
ResidualStorageCapacity[r,s,y] Exogenously defined storage capacities.

### Capacity constraints¶

Name Description
CapacityOfOneTechnologyUnit[r,t,y] Capacity of one new unit of a technology. In case the user sets this parameter, the related technology will be installed only in batches of the specified capacity and the problem will turn into a Mixed Integer Linear Problem.
TotalAnnualMaxCapacity[r,t,y] Total maximum existing (residual plus cumulatively installed) capacity allowed for a technology in a specified year.
TotalAnnualMinCapacity[r,t,y] Total minimum existing (residual plus cumulatively installed) capacity allowed for a technology in a specified year.
Investment constraints
TotalAnnualMaxCapacityInvestment[r,t,y] Maximum capacity of a technology, expressed in power units.
TotalAnnualMinCapacityInvestment[r,t,y] Minimum capacity of a technology, expressed in power units.

### Activity constraints¶

Name Description
TotalTechnologyAnnualActivityUpperLimit[r,t,y] Total maximum level of activity allowed for a technology in one year.
TotalTechnologyAnnualActivityLowerLimit[r,t,y] Total minimum level of activity allowed for a technology in one year.
TotalTechnologyModelPeriodActivityUpperLimit[r,t] Total maximum level of activity allowed for a technology in the entire modelled period.
TotalTechnologyModelPeriodActivityLowerLimit[r,t] Total minimum level of activity allowed for a technology in the entire modelled period.

### Reserve margin¶

Name Description
ReserveMarginTagTechnology[r,t,y] Binary parameter tagging the technologies that are allowed to contribute to the reserve margin. It has value 1 for the technologies allowed, 0 otherwise.
ReserveMarginTagFuel[r,f,y] Binary parameter tagging the fuels to which the reserve margin applies. It has value 1 if the reserve margin applies to the fuel, 0 otherwise.
ReserveMargin[r,y] Minimum level of the reserve margin required to be provided for all the tagged commodities, by the tagged technologies. If no reserve margin is required, the parameter will have value 1; if, for instance, 20% reserve margin is required, the parameter will have value 1.2.

### RE Generation target¶

Name Description
RETagTechnology[r,t,y] Binary parameter tagging the renewable technologies that must contribute to reaching the indicated minimum renewable production target. It has value 1 for thetechnologies contributing, 0 otherwise.
RETagFuel[r,f,y] Binary parameter tagging the fuels to which the renewable target applies to. It has value 1 if the target applies, 0 otherwise.
REMinProductionTarget[r,y] Minimum ratio of all renewable commodities tagged in the RETagCommodity parameter, to be produced by the technologies tagged with the RETechnology parameter.

### Emissions¶

Name Description
EmissionActivityRatio[r,t,e,m,y] Emission factor of a technology per unit of activity, per mode of operation.
EmissionsPenalty[r,e,y] Penalty per unit of emission.
AnnualExogenousEmission[r,e,y] It allows the user to account for additional annual emissions, on top of those computed endogenously by the model (e.g. emissions generated outside the region).
AnnualEmissionLimit[r,e,y] Annual upper limit for a specific emission generated in the whole modelled region.
ModelPeriodExogenousEmission[r,e] It allows the user to account for additional emissions over the entire modelled period, on top of those computed endogenously by the model (e.g. generated outside the region).
ModelPeriodEmissionLimit[r,e] Annual upper limit for a specific emission generated in the whole modelled region, over the entire modelled period.
  Please note that the order of the indexes of the parameters presented here and available in the current version of OSeMOSYS is different from the one in Howells et al. in 2011. For more information refer to the Change Log of the OSeMOSYS versions, available at http://www.osemosys.org/get-started.html.

## Variables¶

The variables are the outputs computed by the code. As much as the parameters, also the variables are functions of the elements in one or more sets. In the following Table, a list and brief description of all the variables computed by the code of OSeMOSYS (in its full version) is given. As will be explained next in this manual, a shortened version of OSeMOSYS has been created, to improve the computational capability at the expenses of the readability of the code. In such version, only some of the variables here listed are computed. When reasonable, the domain of several variables has been constrained to be positive, in order to decrease the size of the solution space and therefore the computational effort.

### Demands¶

Name Description
RateOfDemand[r,l,f,y]>=0 Intermediate variable. It represents the energy that would be demanded in one time slice l if the latter lasted the whole year. It is a function of the parameters SpecifiedAnnualDemand and SpecifiedDemandProfile. | Energy (per year)
Demand[r,l,f,y]>=0 Demand for one fuel in one time slice. Energy

### Storage¶

Name Description
RateOfStorageCharge[r,s,ls,ld,lh,y] Intermediate variable. It represents the commodity that would be charged to the storage facility s in one time slice if the latter lasted the whole year. It is a function of the RateOfActivity and the parameter TechnologyToStorage. | Energy (per year)
RateOfStorageDischarge[r,s,ls,ld,lh,y] Intermediate variable. It represents the commodity that would be discharged from storage facility s in one time slice if the latter lasted the whole year. It is a function of the RateOfActivity and the parameter TechnologyFromStorage. Energy (per year)
NetChargeWithinYear[r,s,ls,ld,lh,y] Net quantity of commodity charged to storage facility s in year y. It is a function of the RateOfStorageCharge and the RateOfStorageDischarge and it can be negative. Energy
NetChargeWithinDay[r,s,ls,ld,lh,y] Net quantity of commodity charged to storage facility s in daytype ld. It is a function of the RateOfStorageCharge and the RateOfStorageDischarge and can be negative. Energy
StorageLevelYearStart[r,s,y]>=0 Level of stored commodity in storage facility s in the first time step of year y. Energy
StorageLevelYearFinish[r,s,y]>=0 Level of stored commodity in storage facility s in the last time step of year y. Energy
StorageLevelSeasonStart[r,s,ls,y]>=0 Level of stored commodity in storage facility s in the first time step of season ls. Energy
StorageLevelDayTypeStart[r,s,ls,ld,y]>=0 Level of stored commodity in storage facility s in the first time step of daytype ld. Energy
StorageLevelDayTypeFinish[r,s,ls,ld,y]>=0 Level of stored commodity in storage facility s in the last time step of daytype ld. Energy
StorageLowerLimit[r,s,y]>=0 Minimum allowed level of stored commodity in storage facility s, as a function of the storage capacity and the user-defined MinStorageCharge ratio. Energy
StorageUpperLimit[r,s,y]>=0 Maximum allowed level of stored commodity in storage facility s. It corresponds to the total existing capacity of storage facility s (summing newly installed and pre-existing capacities). Energy
AccumulatedNewStorageCapacity[r,s,y]>=0 Cumulative capacity of newly installed storage from the beginning of the time domain to year y. Energy
NewStorageCapacity[r,s,y]>=0 Capacity of newly installed storage in year y. Energy
CapitalInvestmentStorage[r,s,y]>=0 Undiscounted investment in new capacity for storage facility s. Derived from the NewStorageCapacity and the parameter CapitalCostStorage. Monetary units
DiscountedCapitalInvestmentStorage[r,s,y]>=0 Investment in new capacity for storage facility s, discounted through the parameter DiscountRate. Monetary units
SalvageValueStorage[r,s,y]>=0 Salvage value of storage facility s in year y, as a function of the parameters OperationalLifeStorage and DepreciationMethod. Monetary units
DiscountedSalvageValueStorage[r,s,y]>=0 Salvage value of storage facility s, discounted through the parameter DiscountRate. Monetary units
TotalDiscountedStorageCost[r,s,y]>=0 Difference between the discounted capital investment in new storage facilities and the salvage value in year y. Monetary units

### Capacity variables¶

Name Description
NumberOfNewTechnologyUnits[r,t,y]>=0, integer Number of newly installed units of technology t in year y, as a function of the parameter CapacityOfOneTechnologyUnit. | No unit
NewCapacity[r,t,y]>=0 Newly installed capacity of technology t in year y. Power
AccumulatedNewCapacity[r,t,y]>=0 Cumulative newly installed capacity of technology t from the beginning of the time domain to year y. Power
TotalCapacityAnnual[r,t,y]>=0 Total existing capacity of technology t in year y (sum of cumulative newly installed and pre-existing capacity). Power

### Activity variables¶

Name Description
RateOfActivity[r,l,t,m,y] >=0 Intermediate variable. It represents the activity of technology t in one mode of operation and in time slice l, if the latter lasted the whole year. | Energy (per year)
RateOfTotalActivity[r,t,l,y] >=0 Sum of the RateOfActivity of a technology over the modes of operation. Energy (per year)
TotalTechnologyAnnualActivity[r,t,y] >=0 Total annual activity of technology t. Energy
TotalAnnualTechnologyActivityByMode[r,t,m,y] >=0 Annual activity of technology t in mode of operation m. Energy
TotalTechnologyModelPeriodActivity[r,t] Sum of the TotalTechnologyAnnualActivity over the years of the modelled period. Energy
RateOfProductionByTechnologyByMode[r,l,t,m,f,y] >=0 Intermediate variable. It represents the quantity of fuel f that technology t would produce in one mode of operation and in time slice l, if the latter lasted the whole year. It is a function of the variable RateOfActivity and the parameter OutputActivityRatio. Energy (per year)
RateOfProductionByTechnology[r,l,t,f,y] >=0 Sum of the RateOfProductionByTechnologyByMode over the modes of operation. Energy (per year)
ProductionByTechnology[r,l,t,f,y] >=0 Production of fuel f by technology t in time slice l. Energy
ProductionByTechnologyAnnual[r,t,f,y] >=0 Annual production of fuel f by technology t. Energy
RateOfProduction[r,l,f,y] >=0 Sum of the RateOfProductionByTechnology over all the technologies. Energy (per year)
Production[r,l,f,y] >=0 Total production of fuel f in time slice l. It is the sum of the ProductionByTechnology over all technologies. Energy
RateOfUseByTechnologyByMode[r,l,t,m,f,y] >=0 Intermediate variable. It represents the quantity of fuel f that technology t would use in one mode of operation and in time slice l, if the latter lasted the whole year. It is the function of the variable RateOfActivity and the parameter InputActivityRatio. Energy (per year)
RateOfUseByTechnology[r,l,t,f,y] >=0 Sum of the RateOfUseByTechnologyByMode over the modes of operation. Energy (per year)
UseByTechnologyAnnual[r,t,f,y] >=0 Annual use of fuel f by technology t. Energy
UseByTechnology[r,l,t,f,y] >=0 Use of fuel f by technology t in time slice l. Energy
Use[r,l,f,y] >=0 Total use of fuel f in time slice l. It is the sum of the UseByTechnology over all technologies. Energy
Trade[r,rr,l,f,y] Quantity of fuel f traded between region r and rr in time slice l. Energy
TradeAnnual[r,rr,f,y] Annual quantity of fuel f traded between region r and rr. It is the sum of the variable Trade over all the time slices. Energy
ProductionAnnual[r,f,y] >=0 Total annual production of fuel f. It is the sum of the variable Production over all technologies. Energy
UseAnnual[r,f,y] >=0 Total annual use of fuel f. It is the sum of the variable Use over all technologies. Energy

### Costing variables¶

Name Description
CapitalInvestment[r,t,y] >=0 Undiscounted investment in new capacity of technology t. It is a function of the NewCapacity and the parameter CapitalCost. | Monetary units
DiscountedCapitalInvestment[r,t,y] >=0 Investment in new capacity of technology t, discounted through the parameter DiscountRate. Monetary units
SalvageValue[r,t,y] >=0 Salvage value of technology t in year y, as a function of the parameters OperationalLife and DepreciationMethod. Monetary units
DiscountedSalvageValue[r,t,y] >=0 Salvage value of technology t, discounted through the parameter DiscountRate. Monetary units
OperatingCost[r,t,y] >=0 Undiscounted sum of the annual variable and fixed operating costs of technology t. Monetary units
DiscountedOperatingCost[r,t,y] >=0 Annual OperatingCost of technology t, discounted through the parameter DiscountRate. Monetary units
AnnualVariableOperatingCost[r,t,y] >=0 Annual variable operating cost of technology t. Derived from the TotalAnnualTechnologyActivityByMode and the parameter VariableCost. Monetary units
AnnualFixedOperatingCost[r,t,y] >=0 Annual fixed operating cost of technology t. Derived from the TotalCapacityAnnual and the parameter FixedCost. Monetary units
TotalDiscountedCostByTechnology[r,t,y] >=0 Difference between the sum of discounted operating cost / capital cost / emission penalties and the salvage value. Monetary units
TotalDiscountedCost[r,y] >=0 Sum of the TotalDiscountedCostByTechnology over all the technologies. Monetary units
ModelPeriodCostByRegion[r] >=0 Sum of the TotalDiscountedCost over all modelled years. Monetary units

### Reserve margin¶

Name Description
TotalCapacityInReserveMargin[r,y] >=0 Total available capacity of the technologies required to provide reserve margin. It is derived from the TotalCapacityAnnual and the parameter ReserveMarginTagTechnology. | Energy
DemandNeedingReserveMargin[r,l,y] >=0 Quantity of fuel produced that is assigned to a target of reserve margin. Derived from the RateOfProduction and the parameter ReserveMarginTagFuel. Energy (per year)
TotalREProductionAnnual[r,y] Annual production by all technologies tagged as renewable in the model. Derived from the ProductionByTechnologyAnnual and the parameter RETagTechnology. Energy
RETotalProductionOfTargetFuelAnnual[r,y] Annual production of fuels tagged as renewable in the model. Derived from the RateOfProduction and the parameter RETagFuel. Energy
AnnualTechnologyEmissionByMode[r,t,e,m,y] >=0 Annual emission of agent e by technology t in mode of operation m. Derived from the RateOfActivity and the parameter EmissionActivityRatio. Quantity of emission
AnnualTechnologyEmission[r,t,e,y] >=0 Sum of the AnnualTechnologyEmissionByMode over the modes of operation. Quantity of emission
AnnualTechnologyEmissionPenaltyByEmission[r,t,e,y] >=0 Undiscounted annual cost of emission e by technology t. It is a function of the AnnualTechnologyEmission and the parameter EmissionPenalty. Monetary units
AnnualTechnologyEmissionsPenalty[r,t,y] >=0 Total undiscounted annual cost of all emissions generated by technology t. Sum of the AnnualTechnologyEmissionPenaltyByEmission over all the emitted agents. Monetary units
DiscountedTechnologyEmissionsPenalty[r,t,y] >=0 Annual cost of emissions by technology t, discounted through the DiscountRate. Monetary units
AnnualEmissions[r,e,y] >=0 Sum of the AnnualTechnologyEmission over all technologies. Quantity of emission
ModelPeriodEmissions[r,e] >=0 Total system emissions of agent e in the model period, accounting for both the emissions by technologies and the user defined ModelPeriodExogenousEmission. Quantity of emission

## Equations¶

The OSeMOSYS code is divided into blocks of equations that comprises one objective function and several constraints. The blocks of code allow for a modular structure in different functionalities can be added or removed based on the user’s needs. This flexible, modular structure allows OSeMOSYS to be used for a wide range of applications of different scales, complexities, and objectives.

### Objective function¶

This equation represents the overall objective of the model. The default in OSeMOSYS is to minimise the total system cost, over the entire model period.

```minimize cost: sum{r in REGION, y in YEAR} TotalDiscountedCost[r,y];
```

### Rate of demand¶

The equation below is used to generate the term RateOfDemand, from the user-provided data for SpecifiedAnnualDemand and SpecifiedDemandProfile. The RateOfDemand is defined for each combination of commodity, TimeSlice and Year.

```s.t. EQ_SpecifiedDemand{r in REGION, l in TIMESLICE, f in FUEL, y in YEAR}:
SpecifiedAnnualDemand[r,f,y]*SpecifiedDemandProfile[r,f,l,y] / YearSplit[l,y]=RateOfDemand[r,l,f,y];
```

Used to first calculate total capacity of each technology for each year based on existing capacity from before the model period (ResidualCapacity), AccumulatedNewCapacity during the modelling period, and NewCapacity installed in each year. It is then ensured that this Capacity is sufficient to meet the RateOfTotalActivity in each TimeSlice and Year. An additional constraint based on the size, or capacity, of each unit of a Technology is included (CapacityOfOneTechnologyUnit). This stipulates that the capacity of certain Technology can only be a multiple of the user-defined CapacityOfOneTechnologyUnit.

```s.t. CAa1_TotalNewCapacity{r in REGION, t in TECHNOLOGY, y in YEAR}:
AccumulatedNewCapacity[r,t,y] = sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} NewCapacity[r,t,yy];

s.t. CAa2_TotalAnnualCapacity{r in REGION, t in TECHNOLOGY, y in YEAR}:
AccumulatedNewCapacity[r,t,y]+ ResidualCapacity[r,t,y] = TotalCapacityAnnual[r,t,y];

s.t. CAa3_TotalActivityOfEachTechnology{r in REGION, t in TECHNOLOGY, l in TIMESLICE, y in YEAR}:
sum{m in MODE_OF_OPERATION} RateOfActivity[r,l,t,m,y] = RateOfTotalActivity[r,t,l,y];

s.t. CAa4_Constraint_Capacity{r in REGION, l in TIMESLICE, t in TECHNOLOGY, y in YEAR}:
RateOfTotalActivity[r,t,l,y] <= TotalCapacityAnnual[r,t,y] * CapacityFactor[r,t,l,y]*CapacityToActivityUnit[r,t];

s.t. CAa5_TotalNewCapacity{r in REGION, t in TECHNOLOGY, y in YEAR:
CapacityOfOneTechnologyUnit[r,t,y]<>0}: CapacityOfOneTechnologyUnit[r,t,y]*NumberOfNewTechnologyUnits[r,t,y] = NewCapacity[r,t,y];
```

NOTE: OSeMOSYS uses Mixed Integer Programming to solve models that define CapacityOfTechnologyUnit. Using this parameter is likely to increase the model computation time.

Ensures that adequate capacity of technologies is present to at least meet the average annual demand.

```s.t. CAb1_PlannedMaintenance{r in REGION, t in TECHNOLOGY, y in YEAR}:
sum{l in TIMESLICE} RateOfTotalActivity[r,t,l,y]*YearSplit[l,y] <= sum{l in TIMESLICE} (TotalCapacityAnnual[r,t,y]*CapacityFactor[r,t,l,y]*YearSplit[l,y])* AvailabilityFactor[r,t,y]*CapacityToActivityUnit[r,t];
```

### Energy Balance A¶

Ensures that demand for each commodity is met in each TimeSlice.

```s.t. EBa1_RateOfFuelProduction1{r in REGION, l in TIMESLICE, f in FUEL, t in TECHNOLOGY, m in MODE_OF_OPERATION, y in YEAR: OutputActivityRatio[r,t,f,m,y] <>0}:
RateOfActivity[r,l,t,m,y]*OutputActivityRatio[r,t,f,m,y]  = RateOfProductionByTechnologyByMode[r,l,t,m,f,y];

s.t. EBa2_RateOfFuelProduction2{r in REGION, l in TIMESLICE, f in FUEL, t in TECHNOLOGY, y in YEAR}:
sum{m in MODE_OF_OPERATION: OutputActivityRatio[r,t,f,m,y] <>0} RateOfProductionByTechnologyByMode[r,l,t,m,f,y] = RateOfProductionByTechnology[r,l,t,f,y];

s.t. EBa3_RateOfFuelProduction3{r in REGION, l in TIMESLICE, f in FUEL, y in YEAR}:
sum{t in TECHNOLOGY} RateOfProductionByTechnology[r,l,t,f,y]  =  RateOfProduction[r,l,f,y];

s.t. EBa4_RateOfFuelUse1{r in REGION, l in TIMESLICE, f in FUEL, t in TECHNOLOGY, m in MODE_OF_OPERATION, y in YEAR: InputActivityRatio[r,t,f,m,y]<>0}:
RateOfActivity[r,l,t,m,y]*InputActivityRatio[r,t,f,m,y]  = RateOfUseByTechnologyByMode[r,l,t,m,f,y];

s.t. EBa5_RateOfFuelUse2{r in REGION, l in TIMESLICE, f in FUEL, t in TECHNOLOGY, y in YEAR}:
sum{m in MODE_OF_OPERATION: InputActivityRatio[r,t,f,m,y]<>0} RateOfUseByTechnologyByMode[r,l,t,m,f,y] = RateOfUseByTechnology[r,l,t,f,y];

s.t. EBa6_RateOfFuelUse3{r in REGION, l in TIMESLICE, f in FUEL, y in YEAR}:
sum{t in TECHNOLOGY} RateOfUseByTechnology[r,l,t,f,y]  = RateOfUse[r,l,f,y];

s.t. EBa7_EnergyBalanceEachTS1{r in REGION, l in TIMESLICE, f in FUEL, y in YEAR}:
RateOfProduction[r,l,f,y]*YearSplit[l,y] = Production[r,l,f,y];

s.t. EBa8_EnergyBalanceEachTS2{r in REGION, l in TIMESLICE, f in FUEL, y in YEAR}:
RateOfUse[r,l,f,y]*YearSplit[l,y] = Use[r,l,f,y];

s.t. EBa9_EnergyBalanceEachTS3{r in REGION, l in TIMESLICE, f in FUEL, y in YEAR}:
RateOfDemand[r,l,f,y]*YearSplit[l,y] = Demand[r,l,f,y];

s.t. EBa10_EnergyBalanceEachTS4{r in REGION, rr in REGION, l in TIMESLICE, f in FUEL, y in YEAR}:

s.t. EBa11_EnergyBalanceEachTS5{r in REGION, l in TIMESLICE, f in FUEL, y in YEAR}:
```

### Energy Balance B¶

Ensures that demand for each commodity is met in each Year.

```s.t. EBb1_EnergyBalanceEachYear1{r in REGION, f in FUEL, y in YEAR}:
sum{l in TIMESLICE} Production[r,l,f,y] = ProductionAnnual[r,f,y];

s.t. EBb2_EnergyBalanceEachYear2{r in REGION, f in FUEL, y in YEAR}:
sum{l in TIMESLICE} Use[r,l,f,y] = UseAnnual[r,f,y];

s.t. EBb3_EnergyBalanceEachYear3{r in REGION, rr in REGION, f in FUEL, y in YEAR}:

s.t. EBb4_EnergyBalanceEachYear4{r in REGION, f in FUEL, y in YEAR}:
```

### Accounting Technology Production/Use¶

Accounting equations used to generate specific intermediate variables: ProductionByTechnology, UseBytechnology, TotalAnnualTechnologyActivityByMode, and ModelPeriodCostByRegion.

```s.t. Acc1_FuelProductionByTechnology{r in REGION, l in TIMESLICE, t in TECHNOLOGY, f in FUEL, y in YEAR}:
RateOfProductionByTechnology[r,l,t,f,y] * YearSplit[l,y] = ProductionByTechnology[r,l,t,f,y];

s.t. Acc2_FuelUseByTechnology{r in REGION, l in TIMESLICE, t in TECHNOLOGY, f in FUEL, y in YEAR}:
RateOfUseByTechnology[r,l,t,f,y] * YearSplit[l,y] = UseByTechnology[r,l,t,f,y];

s.t. Acc3_AverageAnnualRateOfActivity{r in REGION, t in TECHNOLOGY, m in MODE_OF_OPERATION, y in YEAR}:
sum{l in TIMESLICE} RateOfActivity[r,l,t,m,y]*YearSplit[l,y] = TotalAnnualTechnologyActivityByMode[r,t,m,y];

s.t. Acc4_ModelPeriodCostByRegion{r in REGION}:
sum{y in YEAR}TotalDiscountedCost[r,y] = ModelPeriodCostByRegion[r];
```

### Storage Equations¶

```s.t. S1_RateOfStorageCharge{r in REGION, s in STORAGE, ls in SEASON, ld in DAYTYPE, lh in DAILYTIMEBRACKET, y in YEAR}:
sum{t in TECHNOLOGY, m in MODE_OF_OPERATION, l in TIMESLICE:TechnologyToStorage[r,t,s,m]>0} RateOfActivity[r,l,t,m,y] * TechnologyToStorage[r,t,s,m] * Conversionls[l,ls] * Conversionld[l,ld] * Conversionlh[l,lh] = RateOfStorageCharge[r,s,ls,ld,lh,y];

s.t. S2_RateOfStorageDischarge{r in REGION, s in STORAGE, ls in SEASON, ld in DAYTYPE, lh in DAILYTIMEBRACKET, y in YEAR}:
sum{t in TECHNOLOGY, m in MODE_OF_OPERATION, l in TIMESLICE:TechnologyFromStorage[r,t,s,m]>0} RateOfActivity[r,l,t,m,y] * TechnologyFromStorage[r,t,s,m] * Conversionls[l,ls] * Conversionld[l,ld] * Conversionlh[l,lh] = RateOfStorageDischarge[r,s,ls,ld,lh,y];

s.t. S3_NetChargeWithinYear{r in REGION, s in STORAGE, ls in SEASON, ld in DAYTYPE, lh in DAILYTIMEBRACKET, y in YEAR}:
sum{l in TIMESLICE:Conversionls[l,ls]>0&&Conversionld[l,ld]>0&&Conversionlh[l,lh]>0}  (RateOfStorageCharge[r,s,ls,ld,lh,y] - RateOfStorageDischarge[r,s,ls,ld,lh,y]) * YearSplit[l,y] * Conversionls[l,ls] * Conversionld[l,ld] * Conversionlh[l,lh] = NetChargeWithinYear[r,s,ls,ld,lh,y];

s.t. S4_NetChargeWithinDay{r in REGION, s in STORAGE, ls in SEASON, ld in DAYTYPE, lh in DAILYTIMEBRACKET, y in YEAR}:
(RateOfStorageCharge[r,s,ls,ld,lh,y] - RateOfStorageDischarge[r,s,ls,ld,lh,y]) * DaySplit[lh,y] = NetChargeWithinDay[r,s,ls,ld,lh,y];

s.t. S5_and_S6_StorageLevelYearStart{r in REGION, s in STORAGE, y in YEAR}: if y = min{yy in YEAR} min(yy) then StorageLevelStart[r,s]
else StorageLevelYearStart[r,s,y-1] + sum{ls in SEASON, ld in DAYTYPE, lh in DAILYTIMEBRACKET} NetChargeWithinYear[r,s,ls,ld,lh,y-1]
= StorageLevelYearStart[r,s,y];

s.t. S7_and_S8_StorageLevelYearFinish{r in REGION, s in STORAGE, y in YEAR}: if y < max{yy in YEAR} max(yy) then StorageLevelYearStart[r,s,y+1]
else StorageLevelYearStart[r,s,y] + sum{ls in SEASON, ld in DAYTYPE, lh in DAILYTIMEBRACKET} NetChargeWithinYear[r,s,ls,ld,lh,y]
= StorageLevelYearFinish[r,s,y];

s.t. S9_and_S10_StorageLevelSeasonStart{r in REGION, s in STORAGE, ls in SEASON, y in YEAR}: if ls = min{lsls in SEASON} min(lsls) then StorageLevelYearStart[r,s,y]
else StorageLevelSeasonStart[r,s,ls-1,y] + sum{ld in DAYTYPE, lh in DAILYTIMEBRACKET} NetChargeWithinYear[r,s,ls-1,ld,lh,y]
= StorageLevelSeasonStart[r,s,ls,y];

s.t. S11_and_S12_StorageLevelDayTypeStart{r in REGION, s in STORAGE, ls in SEASON, ld in DAYTYPE, y in YEAR}: if ld = min{ldld in DAYTYPE} min(ldld) then StorageLevelSeasonStart[r,s,ls,y]
else StorageLevelDayTypeStart[r,s,ls,ld-1,y] + sum{lh in DAILYTIMEBRACKET} NetChargeWithinDay[r,s,ls,ld-1,lh,y] * DaysInDayType[ls,ld-1,y]
= StorageLevelDayTypeStart[r,s,ls,ld,y];

s.t. S13_and_S14_and_S15_StorageLevelDayTypeFinish{r in REGION, s in STORAGE, ls in SEASON, ld in DAYTYPE, y in YEAR}:	if ls = max{lsls in SEASON} max(lsls) && ld = max{ldld in DAYTYPE} max(ldld) then StorageLevelYearFinish[r,s,y]
else if ld = max{ldld in DAYTYPE} max(ldld) then StorageLevelSeasonStart[r,s,ls+1,y]
else StorageLevelDayTypeFinish[r,s,ls,ld+1,y] - sum{lh in DAILYTIMEBRACKET} NetChargeWithinDay[r,s,ls,ld+1,lh,y] * DaysInDayType[ls,ld+1,y]
= StorageLevelDayTypeFinish[r,s,ls,ld,y];
```

### Storage Constraints¶

```s.t. SC1_LowerLimit_BeginningOfDailyTimeBracketOfFirstInstanceOfDayTypeInFirstWeekConstraint{r in REGION, s in STORAGE, ls in SEASON, ld in DAYTYPE, lh in DAILYTIMEBRACKET, y in YEAR}:
0 <= (StorageLevelDayTypeStart[r,s,ls,ld,y]+sum{lhlh in DAILYTIMEBRACKET:lh-lhlh>0} NetChargeWithinDay[r,s,ls,ld,lhlh,y])-StorageLowerLimit[r,s,y];

s.t. SC1_UpperLimit_BeginningOfDailyTimeBracketOfFirstInstanceOfDayTypeInFirstWeekConstraint{r in REGION, s in STORAGE, ls in SEASON, ld in DAYTYPE, lh in DAILYTIMEBRACKET, y in YEAR}:
(StorageLevelDayTypeStart[r,s,ls,ld,y]+sum{lhlh in DAILYTIMEBRACKET:lh-lhlh>0} NetChargeWithinDay[r,s,ls,ld,lhlh,y])-StorageUpperLimit[r,s,y] <= 0;

s.t. SC2_LowerLimit_EndOfDailyTimeBracketOfLastInstanceOfDayTypeInFirstWeekConstraint{r in REGION, s in STORAGE, ls in SEASON, ld in DAYTYPE, lh in DAILYTIMEBRACKET, y in YEAR}:
0 <= if ld > min{ldld in DAYTYPE} min(ldld) then (StorageLevelDayTypeStart[r,s,ls,ld,y]-sum{lhlh in DAILYTIMEBRACKET:lh-lhlh<0} NetChargeWithinDay[r,s,ls,ld-1,lhlh,y])-StorageLowerLimit[r,s,y];

s.t. SC2_UpperLimit_EndOfDailyTimeBracketOfLastInstanceOfDayTypeInFirstWeekConstraint{r in REGION, s in STORAGE, ls in SEASON, ld in DAYTYPE, lh in DAILYTIMEBRACKET, y in YEAR}:
if ld > min{ldld in DAYTYPE} min(ldld) then (StorageLevelDayTypeStart[r,s,ls,ld,y]-sum{lhlh in DAILYTIMEBRACKET:lh-lhlh<0} NetChargeWithinDay[r,s,ls,ld-1,lhlh,y])-StorageUpperLimit[r,s,y] <= 0;

s.t. SC3_LowerLimit_EndOfDailyTimeBracketOfLastInstanceOfDayTypeInLastWeekConstraint{r in REGION, s in STORAGE, ls in SEASON, ld in DAYTYPE, lh in DAILYTIMEBRACKET, y in YEAR}:
0 <= (StorageLevelDayTypeFinish[r,s,ls,ld,y] - sum{lhlh in DAILYTIMEBRACKET:lh-lhlh<0} NetChargeWithinDay[r,s,ls,ld,lhlh,y])-StorageLowerLimit[r,s,y];

s.t. SC3_UpperLimit_EndOfDailyTimeBracketOfLastInstanceOfDayTypeInLastWeekConstraint{r in REGION, s in STORAGE, ls in SEASON, ld in DAYTYPE, lh in DAILYTIMEBRACKET, y in YEAR}:
(StorageLevelDayTypeFinish[r,s,ls,ld,y] - sum{lhlh in DAILYTIMEBRACKET:lh-lhlh<0} NetChargeWithinDay[r,s,ls,ld,lhlh,y])-StorageUpperLimit[r,s,y] <= 0;

s.t. SC4_LowerLimit_BeginningOfDailyTimeBracketOfFirstInstanceOfDayTypeInLastWeekConstraint{r in REGION, s in STORAGE, ls in SEASON, ld in DAYTYPE, lh in DAILYTIMEBRACKET, y in YEAR}:
0 <= if ld > min{ldld in DAYTYPE} min(ldld) then (StorageLevelDayTypeFinish[r,s,ls,ld-1,y]+sum{lhlh in DAILYTIMEBRACKET:lh-lhlh>0} NetChargeWithinDay[r,s,ls,ld,lhlh,y])-StorageLowerLimit[r,s,y];

s.t. SC4_UpperLimit_BeginningOfDailyTimeBracketOfFirstInstanceOfDayTypeInLastWeekConstraint{r in REGION, s in STORAGE, ls in SEASON, ld in DAYTYPE, lh in DAILYTIMEBRACKET, y in YEAR}:
if ld > min{ldld in DAYTYPE} min(ldld) then (StorageLevelDayTypeFinish[r,s,ls,ld-1,y]+sum{lhlh in DAILYTIMEBRACKET:lh-lhlh>0} NetChargeWithinDay[r,s,ls,ld,lhlh,y])-StorageUpperLimit[r,s,y] <= 0;

s.t. SC5_MaxChargeConstraint{r in REGION, s in STORAGE, ls in SEASON, ld in DAYTYPE, lh in DAILYTIMEBRACKET, y in YEAR}: RateOfStorageCharge[r,s,ls,ld,lh,y] <= StorageMaxChargeRate[r,s];

s.t. SC6_MaxDischargeConstraint{r in REGION, s in STORAGE, ls in SEASON, ld in DAYTYPE, lh in DAILYTIMEBRACKET, y in YEAR}: RateOfStorageDischarge[r,s,ls,ld,lh,y] <= StorageMaxDischargeRate[r,s];
```

### Storage Investments¶

Calculates the total discounted capital costs expenditure for each storage technology in each year.

```s.t. SI1_StorageUpperLimit{r in REGION, s in STORAGE, y in YEAR}:
AccumulatedNewStorageCapacity[r,s,y]+ResidualStorageCapacity[r,s,y] = StorageUpperLimit[r,s,y];

s.t. SI2_StorageLowerLimit{r in REGION, s in STORAGE, y in YEAR}:
MinStorageCharge[r,s,y]*StorageUpperLimit[r,s,y] = StorageLowerLimit[r,s,y];

s.t. SI3_TotalNewStorage{r in REGION, s in STORAGE, y in YEAR}:
sum{yy in YEAR: y-yy < OperationalLifeStorage[r,s] && y-yy>=0} NewStorageCapacity[r,s,yy]=AccumulatedNewStorageCapacity[r,s,y];

s.t. SI4_UndiscountedCapitalInvestmentStorage{r in REGION, s in STORAGE, y in YEAR}:
CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y] = CapitalInvestmentStorage[r,s,y];

s.t. SI5_DiscountingCapitalInvestmentStorage{r in REGION, s in STORAGE, y in YEAR}:
CapitalInvestmentStorage[r,s,y]/((1+DiscountRate[r])^(y-min{yy in YEAR} min(yy))) = DiscountedCapitalInvestmentStorage[r,s,y];

s.t. SI6_SalvageValueStorageAtEndOfPeriod1{r in REGION, s in STORAGE, y in YEAR:
(y+OperationalLifeStorage[r,s]-1) <= (max{yy in YEAR} max(yy))}: 0 = SalvageValueStorage[r,s,y];

s.t. SI7_SalvageValueStorageAtEndOfPeriod2{r in REGION, s in STORAGE, y in YEAR:
(DepreciationMethod[r]=1 && (y+OperationalLifeStorage[r,s]-1) > (max{yy in YEAR} max(yy)) && DiscountRate[r]=0) || (DepreciationMethod[r]=2 && (y+OperationalLifeStorage[r,s]-1) > (max{yy in YEAR} max(yy)))}: CapitalInvestmentStorage[r,s,y]*(1-(max{yy in YEAR} max(yy) - y+1)/OperationalLifeStorage[r,s]) = SalvageValueStorage[r,s,y];

s.t. SI8_SalvageValueStorageAtEndOfPeriod3{r in REGION, s in STORAGE, y in YEAR:
DepreciationMethod[r]=1 && (y+OperationalLifeStorage[r,s]-1) > (max{yy in YEAR} max(yy)) && DiscountRate[r]>0}: CapitalInvestmentStorage[r,s,y]*(1-(((1+DiscountRate[r])^(max{yy in YEAR} max(yy) - y+1)-1)/((1+DiscountRate[r])^OperationalLifeStorage[r,s]-1))) = SalvageValueStorage[r,s,y];

s.t. SI9_SalvageValueStorageDiscountedToStartYear{r in REGION, s in STORAGE, y in YEAR}:
SalvageValueStorage[r,s,y]/((1+DiscountRate[r])^(max{yy in YEAR} max(yy)-min{yy in YEAR} min(yy)+1)) = DiscountedSalvageValueStorage[r,s,y];

s.t. SI10_TotalDiscountedCostByStorage{r in REGION, s in STORAGE, y in YEAR}:
DiscountedCapitalInvestmentStorage[r,s,y]-DiscountedSalvageValueStorage[r,s,y] = TotalDiscountedStorageCost[r,s,y];
```

### Capital Costs¶

Calculates the total discounted capital cost expenditure for each technology in each year.

```s.t. CC1_UndiscountedCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}:
CapitalCost[r,t,y] * NewCapacity[r,t,y] = CapitalInvestment[r,t,y];

s.t. CC2_DiscountingCapitalInvestment{r in REGION, t in TECHNOLOGY, y in YEAR}:
CapitalInvestment[r,t,y]/((1+DiscountRate[r])^(y-min{yy in YEAR} min(yy))) = DiscountedCapitalInvestment[r,t,y];
```

### Salvage Value¶

Calculates the fraction of the initial capital cost that can be recouped at the end of a technologies operational life. The salvage value can be calculated using one of two depreciation methods: straight line and sinking fund.

```s.t. SV1_SalvageValueAtEndOfPeriod1{r in REGION, t in TECHNOLOGY, y in YEAR:
DepreciationMethod[r]=1 && (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)) && DiscountRate[r]>0}: SalvageValue[r,t,y] = CapitalCost[r,t,y]*NewCapacity[r,t,y]*(1-(((1+DiscountRate[r])^(max{yy in YEAR} max(yy) - y+1)-1)/((1+DiscountRate[r])^OperationalLife[r,t]-1)));

s.t. SV2_SalvageValueAtEndOfPeriod2{r in REGION, t in TECHNOLOGY, y in YEAR:
(DepreciationMethod[r]=1 && (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)) && DiscountRate[r]=0) || (DepreciationMethod[r]=2 && (y + OperationalLife[r,t]-1) > (max{yy in YEAR} max(yy)))}: SalvageValue[r,t,y] = CapitalCost[r,t,y]*NewCapacity[r,t,y]*(1-(max{yy in YEAR} max(yy) - y+1)/OperationalLife[r,t]);

s.t. SV3_SalvageValueAtEndOfPeriod3{r in REGION, t in TECHNOLOGY, y in YEAR:
(y + OperationalLife[r,t]-1) <= (max{yy in YEAR} max(yy))}: SalvageValue[r,t,y] = 0;

s.t. SV4_SalvageValueDiscountedToStartYear{r in REGION, t in TECHNOLOGY, y in YEAR}:
DiscountedSalvageValue[r,t,y] = SalvageValue[r,t,y]/((1+DiscountRate[r])^(1+max{yy in YEAR} max(yy)-min{yy in YEAR} min(yy)));
```

### Operating Costs¶

Calculates the total variable and fixed operating costs for each technology, in each year.

```s.t. OC1_OperatingCostsVariable{r in REGION, t in TECHNOLOGY, l in TIMESLICE, y in YEAR}:
sum{m in MODE_OF_OPERATION} TotalAnnualTechnologyActivityByMode[r,t,m,y]*VariableCost[r,t,m,y] = AnnualVariableOperatingCost[r,t,y];

s.t. OC2_OperatingCostsFixedAnnual{r in REGION, t in TECHNOLOGY, y in YEAR}:
TotalCapacityAnnual[r,t,y]*FixedCost[r,t,y] = AnnualFixedOperatingCost[r,t,y];

s.t. OC3_OperatingCostsTotalAnnual{r in REGION, t in TECHNOLOGY, y in YEAR}:
AnnualFixedOperatingCost[r,t,y]+AnnualVariableOperatingCost[r,t,y] = OperatingCost[r,t,y];

s.t. OC4_DiscountedOperatingCostsTotalAnnual{r in REGION, t in TECHNOLOGY, y in YEAR}:
OperatingCost[r,t,y]/((1+DiscountRate[r])^(y-min{yy in YEAR} min(yy)+0.5)) = DiscountedOperatingCost[r,t,y];
```

### Total Discounted Costs¶

Calculates the total discounted system cost over the entire model period to give the TotalDiscountedCost. This is the variable that is minimized in the model’s objective function.

```s.t. TDC1_TotalDiscountedCostByTechnology{r in REGION, t in TECHNOLOGY, y in YEAR}:
DiscountedOperatingCost[r,t,y]+DiscountedCapitalInvestment[r,t,y]+DiscountedTechnologyEmissionsPenalty[r,t,y]-DiscountedSalvageValue[r,t,y] = TotalDiscountedCostByTechnology[r,t,y];

s.t. TDC2_TotalDiscountedCost{r in REGION, y in YEAR}:
sum{t in TECHNOLOGY} TotalDiscountedCostByTechnology[r,t,y]+sum{s in STORAGE} TotalDiscountedStorageCost[r,s,y] = TotalDiscountedCost[r,y];
```

### Total Capacity Constraints¶

Ensures that the total capacity of each technology in each year is greater than and less than the user-defined parameters TotalAnnualMinCapacityInvestment and TotalAnnualMaxCapacityInvestment respectively.

```s.t. TCC1_TotalAnnualMaxCapacityConstraint{r in REGION, t in TECHNOLOGY, y in YEAR}:
TotalCapacityAnnual[r,t,y] <= TotalAnnualMaxCapacity[r,t,y];

s.t. TCC2_TotalAnnualMinCapacityConstraint{r in REGION, t in TECHNOLOGY, y in YEAR:
TotalAnnualMinCapacity[r,t,y]>0}: TotalCapacityAnnual[r,t,y] >= TotalAnnualMinCapacity[r,t,y];
```

### New Capacity Constraints¶

Ensures that the new capacity of each technology installed in each year is greater than and less than the user-defined parameters TotalAnnualMinCapacityInvestment and TotalAnnualMaxCapacityInvestment respectively.

```s.t. NCC1_TotalAnnualMaxNewCapacityConstraint{r in REGION, t in TECHNOLOGY, y in YEAR}:
NewCapacity[r,t,y] <= TotalAnnualMaxCapacityInvestment[r,t,y];

s.t. NCC2_TotalAnnualMinNewCapacityConstraint{r in REGION, t in TECHNOLOGY, y in YEAR:
TotalAnnualMinCapacityInvestment[r,t,y]>0}: NewCapacity[r,t,y] >= TotalAnnualMinCapacityInvestment[r,t,y];
```

### Annual Activity Constraints¶

Ensures that the total activity of each technology over each year is greater than and less than the user-defined parameters TotalTechnologyAnnualActivityLowerLimit and TotalTechnologyAnnualActivityUpperLimit respectively.

```s.t. AAC1_TotalAnnualTechnologyActivity{r in REGION, t in TECHNOLOGY, y in YEAR}:
sum{l in TIMESLICE} RateOfTotalActivity[r,t,l,y]*YearSplit[l,y] = TotalTechnologyAnnualActivity[r,t,y];

s.t. AAC2_TotalAnnualTechnologyActivityUpperLimit{r in REGION, t in TECHNOLOGY, y in YEAR}:
TotalTechnologyAnnualActivity[r,t,y] <= TotalTechnologyAnnualActivityUpperLimit[r,t,y] ;

s.t. AAC3_TotalAnnualTechnologyActivityLowerLimit{r in REGION, t in TECHNOLOGY, y in YEAR:
TotalTechnologyAnnualActivityLowerLimit[r,t,y]>0}: TotalTechnologyAnnualActivity[r,t,y] >= TotalTechnologyAnnualActivityLowerLimit[r,t,y] ;
```

### Total Activity Constraints¶

Ensures that the total activity of each technology over the entire model period is greater than and less than the user-defined parameters TotalTechnologyModelPeriodActivityLowerLimit and TotalTechnologyModelPeriodActivityUpperLimit respectively.

```s.t. TAC1_TotalModelHorizonTechnologyActivity{r in REGION, t in TECHNOLOGY}:
sum{y in YEAR} TotalTechnologyAnnualActivity[r,t,y] = TotalTechnologyModelPeriodActivity[r,t];

s.t. TAC2_TotalModelHorizonTechnologyActivityUpperLimit{r in REGION, t in TECHNOLOGY:
TotalTechnologyModelPeriodActivityUpperLimit[r,t]>0}: TotalTechnologyModelPeriodActivity[r,t] <= TotalTechnologyModelPeriodActivityUpperLimit[r,t] ;

s.t. TAC3_TotalModelHorizenTechnologyActivityLowerLimit{r in REGION, t in TECHNOLOGY:
TotalTechnologyModelPeriodActivityLowerLimit[r,t]>0}: TotalTechnologyModelPeriodActivity[r,t] >= TotalTechnologyModelPeriodActivityLowerLimit[r,t] ;
```

### Reserve Margin Constraints¶

Ensures that sufficient reserve capacity of specific technologies (ReserveMarginTagTechnology = 1) is installed such that the user-defined ReserveMargin is maintained.

```s.t. RM1_ReserveMargin_TechnologiesIncluded_In_Activity_Units{r in REGION, l in TIMESLICE, y in YEAR}:
sum {t in TECHNOLOGY} TotalCapacityAnnual[r,t,y] * ReserveMarginTagTechnology[r,t,y] * CapacityToActivityUnit[r,t]	 = 	TotalCapacityInReserveMargin[r,y];

s.t. RM2_ReserveMargin_FuelsIncluded{r in REGION, l in TIMESLICE, y in YEAR}:
sum {f in FUEL} RateOfProduction[r,l,f,y] * ReserveMarginTagFuel[r,f,y] = DemandNeedingReserveMargin[r,l,y];

s.t. RM3_ReserveMargin_Constraint{r in REGION, l in TIMESLICE, y in YEAR}:
DemandNeedingReserveMargin[r,l,y] * ReserveMargin[r,y]<= TotalCapacityInReserveMargin[r,y];
```

### RE Production Target¶

Ensures that production from technologies tagged as renewable energy technologies (RETagTechnology = 1) is at least equal to the user-defined renewable energy (RE) target.

```s.t. RE1_FuelProductionByTechnologyAnnual{r in REGION, t in TECHNOLOGY, f in FUEL, y in YEAR}:
sum{l in TIMESLICE} ProductionByTechnology[r,l,t,f,y] = ProductionByTechnologyAnnual[r,t,f,y];

s.t. RE2_TechIncluded{r in REGION, y in YEAR}:
sum{t in TECHNOLOGY, f in FUEL} ProductionByTechnologyAnnual[r,t,f,y]*RETagTechnology[r,t,y] = TotalREProductionAnnual[r,y];

s.t. RE3_FuelIncluded{r in REGION, y in YEAR}:
sum{l in TIMESLICE, f in FUEL} RateOfProduction[r,l,f,y]*YearSplit[l,y]*RETagFuel[r,f,y] = RETotalProductionOfTargetFuelAnnual[r,y];

s.t. RE4_EnergyConstraint{r in REGION, y in YEAR}:
REMinProductionTarget[r,y]*RETotalProductionOfTargetFuelAnnual[r,y] <= TotalREProductionAnnual[r,y];

s.t. RE5_FuelUseByTechnologyAnnual{r in REGION, t in TECHNOLOGY, f in FUEL, y in YEAR}:
sum{l in TIMESLICE} RateOfUseByTechnology[r,l,t,f,y]*YearSplit[l,y] = UseByTechnologyAnnual[r,t,f,y];
```

### Emissions Accounting¶

Calculates the annual and model period emissions from each technology, for each type of emission. It also calculates the total associated emission penalties, if any. Finally, it ensures that emissions are maintained before stipulated limits that may be defined for each year and/or the entire model period.

```s.t. E1_AnnualEmissionProductionByMode{r in REGION, t in TECHNOLOGY, e in EMISSION, m in MODE_OF_OPERATION, y in YEAR}:
EmissionActivityRatio[r,t,e,m,y]*TotalAnnualTechnologyActivityByMode[r,t,m,y]=AnnualTechnologyEmissionByMode[r,t,e,m,y];

s.t. E2_AnnualEmissionProduction{r in REGION, t in TECHNOLOGY, e in EMISSION, y in YEAR}:
sum{m in MODE_OF_OPERATION} AnnualTechnologyEmissionByMode[r,t,e,m,y] = AnnualTechnologyEmission[r,t,e,y];

s.t. E3_EmissionsPenaltyByTechAndEmission{r in REGION, t in TECHNOLOGY, e in EMISSION, y in YEAR}:
AnnualTechnologyEmission[r,t,e,y]*EmissionsPenalty[r,e,y] = AnnualTechnologyEmissionPenaltyByEmission[r,t,e,y];

s.t. E4_EmissionsPenaltyByTechnology{r in REGION, t in TECHNOLOGY, y in YEAR}:
sum{e in EMISSION} AnnualTechnologyEmissionPenaltyByEmission[r,t,e,y] = AnnualTechnologyEmissionsPenalty[r,t,y];

s.t. E5_DiscountedEmissionsPenaltyByTechnology{r in REGION, t in TECHNOLOGY, y in YEAR}:
AnnualTechnologyEmissionsPenalty[r,t,y]/((1+DiscountRate[r])^(y-min{yy in YEAR} min(yy)+0.5)) = DiscountedTechnologyEmissionsPenalty[r,t,y];

s.t. E6_EmissionsAccounting1{r in REGION, e in EMISSION, y in YEAR}:
sum{t in TECHNOLOGY} AnnualTechnologyEmission[r,t,e,y] = AnnualEmissions[r,e,y];

s.t. E7_EmissionsAccounting2{r in REGION, e in EMISSION}:
sum{y in YEAR} AnnualEmissions[r,e,y] = ModelPeriodEmissions[r,e]- ModelPeriodExogenousEmission[r,e];

s.t. E8_AnnualEmissionsLimit{r in REGION, e in EMISSION, y in YEAR}:
AnnualEmissions[r,e,y]+AnnualExogenousEmission[r,e,y] <= AnnualEmissionLimit[r,e,y];

s.t. E9_ModelPeriodEmissionsLimit{r in REGION, e in EMISSION}:
ModelPeriodEmissions[r,e] <= ModelPeriodEmissionLimit[r,e];
```