Reputation: 11
I am very new to Pyomo, working on a use case where my objective function coefficient is dynamic & needs a min-max function.
Objective function = Max( sum (P * UC) - sum ( P - min(P)) * UC where P is variable needs to be optimized and UC is function which is derived value based on some calculation.
I have few doubts
I have tried multiple things but none seems to be working. If someone can help me with dummy code that will be great.
Thanks in Advance.
Upvotes: 1
Views: 2689
Reputation: 6642
Min could be implemented by defining a new variable min_P
, which needs to be smaller than any of the P
, expressed by constraints:
min_P <= P[i]
for all i
This will make sure, that min_P
is not larger than the smallest of the P
. Then you can just use min_P
in your objective function. I assume you know how to define constraints like this. This might result in an unbound variable problem, depending on how exactly you are optimizing, but this should put you on the right track.
The max case is analogous, if you define another value for the expression sum (P * UC) - sum ( P - min(P))
.
It is not clear whether UC
is a parameter or a variable itself (calculated in another constraint). In the latter case, the whole problem will be highly nonlinear and should be reconsidered.
I do not understand your AbstractModel vs ConcreteModel question. If you have the data available, use a ConcreteModel. Apart from that, see here.
Upvotes: 1