Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No solution returned although Cbc claim optimality #273

Closed
andreaslundell opened this issue Dec 1, 2019 · 3 comments
Closed

No solution returned although Cbc claim optimality #273

andreaslundell opened this issue Dec 1, 2019 · 3 comments

Comments

@andreaslundell
Copy link
Member

I have encountered a problem when solving the following MILP problem in Cbc:

Minimize
 10.5 i1 - 7.5 i2 - 3.5 i3 + 2.5 i4 - 1.5 i5 + 10 i6 + 0.5 x7 + 0.25 x8 + 1.5 x9 + 0.5 x10 + 0.5 x11
Subject To
 e1: 6 i1 + 3 i2 + 3 i3 + 2 i4 + i5 <= 6.5
 e2: 10 i1 + 10 i3 + i6 <= 20
 e3: 1.13238 i3 - x9 <= 0.32057
 e4: 1.23607 i5 - x11 <= 0.38197
 e5: 1.23607 i2 - x8 <= 0.38197
 e6: 1.5982 i3 - x9 <= 0.63856
 e7: 1.85942 i5 - x11 <= 0.86436
 e8: 1.85942 i2 - x8 <= 0.86436
 e9: 1.99507 i2 - x8 <= 0.99507
 e10: 1.96005 i3 - x9 <= 0.96045
 e11: 10.5 i1 - 7.5 i2 - 3.5 i3 + 2.5 i4 - 1.5 i5 + 10 i6 + 0.5 x7 + 0.25 x8 + 1.5 x9 + 0.5 x10 + 0.5 x11 <= -9.25
Bounds
 0 <= i1 <= 1
 0 <= i2 <= 1
 0 <= i3 <= 1
 0 <= i4 <= 1
 0 <= i5 <= 1
 0 <= i6 <= 20
 0 <= x7 <= 1
 0 <= x8 <= 1
 0 <= x9 <= 1
 0 <= x10 <= 1
 0 <= x11 <= 1
Integers
 i1 i2 i3 i4 i5 i6
End

When solving it with the trunk version of Cbc, I get the following output:

Welcome to the CBC MILP Solver
Version: Trunk (unstable)
Build Date: Dec  1 2019

command line - /opt/cbc-master/bin/cbc test.lp (default strategy 1)
Continuous objective value is -10.1292 - 0.00 seconds
Cgl0004I processed model has 0 rows, 0 columns (0 integer (0 of which binary)) and 0 elements
Cbc3007W No integer variables - nothing to do
Cuts at root node changed objective from -9.2506 to -1.79769e+308
Probing was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Gomory was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Knapsack was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Clique was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
MixedIntegerRounding2 was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
FlowCover was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
TwoMirCuts was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
ZeroHalf was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)

Result - Optimal solution found

Objective value:                -9.25060000
Enumerated nodes:               0
Total iterations:               3
Time (CPU seconds):             0.00
Time (Wallclock seconds):       0.00

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

So far so good... However, if the solution is written to a file using (cbc test.lp solu sol.txt) the correct solution is not returned:

sol.txt:

Status unknown - objective value 0.00000000
      0 i1                     0                       0
      1 i2                     0                       0
      2 i3                     0                       0
      3 i4                     0                       0
      4 i5                     0                       0
      5 i6                     0                       0
      6 x7                     0                       0
      7 x8                     0                       0
      8 x9                     0                       0
      9 x10                    0                       0
     10 x11                    0                       0

Solving the same problem with Gurobi (and CPLEX) gives the correct solution:

Gurobi Optimizer version 8.1.0 build v8.1.0rc1 (linux64)
Copyright (c) 2018, Gurobi Optimization, LLC

Read LP format model from file mod.lp
Reading time = 0.00 seconds
: 11 rows, 11 columns, 35 nonzeros
Optimize a model with 11 rows, 11 columns and 35 nonzeros
Variable types: 5 continuous, 6 integer (0 binary)
Coefficient statistics:
  Matrix range     [2e-01, 1e+01]
  Objective range  [2e-01, 1e+01]
  Bounds range     [1e+00, 2e+01]
  RHS range        [3e-01, 2e+01]
Presolve removed 11 rows and 11 columns
Presolve time: 0.00s
Presolve: All rows and columns removed

Explored 0 nodes (0 simplex iterations) in 0.00 seconds
Thread count was 1 (of 6 available processors)

Solution count 1: -9.2506 

Optimal solution found (tolerance 1.00e-04)
Best objective -9.250600000000e+00, best bound -9.250600000000e+00, gap 0.0000%

Solution:

# Objective value = -9.2506
i1 0
i2 1
i3 1
i4 0
i5 0
i6 0
x7 0
x8 9.9999999999999989e-01
x9 0.9996
x10 0
x11 0

@tkralphs
Copy link
Member

tkralphs commented Dec 1, 2019

Looks like the solution was found in pre-processing, but because the pre-processed model was completely empty, something went wrong in getting the solution out. We'll take a look.

Does the same happen with the latest release? Keep in mind that trunk/master version of Cbc is under active development and some bugs are to be expected.

@jjhforrest
Copy link
Contributor

jjhforrest commented Dec 1, 2019 via email

@andreaslundell
Copy link
Member Author

Using -solu did indeed print the correct solution. I was following the instructions at https://projects.coin-or.org/CoinBinary/export/1059/OptimizationSuite/trunk/Installer/files/doc/cbcCommandLine.pdf, which had just solu. This does not however explain the problems I have solving this problem using the C++ interface, but I will investigate that further...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants