How can I give weight to one of objective function in a multiple objective function?
Awaiting user inputI am going to give the different amounts to alpha, but I do not know how should write in my Python.
Min z=∑_jϵJ〖SVIj * rj 〗+α ∑_iϵI ∑_jϵJ〖PFij * xij 〗
how can I give different amounts instead of alpha in my code?
my code is
m.setObjective(sum((df.SVI[j] * r[j]) for j in CT) + αsum(df2[i][j] * x[i,j] for i in H for j in CT), GRB.MINIMIZE)
when I put α=5 or any amounts GUROBI in python gives me
SyntaxError: invalid syntax |
could you plz let me know how can I give the different amounts to alpha?
-
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?. -
Hi Matin,
Could you tell which variables are optimization variables and which variables are constants?
Do you introduce \(\alpha\) as an optimization variable? If \(\texttt{df}\) and \(\texttt{df2}\) are constants and \(r,x,\alpha\) are optimization variables, then you could try the code
import gurobipy as gp
from gurobipy import GRB
m.setObjective(gp.quicksum(df.SVI[j] * r[j] for j in CT)
+ gp.quicksum(df2[i][j] * x[i,j] * alpha for i in H for j in CT),
GRB.MINIMIZE)If the above does not help, could you provide a minimal working example showing the issue?
Best regards,
Jaromił0
Post is closed for comments.
Comments
2 comments