1

Other than generating an output file then using wc -l output.txt and -1 divide by 2 and head -50 the output.txt, is there any easy way to auto count no of solution inside minizinc and print the first 50 solution? My program run for 12 hour in one scenario and the other one expected to run 2 days!

Also, any way in batch mode (not ide) to generate resources usage other than using time minizinc ...

Thanks for advice

Dennis Ng
  • 361
  • 3
  • 11
  • You will need a third part program to do that. Preferably something that can read a stream (stdout) and count some symbol and once 50 is reached, abort the program. I am not sure a command line program can do that and you might need a script in some real programming language. – Kobbe Mar 29 '16 at 05:40
  • Cannot abort as still have to count the number of solutions. Just to avoid generating 2 GB+ log file out (it is a + as the simple model require 12 hours+ to finish and I think never wait long enough. I only knew the solution to the challenge take only 1.5 minutes to do using Node.js). Try not to give up but ... – Dennis Ng Mar 30 '16 at 13:07
  • But MiniZinc prints the solutions to stdout when it finds them. Start MiniZinc in command line mode with http://stackoverflow.com/questions/2804543/read-subprocess-stdout-line-by-line and read the output in real time. Once you find your 50 solutions, kill the subprocess. – Kobbe Mar 31 '16 at 05:28

1 Answers1

1

The command line program "minizinc" as well as most FlatZinc solvers supports the parameter "-n " which is the number of solutions to show. The MiniZinc IDE has the option "Stop after this many solutions:".

Note that this is relevant for satisfaction problems. For optimization problems, however, there is no consensus how different solvers handle "-n".

hakank
  • 6,629
  • 1
  • 17
  • 27