本文介绍了从Java调用Minizinc模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从带有数组作为传递参数的Java程序中调用Minizinc模型?有什么特殊的命令吗?

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

推荐答案

我经常在python中做同样的事情.可能没有任何模块或扩展可以通过任何方便的方式集成该调用,但是仅调用另一个程序就很容易.

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.

由于我没有用Java尝试过,因此我将让另一个堆栈溢出文章指导您:在Java中执行外部程序.

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

您可以将参数作为-D "var_int_name=10;var_int_array=[1,2,3];"传递,也可以提供数据文件作为对MiniZinc的调用中的最后一个参数.

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.

一个一般性的技巧是使您的MiniZinc模型的输出非常容易识别和解析,因为许多求解程序不仅打印解决方案,而且还会打印更多内容.例如,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.

这篇关于从Java调用Minizinc模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 14:39