Piece-wise Linear multi objective (Python-gurobi)
AnsweredHello everybody,
So I am solving a LP model where I use the model.setPWLObj() function to maximize the sum of all the pwl approximations of my variables. (Actually, there is no variable that does not need a pwl approximation in my problem).
Now I want to introduce some auxiliary variables to the model (I want to add an additional variable to each of the existing ones) so that the original ones x_i are now x_i + x_i_new for all variables i.
In this way, I am trying to approximate with PWL approx. the new variables x_i + x_i_new (because the original non-linear functions that I am approximating remain the same, since I am just adding an additional amount to the actual values of the original variables).
Now, the function setPWLObj() only accepts Var objects and not LinExpr (since x_i + x_i_new turns out to be a LinExpr and not a variable anymore!).
Does anybody know any approach to tackle this problem?
Thank you very much!
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
You can create a(nother) new variable, set it equal to \( x_i + x^{\textrm{new}}_i \), then set that variable's piecewise-linear objective term using Model.setPWLObj(). E.g.:
z = m.addVar(lb=-GRB.INFINITY, name='z')
m.addConstr(z == x + xnew, name='set_auxiliary_z')
m.setPWLObj(z, xpts, ypts)0
Post is closed for comments.
Comments
2 comments