mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
improve max-time-in-vehicle
This commit is contained in:
parent
39ed96341a
commit
8486841884
2 changed files with 2 additions and 52 deletions
|
|
@ -143,52 +143,6 @@ public class MaxTimeInVehicleConstraint implements HardActivityConstraint {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if(newActIsPickup || iFacts.getAssociatedActivities().size() == 1) {
|
||||
// double latest;
|
||||
// if (iFacts.getRoute().isEmpty()) latest = Double.MAX_VALUE;
|
||||
// else if (nextAct instanceof End) {
|
||||
// latest = stateManager.getRouteState(iFacts.getRoute(), iFacts.getNewVehicle(), latestStartId, Double.class);
|
||||
// } else latest = stateManager.getActivityState(nextAct, iFacts.getNewVehicle(), latestStartId, Double.class);
|
||||
//
|
||||
// if (nextActStart > latest) {
|
||||
// return ConstraintsStatus.NOT_FULFILLED;
|
||||
// }
|
||||
//
|
||||
// } else {
|
||||
// boolean isShipment = iFacts.getAssociatedActivities().size() == 2;
|
||||
// if (newActIsDelivery && isShipment) {
|
||||
// StateManager localStateManager = new StateManager(vrp);
|
||||
// StateId stateId = localStateManager.createStateId("local-slack");
|
||||
// UpdateMaxTimeInVehicle updateMaxTimeInVehicle = new UpdateMaxTimeInVehicle(localStateManager, stateId, transportTime, activityCosts);
|
||||
// updateMaxTimeInVehicle.setVehiclesToUpdate(new UpdateVehicleDependentPracticalTimeWindows.VehiclesToUpdate() {
|
||||
// @Override
|
||||
// public Collection<Vehicle> get(VehicleRoute route) {
|
||||
// return Arrays.asList(iFacts.getNewVehicle());
|
||||
// }
|
||||
// });
|
||||
// updateMaxTimeInVehicle.begin(iFacts.getRoute());
|
||||
// List<TourActivity> tourActivities = new ArrayList<>(iFacts.getRoute().getActivities());
|
||||
// tourActivities.add(iFacts.getRelatedActivityContext().getInsertionIndex(), iFacts.getAssociatedActivities().get(0));
|
||||
// for (TourActivity act : tourActivities) {
|
||||
// updateMaxTimeInVehicle.visit(act);
|
||||
// }
|
||||
// updateMaxTimeInVehicle.finish(tourActivities, iFacts.getJob());
|
||||
//
|
||||
// double latest;
|
||||
// if (iFacts.getRoute().isEmpty()) latest = Double.MAX_VALUE;
|
||||
// else if (nextAct instanceof End) {
|
||||
// latest = localStateManager.getRouteState(iFacts.getRoute(), iFacts.getNewVehicle(), stateId, Double.class);
|
||||
// } else
|
||||
// latest = localStateManager.getActivityState(nextAct, iFacts.getNewVehicle(), stateId, Double.class);
|
||||
//
|
||||
// if (nextActStart > latest) {
|
||||
// return ConstraintsStatus.NOT_FULFILLED;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
return ConstraintsStatus.FULFILLED;
|
||||
}
|
||||
|
||||
|
|
@ -196,8 +150,4 @@ public class MaxTimeInVehicleConstraint implements HardActivityConstraint {
|
|||
return Math.max(arrTime, act.getTheoreticalEarliestOperationStartTime());
|
||||
}
|
||||
|
||||
// private double getMaxTime(String jobId) {
|
||||
// if(maxTimes.containsKey(jobId)) return maxTimes.get(jobId);
|
||||
// else return Double.MAX_VALUE;
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ public class MaxTimeInVehicleConstraintTest {
|
|||
c.getAssociatedActivities().add(acts.get(1));
|
||||
|
||||
Assert.assertEquals(HardActivityConstraint.ConstraintsStatus.FULFILLED, constraint.fulfilled(c, route.getStart(), acts.get(0), route.getActivities().get(0), 0));
|
||||
Assert.assertEquals(HardActivityConstraint.ConstraintsStatus.NOT_FULFILLED_BREAK, constraint.fulfilled(c, act(route, 0), acts.get(0), act(route, 1), 20));
|
||||
Assert.assertEquals(HardActivityConstraint.ConstraintsStatus.NOT_FULFILLED, constraint.fulfilled(c, act(route, 0), acts.get(0), act(route, 1), 20));
|
||||
Assert.assertEquals(HardActivityConstraint.ConstraintsStatus.FULFILLED, constraint.fulfilled(c, act(route,1), acts.get(0), route.getEnd(), 40));
|
||||
|
||||
//insert pickup at 0
|
||||
|
|
@ -315,7 +315,7 @@ public class MaxTimeInVehicleConstraintTest {
|
|||
c.getAssociatedActivities().add(acts.get(0));
|
||||
c.getAssociatedActivities().add(acts.get(1));
|
||||
|
||||
Assert.assertEquals("pickup shipment cannot happen at first pos. since d2 has max in-vehicle time", HardActivityConstraint.ConstraintsStatus.NOT_FULFILLED_BREAK, constraint.fulfilled(c, r.getStart(), acts.get(0), r.getActivities().get(0), 0));
|
||||
Assert.assertEquals("pickup shipment cannot happen at first pos. since d2 has max in-vehicle time", HardActivityConstraint.ConstraintsStatus.NOT_FULFILLED, constraint.fulfilled(c, r.getStart(), acts.get(0), r.getActivities().get(0), 0));
|
||||
Assert.assertEquals("pickup shipment can happen at second pos.", HardActivityConstraint.ConstraintsStatus.FULFILLED, constraint.fulfilled(c, r.getActivities().get(0), acts.get(0), r.getActivities().get(1), 10));
|
||||
Assert.assertEquals("d2 has been delivered so pickup shipment is possible", HardActivityConstraint.ConstraintsStatus.FULFILLED, constraint.fulfilled(c, r.getActivities().get(1), acts.get(0), r.getEnd(), 30));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue