Is there a better solution than IntegralityFocus to ensure integrality of variables?
Awaiting user inputI have an MIP model with the following parameter settings:
mdl.Params.IntegralityFocus = 1
mdl.Params.FeasibilityTol = 1e-9
The model sometimes generates variables that are not even close to integer values. For example:
k: v.X for k, v in t.items() if v.X > 0}
{(0, 1): 114.0, (0, 4): 23.558825610628386, (0, 5): 45.0, (0, 6): 111.0, (0, 7): 64.52817997001554, (0, 8): 89.45054879258372, (0, 10): 14.0, (0, 11): 29.558825610628386, (0, 12): 24.0, (0, 13): 12.000000000000016, (0, 14): 7.0, (0, 15): 76.74705379564192, (0, 16): 117.0, (0, 17): 9.000000000000016, (0, 18): 61.0, (0, 19): 18.0, (0, 21): 52.52817997001554, (0, 22): 64.5158780897043, (0, 24): 85.0, (0, 26): 71.0, (0, 27): 99.0, (0, 28): 83.45054879258372, (0, 30): 78.0, (0, 31): 35.0, (0, 32): 20.514940870192838, (0, 33): 28.0, (0, 34): 58.52817997001554, (0, 37): 84.0, (0, 38): 107.0, (0, 39): 3.000000000000016, (0, 40): 26.558825610628386, (0, 41): 6.000000000000015, (0, 43): 52.0, (0, 44): 95.45054879258372, (0, 45): 92.0, (0, 46): 12.0, (0, 48): 15.000000000000016, (0, 49): 30.0, (0, 50): 38.0, (0, 51): 68.0, (0, 52): 32.55882561062839, (0, 53): 58.0, (0, 54): 6.0, (0, 55): 35.558825610628446, (0, 56): 90.0, (0, 58): 55.0, (0, 59): 21.0}
However, the integrality of variables is important in my application and rounding them after the solution process might not be sufficient. What would be your suggestion?
0
-
Official comment
This post is more than two 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. -
How exactly do you define your \(\texttt{t}\) variables? It looks like at least some of them are not defined as integer variables:
(0, 4): 23.558825610628386
(0, 7): 64.52817997001554
(0, 8): 89.45054879258372
(0, 11): 29.558825610628386
(0, 15): 76.74705379564192
(0, 21): 52.52817997001554
(0, 22): 64.5158780897043
(0, 28): 83.45054879258372
(0, 32): 20.514940870192838
(0, 34): 58.52817997001554
(0, 40): 26.558825610628386
(0, 44): 95.45054879258372
(0, 52): 32.55882561062839
(0, 55): 35.558825610628446You can define integer variables by adding the keyword argument \(\texttt{vtype=GRB.INTEGER}\) to your call to Model.addVars() or Model.addVar().
0
Post is closed for comments.
Comments
2 comments