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

cbc shows different results in command line and solution file #694

Open
zxt5 opened this issue Feb 25, 2025 · 3 comments
Open

cbc shows different results in command line and solution file #694

zxt5 opened this issue Feb 25, 2025 · 3 comments

Comments

@zxt5
Copy link

zxt5 commented Feb 25, 2025

For seed.mps.txt

cbc prints the correct result to command line:

root@b9f8d0525121:/tmp/fuzz-mip# cbc seed.mps
Welcome to the CBC MILP Solver
Version: Devel (unstable)
Build Date: Feb 20 2025
command line - potential-bugs/22/seed.mps (default strategy 1)
At line 2 NAME          seed
At line 3 ROWS
At line 296 COLUMNS
At line 4689 RHS
At line 4981 BOUNDS
At line 5012 ENDATA
Problem seed has 291 rows, 15 columns and 4363 elements
Coin0008I seed read with 0 errors
Continuous objective value is -47653.2 - 0.09268 seconds
Cgl0004I processed model has 291 rows, 15 columns (7 integer (0 of which binary)) and 4363 elements
Coin3009W Conflict graph built in 0.000 seconds, density: 0.000%
Cgl0015I Clique Strengthening extended 0 cliques, 0 were dominated
Cbc0012I Integer solution of -47286.63136886 found by DiveCoefficient after 0 iterations and 0 nodes (0.20 seconds)
Cbc0012I Integer solution of -47286.91239671 found by DiveCoefficient after 374 iterations and 0 nodes (0.87 seconds)
Cbc0031I 4 added rows had average density of 15
Cbc0013I At root node, 4 cuts changed objective from -47653.243 to -47610.223 in 100 passes
Cbc0014I Cut generator 0 (Probing) - 0 row cuts average 0.0 elements, 0 column cuts (0 active)  in 0.068 seconds - new frequency is -100
Cbc0014I Cut generator 1 (Gomory) - 263 row cuts average 15.0 elements, 0 column cuts (0 active)  in 0.081 seconds - new frequency is 1
Cbc0014I Cut generator 2 (Knapsack) - 0 row cuts average 0.0 elements, 0 column cuts (0 active)  in 0.011 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 (OddWheel) - 0 row cuts average 0.0 elements, 0 column cuts (0 active)  in 0.003 seconds - new frequency is -100
Cbc0014I Cut generator 5 (MixedIntegerRounding2) - 0 row cuts average 0.0 elements, 0 column cuts (0 active)  in 0.100 seconds - new frequency is -100
Cbc0014I Cut generator 6 (FlowCover) - 0 row cuts average 0.0 elements, 0 column cuts (0 active)  in 0.038 seconds - new frequency is -100
Cbc0010I After 0 nodes, 1 on tree, -47286.912 best solution, best possible -47610.223 (0.88 seconds)
Cbc0012I Integer solution of -47297.26780478 found by DiveCoefficient after 377 iterations and 1 nodes (0.89 seconds)
Cbc0012I Integer solution of -47387.45049856 found by DiveCoefficient after 383 iterations and 2 nodes (0.91 seconds)
Cbc0016I Integer solution of -47475.488 found by strong branching after 410 iterations and 9 nodes (0.96 seconds)
Cbc0004I Integer solution of -47539.757 found after 448 iterations and 16 nodes (1.00 seconds)
Cbc0016I Integer solution of -47576.217 found by strong branching after 507 iterations and 25 nodes (1.07 seconds)
Cbc0001I Search completed - best objective -47576.21726990093, took 537 iterations and 28 nodes (1.10 seconds)
Cbc0032I Strong branching done 120 times (318 iterations), fathomed 6 nodes and fixed 3 variables
Cbc0035I Maximum depth 7, 4 variables fixed on reduced cost
Cuts at root node changed objective from -47653.2 to -47610.2
Probing was tried 100 times and created 0 cuts (0.068366 seconds)
Gomory was tried 114 times and created 295 cuts (0.090192 seconds)
Knapsack was tried 100 times and created 0 cuts (0.01145 seconds)
Clique was tried 100 times and created 0 cuts (0.000528 seconds)
OddWheel was tried 100 times and created 0 cuts (0.002576 seconds)
MixedIntegerRounding2 was tried 100 times and created 0 cuts (0.099902 seconds)
FlowCover was tried 100 times and created 0 cuts (0.037803 seconds)
TwoMirCuts was tried 1 times and created 0 cuts (0.001219 seconds)
ZeroHalf was tried 1 times and created 0 cuts (2e-06 seconds)

