coin-or / python-mip

Python-MIP: collection of Python tools for the modeling and solution of Mixed-Integer Linear programs
Eclipse Public License 2.0
514 stars 89 forks source link

Optimal value violates constraint #273

Closed Simon-Rey closed 2 years ago

Simon-Rey commented 2 years ago

Hi all,

I'm not sure if this is a bug or a complete misunderstanding from my side. I have a very simple ILP but the value of the objective at the end seems to be incorrect, or at least it seems to violate a constraint.

Here is the model:

\Problem name:

Minimize OBJROW: - minVar Subject To budgetCstr: 2 p_2 + p_3 + 2 p_1 <= 3 minVarConstr1_0: 0,66667 p_3 + 1,33333 p_1 - minVar >= -0 minVarConstr1_1: 1,33333 p_2 - minVar >= -0 Bounds 0 <= p_2 <= 1 0 <= p_3 <= 1 0 <= p_1 <= 1 0 <= minVar <= 1 Integers p_2 p_3 p_1 End

And this is the output:

Welcome to the CBC MILP Solver Version: devel Build Date: Nov 15 2020

Starting solution of the Linear programming relaxation problem using Dual Simplex

Coin0506I Presolve 3 (0) rows, 4 (-2) columns and 8 (0) elements Clp0000I Optimal - objective value 1 Coin0511I After Postsolve, objective 1, infeasibilities - dual 0 (0), primal 0 (0) Clp0032I Optimal objective 1 - 2 iterations time 0,002, Presolve 0,00

Starting MIP optimization Cgl0004I processed model has 3 rows, 4 columns (3 integer (3 of which binary)) and 8 elements Coin3009W Conflict graph built in 0,000 seconds, density: 11,111% Cgl0015I Clique Strengthening extended 0 cliques, 0 were dominated Cbc0038I Initial state - 0 integers unsatisfied sum - 0 Cbc0038I Solution found of -1 Cbc0038I Relaxing continuous gives -1 Cbc0038I Before mini branch and bound, 3 integers at bound fixed and 1 continuous Cbc0038I Mini branch and bound did not improve solution (0,00 seconds) Cbc0038I After 0,00 seconds - Feasibility pump exiting with objective of -1 - took 0,00 seconds Cbc0012I Integer solution of -1 found by feasibility pump after 0 iterations and 0 nodes (0,00 seconds) Cbc0001I Search completed - best objective -1, took 0 iterations and 0 nodes (0,00 seconds) Cbc0035I Maximum depth 0, 0 variables fixed on reduced cost Total time (CPU seconds): 0,00 (Wallclock seconds): 0,00

Solution of value 1.0 found, minVar is 1.0, optimization status is OptimizationStatus.OPTIMAL Selected are p_2 and p_3.

Now given the formulation of the problem, selecting p_2 and p_3, i.e., setting them to 1 would mean that minVarConstr1_0 says that 0,66667 p_3 - minVar >= -0 and thus that 0,66667 >= minVar. How can the optimal value be 1 then?

Sorry again if this is a trivial thing that I'm missing, I just don't understand the behaviour here.

Thanks for the support,

Simon.

sebheger commented 2 years ago

Could confirm that the optimal solution is 0 and -1 is obviously wrong. Solving the .lp with CBC 2.10.3 from the command line interface states the right solution. @Simon-Rey Would you be so kind to provide me the following information:

Thanks for your support

Simon-Rey commented 2 years ago

Thanks for your answer!

So I believe optimal solution is for minVar = 0.66667 so objective -0.66667, achieved with p_1 = 0, p_2 = p_3 = 1.

OS is debian 11 bullseye and python-mip is version 1.13.0 installed with pip3.

For the python code, I'll need a bit of time to prepare something readable ;)

Simon-Rey commented 2 years ago

Ok it's a bit embarassing, but as expected it's a problem on my side and not on the solver's side. There is no problem, I made some mistakes in the way I am dealing with the solver's output.

Sorry for the inconvenience, and thanks for the support and everything you're doing, it's great working with python-mip :)