coin-or / Cbc

COIN-OR Branch-and-Cut solver
Other
798 stars 115 forks source link

std::bad_array_new_length in CbcHeuristicDINS::solution #495

Open IlyaShaternik opened 2 years ago

IlyaShaternik commented 2 years ago

Hi, I'm getting std::bad_array_new_length exception when running Coin-or CBC with following parameters:

Coin:preT 1e-04
preTolerance was changed from 1e-08 to 0.0001
Coin:dualT 1e-04
dualTolerance was changed from 1e-07 to 0.0001
Coin:primalT 1e-04
primalTolerance was changed from 1e-07 to 0.0001
Coin:integerT 1e-04
integerTolerance was changed from 1e-07 to 0.0001
Coin:maxSaved 10
maxSavedSolutions was changed from 0 to 10
Coin:RENS on
Option for Rens changed from off to on
Coin:DINS on
Option for Dins changed from off to on
Coin:Local on
Option for localTreeSearch changed from off to on

I've build CBC with the following set of commands:

wget https://raw.githubusercontent.com/coin-or/coinbrew/master/coinbrew
chmod u+x coinbrew
./coinbrew fetch Cbc@2.10
./coinbrew build Cbc --parallel-jobs 4 --tests all --build-dir ./../build -p

I've build it on Windows with MSYS2 MinGW64 and also on WSL. Behavior is consistent between both systems. The backtrace from gdb:

(gdb) bt
#0  0x00007ffff7e87672 in __cxa_throw () from /lib/x86_64-linux-gnu/libstdc++.so.6
#1  0x00007ffff7e7b3e6 in __cxa_throw_bad_array_new_length () from /lib/x86_64-linux-gnu/libstdc++.so.6
#2  0x000055555566e890 in CbcHeuristicDINS::solution (this=0x5555b6958120, solutionValue=@0x7fffffff32f0: 38301614.03998924, betterSolution=0x5555bda26a00)
    at /home/user/work/CBC/stable/source/Cbc/Cbc/src/CbcHeuristicDINS.cpp:225
#3  0x00005555556e9c15 in CbcModel::doHeuristicsAtRoot (this=0x555596bb2770, deleteHeuristicsAfterwards=0) at /home/user/work/CBC/stable/source/Cbc/Cbc/src/CbcModel.cpp:15701
#4  0x00005555556b8993 in CbcModel::branchAndBound (this=0x555596bb2770, doStatistics=0) at /home/user/work/CBC/stable/source/Cbc/Cbc/src/CbcModel.cpp:2814
#5  0x000055555572d975 in CbcTreeLocal::empty (this=0x555565735a40) at /home/user/work/CBC/stable/source/Cbc/Cbc/src/CbcTreeLocal.cpp:527
#6  0x00005555556be88a in CbcModel::branchAndBound (this=0x555560914ab0, doStatistics=0) at /home/user/work/CBC/stable/source/Cbc/Cbc/src/CbcModel.cpp:4399
#7  0x00005555555a2360 in CbcMain1 (argc=1, argv=0x7fffffffe368, model=..., callBack=0x55555558041d <dummyCallBack(CbcModel*, int)>, parameterData=...)
    at /home/user/work/CBC/stable/source/Cbc/Cbc/src/CbcSolver.cpp:7290
#8  0x00005555555804fa in main (argc=1, argv=0x7fffffffe368) at /home/user/work/CBC/stable/source/Cbc/Cbc/src/CoinSolve.cpp:354

I've attached .mps file I used but it takes a lot of time to get to the point of exception, maybe around an hour. Also exception occurs after 2000 nodes in CbcTreeLocal, which is a node limit. problem.zip

jjhforrest commented 2 years ago

I am not very familiar with the DINS heuristic, but debugging I find that the heuristic is entered with a solution - but the solution had been found outside that CbcModel.  This meant that "bestSolution" pointed to a valid solution but the solution count was 0.

This meant that the code did not set up all the data and so "numberIntegers_" was still at -1 - and

      double *element = new double[numberIntegers_];

was not a good idea.

I will try and find out more, but changing line 164 of CbcHeuristicDins.cpp

from   if (!bestSolution)

to

  if (!bestSolution || !model_->getSolutionCount())

should fix problem.

John Forrest

On 25/04/2022 01:54, IlyaShaternik wrote:

Hi, I'm getting std::bad_array_new_length exception when running Coin-or CBC with following parameters:

|Coin:preT 1e-04 preTolerance was changed from 1e-08 to 0.0001 Coin:dualT 1e-04 dualTolerance was changed from 1e-07 to 0.0001 Coin:primalT 1e-04 primalTolerance was changed from 1e-07 to 0.0001 Coin:integerT 1e-04 integerTolerance was changed from 1e-07 to 0.0001 Coin:maxSaved 10 maxSavedSolutions was changed from 0 to 10 Coin:RENS on Option for Rens changed from off to on Coin:DINS on Option for Dins changed from off to on Coin:Local on Option for localTreeSearch changed from off to on |

I've build CBC with the following set of commands:

|wget https://raw.githubusercontent.com/coin-or/coinbrew/master/coinbrew chmod u+x coinbrew ./coinbrew fetch @.*** ./coinbrew build Cbc --parallel-jobs 4 --tests all --build-dir ./../build -p |

I've build it on Windows with MSYS2 MinGW64 and also on WSL. Behavior is consistent between both systems. The backtrace from gdb:

|(gdb) bt #0 0x00007ffff7e87672 in cxa_throw () from /lib/x86_64-linux-gnu/libstdc++.so.6 #1 0x00007ffff7e7b3e6 in cxa_throw_bad_array_new_length () from /lib/x86_64-linux-gnu/libstdc++.so.6 #2 0x000055555566e890 in CbcHeuristicDINS::solution (this=0x5555b6958120, @.***: 38301614.03998924, betterSolution=0x5555bda26a00) at /home/user/work/CBC/stable/source/Cbc/Cbc/src/CbcHeuristicDINS.cpp:225

3 0x00005555556e9c15 in CbcModel::doHeuristicsAtRoot

(this=0x555596bb2770, deleteHeuristicsAfterwards=0) at /home/user/work/CBC/stable/source/Cbc/Cbc/src/CbcModel.cpp:15701 #4 0x00005555556b8993 in CbcModel::branchAndBound (this=0x555596bb2770, doStatistics=0) at /home/user/work/CBC/stable/source/Cbc/Cbc/src/CbcModel.cpp:2814 #5 0x000055555572d975 in CbcTreeLocal::empty (this=0x555565735a40) at /home/user/work/CBC/stable/source/Cbc/Cbc/src/CbcTreeLocal.cpp:527 #6 0x00005555556be88a in CbcModel::branchAndBound (this=0x555560914ab0, doStatistics=0) at /home/user/work/CBC/stable/source/Cbc/Cbc/src/CbcModel.cpp:4399 #7 0x00005555555a2360 in CbcMain1 (argc=1, argv=0x7fffffffe368, model=..., callBack=0x55555558041d <dummyCallBack(CbcModel*, int)>, parameterData=...) at /home/user/work/CBC/stable/source/Cbc/Cbc/src/CbcSolver.cpp:7290 #8 0x00005555555804fa in main (argc=1, argv=0x7fffffffe368) at /home/user/work/CBC/stable/source/Cbc/Cbc/src/CoinSolve.cpp:354 |

I've attached .mps file I used but it takes a lot of time to get to the point of exception, maybe around an hour. Also exception occurs after 2000 nodes in CbcTreeLocal, which is a node limit. problem.zip https://github.com/coin-or/Cbc/files/8550814/problem.zip

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