Search code examples
minizinc

How to write intermediate solutions as output in Minizic comand line?


I have been running Minizinc models from the command line, and I get final solutions as output. I know I can make Minizic print intermedite solutions in the IDE. How can I make the same from the command line, so that they are printed as output like in the IDE? Btw, I'm refering to the output Minizinc prints by default, not to the 'output' (the one that acts like print) that you can include in the code of the model.


Solution

  • To output intermediate solutions you can use the -a flag on optimisation problems. So for example minizinc --solver gecode -a model.mzn data.dzn will solve model.mzn with data.dzn on the Gecode solver and output all intermediate solutions.

    Note, however, that the -a flag has has a few peculiarities:

    • -a for satisfiability will output all solutions instead of intermediate solutions. So while scripting you need to be careful.
    • Not all solvers support the -a flag. Not all solver will have (or output) intermediate solution.