Originally posted by: SystemAdmin
I would suggest you to go through the Iterators.java example (located in the <CPLEX_StudioXXX>\opl\examples\opl_interfaces\java\iterators\src\iterators directory). It has a method called 'sample2' which talks about retrieving values of a 2D variable called "x" indexed over "s1" and "s2". You will need to extend this idea to retrieve the values of your 3D "var" variable. Here's a code snippet from the sample:
IloOplFactory oplF =
new IloOplFactory(); IloOplRunConfiguration rc = oplF.createOplRunConfiguration(DATADIR +
"/iterators.mod"); IloOplModel opl = rc.getOplModel(); opl.generate();
// Get the x, s1 and s2 elements from the OplModel. IloIntMap x = opl.getElement(
"x").asIntMap(); IloSymbolSet s1 = opl.getElement(
"s1").asSymbolSet(); IloSymbolSet s2 = opl.getElement(
"s2").asSymbolSet();
// Iterate on the first indexer.
for (java.util.Iterator it1 = s1.iterator(); it1.hasNext();)
{ String sub1 = (String) it1.next();
// Get the 2nd dimension array from the 1st dimension. IloIntMap sub = x.getSub(sub1);
// Iterate on the second indexer of x (that is the indexer of the
// sub array).
for (java.util.Iterator it2 = s2.iterator(); it2.hasNext();)
{ String sub2 = (String) it2.next();
// We are in the last dimension of the array, so we can directly
// use the get method. System.out.println(sub1 +
" " + sub2 +
" " + sub.get(sub2));
}
}
Ofcourse, in your case, you should retrieve the values after the 'solve' call.
#CPLEXOptimizers#DecisionOptimization