1
0
Fork 0
mirror of https://github.com/graphhopper/jsprit.git synced 2020-01-24 07:45:05 +01:00

fix bug in CalculatesServiceInsertion

This commit is contained in:
Stefan Schroeder 2013-08-30 10:51:50 +02:00
parent 9d40d76a2b
commit 07ecdc2f28
2 changed files with 7 additions and 15 deletions

View file

@ -4,16 +4,6 @@ import basics.route.TourActivity;
class CalcUtils {
/**
*
* @param startTimeAtPrevAct
* @param tpTime_prevAct_nextAct
* @param nextAct
* @return
*/
static double getStartTimeAtAct(double startTimeAtPrevAct, double tpTime_prevAct_nextAct, TourActivity nextAct){
return Math.max(startTimeAtPrevAct + tpTime_prevAct_nextAct, nextAct.getTheoreticalEarliestOperationStartTime()) + nextAct.getOperationTime();
}
/**
* Calculates actEndTime assuming that activity can at earliest start at act.getTheoreticalEarliestOperationStartTime().

View file

@ -102,11 +102,9 @@ final class CalculatesServiceInsertion implements JobInsertionCalculator{
TourActivity prevAct = start;
double prevActStartTime = newVehicleDepartureTime;
int actIndex = 0;
// logger.info("start");
for(TourActivity nextAct : currentRoute.getTourActivities().getActivities()){
if(deliveryAct2Insert.getTheoreticalLatestOperationStartTime() < prevAct.getTheoreticalEarliestOperationStartTime()){
break;
}
// logger.info("prevActStartTime="+prevActStartTime);
if(neighborhood.areNeighbors(deliveryAct2Insert.getLocationId(), prevAct.getLocationId()) && neighborhood.areNeighbors(deliveryAct2Insert.getLocationId(), nextAct.getLocationId())){
Marginals mc = calculate(insertionContext, prevAct, nextAct, deliveryAct2Insert, prevActStartTime);
if(mc != null){
@ -117,10 +115,14 @@ final class CalculatesServiceInsertion implements JobInsertionCalculator{
}
}
}
double nextActArrTime = prevActStartTime + transportCosts.getTransportTime(prevAct.getLocationId(), nextAct.getLocationId(), prevActStartTime, newDriver, newVehicle);
double nextActEndTime = CalcUtils.getActivityEndTime(nextActArrTime, nextAct);
prevActStartTime = nextActEndTime;
prevAct = nextAct;
prevActStartTime = CalcUtils.getStartTimeAtAct(prevActStartTime, transportCosts.getTransportTime(prevAct.getLocationId(), nextAct.getLocationId(), prevActStartTime, newDriver, newVehicle), nextAct);
actIndex++;
}
// logger.info("prevActStartTime="+prevActStartTime);
End nextAct = end;
if(neighborhood.areNeighbors(deliveryAct2Insert.getLocationId(), prevAct.getLocationId()) && neighborhood.areNeighbors(deliveryAct2Insert.getLocationId(), nextAct.getLocationId())){
Marginals mc = calculate(insertionContext, prevAct, nextAct, deliveryAct2Insert, prevActStartTime);