Cbc icon indicating copy to clipboard operation
Cbc copied to clipboard

cbc not respecting timeout

Open zengberg opened this issue 3 years ago • 5 comments

Hello,

I'm running into an issue with cbc not respecting the seconds timeout I set. When I run

cbc -seconds 10 -import tmploqs9qnp.pyomo.lp -solve

the solver just hangs. I've attached the problem definition tmploqs9qnp.pyomo.lp.txt.

I'm seeking a workaround for this issue.

More detail: cbc is aware that the problem is infeasible (see terminal output below), but does not quit after the 10 seconds I've allotted. This is related to #381.

$ cbc -seconds 10 -import tmploqs9qnp.pyomo.lp -stat -solve
Welcome to the CBC MILP Solver 
Version: 2.10.7 
Build Date: Jan 26 2022 

command line - cbc -seconds 10 -import tmploqs9qnp.pyomo.lp -stat -solve (default strategy 1)
seconds was changed from 1e+100 to 10
Presolve determined that the problem was infeasible with tolerance of 1e-08
Presolved model looks infeasible - will use unpresolved
Original problem has 946 integers (946 of which binary)
==== 947 zero objective 375 different
==== absolute objective values 375 different
==== for integers 946 zero objective 1 different
946 variables have objective of 0
==== for integers absolute objective values 1 different
946 variables have objective of 0
===== end objective counts


Problem has 1956 rows, 1772 columns (825 with objective) and 240706 elements
There are 1 singletons with no objective 
Column breakdown:
1 of type 0.0->inf, 0 of type 0.0->up, 0 of type lo->inf, 
363 of type lo->up, 11 of type free, 451 of type fixed, 
0 of type -inf->0.0, 0 of type -inf->up, 946 of type 0.0->1.0 
Row breakdown:
39 of type E 0.0, 40 of type E 1.0, 0 of type E -1.0, 
0 of type E other, 0 of type G 0.0, 0 of type G 1.0, 
491 of type G other, 0 of type L 0.0, 895 of type L 1.0, 
491 of type L other, 0 of type Range 0.0->1.0, 0 of type Range other, 
0 of type Free 

zengberg avatar Mar 23 '22 15:03 zengberg

cbc doesn't like the .txt extension, and after downloading and renaming I do not have this issue (i.e., the timeout is respected) on Ubuntu running cbc 2.10.3 (installed via apt-get):

$ cbc -seconds 10 -import tmploqs9qnp.pyomo.lp -stat -solve
Welcome to the CBC MILP Solver 
Version: 2.10.3 
Build Date: Mar 24 2020 

command line - cbc -seconds 10 -import tmploqs9qnp.pyomo.lp -stat -solve (default strategy 1)
seconds was changed from 1e+100 to 10
Presolve determined that the problem was infeasible with tolerance of 1e-08
Presolved model looks infeasible - will use unpresolved
Original problem has 946 integers (946 of which binary)
==== 947 zero objective 375 different
==== absolute objective values 375 different
==== for integers 946 zero objective 1 different
946 variables have objective of 0
==== for integers absolute objective values 1 different
946 variables have objective of 0
===== end objective counts


Problem has 1956 rows, 1772 columns (825 with objective) and 240706 elements
There are 1 singletons with no objective 
Column breakdown:
1 of type 0.0->inf, 0 of type 0.0->up, 0 of type lo->inf, 
363 of type lo->up, 11 of type free, 451 of type fixed, 
0 of type -inf->0.0, 0 of type -inf->up, 946 of type 0.0->1.0 
Row breakdown:
39 of type E 0.0, 40 of type E 1.0, 0 of type E -1.0, 
0 of type E other, 0 of type G 0.0, 0 of type G 1.0, 
491 of type G other, 0 of type L 0.0, 895 of type L 1.0, 
491 of type L other, 0 of type Range 0.0->1.0, 0 of type Range other, 
0 of type Free 
Problem is stopped - 9.74 seconds
Total time (CPU seconds):       10.00   (Wallclock seconds):       10.02

However, for a very similar problem, I get the same behavior that @zengberg reported (note I had to use "ctrl + C" to kill):

$ cbc -seconds 3 -threads 8 -RandomCbcSeed 42 -RandomSeed 42 -timeMode elapsed -preprocess on -printingOptions all -import tmpagw0rwsl.pyomo.lp -mipstart tmp5f2geuyi.cbc.soln -stat=1 -solve -solu tmpagw0rwsl.pyomo.soln
Welcome to the CBC MILP Solver 
Version: 2.10.3 
Build Date: Mar 24 2020 

command line - cbc -seconds 3 -threads 8 -RandomCbcSeed 42 -RandomSeed 42 -timeMode elapsed -preprocess on -printingOptions all -import tmpagw0rwsl.pyomo.lp -mipstart tmp5f2geuyi.cbc.soln -stat=1 -solve -solu tmpagw0rwsl.pyomo.soln (default strategy 1)
seconds was changed from 1e+100 to 3
threads was changed from 0 to 8
randomCbcSeed was changed from -1 to 42
randomSeed was changed from 1234567 to 42
Option for timeMode changed from cpu to elapsed
Option for preprocess changed from sos to on
Option for printingOptions changed from normal to all
opening mipstart file ./tmp5f2geuyi.cbc.soln.
MIPStart values read for 39 variables.
Presolve determined that the problem was infeasible with tolerance of 1e-08
Presolved model looks infeasible - will use unpresolved
Original problem has 946 integers (946 of which binary)
==== 947 zero objective 375 different
==== absolute objective values 375 different
==== for integers 946 zero objective 1 different
946 variables have objective of 0
==== for integers absolute objective values 1 different
946 variables have objective of 0
===== end objective counts


Problem has 1956 rows, 1772 columns (825 with objective) and 240706 elements
There are 1 singletons with no objective 
Column breakdown:
1 of type 0.0->inf, 0 of type 0.0->up, 0 of type lo->inf, 
363 of type lo->up, 11 of type free, 451 of type fixed, 
0 of type -inf->0.0, 0 of type -inf->up, 946 of type 0.0->1.0 
Row breakdown:
39 of type E 0.0, 40 of type E 1.0, 0 of type E -1.0, 
0 of type E other, 0 of type G 0.0, 0 of type G 1.0, 
491 of type G other, 0 of type L 0.0, 895 of type L 1.0, 
491 of type L other, 0 of type Range 0.0->1.0, 0 of type Range other, 
0 of type Free 
^CProblem is infeasible - 69.57 seconds
Total time (CPU seconds):       69.84   (Wallclock seconds):       69.85

I've attached the .lp and .soln files with an additional .txt extension so that GitHub will accept them. tmp5f2geuyi.cbc.soln.txt tmpagw0rwsl.pyomo.lp.txt

blthayer avatar Mar 23 '22 15:03 blthayer

I can confirm that both of the calls @blthayer demonstrated hang for me running cbc 2.10.7 on macOS. I've also tried with -moreS 1 and -moreS 2, and I didn't see any changes.

zengberg avatar Mar 23 '22 16:03 zengberg

When I run with several versions of solver and compilation options - all is fine.  BUT I did find one combination which had trouble proving infeasibility.  Even odder is that if I exported the .lp file as an .mps file - that was fine.  Will look into it.

Your problem is fairly dense and there may be some numerical issue.  For now, I would suggest doing

.... -primals -solve

The lp phase of Cbc does not use the second parameter as it thinks that will be a trivial part of solve - maye it should.

On 23/03/2022 15:06, zengberg wrote:

Hello,

I'm running into an issue with |cbc| not respecting the |seconds| timeout I set. When I run

|cbc -seconds 10 -import tmploqs9qnp.pyomo.lp -solve |

the solver just hangs. I've attached the problem definition tmploqs9qnp.pyomo.lp.txt https://github.com/coin-or/Cbc/files/8334078/tmploqs9qnp.pyomo.lp.txt.

I'm seeking a workaround for this issue.

More detail: |cbc| is aware that the problem is infeasible (see terminal output below), but does not quit after the 10 seconds I've allotted. This is related to #381 https://github.com/coin-or/Cbc/issues/381.

|$ cbc -seconds 10 -import tmploqs9qnp.pyomo.lp -stat -solve Welcome to the CBC MILP Solver Version: 2.10.7 Build Date: Jan 26 2022 command line - cbc -seconds 10 -import tmploqs9qnp.pyomo.lp -stat -solve (default strategy 1) seconds was changed from 1e+100 to 10 Presolve determined that the problem was infeasible with tolerance of 1e-08 Presolved model looks infeasible - will use unpresolved Original problem has 946 integers (946 of which binary) ==== 947 zero objective 375 different ==== absolute objective values 375 different ==== for integers 946 zero objective 1 different 946 variables have objective of 0 ==== for integers absolute objective values 1 different 946 variables have objective of 0 ===== end objective counts Problem has 1956 rows, 1772 columns (825 with objective) and 240706 elements There are 1 singletons with no objective Column breakdown: 1 of type 0.0->inf, 0 of type 0.0->up, 0 of type lo->inf, 363 of type lo->up, 11 of type free, 451 of type fixed, 0 of type -inf->0.0, 0 of type -inf->up, 946 of type 0.0->1.0 Row breakdown: 39 of type E 0.0, 40 of type E 1.0, 0 of type E -1.0, 0 of type E other, 0 of type G 0.0, 0 of type G 1.0, 491 of type G other, 0 of type L 0.0, 895 of type L 1.0, 491 of type L other, 0 of type Range 0.0->1.0, 0 of type Range other, 0 of type Free |

— Reply to this email directly, view it on GitHub https://github.com/coin-or/Cbc/issues/487, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABWJYHHAP6FKUXR6YU4ZGUDVBMXO3ANCNFSM5ROKKXAA. You are receiving this because you are subscribed to this thread.Message ID: @.***>

jjhforrest avatar Mar 23 '22 18:03 jjhforrest

@jjhforrest adding the -primals flag to my second example above seemed to do the trick, thanks for the tip (output below)! Forgive my ignorance here - is it safe to always provide the primals flag? I presume cbc has some internal way of choosing between the primal and dual algorithms (-primals and -duals flags, respectively)? (I'm admittedly more than a little rusty on some of the theoretical underpinnings here, any pointing in the right direction is appreciate :smile:)

$ cbc -seconds 3 -threads 8 -RandomCbcSeed 42 -RandomSeed 42 -timeMode elapsed -preprocess on -printingOptions all -import tmpagw0rwsl.pyomo.lp -mipstart tmp5f2geuyi.cbc.soln -stat=1 -primals -solve -solu tmpagw0rwsl.pyomo.soln
Welcome to the CBC MILP Solver 
Version: 2.10.3 
Build Date: Mar 24 2020 

command line - cbc -seconds 3 -threads 8 -RandomCbcSeed 42 -RandomSeed 42 -timeMode elapsed -preprocess on -printingOptions all -import tmpagw0rwsl.pyomo.lp -mipstart tmp5f2geuyi.cbc.soln -stat=1 -primals -solve -solu tmpagw0rwsl.pyomo.soln (default strategy 1)
seconds was changed from 1e+100 to 3
threads was changed from 0 to 8
randomCbcSeed was changed from -1 to 42
randomSeed was changed from 1234567 to 42
Option for timeMode changed from cpu to elapsed
Option for preprocess changed from sos to on
Option for printingOptions changed from normal to all
opening mipstart file ./tmp5f2geuyi.cbc.soln.
MIPStart values read for 39 variables.
Presolve determined that the problem was infeasible with tolerance of 1e-08
Presolved model looks infeasible - will use unpresolved
Original problem has 946 integers (946 of which binary)
==== 947 zero objective 375 different
==== absolute objective values 375 different
==== for integers 946 zero objective 1 different
946 variables have objective of 0
==== for integers absolute objective values 1 different
946 variables have objective of 0
===== end objective counts


Problem has 1956 rows, 1772 columns (825 with objective) and 240706 elements
There are 1 singletons with no objective 
Column breakdown:
1 of type 0.0->inf, 0 of type 0.0->up, 0 of type lo->inf, 
363 of type lo->up, 11 of type free, 451 of type fixed, 
0 of type -inf->0.0, 0 of type -inf->up, 946 of type 0.0->1.0 
Row breakdown:
39 of type E 0.0, 40 of type E 1.0, 0 of type E -1.0, 
0 of type E other, 0 of type G 0.0, 0 of type G 1.0, 
491 of type G other, 0 of type L 0.0, 895 of type L 1.0, 
491 of type L other, 0 of type Range 0.0->1.0, 0 of type Range other, 
0 of type Free 
Presolve determined that the problem was infeasible with tolerance of 1e-08
Analysis indicates model infeasible or unbounded
0  Obj -90270.066 Primal inf 1891742.1 (552) Dual inf 7.5395451e+14 (1025)
End of values pass after 68 iterations
68  Obj -87682.09 Primal inf 1871171.5 (499) Dual inf 7.2627845e+14 (986) w.o. free dual inf (984)
End of values pass after 68 iterations
68  Obj -87682.09 Primal inf 1871171.5 (499) Dual inf 7.2627845e+14 (986) w.o. free dual inf (984)
End of values pass after 162 iterations
162  Obj -45241.297 Primal inf 1160942.8 (496) Dual inf 1.1752434e+16 (800) w.o. free dual inf (796)
End of values pass after 162 iterations
162  Obj -45241.297 Primal inf 1160942.8 (496) Dual inf 1.1752434e+16 (800) w.o. free dual inf (795)
End of values pass after 162 iterations
162  Obj -45241.297 Primal inf 1160942.8 (496) Dual inf 1.1752434e+16 (800) w.o. free dual inf (794)
End of values pass after 162 iterations
162  Obj -45241.297 Primal inf 1160942.8 (496) Dual inf 1.1752434e+16 (800) w.o. free dual inf (794)
End of values pass after 264 iterations
264  Obj -55054.637 Primal inf 1029373.6 (473) Dual inf 1.1769012e+16 (744) w.o. free dual inf (736)
End of values pass after 264 iterations
264  Obj -55054.637 Primal inf 1029373.6 (473) Dual inf 1.1769012e+16 (744) w.o. free dual inf (735)
End of values pass after 264 iterations
264  Obj -55054.637 Primal inf 1029373.6 (473) Dual inf 1.1769012e+16 (744) w.o. free dual inf (735)
End of values pass after 315 iterations
315  Obj -50459.216 Primal inf 972805.96 (459) Dual inf 1.1792754e+16 (718) w.o. free dual inf (708)
End of values pass after 329 iterations
329  Obj -50124.204 Primal inf 970827.33 (459) Dual inf 1.18081e+16 (712) w.o. free dual inf (701)
End of values pass after 334 iterations
334  Obj -50133.43 Primal inf 970212.02 (458) Dual inf 1.1783627e+16 (707) w.o. free dual inf (696)
511  Obj -41430.338 Primal inf 557154.22 (505) Dual inf 7.2296964e+15 (340)
643  Obj -34695.22 Primal inf 453754.47 (506) Dual inf 3.8111482e+10 (412)
761  Obj -34732.206 Primal inf 452070.53 (509) Dual inf 7.898278e+09 (410)
875  Obj -30932.552 Primal inf 445357.57 (568) Dual inf 1.7195077e+09 (327)
994  Obj -30825.833 Primal inf 441916.36 (575) Dual inf 2.0551153e+09 (310)
1114  Obj -30830.67 Primal inf 441499.74 (556) Dual inf 2.2306792e+09 (321)
1236  Obj -30857.143 Primal inf 440566.12 (548) Dual inf 2.9977e+09 (323)
1356  Obj -30733.234 Primal inf 439860.66 (574) Dual inf 9.9072873e+08 (222)
1470  Obj -30742.068 Primal inf 439803.09 (581) Dual inf 8.2099197e+08 (212)
1587  Obj -30737.017 Primal inf 439718.72 (555) Dual inf 52348872 (165)
1702  Obj -30749.444 Primal inf 439691.33 (543) Dual inf 5460414.6 (96)
1817  Obj -30745.528 Primal inf 439669.89 (551) Dual inf 14509862 (72)
1931  Obj -30729.478 Primal inf 439658.21 (537) Dual inf 4406770.9 (38)
1984  Obj -30720.868 Primal inf 439654.6 (532)
Primal infeasible - objective value -30720.868
PrimalInfeasible objective -30720.86826 - 1984 iterations time 0.252

Result - Linear relaxation infeasible

Enumerated nodes:           0
Total iterations:           0
Time (CPU seconds):         0.52
Time (Wallclock Seconds):   0.54

Problem is infeasible - 0.09 seconds
Total time (CPU seconds):       0.61   (Wallclock seconds):       0.63

blthayer avatar Mar 23 '22 23:03 blthayer