I'm still a bit puzzled about the JSON output. In my optimization problem, I run into a time-out, so to get the best solution I need to use the
option, I think. This means that all intermediate solutions are printed as well. I'm ok with that, but now I have to read all these solutions together, as I use a file based interface. I want to parse the result as an JSONArray, with each solution found as a JSONObject structure describing the results. So I'm using the flags
--output-mode json --solution-separator "" error-msg "]" --time-limit 60000 --solution-comma "," --unsat-msg "]" --unbounded-msg "]" --search-complete-msg "]" --no-output-comments
This works, but the resulting output is missing the starting "[" , which is a bit weird. Is there a way of adding this by minizinc, so that the result file is valid JSON? Alternatively can I get only the best solution within a time-out, skipping all intermediate solutions?
Also, using
--output-time
does not work in this setting, it is printed as a comment "% ..." which is not supported by JSON. As a feature request, it would be nice if it was added to the JSONObject as an extra field, like the "_objective" field added by
--output-objective.
which I don't use, as the objective already is a decision variable in my model.
The complete command line I currently use (with different solvers and timeout values) is
minizinc --output-mode json --no-output-comments --output-time --solver Chuffed --solution-separator "" --solution-comma "," --error-msg "]" --unsat-msg "]" --unbounded-msg "]" --search-complete-msg "]" --output-objective -a --time-limit 30000 -o result.json program.mzn
I hope this is not too much information, but it might serve as an (bad) example.