Result - Optimal solution found
Objective value:                -47576.2169985
Enumerated nodes:               28
Total iterations:               537
Time (CPU seconds):             1.1347
Time (Wallclock seconds):       1.64577
Total time (CPU seconds):       1.16141   (Wallclock seconds):       1.65971

but write a "unknown solution" to the file:

root@b9f8d0525121:/tmp/fuzz-mip# cbc seed.mps -solution seed-solution.txt
Welcome to the CBC MILP Solver
Version: Devel (unstable)
Build Date: Feb 20 2025
command line - potential-bugs/22/seed.mps -solution seed-solution.txt (default strategy 1)
At line 2 NAME          seed
At line 3 ROWS
At line 296 COLUMNS
At line 4689 RHS
At line 4981 BOUNDS
At line 5012 ENDATA
Problem seed has 291 rows, 15 columns and 4363 elements
Coin0008I seed read with 0 errors
Total time (CPU seconds):       0   (Wallclock seconds):       0.00380898

root@b9f8d0525121:/tmp/fuzz-mip# cat seed-solution.txt
Status unknown - objective value 0.00000000
      0 x0                     0                       0
      1 x1                     0                       0
      2 x10                    0                       0
      3 x11                    0                       0
      4 x12                    0                       0
      5 x13                    0                       0
      6 x14                    0                       0
      7 x2                     0                       0
      8 x3                     0                       0
      9 x4                     0                       0
     10 x5                     0                       0
     11 x6                     0                       0
     12 x7                     0                       0
     13 x8                     0                       0
     14 x9                     0                       0
@jjhforrest
Copy link
Contributor

cbc seed.mps is actualy taken as cbc seed.mps -solve. The -solve is added if the only parameter is a model.

The correct format of second command is
cbc seed.mps -solve -solution seed-solution.txt

not

cbc seed.mps -solution seed-solution.txt

@zxt5
Copy link
Author

zxt5 commented Feb 26, 2025

Oh I see, my mistake.

@zxt5
Copy link
Author

zxt5 commented Feb 26, 2025

Now I can reproduce my problem:
I am using the default cbc in pulp-2.9.0(python3.8/dist-packages/pulp/solverdir/cbc/linux/64/cbc), seeing the command-line and the solution file show different results. I have also checked the master branch, which doesn't have this problem.

root@b9f8d0525121:/tmp/fuzz-mip# /usr/local/lib/python3.8/dist-packages/pulp/solverdir/cbc/linux/64/cbc seed.mps -solve -solution seed-solution.txt
Welcome to the CBC MILP Solver
Version: 2.10.3
Build Date: Dec 15 2019

