Hello Alessandra,
I hope you are doing well.
Based on your function, you have three terms: model.revenue, model.cost, and model.export_lifetime_discounted_var. Which of them are variables, and which of them are parameters? If two of them are variables, then are there any binary/integer variables in your model?
If I've guessed correctly, your problem is a bi-linear model, and you can solve it using McCormick Envelope as follows in Pyomo:
#Linear (McCormick Envelope)
def eq3000_rule(MP0, I, T):
return MP0.P[I,T] == MP0.W[I,T]
MP0.eq3000 = Constraint(MP0.I, MP0.T, rule=eq3000_rule)
def eq30001_rule(MP0, I, T):
return MP0.W[I,T] >= (MP0.Q[I,T]*MP0.Imin[I]) + (MP0.I[I,T]*MP0.Qmin[I]) - (MP0.Qmin[I]*MP0.Imin[I])
MP0.eq30001 = Constraint(MP0.I, MP0.T, rule=eq30001_rule)
def eq30002_rule(MP0, I, T):
return MP0.W[I,T] >= (MP0.Q[I,T]*MP0.Imax[I]) + (MP0.I[I,T]*MP0.Qmax[I]) - (MP0.Qmax[I]*MP0.Imax[I])
MP0.eq30002 = Constraint(MP0.I, MP0.T, rule=eq30002_rule)
def eq30003_rule(MP0, I, T):
return MP0.W[I,T] <= (MP0.Q[I,T]*MP0.Imax[I]) + (MP0.I[I,T]*MP0.Qmin[I]) - (MP0.Qmin[I]*MP0.Imax[I])
MP0.eq30003 = Constraint(MP0.I, MP0.T, rule=eq30003_rule)
def eq30004_rule(MP0, I, T):
return MP0.W[I,T] <= (MP0.Q[I,T]*MP0.Imin[I]) + (MP0.I[I,T]*MP0.Qmax[I]) - (MP0.Qmax[I]*MP0.Imin[I])
MP0.eq30004 = Constraint(MP0.I, MP0.T, rule=eq30004_rule)
In the constraints above, suppose we have P == Q*I where both Q and I are variables, and their minimum and maximum values are given. Then, using the linear version, we'll have W as the multiplication of Q and I, the rest of the story.
For further information, please refer to
On Thursday, September 12, 2024 at 6:38:20 PM UTC-5 Alessandra Vidal Meza wrote:
Hi all,
We're working on an optimization problem for an energy project using CPLEX. Our objective function is leading us to a nonlinear terms issue. All variables in our objective function are scalar.
def obj_rule(model):
return (model.revenue - model.cost)/model.export_lifetime_discounted_var
model.obj = Objective(rule = obj_rule, sense = maximize)
We are wondering what are ways folks have gotten around this issue?
Best,
Alessandra