Ok I've spent the last 2 hours trying to make this work but I've run out of ideas.
I have developed an OPL model just like the examples shipped with ILOG. What I'm doing is that I load the dataset + the model through a C++ interface program and what I want in the end is to post process the solution save it to files send it to other solvers etc.
The model works perfectly fine, the solution is printed perfectly find using opl.printSolution()
. However, when I'm trying to manually access the data
structures it seems like information is missing and I have no idea why.
The variables I'm interested in are defined in the model as follows:
tuple Mode {
int opId;
int mch;
int pt;
};
{Mode} Modes = ...;
dvar interval modes[md in Modes] optional size md.pt;
And after cp.solve()
returns successfully I'm trying to parse the data using the following code:
IloIntervalVarMap modes = opl.getElement("modes").asIntervalVarMap();
IloTupleSet Modes = opl.getElement("Modes").asTupleSet();
int index = 0;
for (IloTupleIterator iter(Modes); iter.ok(); ++iter){
IloTuple t = *iter;
printf("Tuple Values [%d,%d,%d]\n",
(int) t.getIntValue((IloInt) 0),
(int) t.getIntValue((IloInt) 1),
(int) t.getIntValue((IloInt) 2));
//Fetch the mode in solution to find out what is its deal
int t_uid = (int) t.getIndex();
IloIntervalVar t_val = modes.get(t);
float t_start = (float) t_val.getStartMin();
float t_end = (float) t_val.getEndMin();
bool t_present = (bool) t_val.isPresent();
float t_size = (float) t_val.getSizeMin();
printf("\t Map Values %f %f %f \n", t_start, t_end, t_size);
if (t_val.isPresent()){
printf("Found Present Mode - Index %d\n", t_uid);
}
}
When I'm printing the solution using opl.printSolution()
, modes
looks like this:
modes = [<0 0 0 0> <1 0 123 123> <0 0 0 0> <1 123 253 130>
<0 0 0 0> <0 0 0 0> <1 581 731 150>
<0 0 0 0> <0 0 0 0> <0 0 0 0> <1 253 398 145>
<1 174 388 214> <0 0 0 0> <1 398 464 66>
<0 0 0 0> <0 0 0 0> <1 481 576 95>
<0 0 0 0> <1 500 620 120> <0 0 0 0>
<1 87 174 87> <0 0 0 0> <0 0 0 0> <1 245 350 105>
<0 0 0 0> <0 0 0 0> <1 260 360 100>
<0 0 0 0> <0 0 0 0> <1 398 563 165>
<1 0 87 87> <0 0 0 0> <0 0 0 0> <1 87 260 173>
<1 350 495 145> <0 0 0 0> <0 0 0 0>
<1 87 257 170> <1 388 516 128> <0 0 0 0>
<0 0 0 0> <1 516 581 65> <0 0 0 0>
<0 0 0 0> <1 581 681 100> <0 0 0 0>
<0 0 0 0> <0 0 0 0> <1 581 746 165>
<1 253 398 145> <0 0 0 0> <0 0 0 0>
<1 475 598 123> <0 0 0 0> <0 0 0 0>
<1 620 740 120> <0 0 0 0> <0 0 0 0>
<0 0 0 0> <1 701 751 50> <0 0 0 0>
<1 0 145 145> <1 598 722 124> <0 0 0 0>
<0 0 0 0> <0 0 0 0> <1 145 323 178>
<1 360 500 140> <0 0 0 0> <0 0 0 0>
<1 0 245 245> <0 0 0 0> <1 257 481 224>
<0 0 0 0> <0 0 0 0> <1 323 501 178>
<1 551 701 150> <0 0 0 0> <0 0 0 0>
<1 145 295 150> <1 295 475 180> <0 0 0 0>
<0 0 0 0> <1 501 551 50> <1 576 726 150>
<0 0 0 0>];
When I'm querying the structure though, all intervalvar variables accessed seem like they are reset or something. t_val.isPresent()
method always returns false, while the start and end times are with minor exceptions set to -2 (exception values are 0 when I'm querying the MinStart times...). Their size though (tval.getSizeMin/Max()
) is correct.
Am i doing something wrong or is this a bug or something?