Define shortage in oemof

Hello everyone,

what is the best way to define shortage on annual demand as constraint in oemof. I’ve seen in some examples shortage is simply created as a fake source and not defined in the same way as the emission constraint offered by oemof (with po.Constraint() etc…).
Is that the right best way to do that? honestly for me that looks a bit counterintuitive to have just a source as shortage, because source means we are producing something while shortage means there a lack of something.

I’m grateful for any help!

If there is a lack of something the equilibrium model will be infeasible. Therefore, a shortage source is very helpful. If this source is very(!) expensive it will only be used if nothing else can be used. In that way you can identify the lack of something. If the problem is infeasible you cannot analyse the results (because there are no results) and it is more difficult to find the problem.

1 Like

If you are thinking about shortages in systems is a wider context, this very readable article by United Kingdom economist Tim Harford might be of interest (and just ignore the click‑bait title):

1 Like

This sounds as if there is a misunderstanding: The “shortage fake source” does not model the shortage but its usage signifies that there is a shortage. Let’s just assume the demand series [4, 5, 3, 8]. There are two sources. One is for free and provides (up to) [4, 3, 4, 3], the other has a cost and can constantly supply 4 * [2]. Now, the demand cannot be fulfilled in time step 4. To allow the model to solve, a third source (“shortage”) is defined. Although it is very costly, it will provide [0, 0, 0, 3], meaning that there is a shortage of 3 in the last time step.

1 Like

Thank you so much @pschoen for this example! it’s helping me to get the point that’s why I have further questions:

Do you mean the second source with cost can constantly provide [2,2,2,2]? the demand cannot be fulfilled in time step 4 because [3] from source 1 and [2] from source 2 in time step 4 are in total less than 8 right? That’s mean once I defined the shortage in this fictive energy system and the model is solved, I will see later the extracted energy flows data with [0, 0, 0, 3]. → In this case the shortage is resulted automatically [0, 0, 0, 3] because of the defined nominal_values of the sources and without the shortage as third source the model could not be solved right?

In an optimisation problem where the aim is to minimise the cost resulting in optimized capacities and flows of the assets the demand has to be fulfilled anyway, thereby the shortage is null and therefore there is no need to define it. Did I got the point?

Now I’m wondering what If I want to enforce a shortage in this simple system. I have a pv plant and dieselGen in the system. The objective is to determine the capacities of the assets pv and diesel based on the periodical costs. I have household demand with total_demand X in kWh. My goal is to consider the fact that 10% of the demand is not covered for example due a technical issue in the reality or something.
This is the way I tried to model a shortage. So I created a source with nominal value total_demand *0.1 and cost of 0.
I’m trying to apply your great example in my case but it’s not the same :confused: I Think this is wrong what I did :sweat_smile:

source_shortage = solph.Source(label= shortage_demand, 
                            outputs={el_ac_bus: solph.Flow(
                            nominal_value=0.1 * total_demand,

I’m grateful for any explanation or help. This is basic concept in oemof which I would love to understand better.

Thank you @robbie.morrison! the article seems to be quite interesting! I will definitely check that!

Thanks @uwe.krien for the explanation! that means the shortage source should always be the most expensive source in the system right?
However this depends generally on the kind of the optimisation problem not? for example if the target is consisting of the optimising of the capacities of component’s based on the costs the shortage source becomes in this case not relevant because it’s 0 isn’t?

Concerning cost of the shortage (#5, #7), @uwe.krien’s and my implicit viewpoint is/was that shortages should not happen. In this view, the “shortage” source is just a hack to make sure the optimisation can be solved. (Maybe, it’s privileged 1st world view. We would probably call it demand side management, if there is demand that is optional.)

What you plan, really has a different view. If you want to have 10 % uncovered, why don’t you just scale down the demand? When, your (fake) demand is 90 % of the real demand, you will have 10 % uncovered. If, for example, you want 90 % to be covered with a guarantee, but 10 % are optional, you might want to implement two different sinks, one with nominal_value=total_demand, fix=0.9, the other with nominal_value=total_demand, max=0.1, variable_costs=SMALL_NEGATIVE_VALUE. The small negative value (negative cost means revenue) would give an incentive to fulfil that demand – if it is possible at a low cost.

1 Like

Now I see the difference between my case and the case you described!
Thanks for help! I appreciate it

Text and images licensed under CC BY 4.0Data licensed under CC0 1.0Code licensed under MITSite terms of serviceOpenmod mailing listOpenmod wiki.