Description
In my project I use Minizinc to solve an optimization/scheduling problem. I run tests to test my integration with Minizinc and that my model produces correct solutions.
The tests break somewhere between 2.4.3 and HEAD. I tried running minizinc simple-planning.mzn input.dzn --solver gecode
with the attached files. Here's what minizinc --help
says about available solvers:
Available solvers (get help using --help <solver id>):
Gecode 6.2.0 (org.gecode.gecode, cp, int, float, set, restart)
Gecode Gist 6.2.0 (org.gecode.gist, cp, int, float, set, restart)
OK on Minizinc 2.4.3
On Minizinc 2.4.3, I get an OK output on my test:
stock = array2d(0..2, Ingredients, [2, 2, 1, 2, 1, 1]);
recipe_cooked = array1d(0..1, [R2_Raw_apple, R0_Raw_egg]);
recipe_cooked_idx = array1d(0..1, [3, 1]);
products_bought = array2d(0..1, Products, []);
products_bought_overall = array1d(Products, []);
used_directly = array2d(0..1, Ingredients, [1, 0, 0, 1]);
as_used_by_recipe = array2d(0..1, Ingredients, [1, 0, 0, 1]);
as_thrown_in = array2d(0..1, Ingredients, [1, 0, 0, 1]);
using_diet_bit = array2d(0..1, DietBits, [false, false, false, false, false, false, false, false, false, false]);
obtain_externally = array1d(Ingredients, [0, 0]);
total_ingredient_use = array1d(Ingredients, [1, 1]);
recipe_ever_cooked = array1d(Recipes, [true, false, true]);
generalization_to_from = array3d(0..1, Ingredients, Ingredients, [0, 0, 0, 0, 0, 0, 0, 0]);
total_products_bought = 0;
----------
==========
Failure in HEAD
I just uninstalled the Minizinc package on my system (Pop!_OS 20.10 if relevant), installed libgecode-dev
, updated my clone of libminizinc to commit e385f96, and used cmake . && make
, then sudo make install
.
$ minizinc --version
MiniZinc to FlatZinc converter, version 2.5.3
I passed this json-config.msc
:
{
"id": "org.gecode.gecode",
"name": "Gecode",
"description": "Gecode FlatZinc executable",
"version": "6.2.0",
"mznlib": "/usr/share/minizinc/gecode",
"executable": "/usr/bin/fzn-gecode",
"tags": ["cp", "int", "float", "set", "restart"],
"stdFlags": ["-a", "-f", "-n", "-p", "-r", "-s", "-t"],
"supportsMzn": false,
"supportsFzn": true,
"needsSolns2Out": true,
"needsMznExecutable": false,
"needsStdlibDir": false,
"isGUIApplication": false
}
And I run: minizinc simple-planning.mzn input.dzn --solver json-config.msc --stdlib-dir /usr/local/share/minizinc
and get a segmentation fault:
[1] 2698470 segmentation fault (core dumped) minizinc simple-planning.mzn input.dzn --solver json-config.msc --stdlib-dir
I didn't yet build minizinc with debug symbol, but I get this backtrace from gdb:
#0 0x000055555579d81f in MiniZinc::create_enum_mapper(MiniZinc::EnvI&, MiniZinc::Model*, unsigned int, MiniZinc::VarDecl*, MiniZinc::Model*) ()
#1 0x00005555557b229e in MiniZinc::typecheck(MiniZinc::Env&, MiniZinc::Model*, std::vector<MiniZinc::TypeError, std::allocator<MiniZinc::TypeError> >&, bool, bool, bool) ()
#2 0x000055555576b936 in MiniZinc::CompilePass::run(MiniZinc::Env*, std::ostream&) ()
#3 0x0000555555707493 in MiniZinc::Flattener::multiPassFlatten(std::vector<std::unique_ptr<MiniZinc::Pass, std::default_delete<MiniZinc::Pass> >, std::allocator<std::unique_ptr<MiniZinc::Pass, std::default_delete<MiniZinc::Pass> > > > const&) ()
#4 0x000055555570cfc5 in MiniZinc::Flattener::flatten(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
#5 0x00005555555caebd in MiniZinc::MznSolver::run(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
#6 0x00005555555bc79d in main ()
I faintly remember that there were some changes in Minizinc related to enums between 2.4.3 and now, so maybe they might have some bug in them.