A huge number of Equality constraints
回答済みHello!
What is the best way to Handel a huge number of equality constraints like the two constraints given here?
The model is infeasible. The model will solve if I replace the equality sign by "<=" . I am wondering what the most accurate way to solve this problem is.
Thanks!
m=gp.Model()
y=m.addVars(24, 11, 9, 21, vtype='C',lb=0, ub=1, name='y')
obj=gp.quicksum(C_[q,k,i,j]*y[i,j,q,k] for i in range(24) for j in range (11) for q in range (9) for k in range (21) )
m.setObjective(obj)
m.addConstr((gp.quicksum(y[i,j,q,k] for i in range(24) for j in range (11) for q in range (9) for k in range (21) )) == 1)
m.addConstrs((gp.quicksum(y[ii,jj,qq,k] for k in range (21)) - (gp.quicksum(y[i,j,q,k]*(mm[q][qq]*SOC_p[k][j][jj]*t_p[i][ii]) for k in range (21) for i in range(24) for j in range (11) for q in range (9))) ==0 for ii in range(24) for jj in range (11) for qq in range (9)), name='const')
m.optimize()
-
正式なコメント
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. -
Hi,
Please note that your code snippet does not work. There are definitions missing for \(\texttt{C_,mm,SOC_p,t_p}\).
Maybe the Knowledge Base article How do I determine why my model is infeasible? can help.
Best regards,
Jaromił1 -
Dear Mr. Jaromił,
Thank you so much for your comment!
This model is a Markov decision process which is supposed to be feasible, but I guess because I have a large number of equality constraints and a large number of variables, and the summation of this variable is 1, which means some of them will be pretty small. If I replace the equality sign in the second constraint with <= it will solve and give acceptable results. The error in the constraints will be 2%.
For the missing parameters, they are calculated based on data, and it does not allow me here to share the data.
Thanks
0 -
Dear Hussein,
For the missing parameters, they are calculated based on data, and it does not allow me here to share the data.
I understand.
If I replace the equality sign in the second constraint with <= it will solve and give acceptable results. The error in the constraints will be 2%.
Is it possible that your data has values with various orders of magnitude? This may lead to numerical issues and ultimately infeasibility. Our Guidelines for Numerical Issues hold helpful information about how to detect whether your model has numerical issues and how to tackle them.
Note that often real world data is not clean, i.e., there are (round-off) errors in the data which results in infeasibility when used in optimization algorithms. It is often useful to clean up the data before using it.
Did you try computing an IIS or a feasibility relaxation as proposed in How do I determine why my model is infeasible? This may give you an idea on which variables/constraint to adjust in order to retain feasibility.
If it is not possible to improve the data or achieve feasibility with equalities, you might consider formulating the equality constraints as range constraints, i.e., replace \(x = 0\) by \(-\delta \leq x \leq \delta\) with \(\delta > 0\). This will allow for a bit of wiggle room while still being close to equalities. You can use Gurobi's range constraints for this.
Best regards,
JaromiłBest regards,
Jaromił0
投稿コメントは受け付けていません。
コメント
4件のコメント