MiniZinc / minizinc-python

Access to all MiniZinc functionality directly from Python
https://python.minizinc.dev
Mozilla Public License 2.0
149 stars 22 forks source link

gecode solver doesn't appear to work out of the box for MiniZinc 2.8.7 on Windows x64 #174

Open DavidPratten opened 2 weeks ago

DavidPratten commented 2 weeks ago

Just installed both minizinc module for python 3.12 and MiniZincIDE-2.8.7-bundled-setup-win64.exe and while chuffed works, gecode doesn't appear to be available.

Any tips on how to get gecode going?

Below the error messages, there is some solver metadata output by minizinc.

Here is chuffed working fine

import minizinc
model = minizinc.Model()
model.add_string("""
var -100..100: x;
constraint x=2;
solve satisfy;
""")
this_solver = minizinc.Solver.lookup("chuffed") # ("gecode")
inst = minizinc.Instance(this_solver, model)
try:
    result = inst.solve(verbose=True)
    if result.status == minizinc.Status.SATISFIED or result.status == minizinc.Status.OPTIMAL_SOLUTION:
        print("Solution found:")
        print("x =", result["x"])
    else:
        print("No solution found. Status:", result.status)
except Exception as e:
    print("An error did occur:", str(e))

result:

Solution found:
x = 2

But when I replace line 8 with this

this_solver = minizinc.Solver.lookup("gecode")

I get the following:

An error did occur: MiniZinc to FlatZinc converter, version 2.8.7, build 1478320236
Copyright (C) 2014-2024 Monash University, NICTA, Data61
Parsing file(s) ...\AppData\Local\Temp\mzn_fragmentrl99scs6.mzn' ...
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\stdlib.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\stdlib\stdlib_internal.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\output.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\output\array2d_bool.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\output\gantt.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\stdlib\stdlib_random.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\stdlib\stdlib_debug.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\stdlib\stdlib_reflect.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\stdlib\stdlib_ite.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\stdlib\stdlib_language.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\stdlib\stdlib_sort.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\stdlib\stdlib_opt.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\stdlib\stdlib_ann.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\stdlib\stdlib_enum.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\stdlib\stdlib_string.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\stdlib\stdlib_set.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\stdlib\stdlib_logic.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\stdlib\stdlib_array.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\stdlib\stdlib_coercion.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\stdlib\stdlib_math.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\stdlib\stdlib_compare.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\flatzinc_builtins.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\solver_redefinitions.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\table.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_table_int_opt.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\gecode\fzn_table_int_reif.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\gecode\fzn_table_int.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\gecode\fzn_table_bool_reif.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\gecode\fzn_table_bool.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_array_set_intersect.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_array_set_union.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_array_opt_int_union.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_array_int_union.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\lex_lesseq.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_lex_lesseq_set_reif.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_lex_lesseq_set.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_lex_lesseq_int_reif.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\gecode\fzn_lex_lesseq_int.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_lex_lesseq_float_reif.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_lex_lesseq_float.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_lex_lesseq_bool_reif.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\gecode\fzn_lex_lesseq_bool.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\lex_less.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_lex_less_set_reif.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_lex_less_set.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_lex_less_int_reif.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\gecode\fzn_lex_less_int.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_lex_less_float_reif.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_lex_less_float.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_lex_less_bool_reif.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\gecode\fzn_lex_less_bool.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_if_then_else_partiality.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_if_then_else_var_set.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_if_then_else_set.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_if_then_else_var_opt_float.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_if_then_else_var_float.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_if_then_else_opt_float.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_if_then_else_float.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_if_then_else_var_opt_bool.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_if_then_else_var_bool.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_if_then_else_opt_bool.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_if_then_else_bool.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_if_then_else_var_opt_int.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_if_then_else_var_int.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_if_then_else_opt_int.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_if_then_else_int.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\count_fn.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\count_lt.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_count_lt_par_reif.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_count_lt_reif.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_count_lt_par.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_count_lt.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\count_gt.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_count_gt_reif.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_count_gt_par_reif.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_count_gt.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_count_gt_par.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\count_neq.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_count_neq_reif.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_count_neq_par_reif.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_count_neq.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_count_neq_par.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\count_leq.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_count_leq_reif.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_count_leq_par_reif.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_count_leq.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_count_leq_par.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\count_geq.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_count_geq_reif.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_count_geq_par_reif.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_count_geq.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_count_geq_par.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\count_eq.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_count_eq_par_reif.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\gecode\fzn_count_eq_reif.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\fzn_count_eq_par.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\gecode\fzn_count_eq.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\redefinitions-2.7.1.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\gecode\redefinitions-2.5.2.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\redefinitions-2.3.3.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\gecode\redefinitions-2.2.1.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\redefinitions-2.1.1.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\std\redefinitions-2.1.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\gecode\redefinitions-2.0.2.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\gecode\redefinitions-2.0.mzn'
processing file 'c:\Program Files\MiniZinc\share\minizinc\gecode\redefinitions.mzn'
processing file '...\AppData\Local\Temp\mzn_fragmentrl99scs6.mzn'
 done parsing (0.02 s)
