OSeMOSYS / OSeMOSYS_GNU_MathProg

The GNU MathProg implementation of OSeMOSYS
Apache License 2.0
9 stars 14 forks source link

User-defined constraints #75

Open abhishek0208 opened 2 years ago

abhishek0208 commented 2 years ago

This functionality allows for flexible user-defined constraints to be added. It allows for creation of relationships between the capacities and activities of specific technologies. For instance, the total new capacity of all renewable powerplants can be set using such a relationship. It is an expansion of the OEP presented here. The formulation of the constraints is as follows:

s.t. UDC0_UserDefinedConstraintEquality{r in REGION, u in UDC, y in YEAR: UDCTag[r,u] = 0}: 
sum{t in TECHNOLOGY}UDCMultiplierTotalCapacity[r,t,u,y]*TotalCapacityAnnual[r,t,y] + 
sum{t in TECHNOLOGY}UDCMultiplierNewCapacity[r,t,u,y]*NewCapacity[r,t,y] +
sum{t in TECHNOLOGY}UDCMultiplierActivity[r,t,u,y]*TotalTechnologyAnnualActivity[r,t,y] = UDCConstant[r,u,y];

s.t. UDC1_UserDefinedConstraintInequality{r in REGION, u in UDC, y in YEAR: UDCTag[r,u] = 1}: 
sum{t in TECHNOLOGY}UDCMultiplierTotalCapacity[r,t,u,y]*TotalCapacityAnnual[r,t,y] + 
sum{t in TECHNOLOGY}UDCMultiplierNewCapacity[r,t,u,y]*NewCapacity[r,t,y] +
sum{t in TECHNOLOGY}UDCMultiplierActivity[r,t,u,y]*TotalTechnologyAnnualActivity[r,t,y] >= UDCConstant[r,u,y];

s.t. UDC2_UserDefinedConstraintInequality{r in REGION, u in UDC, y in YEAR: UDCTag[r,u] = 2}: 
sum{t in TECHNOLOGY}UDCMultiplierTotalCapacity[r,t,u,y]*TotalCapacityAnnual[r,t,y] + 
sum{t in TECHNOLOGY}UDCMultiplierNewCapacity[r,t,u,y]*NewCapacity[r,t,y] +
sum{t in TECHNOLOGY}UDCMultiplierActivity[r,t,u,y]*TotalTechnologyAnnualActivity[r,t,y] <= UDCConstant[r,u,y];

where UDCTag specifies whether a user-defined constraint is an equality [0], LHS>=RHS [1], or LHS<=RHS [2]; UDCConstant is the RHS of the UDC; three multipliers - UDCMultiplier* - are used as co-efficients for TotalCapacityAnnual, NewCapacity, TotalTechnologyAnnualActivity.

Below is a summary of additions: 1 new set: set UDC

5 new parameters: param UDCMultiplierTotalCapacity param UDCMultiplierNewCapacity param UDCMultiplierActivity param UDCConstant param UDCTag

and 3 new constraints: s.t. UDC0_UserDefinedConstraintEquality s.t. UDC1_UserDefinedConstraintInequality s.t. UDC2_UserDefinedConstraintInequality

A simple test case 'simplicity_udc.txt' has been used to test these constraints for all three versions of the OSeMOSYS_GNU_MathProg code. In this example, three user-defined constraints are created:

  1. TotalCapacityAnnual of GAS_EXTRACTION and GAS_IMPORT must together equal 10.
  2. TotalTechnologyAnnualActivity of SOLPV1, SOLPV2, and WINDPOWER must be >= 50% of SpecifiedAnnualDemand of FEL1
  3. NewCapacity of SOLPV1 and SOLPV2 together must be <= 0
tniet commented 2 years ago

@abhishek0208 - looks like a good enhancement and I think the formulation looks good as well. Does this allow us to require a given land area for an installed capacity of solar in CLEWs? I think it does but wanted to get your thoughts on that.

I think we should consider the data for the constraints you've added and decide if these are reasonable for Simplicity and then make the TravisCI checks work for the added constraints. Maybe @willu47 can provide some assistance with updating the checks/constraints to work?

abhishek0208 commented 2 years ago

Thanks @tniet. My understanding is that this formulation will allow a user to set the total or minimum land area for a given capacity of a technology (e.g. solar). I don't think it'll quite work to set land area per unit capacity of a technology (we can use other parameters for that: InputToTotalCapacityRatio and InputToNewCapacityRatio). Happy to be corrected on this.

tniet commented 2 years ago

@abhishek0208 It seems to me that these can allow you to link installed capacity, new capacity and activity for any user defined group of techs and commodities, so I think you should be able to do what you've described. Might be easier and clearer to have separate constraints, but nominally I think it should work.