Call Minizinc model from Java

老子叫甜甜 提交于 2019-12-13 07:38:23

问题


How to call a Minizinc model from a Java program with arrays as passed-on parameters? Is there any special command for doing this?


回答1:


I frequently do the same but in python. There is probably not any module or extension that can integrate the call in any convenient way but it is quite easy to just call another program.

Since I have not tried it in Java, I will let another stack overflow post guide you: Execute external program in java.

You can pass the parameters either as -D "var_int_name=10;var_int_array=[1,2,3];" or you can supply a data file as the last argument in the call to MiniZinc.

A general tip is to make the output from your MiniZinc model very easy to recognise and parse since many solvers print extra stuff and not just the solution. For example does MiniZinc itself print ---------- between solution. Surround the answer with & or any other sign that is easy to find and parse by a computer. You might also want to verify that you indeed got a solution back.



来源:https://stackoverflow.com/questions/33815339/call-minizinc-model-from-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!