Tolerance and bineary variables
回答済みThe decision variables are defined to be greater equal than 0. However the result i get containes values like -2.84e-14. My objective function is to count the nonzero values and these values leads to wrong results. I defined bineary variables and used bigM constraints to do the nonzero value counting, even the result of bineary variables are not equal to 0 or 1.
Is there anyway to aviod this issue?
-
Do you mean -2.84e-14? Or are you saying your non-negative variables have solution values like -284000000000000?
0 -
Sorry, i mean -2.84e-14
0 -
Hi Ying,
You can try and reduce it the issue using IntegralityFocus - this is particularly relevant if you have big M constraints, and you should also try and find the tightest M values possible, even if this means a different M value for each big M constraint. You could also try using indicator constraints instead of Big M constraints. See this discussion on Stack Overflow.
Ultimately though, these tiny "errors" are a consequence of floating point arithmetic, and solvers must use tolerances when making calculations and deciding feasibility, so there may be no way to avoid it. One possible action you could try, if you are using gurobipy, is to call Model.fixed() after solving, then solve the fixed model. Presolve may then eliminate any small values which should be 0 due to the big M constraints, however it may be that the solution then becomes infeasible - try it and see.
- Riley
1 -
Also, please see Why does Gurobi sometimes return non-integral values for integer variables? for more information.
0
サインインしてコメントを残してください。
コメント
4件のコメント