Originally posted by: _Hadi_
Philippe,
I have implemented my original model in JAVA API and I wanted to add the travel part into the model.
This is what I have written for this constraint which you mentioned:
endAtStart(taskR[i][r], ttR[i][r]);
presenceOf(taskR[i][r]) == presenceOf(ttR[i][r]);
lengthOf(ttR[i][r]) == TT[i][typeOfNext(routeR[r],taskR[i][r],0)];
siteCounter = 0;
for (SitesClass s : sites){
vehicleCounter = 0 ;
for(vehicleClass c : vehicles){
name = s.siteCity + "*" + c.vehicleName;
draftInterval = taskOpt_multimap.get(name);
ddraftInterval =travelOpt_multimap.get(name);
for (IloIntervalVar d :draftInterval){
for (IloIntervalVar dd :ddraftInterval){
cp.add(cp.imply(cp.presenceOf(d), cp.presenceOf(dd)));
cp.endAtStart(d, dd);
cp.eq(cp.lengthOf(dd), setup.getValue( siteCounter, cp.element(sitearray, cp.typeOfNext(VehicleSeqOpt[vehicleCounter], d, siteCounter, 0)))); )
}
}
vehicleCounter++;
}
siteCounter++;
}
but the issue here is cp.typeOfNext has IntExpr type and JAVA won't accept this in the setup.getvalue since it only accepts integers. I assume using cp.element may help this case and I tried but I wasn't successful. Can you help me with this?
Thanks,
Hadi
#CPOptimizer#DecisionOptimization