2
$\begingroup$

I have an application where I want to monitor the variables over time. I declare all the variables in my model like this:

x = model.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

However when reaching my iteration limit and retrieve 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 violate 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 variable vector that is observing my upper and lower bounds?

Furthermore, I do have a feasible cbasis and vbasis that I am using as a starting point for this problem and the params specify that I am forcing the primal simplex method. Presolver is also turned off.

The problem is that I start in the feasible region and then I leave the feasible region in this iteration.

(Edit: added sentence at the end to clarify why this vector being infeasible is so confusing)

$\endgroup$
3
  • 6
    $\begingroup$ Any good reason to cripple gurobi like that? Anyway, if you want feasible solutions, you will need to wait until gurobi found one. $\endgroup$ Jul 22 at 21:14
  • $\begingroup$ I want to record changes in basis from my feasible start to the optimal $\endgroup$
    – user5906
    Jul 25 at 3:04
  • 1
    $\begingroup$ It seems the advanced basis was not feasible, not complete, or it was loaded incorrectly. $\endgroup$ Jul 25 at 3:40
4
$\begingroup$

If you look at the output log, you'll see a primal infeasibility value of 2.0 (which is the sum of the absolute values of the violations in the two values you noted). That just means it will take more than one iteration to find an initial feasible solution. In other words, your iteration limit is too small.

$\endgroup$
3
  • $\begingroup$ You make a good point and I edited my question why the infeasible vector confuses me $\endgroup$
    – user5906
    Jul 22 at 21:39
  • 1
    $\begingroup$ Erwin's comment is on point. If you want a feasible solution, you need to increase the iteration limit enough to let the solver find one. $\endgroup$
    – prubin
    Jul 23 at 23:19
  • $\begingroup$ But I start with a feasible solution, I have a feasible cBasis, Vbasis, PStart and Dstart I can set. no matter what I do the gurobi solver leaves the feasible region. I have a temporary fix in place that lets it iterate till it finds a feasible answer. $\endgroup$
    – user5906
    Jul 25 at 3:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.