简体   繁体   中英

How to save opl.postProcess(); output to an 2D array in Java

I'm using CP Optimizer from ILOG CPLEX Studio to run an optimization problem. Specifically, I'm running an OPL code in Java using Eclipse IDE. My code is working and I'm getting for an instance the following output:

在此处输入图像描述

Where "Fitness" is the value of the objective function and the next 100 numbers are a feasible solution for the problem. I want to save the numbers in the red box in a 2D array of integers (of dimension 10 rows x 10 columns) for being utilized for continuing the search with a local search method. The solution is displayed when I call: opl.postProcess(); in my Java code. Here is an extraction of my code:

            if (cp.solve()) {
            System.out.println("Fitness: " + opl.getCP().getObjValue());
            opl.postProcess();
            }

There exist an alternative for saving that information in a 2D array of integers?

You could have a look at the example CPLEX_Studio1210\opl\examples\opl_interfaces\java\iterators\src\iterators that shows you how to get back in java the values that you have in OPL.

Another way is to go through a file and use IloOplOutputFile in your postProcess in order ro save your array in a text file or csv file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM