Reduced costs, marginal price from dual solution

96 views
Skip to first unread message

Will Usher

unread,
Oct 7, 2020, 5:14:58 AM10/7/20
to OSeMOSYS
I'm interested in extracting the marginal price of electricity from an OSeMOSYS model.

I believe that this can be taken from constraint EBa11:

s.t. EBa11_EnergyBalanceEachTS5{r in REGION, l in TIMESLICE, f in FUEL, y in YEAR}:
Production[r,l,f,y]
>=
Demand[r,l,f,y] + Use[r,l,f,y] + sum{rr in REGION} Trade[r,rr,l,f,y] * TradeRoute[r,rr,f,y];

Following the solve step in the MathProg version of the model, I can write the results out using the following:

table ProductionDual
{r in REGION, l in TIMESLICE, f in FUEL, y in YEAR:
EBa11_EnergyBalanceEachTS5[r,l,f,y].dual <> 0}
OUT "CSV"
ResultsPath & "/ProductionDual.csv" :
r~REGION, l~TIMESLICE, f~FUEL, y~YEAR,
EBa11_EnergyBalanceEachTS5[r,l,f,y].dual~DUAL,
EBa11_EnergyBalanceEachTS5[r,l,f,y].lb~LB,
EBa11_EnergyBalanceEachTS5[r,l,f,y].ub~UP,
EBa11_EnergyBalanceEachTS5[r,l,f,y].val~VALUE,
EBa11_EnergyBalanceEachTS5[r,l,f,y].status~STATUS
;

This produces a CSV file containing columns for the dual and primal values of the optimal solution, upper and lower bounds and status. Where the status codes take one of the following meanings:

0 — undefined
1 — non-active
2 — active on lower bound
3 — active on upper bound
4 — active free (unbounded) row
5 — active equality constraint

Does anyone have any insights into how best to interpret the dual values in OSeMOSYS - and perhaps a simple worked example? For example, showing how the marginal cost of electricity is equal to the sum of -costs + revenues of upstream technologies?

Will Usher

unread,
Nov 3, 2020, 5:43:55 AM11/3/20
to OSeMOSYS
Hi all;

I've been investigating this to develop a course involving teaching the economic interpretation of OSeMOSYS results, and I can confirm that the dual solution of the EBa11 constraint is indeed the correct equation to use.

Using a simple model, I have shown that  EBa11_EnergyBalanceEachTS5[r,l,f,y].dual gives the marginal cost of the fuels in each timeslice. This marginal cost takes into account the fixed and variables costs of inputs, capital cost of capacity needed to meet increased demands and emission penalties.

Crucially, EBa11_EnergyBalanceEachTS5 is available in long, short and fast versions of OSeMOSYS, so no matter which version you use, you should be able to extract this very useful information for debugging, and reporting purposes.

Will

Franklyn

unread,
Sep 6, 2021, 1:28:27 AM9/6/21
to OSeMOSYS

Hi Will, 
I'm interested in extracting the marginal price of electricity from an OSeMOSYS model and I have followed your procedure to extract "EBa11_EnergyBalanceEachTS5[r,l,f,y]" from the model as you can see below for just two years and one timeslice. 
WAP is the region, AMAN is the timeslice. There are 8 fuels: BFBM: Biomass, BFCO: Coal, BFDS: Diesel, BFED: Electricity distribution, BFET: Electricity transmission, BFFD: Final demand, BFHF: Heavy Fuel Oil, and BFNG: Natural gas. 

I want to extract the marginal price of electricity. Should I just add all the values under each year for all the fuels and the sum will represent the marginal price of electricity for that year in that timeslice or is there one fuel that represents the marginal price of electricity? like the BFFD the final demand or BFET the electricity transmission?. This is my confusion, am not sure whether to add or just take the value of one fuel. 

Constraint                                            Region         Timeslice      Fuel    2018                                                         2019
EBa11_EnergyBalanceEachTS5 WAP        AMAN    BFBM  0.0                                                           0.0
EBa11_EnergyBalanceEachTS5 WAP        AMAN    BFCO -0.0                                                           -0.0
EBa11_EnergyBalanceEachTS5 WAP        AMAN    BFDS 0.0002175856925656916                    0.0
EBa11_EnergyBalanceEachTS5 WAP        AMAN    BFED 65.69840555585535                          17.373253894054958
EBa11_EnergyBalanceEachTS5 WAP        AMAN    BFET 33.912393149824034                  34.644795259859215
EBa11_EnergyBalanceEachTS5 WAP        AMAN    BFFD 94.62910561259459                          40.07497069074675
EBa11_EnergyBalanceEachTS5 WAP        AMAN    BFHF -0.0                                                           0.0
EBa11_EnergyBalanceEachTS5 WAP        AMAN    BFNG -0.0                                                          -0.0

Thank you
Franklyn

Vignesh Sridharan

unread,
Sep 27, 2021, 4:41:27 AM9/27/21
to osem...@googlegroups.com
Hi Franklyn,

If I am not wrong, You need to take the dual values for the fuel for which you want the marginal costs. In this case, if you want to calculate the marginal costs for electricity (end-user or demand) you need to take the values for BFFD. It will give you the marginal change in the objective function for a unit increase in the demand. If you have any accumulated demand, you might also want to check EBb4_EnergyBalanceEachYear4 as Accumulated Annual demand is accounted for on the yearly energy balance and not on the time slice (EBa11) one. 

Finally, the output is a discounted value. You might want to un-discount them to get the actual value for the respective year.

Best
Vignesh

--
You received this message because you are subscribed to the Google Groups "OSeMOSYS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osemosys+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osemosys/de15a554-ce15-4a64-ba0a-24ea7792dd71n%40googlegroups.com.

Will Usher

unread,
Oct 21, 2021, 5:16:25 AM10/21/21
to OSeMOSYS
Vignesh's answer is correct.  If you think about marginal price, and try to understand what is happening, you'll see that they increase as your go through the transformations of the energy system. Each transformation increases the marginal price of the fuel and this is proportional to the losses in the transformation step.

What's not clear to me is why your BFET marginal is higher than your BFED marginal in 2019?  You should have BFET -> BFED -> BFFD?  And I would expect the marginal's to increase from primary through to final energy.  Perhaps some demand is transmission connected?

We built a lab around the marginal price information which you can find in this repository: https://github.com/KTH-dESA/MJ2383 or you can check out the lab online: https://mybinder.org/v2/gh/KTH-dESA/MJ2383/main?filepath=MJ2383_Lab_3.ipynb

Georgios Avgerinopoulos

unread,
Oct 21, 2021, 9:20:39 AM10/21/21
to osem...@googlegroups.com
Hi all,

With regards to Will's question, ie why is it that the price of primary fuels increases, there are two things to consider:
- It might just be a change in specific time-slices while the annual average could remain constant.
- More importantly, the dual value of primary fuels prices does increase when there are associated carbon constraints (annual/total period budget or price)

One thing that occurred in our model is that the price for particular primary fuels was recorded under EBa11 for some years while for others under EBb4. That's a bit fuzzy as there's both specified and accumulated demand associated with those fuels in all years. Any hint?

Best,
G.





--
Georgios Avgerinopoulos
Research Engineer at Royal Institute of Technology (KTH)
MSc in Sustainable Energy Engineering
00447885802151
Sweden

Franklyn

unread,
Oct 21, 2021, 12:06:41 PM10/21/21
to OSeMOSYS
Thank you all, appreciate the help. You are right,  some demand is transmission connected. This is a multiple-region model with cross-border electricity trade allowed starting in 2019.

Love the git repository. 

Thanks
Franklyn

lucas...@gmail.com

unread,
Oct 21, 2021, 6:09:41 PM10/21/21
to OSeMOSYS
Hi everyone,

Following with the topic. I ran my model with CBC solver. Does anyone know how to extract this variable from there? The output file that I get only contains the main parameters, which are very useful, but I do not know how to modify what variables the solver prints out. 

Thanks,
Lucas. 

Vignesh Sridharan

unread,
Oct 27, 2021, 2:34:26 AM10/27/21
to osem...@googlegroups.com
Hi Lucas,
I have not tried this. But can you try using "-printing all" in the command when you run CBC. 

If you can write back if it works that would be helpful. 

best
Vignesh

H.Henke

unread,
Oct 29, 2021, 6:17:39 AM10/29/21
to OSeMOSYS
Hi,

I have a question regarding the use of the dual value in relation to emissions.
Let's say one is interested in identifying the needed carbon price for reaching net-zero emissions.
Then one option is to do iterative runs and try to find the right price level uding the EmissionsPenalty to reach net-zero.  (rather tedious)
To avoid this, I'm thinking that if one implements an EmissionsLimit that brings you to net-zero in the year of your interest, one should be able to read the marginal cost for emissions from equation E8_AnnualEmissionsLimit.dual Is this right?
Furthermore, I'm wondering, if remove the EmissionsLimit and instead implement the dual value of E8 of each year in which I had the  EmissionsPenalty before, would I reach the same result?

Thanks for your thoughts on this!

Best,
Hauke

Georgios Avgerinopoulos

unread,
Oct 29, 2021, 7:22:40 AM10/29/21
to osem...@googlegroups.com
Hi Hauke,

That is exactly right. The equation is correct and if you then plug the dual prices as an input (after you undiscount them for each year) you will get the exact same solution (been tested).

Best,
G.

--
Sent from Gmail Mobile

Hauke Henke

unread,
Nov 3, 2021, 12:10:05 PM11/3/21
to osem...@googlegroups.com
Great! Thanks a lot for the confirmation Georgios!

Best,
Hauke

You received this message because you are subscribed to a topic in the Google Groups "OSeMOSYS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/osemosys/er3k6kaV39o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to osemosys+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osemosys/CAAVXX_RvuTOCFXLoFN3buSya-WpNvzBPopnS0gLdn%2BCKzyi3GQ%40mail.gmail.com.

Reply all
Reply to author
Forward
0 new messages