0

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

jan06
  • 79
  • 2
  • 9
  • Exactly what is it you would like to pass on? Data? MiniZinc code? Name of MiniZinc model? – hakank Nov 22 '15 at 18:36
  • Here is more details: I have a java program and want to incorporate the minizinc model which can be used to process some data(arrays) and return the result to my java program. Can I possibly call a minizinc model directly from the java program? If I can't- does it mean I have to run the minizinc model manually in order to process some data for my java program? – jan06 Nov 23 '15 at 17:51

1 Answers1

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.

Community
  • 1
  • 1
Kobbe
  • 809
  • 5
  • 16