Originally posted by: SystemAdmin
[spleen said:]
I have one simple scheduling model and I can now solve it efficiently. Now I would like to read the optimized interval value in the java interface function.
I had done everything ok and the solution can be printed by
opl.printSolution(System.out);
However, one thing is quite difficult, at least for me.
I defined a few decision variables like
dvar boolean X[range1][range2];
dvar interval Work [f in range1] [v in range2] optional size List[f].workingTime ;
dvar interval Workspan [f in range1];
I have full read access to the decision variable X in the java project, yet I can not readout the Work array directly. I looked up in the java reference and found that there does exist a IloIntMap interface, yet does not exist a IloIntervalMap. I use the IloIntervalVarMap instead and it only reads out the interval variables instead of the decision values of those variables. Could you kindly tell me how to access that? Thanks in advance.
Here is the code:
IloIntervalVarMap Work = opl.getElement("Work").asIntervalVarMap();
IloIntMap X = opl.getElement("X").asIntMap();
ilog.concert.IloIntRange s1 = opl.getElement("range1").asIntRange();
ilog.concert.IloIntRange s2 = opl.getElement("range2").asIntRange();
// Iterate on the first indexer.
for (int i = 1; i <= s1.getSize(); i++ ){<br /> // Get the second dimension array from the first dimension.
IloIntervalVarMap sub = Work.getSub(i);
IloIntMap subx = X.getSub(i);
System.out.print(i);
// Iterate on the second indexer of x (that is the indexer of the subarray).
for (int j = 1; j<= s2.getSize(); j++){<br /> IloIntervalVar oneTrip = sub.get(j);
int bl = subx.get(j);
int start1 = oneTrip.getStartMax();
int end2 = oneTrip.getEndMax();
System.out.print(" bool = ");
System.out.print(bl);
System.out.print(" start1 = ");
System.out.print(start1);
System.out.print(oneTrip);
System.out.print("\n");
if(oneTrip.isPresent()){
int start = oneTrip.getStartMax();
int end = oneTrip.getEndMax();
System.out.print(start);
System.out.print(end);
}
}
}
#DecisionOptimization#OPLusingCPLEXOptimizer