Flattening ...
    CompilePass: Flatten with 'c:\Program Files\MiniZinc\share\minizinc\gecode' library ...
MIP domains ...
 done (0.02 s)
Optimizing ... done (0.02 s)
Converting to old FlatZinc ... done (0.02 s)
 done (0.02 s)
 done (0.04 s), max stack depth 5
Maximum memory 4 Mbytes.
      % SOLVING PHASE
FZN solver plugin, compiled  Oct  2 2024  18:19:46
Using FZN solver c:\Program Files\MiniZinc\bin\fzn-gecode.EXE for solving, parameters: -s 
   Done (overall time 0.06 s).

Diagnostics

versions

import minizinc
print("MiniZinc Python library version:", minizinc.__version__)
print("MiniZinc CLI version:", minizinc.default_driver._version)

reports

MiniZinc Python library version: 0.9.0
MiniZinc CLI version: (2, 8, 7)

solver metadata

from minizinc import Solver
print(Solver.lookup("gecode"))
print()
print(Solver.lookup("chuffed"))

reports

Solver(name='Gecode', version='6.3.0', id='org.gecode.gecode', executable='../../../bin/fzn-gecode', mznlib='../gecode', mznlibVersion=1, description='Gecode FlatZinc executable', tags=['cp', 'int', 'float', 'set', 'restart', 'org.gecode.gecode', 'gecode'], stdFlags=['-a', '-f', '-n', '-p', '-r', '-s', '-t', '--cp-profiler'], extraFlags=[['--c-d', 'Recomputation commit distance', 'int', '8'], ['--a-d', 'Recomputation adaption distance', 'int', '2'], ['--decay', 'Decay factor', 'float', '0.99'], ['--node', 'Node cutoff', 'int', '0'], ['--fail', 'Failure cutoff', 'int', '0'], ['--restart', 'Restart sequence type', 'opt:none:constant:linear:luby:geometric', 'none'], ['--restart-base', 'Base for geometric restart sequence', 'float', '1.5'], ['--restart-scale', 'Scale factor for restart sequence', 'int', '250'], ['--restart-limit', 'Restart cutoff', 'int', '0'], ['--nogoods', 'Use no-goods from restarts', 'bool', 'false'], ['--nogoods-limit', 'Depth limit for no-good extraction', 'int', '128']], requiredFlags=[], inputType='FZN', supportsMzn=False, supportsFzn=True, supportsNL=False, needsSolns2Out=True, needsMznExecutable=False, needsStdlibDir=False, needsPathsFile=False, isGUIApplication=False, _identifier='org.gecode.gecode@6.3.0')

