Panda
Panda

Reputation: 241

Python-How to terminate The integer linear programming(ILP) function when it finds solution in CVXOPT

I want to terminate solving when it finds one solution, How can I do that?

Now it returns something like below:

*    62: obj =  -8.419980000e+05 inf =   0.000e+00 (0)
      OPTIMAL LP SOLUTION FOUND
      Integer optimization begins...
       +    62: mip =     not found yet >=              -inf        (1; 0)
      +   149: >>>>>  -1.370260000e+05 >=  -7.939630000e+05 479.4% (26; 0)
     +  1390: >>>>>  -1.375090000e+05 >=  -4.261680000e+05 209.9% (264; 27)
    + 28323: mip =  -1.375090000e+05 >=  -1.921510000e+05  39.7% (2232; 1534)
    + 52571: mip =  -1.375090000e+05 >=  -1.781890000e+05  29.6% (2983; 3596)

Upvotes: 0

Views: 134

Answers (1)

sascha
sascha

Reputation: 33542

I think there is no nice way doing this.

These kind of advanced usages are usually done with more direct access to the solver (opposed to wrappers like this one; i'm assuming you are still using cvxopt like in your other questions).

Some remarks:

  • I didn't find any solver-parameter supporting this kind of early abort
  • cbc (which i prefer to glpk; supports this through setMaximumSolutions, but i think there is no wrapper within cvxopt)
  • What you could try:
    • set objll or objul docs
    • objul (default: +DBL_MAX) Upper limit of the objective function. If the objective function reaches this limit and continues increasing, the solver stops the search. This parameter is used in the dual simplex only.
    • objll (default: -DBL_MAX) Lower limit of the objective function. If the objective function reaches this limit and continues decreasing, the solver stops the search. This parameter is used in the dual simplex method only.
    • So: if you are minimizing, set objll to a huge value (or better: the expected worst-solution value = biggest value)
    • if you are maximizing, set objul to a tiny value (possibly negative; or better: the expected worst-solution value = smallest value)

Upvotes: 1

Related Questions