How to fix a variable and optimize coefficients of objective function
AnsweredDear Gurobi's staff:
I have a linear multi-objective optimization problem such that each objective is multiplied with a parameter (teta1,teta2,teta3).
Now, I want to fix the y variables (known facility locations) and solve the model to find the x[i,j] and teta1,teta2,teta3.
What I did was to define 3 variables called teta1,teta2,teta3. and in the constraints I added (teta1+teta2+teta3==1) and solve the model with known y[j] variables. But the model is infeasible.
I would really appreciate that if you could please help me on this. The first model looks like this.
y=m.addVars(J,vtype=GRB.BINARY,name='facility')
x=m.addVars(I,J,lb=0,ub=1,vtype=GRB.CONTINUOUS,name='assignment')
m.addConstr(sum(y[j] for j in J)<=10)
for j in J:
m.addConstr((sum(x[i,j]*demand[i] for i in I))<=(500*y[j]))
for i in I:
m.addConstr((sum(x[i,j] for j in J)<=1))
m.setObjective((teta1)*((sum((x[i,j])*demand[i] for i in I for j in J))+
(teta2)*((sum(y[j]*100 for j in J)))+
(teta3)*((sum(*x[i,j]*demand[i]*risk[i] for i in I for j in J))
-
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 try Gurobot, our chatbot interface offering instant, expert-level support. -
In fact my question is that "if we know one solution of the model (in terms of facility locations not assignment), how to determine which coefficients gives us that specific solution?". The main difficulty is that if I want to put x[i,j] and tetas as decision variables, the objective function include quadratic terms. Any help is much appreciated.
0 -
You can fix variables by setting their lower and upper bound attribute to the same value
for j in J:
y[j].lb = 0
y[j].ub = 0Alternatively, you can add equality constraints to fix the variables
for j in J:
m.addConstr(y[j] == 0)What I did was to define 3 variables called teta1,teta2,teta3. and in the constraints I added (teta1+teta2+teta3==1) and solve the model with known y[j] variables. But the model is infeasible.
Did you try to find the reason for the infeasibility, see How do I determine why my model is infeasible?
I have a linear multi-objective optimization problem such that each objective is multiplied with a parameter (teta1,teta2,teta3).
You could try Gurobi's multi-objective feature to avoid bilinear terms in your objective.
Best regards,
Jaromił0 -
Sorry to add additional questions,
I think I have a similar problem here: https://support.gurobi.com/hc/en-us/community/posts/6208930568721-fix-variables-to-convert-bilinear-QP-to-LP .
You could try Gurobi's multi-objective feature to avoid bilinear terms in your objective.
I don't understand how to avoid bilinear terms of `tera` and `y` in this situation.
0 -
I don't understand how to avoid bilinear terms of and in this situation.
When using multi-objective optimization in this case, one could drop the \(\texttt{teta}\) variables. This would solve each objective independently and one would have to adjust \(\texttt{teta}\) values accordingly. It is just an idea, it does not mean that it works best here.
0
Post is closed for comments.
Comments
5 comments