Transformer model using Investment and NonConvex classes

Dear all,

I realized that in oemof, so far, it is not possible to optimize the capacity of a transformer using the Investment class and simultaneously set a minimum load, such as 30% using the NonConvex class.
I want to create such a model for a diesel genset which is the non-renewable part of a mini-grid power generation system. The renewable part consists of PV cells, storage (battery), and dc/ac inverter.
As we all know, diesel gensets cannot operate under a certain load (normally around 20-30%). But, since I cannot use the Investment and NonConvex classes simultaneously, first, I must obtain the nominal capacity of the diesel genset using only the Investment class; then, in a second optimization problem, I must assume a fixed capacity for the diesel genset and use the NonConvex class to implement the minimum load and the on/off status for this component.
This approach is not accurate because, according to the results of the first optimization (capacity optimization), the diesel genset operates only a few hours in full-load, but most of the time, it operates below the minimum load for this component, which is practically not feasible. Moreover, when I run the second optimization problem, the annuity associated with the diesel genset will not be part of the objective function, and the results will not represent the real optimal results.
So, to make the long story short, I know that the usage of the Investment class is not compatible with the NonConvex class in oemof so far, but I would like to know if it is possible to create a new transformer and use these two classes together? Or is there any other way to do it in oemof?
As you might know, in some other optimization platforms, such as gurobipy, this is possible, but since oemof offers a variety of other options besides the optimizer, I would like to create the model in oemof. I would appreciate it if someone with good oemof knowledge could help me with this issue. Thanks!


Hi @sasa821,

to my knowledge, that feature is lacking because of priorities not because it’s not possible to implement it. To get a better understanding, let’s be precise here: Both, Investment and NonConvex are mutually exclusive attributes to a Flow, not the Transformer itself. (To make this clearer, NonConvexFlow and InvestmentFlow will be independent classes in the future.) So, in principle you can make the input nonconvex and optimise the size of the output. Still, the min attribute to the Flow currently only works with constant nominal_value. Thus the input would be of constant size then.

Long story short: It should be doable and I’d be glad to assist with feedback and code reviews. However, I am lacking the time to just do it.


Hi @pschoen,

Thank you very much for your answer.

So, if I understand it correctly, the current Flow class will be replaced in the future with the NonConvexFlow and InvestmentFlow in oemof-solph.blocks, but these classes are still not usable, right?

Since implementing the min attribute in my problem is necessary, I guess using both NonConvexFlow and InvestmentFlow will not solve the problem. Do you think a third kind of the Flow class (e.g., NonConvexInvestmentFlow) must be developed, in which the min attribute is also integrated? If yes, I would be glad to try to develop such a component to solve my problem and maybe in the future someone else’s. However, since I do not have any experience as a developer of oemof, I would appreciate it if you could provide me with some useful material to learn about adding new features to oemof.


I dropped the information about the future API, as I wanted to make clear what is possible and what is not. As NonConvexFlow and InvestmentFlow are two different things, it is not possible to have one Flow with both features. So, you are right, a NonConvexInvestmentFlow has to be developed.

Maybe look at the branch for the upcoming v0.5 release. It puts a clearer structure in the code, so you can find constraints (blocks) next to the solph classes. As mentioned, the flow classes in the v0.5 development branch have the separated interfaces.

But if we create such a flow, we must add something like the following constraint to implement the minimum value of the flow at each time step:

p[t] >= min_load * p_invest * status[t]

Here, since p_invest and status[t] are both optimization variables, if we multiply them, the problem becomes nonlinear. Am I making a mistake somewhere?

You are right, this type of problem seems to lead to a non-linear problem. If somehow realistic, you could alter the constraint, so that a constant minimum instead of a fractional load is allowed. This would then work right out of the box having one InvestmentFlow and one NonConvexFlow sequentially.

I realized that in the gurobi solver, the multiplication of a binary variable and a continuous variable will automatically be linearized (probably using the big M method), but the cbc solver won’t be able to solve the problem if we put the line I wrote in my previous post as a constraint. We must linearize it first and then call the solver.

I took a look at the new version of oemof.solph (0.4.5) and the new classes for Flows and finally could develop a new class representing the NonConvexInvestmentFlow. In the constraints, I linearized those nonlinearities I explained in my previous post, and the good news is that it works! Of course, it is slow because of considering the min and max loads as well as the status of the flow while performing the capacity optimization, but it works!

1 Like

Thanks for implementing the feature and issuing a pull request to include investment for non-convex flows in solph v0.5. I just added it to the according milestone, so it is now planned to have this resolved for the next release.

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