Thanks Stefan, I was thinking along those lines. But, actually I am looking for max working hours (which includes driving + service time at service + any waiting time). In other words, I am looking for time from start till the end of the route.
Here is my thoughts/logic:
// assume that we have a route
1) get the arrival time of first act/service on the route, i.e., arrivalTimeForFirstActOnRoute
2) get driving time from depot to that first service as follows:
drivingTimeFromDepotToFirstAct = costMatrix.getTransportTime(iFacts.getRoute().getStart().getLocation(), firstActOnRoute.getLocation(), 0, null, null);
3) get the actual departure time of route (vehicle) as follows:
actualDept = arrivalTimeForFirstActOnRoute - drivingTimeFromDepotToFirstAct;
4) get actual end time of route (vehicle) as follows:
actualEnd = iFacts.getRoute().getEnd().getArrTime();
5) calculate the woking time needed to insert newAct as follows:
workingTimeForNewAct = get driving Time From PrevAct To NewAct + get driving Time From NewAct To NextAct + newAct.getOperationTime();
6) get the total working time when newAct is inserted
TotalWorkingTime = (actualEnd - actualDept) + workingTimeForNewAct
7) then check TotalWorkingTime if it is not in a specific range, e.g,
if (x < TotalWorkingTime < y) then return ConstraintsStatus.NOT_FULFILLED;
I tried this solution, but for some routes, I got the TotalWorkingTime to be in this range which I don't want.
Am I missing anything here, or doing something wrong?
Thanks so much!