3

I have a question concerning the communication of two Java programs, one embeds the other.

The embedded one is a CPLEX linear program (Java SE + CPLEX libs) which calculates resources and the other root application is a simulation software (AnyLogic). Now the idea is that the simulation should use the resources calculated by the linear program.

I now want the simulation to call the linear program, which then calculates the resources and hands them back as an array or object, then the simulation continues.

Simulation (AnyLogic) ----> Linear Program (CPLEX)
             <--------(VALUES?)--------|

My problem is the "hand over", return values (args) seam not enough. How can I do this?

At the moment I use a text file which stores the values. I read about RMI and sockets but don't know if this is such a good idea.

Any help is appreciated! Thank you.

4

1 回答 1

1

一种方法是使用 Java 启动 CPLEX 程序Process这个问题的第一个答案详细说明了如何从已启动的项目中获取反馈Process(以及如何启动它)。具体来说,它展示了如何启动Process打印其输出的 a,该输出随后由启动程序读取。我想您的 CPLEX 程序可以打印出任何相关结果,然后您的 AnyLogic 仿真可以通过所描述的机制获取这些结果。

于 2014-10-20T15:51:42.507 回答