Solver(name='Chuffed', version='0.13.2', id='org.chuffed.chuffed', executable='../../../bin/fzn-chuffed', mznlib='../chuffed', mznlibVersion=1, description='Chuffed FlatZinc executable', tags=['cp', 'lcg', 'int', 'org.chuffed.chuffed', 'chuffed'], stdFlags=['-a', '-f', '-n', '-r', '-s', '-t', '-v', '--cp-profiler'], extraFlags=[['--prop-fifo', 'Use FIFO queues for propagation', 'bool', 'false'], ['--vsids', 'Use activity-based search on the Boolean variables', 'bool', 'false'], ['--toggle-vsids', 'Alternate search between user-specified and activity-based one', 'bool', 'false'], ['--restart', 'Restart sequence type', 'opt:chuffed:none:constant:linear:luby:geometric', 'chuffed'], ['--restart-base', 'Base for geometric restart sequence', 'float', '1.5'], ['--restart-scale', 'Scale factor for restart sequence', 'int', '1000000000'], ['--switch-to-vsids-after', 'Search starts with the user-specified one and switches to the activity-based one after a specified number of conflicts', 'int', '1000000000'], ['--branch-random', 'Use random variable selection for tie breaking instead of input order', 'bool', 'false'], ['--sat-polarity', 'Selection of the polarity of Boolean variables (0 = default, 1 = same, 2 = anti, 3 = random)', 'int', '0'], ['--lazy', 'Allow clause generation for domain update', 'bool:on:off', 'true'], ['--finesse', 'Try to generated stronger clauses', 'bool:on:off', 'true'], ['--learn', 'Compute nogoods when a conflict is encountered', 'bool:on:off', 'true'], ['--eager-limit', 'The maximal domain size of eager integer variables', 'int', '1000'], ['--sat-var-limit', 'The maximal number of Boolean variables', 'int', '2000000'], ['--n-of-learnts', 'The maximal number of learnt clauses', 'int', '100000'], ['--learnts-mlimit', 'The maximal memory limit for learnt clauses in Bytes', 'int', '500000000'], ['--sort-learnt-level', 'Sort literals in a learnt clause based on their decision level', 'bool', 'false'], ['--one-watch', 'Watch only one literal in a learn clause', 'bool:on:off', 'true'], ['--bin-clause-opt', 'Optimise learnt clauses of length 2', 'bool:on:off', 'true'], ['--assump-int', 'Try and convert assumptions from the assumption interface back to integer domain expressions', 'bool:on:off', 'false'], ['--introduced-heuristic', 'Decide if variable is introduced based on its name', 'bool', 'false'], ['--use-var-is-introduced', 'Decide if variable is introduced based on var_is_introduced annotation', 'bool', 'false'], ['--exclude-introduced', 'Exclude introduced variables from learnt clauses', 'bool', 'false'], ['--decide-introduced', 'Allow search decisions on introduced variables and their derived internal variables', 'bool:on:off', 'true'], ['--fd-simplify', 'Remove FD propagators that are satisfied globally', 'bool:on:off', 'true'], ['--sat-simplify', 'Remove of clauses that are satisfied globally', 'bool:on:off', 'true'], ['--cumu-global', 'Use the global cumulative propagator if possible', 'bool:on:off', 'true'], ['--disj-edge-find', 'Use the edge-finding propagator for disjunctive constraints', 'bool:on:off', 'true'], ['--disj-set-bp', 'Use the set bounds propagator for disjunctive constraints', 'bool:on:off', 'true'], ['--mdd', 'Use the MDD propagator if possible', 'bool', 'false'], ['--mip', 'Use the MIP propagator if possible', 'bool', 'false'], ['--mip-branch', 'Use MIP branching as the branching strategy', 'bool', 'false'], ['--sym-static', 'Use static symmetry breaking constraints', 'bool', 'false'], ['--ldsb', "Use lightweight dynamic symmetry breaking constraints '1UIP crippled'", 'bool', 'false'], ['--ldsbta', "Use lightweight dynamic symmetry breaking constraints '1UIP'", 'bool', 'false'], ['--ldsbad', "Use lightweight dynamic symmetry breaking constraints 'all decision clause'", 'bool', 'false'], ['--sbps', 'Use Solution-based phase saving (SBPS) value selection heuristic', 'bool', 'false']], requiredFlags=[], inputType='FZN', supportsMzn=False, supportsFzn=True, supportsNL=False, needsSolns2Out=True, needsMznExecutable=False, needsStdlibDir=False, needsPathsFile=False, isGUIApplication=False, _identifier='org.chuffed.chuffed@0.13.2')
Dekker1 commented 2 weeks ago

@cyderize Would you have time to have a look? I'm not sure what has changed in the last releases. It seems to work on my machine. Could this be a Windows issue?

DavidPratten commented 2 weeks ago

@cyderize Would you have time to have a look? I'm not sure what has changed in the last releases. It seems to work on my machine. Could this be a Windows issue?

I'm happy to run further diagnostic code if that assists

David

cyderize commented 2 weeks ago

Hmm, it seems to work for me on my Windows machine with the same versions of everything.

@DavidPratten Does Gecode work from the MiniZincIDE?

DavidPratten commented 2 weeks ago

Hi

Yes gecode does work from the IDE.

All the best,

David Pratten