OSeMOSYS / OSeMOSYS_GNU_MathProg

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

Duplicate term for Capital Cost of Storage in objective function of OSeMOSYS fast #83

Closed willu47 closed 1 year ago

willu47 commented 1 year ago

I asked ChatGTP if it could find any errors in the objective function of OSeMOSYS. Here's what it came back with:

minimize cost: sum{r in REGION, t in TECHNOLOGY, y in YEAR} 
    (((((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0} 
        NewCapacity[r,t,yy])+ ResidualCapacity[r,t,y])*FixedCost[r,t,y] + 
        sum{m in MODEperTECHNOLOGY[t], l in TIMESLICE} 
            RateOfActivity[r,l,t,m,y]*YearSplit[l,y]*VariableCost[r,t,m,y]) / DiscountFactorMid[r,y] + 
            CapitalCost[r,t,y] * NewCapacity[r,t,y] * CapitalRecoveryFactor[r,t] * PvAnnuity[r,t] / DiscountFactor[r,y] + 
            DiscountedTechnologyEmissionsPenalty[r,t,y] - DiscountedSalvageValue[r,t,y]) + 
            sum{s in STORAGE} (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y] / DiscountFactor[r,y] - 
            CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y] / DiscountFactor[r,y]));

From ChatGTP:

This is a cost minimization objective function for a model of energy systems. The objective is to minimize the total cost of energy across different regions, technologies, and years. The cost includes:

  • The fixed and variable costs of operating existing and new energy capacity
  • The capital costs of building new energy capacity and storage capacity
  • The emissions penalties associated with energy production
  • The salvage value of decommissioned energy capacity and storage capacity

The objective function is a summation over all regions, technologies, and years. The fixed and variable costs are calculated by summing over the different modes of operation for each technology and the different time slices in a year. The capital costs are calculated by multiplying the new capacity and storage capacity by the capital recovery factor and the present value of an annuity. The emissions penalties and salvage values are discounted to their present values using discount factors.

@willu47 : "Are there any bugs or errors in the above?"

It appears that there are a few issues with the cost function:

  1. The ResidualCapacity variable is not defined and would cause an error if the model is solved as is.
  2. The SalvageValue variable is not used in the cost function and the SalvageValueStorage variable is used in the wrong place.
  3. The last term in the cost function subtracts the same value from itself, which would not affect the final cost.
  4. The formula for calculating discounted salvage value is also not provided and it seems to be missing.
  5. The formula is also not clear as to what it is trying to minimize.
  6. CapitalRecoveryFactor and PvAnnuity also not defined.

It would be best to consult with the original developer of the model to determine the correct cost function.

I believe points 3 and 4 are right...

willu47 commented 1 year ago

Closed by #89, #91