command line - /usr/local/lib/python3.8/dist-packages/pulp/solverdir/cbc/linux/64/cbc seed.mps -solve -solution seed-solution.txt (default strategy 1)
At line 2 NAME          seed
At line 3 ROWS
At line 296 COLUMNS
At line 4689 RHS
At line 4981 BOUNDS
At line 5012 ENDATA
Problem seed has 291 rows, 15 columns and 4363 elements
Coin0008I seed read with 0 errors
Continuous objective value is -47653.2 - 0.00 seconds
Cgl0004I processed model has 291 rows, 15 columns (7 integer (0 of which binary)) and 4363 elements
Cbc0012I Integer solution of -47286.631 found by DiveCoefficient after 0 iterations and 0 nodes (0.00 seconds)
Cbc0012I Integer solution of -47286.912 found by DiveCoefficient after 217 iterations and 0 nodes (0.12 seconds)
Cbc0031I 5 added rows had average density of 15
Cbc0013I At root node, 5 cuts changed objective from -47653.243 to -47610.265 in 100 passes
Cbc0014I Cut generator 0 (Probing) - 0 row cuts average 0.0 elements, 0 column cuts (0 active)  in 0.016 seconds - new frequency is -100
Cbc0014I Cut generator 1 (Gomory) - 241 row cuts average 15.0 elements, 0 column cuts (0 active)  in 0.015 seconds - new frequency is 1
Cbc0014I Cut generator 2 (Knapsack) - 0 row cuts average 0.0 elements, 0 column cuts (0 active)  in 0.002 seconds - new frequency is -100
Cbc0014I Cut generator 3 (Clique) - 0 row cuts average 0.0 elements, 0 column cuts (0 active)  in 0.000 seconds - new frequency is -100
Cbc0014I Cut generator 4 (MixedIntegerRounding2) - 0 row cuts average 0.0 elements, 0 column cuts (0 active)  in 0.017 seconds - new frequency is -100
Cbc0014I Cut generator 5 (FlowCover) - 0 row cuts average 0.0 elements, 0 column cuts (0 active)  in 0.007 seconds - new frequency is -100
Cbc0010I After 0 nodes, 1 on tree, -47286.912 best solution, best possible -47610.265 (0.12 seconds)
Cbc0012I Integer solution of -47431.131 found by DiveCoefficient after 230 iterations and 1 nodes (0.13 seconds)
Cbc0012I Integer solution of -47519.768 found by DiveCoefficient after 233 iterations and 2 nodes (0.13 seconds)
Cbc0012I Integer solution of -47539.757 found by DiveCoefficient after 266 iterations and 4 nodes (0.15 seconds)
Cbc0012I Integer solution of -47540.695 found by DiveCoefficient after 291 iterations and 9 nodes (0.16 seconds)
Cbc0016I Integer solution of -47576.217 found by strong branching after 418 iterations and 14 nodes (0.19 seconds)
Cbc0001I Search completed - best objective -47576.21726990087, took 430 iterations and 16 nodes (0.19 seconds)
Cbc0032I Strong branching done 86 times (234 iterations), fathomed 3 nodes and fixed 6 variables
Cbc0035I Maximum depth 4, 7 variables fixed on reduced cost
0  Obj -47653.243 Primal inf 2.4002514 (6) Dual inf 6.0303144e+10 (7)
7  Obj -47576.217 Primal inf 6.064645e-07 (1)
7  Obj -47576.217 Primal inf 6.064645e-07 (1)
Primal infeasible - objective value -47576.217
Cuts at root node changed objective from -47653.2 to -47610.3
Probing was tried 100 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.016 seconds)
Gomory was tried 155 times and created 367 cuts of which 0 were active after adding rounds of cuts (0.022 seconds)
Knapsack was tried 100 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.002 seconds)
Clique was tried 100 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
MixedIntegerRounding2 was tried 100 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.017 seconds)
FlowCover was tried 100 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.007 seconds)
TwoMirCuts was tried 1 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
ZeroHalf was tried 1 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
0  Obj -106434.51 Primal inf 39488.533 (119) Dual inf 3361.2645 (3)
18  Obj -47576.217 Primal inf 1.3401913e-06 (1)
18  Obj -47914.51 Primal inf 1.3401913e-06 (1)
Primal infeasible - objective value -47914.51
Cgl0013I Postprocessed model is infeasible - possible tolerance issue - try without preprocessing
103 relaxed row infeasibilities - summing to 749784
103 relaxed row infeasibilities - summing to 749784
103 relaxed row infeasibilities - summing to 749784

Result - Optimal solution found

Objective value:                -47576.21726990
Enumerated nodes:               16
Total iterations:               430
Time (CPU seconds):             0.21
Time (Wallclock seconds):       0.21

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

root@b9f8d0525121:/tmp/fuzz-mip# cat seed-solution.txt
Optimal - objective value 12715541.16626296
      0 x0                  -200              -7533.4668
      1 x1                  -200              -10334.988
**       2 x10           -15408.935                       0
      3 x11                 -200              -3996.0108
**       4 x12            132220.84                       0
      5 x13                 -200              -15722.932
**       6 x14           -69608.106                       0
      7 x2                  -200              -16155.608
      8 x3                  -200              -4190.8393
      9 x4                  -200              -6873.7155
**      10 x5             46805.098                       0
     11 x6                   200              -1231.8244
**      12 x7             35077.961                       0
**      13 x8             29326.093                       0
**      14 x9             42400.103                       0

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

2 participants