coin-or / CyLP

A Python interface to CLP, CBC, and CGL to solve LPs and MIPs.
Other
182 stars 69 forks source link

solver status not reported correctly #81

Open HuangRicky opened 4 years ago

HuangRicky commented 4 years ago

It is difficult to tell whether it's CyLP issue or cvxpy issue but i'm using CyLP with cvxpy. I got these verbose output: (I tried the pypi version as well latest compiled trunk version as of Nov 10, 2019)

Welcome to the CBC MILP Solver 
Version: Trunk (unstable) 
Build Date: Mar 24 2019 
Revision Number: 2539 
command line - ICbcModel -solve -quit (default strategy 1)
Continuous objective value is 4.84888 - 0.00 seconds
Cgl0003I 0 fixed, 0 tightened bounds, 1 strengthened rows, 0 substitutions
Cgl0003I 0 fixed, 0 tightened bounds, 1 strengthened rows, 0 substitutions
Cgl0004I processed model has 151 rows, 91 columns (28 integer (28 of which binary)) and 1384 elements
Cbc0031I 18 added rows had average density of 55.055556
Cbc0013I At root node, 18 cuts changed objective from 4.8488812 to 4.8493148 in 43 passes
Cbc0014I Cut generator 0 (Probing) - 5 row cuts average 2.0 elements, 0 column cuts (0 active)  in 0.016 seconds - new frequency is -100
Cbc0014I Cut generator 1 (Gomory) - 218 row cuts average 75.8 elements, 0 column cuts (0 active)  in 0.015 seconds - new frequency is -100
Cbc0014I Cut generator 2 (Knapsack) - 0 row cuts average 0.0 elements, 0 column cuts (0 active)  in 0.008 seconds - new frequency is -100
Cbc0014I Cut generator 3 (Clique) - 0 row cuts average 0.0 elements, 0 column cuts (0 active)  in 0.001 seconds - new frequency is -100
Cbc0014I Cut generator 4 (MixedIntegerRounding2) - 1 row cuts average 21.0 elements, 0 column cuts (0 active)  in 0.002 seconds - new frequency is -100
Cbc0014I Cut generator 5 (FlowCover) - 0 row cuts average 0.0 elements, 0 column cuts (0 active)  in 0.019 seconds - new frequency is -100
Cbc0014I Cut generator 6 (TwoMirCuts) - 23 row cuts average 61.1 elements, 0 column cuts (0 active)  in 0.004 seconds - new frequency is -100
Cbc0010I After 0 nodes, 1 on tree, 1e+50 best solution, best possible 4.8493148 (0.15 seconds)
Cbc0001I Search completed - best objective 1e+50, took 442 iterations and 24 nodes (0.27 seconds)
Cbc0032I Strong branching done 358 times (1257 iterations), fathomed 1 nodes and fixed 0 variables
Cbc0035I Maximum depth 11, 0 variables fixed on reduced cost
Cuts at root node changed objective from 4.84888 to 4.84931
Probing was tried 43 times and created 5 cuts of which 0 were active after adding rounds of cuts (0.016 seconds)
Gomory was tried 43 times and created 218 cuts of which 0 were active after adding rounds of cuts (0.015 seconds)
Knapsack was tried 43 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.008 seconds)
Clique was tried 43 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.001 seconds)
MixedIntegerRounding2 was tried 43 times and created 1 cuts of which 0 were active after adding rounds of cuts (0.002 seconds)
FlowCover was tried 43 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.019 seconds)
TwoMirCuts was tried 43 times and created 23 cuts of which 0 were active after adding rounds of cuts (0.004 seconds)
ZeroHalf was tried 1 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Result - Problem proven infeasible
No feasible solution found
Enumerated nodes:               24
Total iterations:               442

However, cvxpy's problem object didn't capture this infeasible, it is still "optimal".

        prob_ = cvx.Problem(objfuncm, conslist)
        prob_.solve(verbose=True, solver=cvx.CBC, maximumSeconds=20) 

I post this issue here to see if someone happen to understand this Result - Problem proven infeasible message and make sure it's reported correctly to cvxpy (something like standard exit code, etc)

Thank you very much.

mkoeppe commented 2 years ago

I have run into the same problem. @tkralphs

Result - Problem proven infeasible

No feasible solution found
Enumerated nodes:               0
Total iterations:               0
Time (CPU seconds):             0.00
Time (Wallclock seconds):       0.00

Total time (CPU seconds):       0.00   (Wallclock seconds):       0.00

> /Users/mkoeppe/s/sage/cvxpy/cvxpy/reductions/solvers/conic_solvers/cbc_conif.py(187)solve_via_data()
-> solution = {}
(Pdb) p cbcModel.solutionCount
0
(Pdb) p cbcModel.status
'solution'

The code for https://github.com/coin-or/CyLP/blob/master/cylp/cy/CyCbcModel.pyx#L152 looks rather suspicious.

Looks like there are no tests in https://github.com/coin-or/CyLP/blob/master/cylp/tests/test_MIP.py for infeasible integer models.

tkralphs commented 2 years ago

I think this should now be fixed in #150, but I've only done minimal testing. Can you check it and let me know? I will try to add some tests, too, but that's a whole can of worms that I was putting off "until I have time." There is at least one test that is failing and can't be easily fixed.