Varible vector violates upper and lower bounds when I hit iteration limit
AnsweredHi all,
I have an application where I want to monitor the variables over time. I declair all the variables in my model like this:
x = m.addVars(np.size(distances, axis = 0), np.size(distances, axis=1), lb=0.0,ub=1.0, name="x")
I set the following parameters:
model.Params.IterationLimit = 1.
model.Params.Method = 0
model.Params.Presolve = 0
model.Params.Sifting = 0
This is what gets written to model when I perform model.optimize:
Changed value of parameter IterationLimit to 1.0
Prev: inf Min: 0.0 Max: inf Default: inf
Parameter Method unchanged
Value: 0 Min: -1 Max: 5 Default: -1
Parameter Presolve unchanged
Value: 0 Min: -1 Max: 2 Default: -1
Changed value of parameter Sifting to 0
Prev: -1 Min: -1 Max: 2 Default: -1
Gurobi Optimizer version 9.0.1 build v9.0.1rc0 (win64)
Optimize a model with 35 rows, 125 columns and 375 nonzeros
Coefficient statistics:
Matrix range [1e+00, 1e+00]
Objective range [1e+01, 2e+02]
Bounds range [1e+00, 1e+00]
RHS range [1e+00, 6e+00]
Iteration Objective Primal Inf. Dual Inf. Time
0 2.6665428e+03 2.000000e+00 5.000035e+07 0s
Stopped in 1 iterations and 0.01 seconds
Iteration limit reached
However when reach my iteration limit and retrive the variables I get the following vector:
```
[0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, -1.0, 0.0, 0.0,
0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0,
1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 1.0, 0.0,
0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0]
```
The problem is the -1 and 2 which violates my bounds.
Is there something I need to do when my IterationLimit is reached to clean up where my gurobi model currently stopped to get a varible vector that is observing my upper and lower bounds?
-
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?. -
Are you retrieving the variable values in a callback, or by querying the X variable attributes after the optimization completes? Can you please post a minimal working code example that reproduces the issue?
0 -
I am retrieving the variables with
x = model.x
a minimal working code example is tricky because I am looking at site assignment changes when I have the optimal assignment for one objective function and use that assignment as the initial feasible solution for a new objective function, so with the helper functions it can get quite large to generate all to constants and coefficients.
Also, since I left it out of the origional post, I have an initial feasible cbasis and vbasis that I use to make sure that I am in the feasible region to start, and I am specifying the primal simplex method, so I am confused why I am leaving the feasible region after the first iteration.
0 -
I see, thanks for the clarification. If you set an iteration limit, Gurobi may terminate with an ITERATION_LIMIT status during phase 1 of the simplex algorithm, before a feasible solution is available. If this happens, Gurobi may return an infeasible solution. You can check whether the solution is feasible by querying the BoundVio and ConstrVio model attributes and comparing this to the feasibility tolerance.
0 -
Thank you for your help. I will implement this check to iterate around this. I was suprised that a primal simplex step with a feasible starting cbasis and vbasis and starting point could become infeasible during the simplex iterations.
0
Post is closed for comments.
Comments
5 comments