mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
make service time dependent on vehicle - #199
This commit is contained in:
parent
627c2184ce
commit
ca26171548
12 changed files with 23 additions and 14 deletions
|
|
@ -20,6 +20,7 @@ import com.graphhopper.jsprit.core.problem.JobActivityFactory;
|
||||||
import com.graphhopper.jsprit.core.problem.Location;
|
import com.graphhopper.jsprit.core.problem.Location;
|
||||||
import com.graphhopper.jsprit.core.problem.constraint.*;
|
import com.graphhopper.jsprit.core.problem.constraint.*;
|
||||||
import com.graphhopper.jsprit.core.problem.constraint.HardActivityConstraint.ConstraintsStatus;
|
import com.graphhopper.jsprit.core.problem.constraint.HardActivityConstraint.ConstraintsStatus;
|
||||||
|
import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingActivityCosts;
|
||||||
import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
||||||
import com.graphhopper.jsprit.core.problem.driver.Driver;
|
import com.graphhopper.jsprit.core.problem.driver.Driver;
|
||||||
import com.graphhopper.jsprit.core.problem.job.Break;
|
import com.graphhopper.jsprit.core.problem.job.Break;
|
||||||
|
|
@ -31,7 +32,6 @@ import com.graphhopper.jsprit.core.problem.solution.route.activity.End;
|
||||||
import com.graphhopper.jsprit.core.problem.solution.route.activity.Start;
|
import com.graphhopper.jsprit.core.problem.solution.route.activity.Start;
|
||||||
import com.graphhopper.jsprit.core.problem.solution.route.activity.TourActivity;
|
import com.graphhopper.jsprit.core.problem.solution.route.activity.TourActivity;
|
||||||
import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
|
import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
|
||||||
import com.graphhopper.jsprit.core.util.CalculationUtils;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
|
@ -40,7 +40,7 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculator that calculates the best insertion position for a {@link jsprit.core.problem.job.Service}.
|
* Calculator that calculates the best insertion position for a service.
|
||||||
*
|
*
|
||||||
* @author schroeder
|
* @author schroeder
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ package com.graphhopper.jsprit.core.algorithm.recreate;
|
||||||
import com.graphhopper.jsprit.core.problem.JobActivityFactory;
|
import com.graphhopper.jsprit.core.problem.JobActivityFactory;
|
||||||
import com.graphhopper.jsprit.core.problem.constraint.*;
|
import com.graphhopper.jsprit.core.problem.constraint.*;
|
||||||
import com.graphhopper.jsprit.core.problem.constraint.HardActivityConstraint.ConstraintsStatus;
|
import com.graphhopper.jsprit.core.problem.constraint.HardActivityConstraint.ConstraintsStatus;
|
||||||
|
import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingActivityCosts;
|
||||||
import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
||||||
import com.graphhopper.jsprit.core.problem.driver.Driver;
|
import com.graphhopper.jsprit.core.problem.driver.Driver;
|
||||||
import com.graphhopper.jsprit.core.problem.job.Job;
|
import com.graphhopper.jsprit.core.problem.job.Job;
|
||||||
|
|
@ -31,7 +32,6 @@ import com.graphhopper.jsprit.core.problem.solution.route.activity.Start;
|
||||||
import com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindow;
|
import com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindow;
|
||||||
import com.graphhopper.jsprit.core.problem.solution.route.activity.TourActivity;
|
import com.graphhopper.jsprit.core.problem.solution.route.activity.TourActivity;
|
||||||
import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
|
import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
|
||||||
import com.graphhopper.jsprit.core.util.CalculationUtils;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
|
@ -54,11 +54,13 @@ final class ShipmentInsertionCalculator implements JobInsertionCostsCalculator {
|
||||||
|
|
||||||
private VehicleRoutingTransportCosts transportCosts;
|
private VehicleRoutingTransportCosts transportCosts;
|
||||||
|
|
||||||
|
private VehicleRoutingActivityCosts activityCosts;
|
||||||
|
|
||||||
private JobActivityFactory activityFactory;
|
private JobActivityFactory activityFactory;
|
||||||
|
|
||||||
private AdditionalAccessEgressCalculator additionalAccessEgressCalculator;
|
private AdditionalAccessEgressCalculator additionalAccessEgressCalculator;
|
||||||
|
|
||||||
public ShipmentInsertionCalculator(VehicleRoutingTransportCosts routingCosts, ActivityInsertionCostsCalculator activityInsertionCostsCalculator, ConstraintManager constraintManager) {
|
public ShipmentInsertionCalculator(VehicleRoutingTransportCosts routingCosts, VehicleRoutingActivityCosts activityCosts, ActivityInsertionCostsCalculator activityInsertionCostsCalculator, ConstraintManager constraintManager) {
|
||||||
super();
|
super();
|
||||||
this.activityInsertionCostsCalculator = activityInsertionCostsCalculator;
|
this.activityInsertionCostsCalculator = activityInsertionCostsCalculator;
|
||||||
this.hardRouteLevelConstraint = constraintManager;
|
this.hardRouteLevelConstraint = constraintManager;
|
||||||
|
|
@ -66,6 +68,7 @@ final class ShipmentInsertionCalculator implements JobInsertionCostsCalculator {
|
||||||
this.softActivityConstraint = constraintManager;
|
this.softActivityConstraint = constraintManager;
|
||||||
this.softRouteConstraint = constraintManager;
|
this.softRouteConstraint = constraintManager;
|
||||||
this.transportCosts = routingCosts;
|
this.transportCosts = routingCosts;
|
||||||
|
this.activityCosts = activityCosts;
|
||||||
additionalAccessEgressCalculator = new AdditionalAccessEgressCalculator(routingCosts);
|
additionalAccessEgressCalculator = new AdditionalAccessEgressCalculator(routingCosts);
|
||||||
logger.debug("initialise {}", this);
|
logger.debug("initialise {}", this);
|
||||||
}
|
}
|
||||||
|
|
@ -159,7 +162,7 @@ final class ShipmentInsertionCalculator implements JobInsertionCostsCalculator {
|
||||||
|
|
||||||
TourActivity prevAct_deliveryLoop = pickupShipment;
|
TourActivity prevAct_deliveryLoop = pickupShipment;
|
||||||
double shipmentPickupArrTime = prevActEndTime + transportCosts.getTransportTime(prevAct.getLocation(), pickupShipment.getLocation(), prevActEndTime, newDriver, newVehicle);
|
double shipmentPickupArrTime = prevActEndTime + transportCosts.getTransportTime(prevAct.getLocation(), pickupShipment.getLocation(), prevActEndTime, newDriver, newVehicle);
|
||||||
double shipmentPickupEndTime = CalculationUtils.getActivityEndTime(shipmentPickupArrTime, pickupShipment);
|
double shipmentPickupEndTime = Math.max(shipmentPickupArrTime, pickupShipment.getTheoreticalEarliestOperationStartTime()) + activityCosts.getActivityDuration(pickupShipment, shipmentPickupArrTime, newDriver, newVehicle);
|
||||||
|
|
||||||
pickupContext.setArrivalTime(shipmentPickupArrTime);
|
pickupContext.setArrivalTime(shipmentPickupArrTime);
|
||||||
pickupContext.setEndTime(shipmentPickupEndTime);
|
pickupContext.setEndTime(shipmentPickupEndTime);
|
||||||
|
|
@ -211,7 +214,7 @@ final class ShipmentInsertionCalculator implements JobInsertionCostsCalculator {
|
||||||
if (deliveryInsertionNotFulfilledBreak) break;
|
if (deliveryInsertionNotFulfilledBreak) break;
|
||||||
//update prevAct and endTime
|
//update prevAct and endTime
|
||||||
double nextActArrTime = prevActEndTime_deliveryLoop + transportCosts.getTransportTime(prevAct_deliveryLoop.getLocation(), nextAct_deliveryLoop.getLocation(), prevActEndTime_deliveryLoop, newDriver, newVehicle);
|
double nextActArrTime = prevActEndTime_deliveryLoop + transportCosts.getTransportTime(prevAct_deliveryLoop.getLocation(), nextAct_deliveryLoop.getLocation(), prevActEndTime_deliveryLoop, newDriver, newVehicle);
|
||||||
prevActEndTime_deliveryLoop = CalculationUtils.getActivityEndTime(nextActArrTime, nextAct_deliveryLoop);
|
prevActEndTime_deliveryLoop = Math.max(nextActArrTime, nextAct_deliveryLoop.getTheoreticalEarliestOperationStartTime()) + activityCosts.getActivityDuration(nextAct_deliveryLoop,nextActArrTime,newDriver,newVehicle);
|
||||||
prevAct_deliveryLoop = nextAct_deliveryLoop;
|
prevAct_deliveryLoop = nextAct_deliveryLoop;
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
|
@ -221,7 +224,7 @@ final class ShipmentInsertionCalculator implements JobInsertionCostsCalculator {
|
||||||
}
|
}
|
||||||
//update prevAct and endTime
|
//update prevAct and endTime
|
||||||
double nextActArrTime = prevActEndTime + transportCosts.getTransportTime(prevAct.getLocation(), nextAct.getLocation(), prevActEndTime, newDriver, newVehicle);
|
double nextActArrTime = prevActEndTime + transportCosts.getTransportTime(prevAct.getLocation(), nextAct.getLocation(), prevActEndTime, newDriver, newVehicle);
|
||||||
prevActEndTime = CalculationUtils.getActivityEndTime(nextActArrTime, nextAct);
|
prevActEndTime = Math.max(nextActArrTime, nextAct.getTheoreticalEarliestOperationStartTime()) + activityCosts.getActivityDuration(nextAct,nextActArrTime,newDriver,newVehicle);
|
||||||
prevAct = nextAct;
|
prevAct = nextAct;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
||||||
import com.graphhopper.jsprit.core.problem.misc.JobInsertionContext;
|
import com.graphhopper.jsprit.core.problem.misc.JobInsertionContext;
|
||||||
import com.graphhopper.jsprit.core.problem.solution.route.activity.End;
|
import com.graphhopper.jsprit.core.problem.solution.route.activity.End;
|
||||||
import com.graphhopper.jsprit.core.problem.solution.route.activity.TourActivity;
|
import com.graphhopper.jsprit.core.problem.solution.route.activity.TourActivity;
|
||||||
import com.graphhopper.jsprit.core.util.CalculationUtils;
|
|
||||||
|
|
||||||
public class VariableTransportCostCalculator implements SoftActivityConstraint {
|
public class VariableTransportCostCalculator implements SoftActivityConstraint {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
package com.graphhopper.jsprit.core.algorithm.state;
|
package com.graphhopper.jsprit.core.algorithm.state;
|
||||||
|
|
||||||
import com.graphhopper.jsprit.core.problem.Location;
|
import com.graphhopper.jsprit.core.problem.Location;
|
||||||
|
import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingActivityCosts;
|
||||||
import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
||||||
import com.graphhopper.jsprit.core.problem.solution.route.RouteVisitor;
|
import com.graphhopper.jsprit.core.problem.solution.route.RouteVisitor;
|
||||||
import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute;
|
import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute;
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import com.graphhopper.jsprit.core.problem.Capacity;
|
||||||
import com.graphhopper.jsprit.core.problem.Location;
|
import com.graphhopper.jsprit.core.problem.Location;
|
||||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||||
import com.graphhopper.jsprit.core.problem.cost.TransportDistance;
|
import com.graphhopper.jsprit.core.problem.cost.TransportDistance;
|
||||||
|
import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingActivityCosts;
|
||||||
import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
||||||
import com.graphhopper.jsprit.core.problem.solution.SolutionCostCalculator;
|
import com.graphhopper.jsprit.core.problem.solution.SolutionCostCalculator;
|
||||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,11 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package com.graphhopper.jsprit.core.problem.constraint;
|
package com.graphhopper.jsprit.core.problem.constraint;
|
||||||
|
|
||||||
|
import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingActivityCosts;
|
||||||
import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
||||||
import com.graphhopper.jsprit.core.problem.misc.JobInsertionContext;
|
import com.graphhopper.jsprit.core.problem.misc.JobInsertionContext;
|
||||||
import com.graphhopper.jsprit.core.problem.solution.route.activity.End;
|
import com.graphhopper.jsprit.core.problem.solution.route.activity.End;
|
||||||
import com.graphhopper.jsprit.core.problem.solution.route.activity.TourActivity;
|
import com.graphhopper.jsprit.core.problem.solution.route.activity.TourActivity;
|
||||||
import com.graphhopper.jsprit.core.util.CalculationUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates additional transportation costs induced by inserting newAct.
|
* Calculates additional transportation costs induced by inserting newAct.
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,12 @@ package com.graphhopper.jsprit.core.problem.constraint;
|
||||||
|
|
||||||
import com.graphhopper.jsprit.core.algorithm.state.InternalStates;
|
import com.graphhopper.jsprit.core.algorithm.state.InternalStates;
|
||||||
import com.graphhopper.jsprit.core.problem.Location;
|
import com.graphhopper.jsprit.core.problem.Location;
|
||||||
|
import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingActivityCosts;
|
||||||
import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
||||||
import com.graphhopper.jsprit.core.problem.misc.JobInsertionContext;
|
import com.graphhopper.jsprit.core.problem.misc.JobInsertionContext;
|
||||||
import com.graphhopper.jsprit.core.problem.solution.route.activity.End;
|
import com.graphhopper.jsprit.core.problem.solution.route.activity.End;
|
||||||
import com.graphhopper.jsprit.core.problem.solution.route.activity.TourActivity;
|
import com.graphhopper.jsprit.core.problem.solution.route.activity.TourActivity;
|
||||||
import com.graphhopper.jsprit.core.problem.solution.route.state.RouteAndActivityStateGetter;
|
import com.graphhopper.jsprit.core.problem.solution.route.state.RouteAndActivityStateGetter;
|
||||||
import com.graphhopper.jsprit.core.util.CalculationUtils;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,8 @@ package com.graphhopper.jsprit.core.util;
|
||||||
import com.graphhopper.jsprit.core.problem.cost.ForwardTransportTime;
|
import com.graphhopper.jsprit.core.problem.cost.ForwardTransportTime;
|
||||||
import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingActivityCosts;
|
import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingActivityCosts;
|
||||||
import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute;
|
import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute;
|
||||||
import com.graphhopper.jsprit.core.problem.solution.route.activity.*;
|
import com.graphhopper.jsprit.core.problem.solution.route.activity.ActivityVisitor;
|
||||||
|
import com.graphhopper.jsprit.core.problem.solution.route.activity.TourActivity;
|
||||||
|
|
||||||
public class ActivityTimeTracker implements ActivityVisitor {
|
public class ActivityTimeTracker implements ActivityVisitor {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,9 @@ import com.graphhopper.jsprit.core.problem.AbstractActivity;
|
||||||
import com.graphhopper.jsprit.core.problem.JobActivityFactory;
|
import com.graphhopper.jsprit.core.problem.JobActivityFactory;
|
||||||
import com.graphhopper.jsprit.core.problem.Location;
|
import com.graphhopper.jsprit.core.problem.Location;
|
||||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||||
|
import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingActivityCosts;
|
||||||
import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
||||||
|
import com.graphhopper.jsprit.core.problem.cost.WaitingTimeCosts;
|
||||||
import com.graphhopper.jsprit.core.problem.driver.Driver;
|
import com.graphhopper.jsprit.core.problem.driver.Driver;
|
||||||
import com.graphhopper.jsprit.core.problem.job.Delivery;
|
import com.graphhopper.jsprit.core.problem.job.Delivery;
|
||||||
import com.graphhopper.jsprit.core.problem.job.Job;
|
import com.graphhopper.jsprit.core.problem.job.Job;
|
||||||
|
|
|
||||||
|
|
@ -201,7 +201,7 @@ public class UpdateVehicleDependentTimeWindowTest {
|
||||||
.addService(service).addService(service2, TimeWindow.newInstance(70, 80)).build();
|
.addService(service).addService(service2, TimeWindow.newInstance(70, 80)).build();
|
||||||
|
|
||||||
StateManager stateManager = new StateManager(vrp);
|
StateManager stateManager = new StateManager(vrp);
|
||||||
UpdateVehicleDependentPracticalTimeWindows updater = new UpdateVehicleDependentPracticalTimeWindows(stateManager,routingCosts);
|
UpdateVehicleDependentPracticalTimeWindows updater = new UpdateVehicleDependentPracticalTimeWindows(stateManager,routingCosts,activityCosts);
|
||||||
updater.setVehiclesToUpdate(new UpdateVehicleDependentPracticalTimeWindows.VehiclesToUpdate() {
|
updater.setVehiclesToUpdate(new UpdateVehicleDependentPracticalTimeWindows.VehiclesToUpdate() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,9 @@ import com.graphhopper.jsprit.core.algorithm.state.StateManager;
|
||||||
import com.graphhopper.jsprit.core.algorithm.state.UpdateActivityTimes;
|
import com.graphhopper.jsprit.core.algorithm.state.UpdateActivityTimes;
|
||||||
import com.graphhopper.jsprit.core.algorithm.state.UpdateVehicleDependentPracticalTimeWindows;
|
import com.graphhopper.jsprit.core.algorithm.state.UpdateVehicleDependentPracticalTimeWindows;
|
||||||
import com.graphhopper.jsprit.core.problem.*;
|
import com.graphhopper.jsprit.core.problem.*;
|
||||||
|
import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingActivityCosts;
|
||||||
import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
||||||
|
import com.graphhopper.jsprit.core.problem.cost.WaitingTimeCosts;
|
||||||
import com.graphhopper.jsprit.core.problem.job.Job;
|
import com.graphhopper.jsprit.core.problem.job.Job;
|
||||||
import com.graphhopper.jsprit.core.problem.job.Service;
|
import com.graphhopper.jsprit.core.problem.job.Service;
|
||||||
import com.graphhopper.jsprit.core.problem.misc.JobInsertionContext;
|
import com.graphhopper.jsprit.core.problem.misc.JobInsertionContext;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue