eomahony / Numberjack

Python Combinatorial Optimisation Platform
http://numberjack.ucc.ie
GNU Lesser General Public License v2.1
157 stars 36 forks source link

Mistral2 crashes with higher verbosity #26

Open pthedinger opened 9 years ago

pthedinger commented 9 years ago

The following little test program crashes on my osx machine. It runs ok until I turn the verbosity up to 10, and then the crash report says:

Exception Type: EXC_ARITHMETIC (SIGFPE) Exception Codes: EXC_I386_DIV (divide by zero)

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 _Mistral2.so 0x0000000106171470 Mistral::SolverStatistics::print_short(std::ostream&) const + 224 1 _Mistral2.so 0x0000000106179913 Mistral::Solver::restart_search(int, bool) + 1715 2 _Mistral2.so 0x000000010610271a Mistral2Solver::solve() + 202 3 _Mistral2.so 0x00000001060f5214 _wrap_Mistral2Solver_solve(object, object) + 100 4 org.python.python 0x0000000105dd77c9 PyEval_EvalFrameEx + 14387 5 org.python.python 0x0000000105dda60e 0x105d50000 + 566798 6 org.python.python 0x0000000105dd73e3 PyEval_EvalFrameEx + 13389 7 org.python.python 0x0000000105dda60e 0x105d50000 + 566798 8 org.python.python 0x0000000105dd73e3 PyEval_EvalFrameEx + 13389 9 org.python.python 0x0000000105dd3d62 PyEval_EvalCodeEx + 1413 10 org.python.python 0x0000000105dd37d7 PyEval_EvalCode + 54 11 org.python.python 0x0000000105df37bd 0x105d50000 + 669629 12 org.python.python 0x0000000105df3860 PyRun_FileExFlags + 133 13 org.python.python 0x0000000105df33fd PyRun_SimpleFileExFlags + 769 14 org.python.python 0x0000000105e04b23 Py_Main + 3051 15 libdyld.dylib 0x00007fff89cd75c9 start + 1


I have tried this with the 1.1.4 tag and the latest version of Mistral2 on the master branch.


import Numberjack

N = 100 name = "i"

variables = {} variables[name] = Numberjack.Variable(N, name)

varArray = Numberjack.VarArray([variables[name]])

model = Numberjack.Model(Numberjack.Minimise(Numberjack.Max(varArray))) model = Numberjack.Model() solver = model.load("Mistral2") solver.setVerbosity(10) solved = solver.solve()

print "{}".format(variables[name].get_value())

9thbit commented 9 years ago

Hi @pthedinger, thanks very much for the bug report, there is a few in here for us to tackle.

One thing about your example is that there is a second instantiation of Model so you're really just passing in an empty model to the solver. There is a bug here though with the high verbosity when printing an empty model, I've passed this bug along to the developers of Mistral.

Another thing is that you're creating a Max expression over just one variable which Mistral2 did not like. We should rewrite this expression at the Numberjack level to be just the single variable before loading it to the solver. We'll fix this. Thanks again for the report, let us know if you encounter anything else.