mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
refinements to incorporate pickup and deliveries
This commit is contained in:
parent
07ecdc2f28
commit
6cf67f7ba0
6 changed files with 69 additions and 110 deletions
|
|
@ -27,30 +27,6 @@ class StateManagerImpl implements StateManager{
|
|||
|
||||
private Map<TourActivity,States> activityStates = new HashMap<TourActivity, StateManager.States>();
|
||||
|
||||
// Map<VehicleRoute, States> getRouteStates() {
|
||||
// return Collections.unmodifiableMap(vehicleRouteStates);
|
||||
// }
|
||||
//
|
||||
// States getRouteStates(VehicleRoute route){
|
||||
// return vehicleRouteStates.get(route);
|
||||
// }
|
||||
//
|
||||
// void put(VehicleRoute route, States states) {
|
||||
// vehicleRouteStates.put(route, states);
|
||||
// }
|
||||
//
|
||||
// Map<TourActivity, States> getActivityStates() {
|
||||
// return Collections.unmodifiableMap(activityStates);
|
||||
// }
|
||||
//
|
||||
// States getActivityStates(TourActivity act){
|
||||
// return activityStates.get(act);
|
||||
// }
|
||||
//
|
||||
// void put(TourActivity act, States states) {
|
||||
// activityStates.put(act, states);
|
||||
// }
|
||||
|
||||
public void clear(){
|
||||
vehicleRouteStates.clear();
|
||||
activityStates.clear();
|
||||
|
|
@ -84,6 +60,8 @@ class StateManagerImpl implements StateManager{
|
|||
if(stateType.equals(StateTypes.DURATION)) return new StateImpl(0);
|
||||
if(stateType.equals(StateTypes.EARLIEST_OPERATION_START_TIME)) return new StateImpl(act.getTheoreticalEarliestOperationStartTime());
|
||||
if(stateType.equals(StateTypes.LATEST_OPERATION_START_TIME)) return new StateImpl(act.getTheoreticalLatestOperationStartTime());
|
||||
if(stateType.equals(StateTypes.FUTURE_PICKS)) return new StateImpl(0);
|
||||
if(stateType.equals(StateTypes.PAST_DELIVERIES)) return new StateImpl(0);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,5 +11,9 @@ class StateTypes {
|
|||
|
||||
final static String EARLIEST_OPERATION_START_TIME = "earliestOST";
|
||||
|
||||
public static final String COSTS = "costs";
|
||||
static final String COSTS = "costs";
|
||||
|
||||
final static String FUTURE_PICKS = "futurePicks";
|
||||
|
||||
final static String PAST_DELIVERIES = "pastDeliveries";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package algorithms;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import algorithms.ForwardInTimeListeners.ForwardInTimeListener;
|
||||
import algorithms.StateManager.StateImpl;
|
||||
import basics.costs.ForwardTransportCost;
|
||||
|
|
@ -7,10 +9,13 @@ import basics.costs.VehicleRoutingActivityCosts;
|
|||
import basics.route.End;
|
||||
import basics.route.Start;
|
||||
import basics.route.TourActivity;
|
||||
import basics.route.TourActivity.JobActivity;
|
||||
import basics.route.VehicleRoute;
|
||||
|
||||
class UpdateCostsAtAllLevels implements ForwardInTimeListener{
|
||||
|
||||
private static Logger log = Logger.getLogger(UpdateCostsAtAllLevels.class);
|
||||
|
||||
private VehicleRoutingActivityCosts activityCost;
|
||||
|
||||
private ForwardTransportCost transportCost;
|
||||
|
|
@ -38,16 +43,22 @@ class UpdateCostsAtAllLevels implements ForwardInTimeListener{
|
|||
vehicleRoute.getVehicleRouteCostCalculator().reset();
|
||||
prevAct = start;
|
||||
startTimeAtPrevAct = departureTime;
|
||||
// log.info(start + " depTime=" + departureTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nextActivity(TourActivity act, double arrTime, double endTime) {
|
||||
// log.info(act + " job " + ((JobActivity)act).getJob().getId() + " arrTime=" + arrTime + " endTime=" + endTime);
|
||||
double transportCost = this.transportCost.getTransportCost(prevAct.getLocationId(), act.getLocationId(), startTimeAtPrevAct, vehicleRoute.getDriver(), vehicleRoute.getVehicle());
|
||||
double actCost = activityCost.getActivityCost(act, arrTime, vehicleRoute.getDriver(), vehicleRoute.getVehicle());
|
||||
|
||||
vehicleRoute.getVehicleRouteCostCalculator().addTransportCost(transportCost);
|
||||
vehicleRoute.getVehicleRouteCostCalculator().addActivityCost(actCost);
|
||||
|
||||
if(transportCost > 10000 || actCost > 100000){
|
||||
throw new IllegalStateException("aaaääähh");
|
||||
}
|
||||
|
||||
totalOperationCost += transportCost;
|
||||
totalOperationCost += actCost;
|
||||
|
||||
|
|
@ -59,12 +70,17 @@ class UpdateCostsAtAllLevels implements ForwardInTimeListener{
|
|||
|
||||
@Override
|
||||
public void end(End end, double arrivalTime) {
|
||||
// log.info(end + " arrTime=" + arrivalTime);
|
||||
double transportCost = this.transportCost.getTransportCost(prevAct.getLocationId(), end.getLocationId(), startTimeAtPrevAct, vehicleRoute.getDriver(), vehicleRoute.getVehicle());
|
||||
double actCost = activityCost.getActivityCost(end, arrivalTime, vehicleRoute.getDriver(), vehicleRoute.getVehicle());
|
||||
|
||||
vehicleRoute.getVehicleRouteCostCalculator().addTransportCost(transportCost);
|
||||
vehicleRoute.getVehicleRouteCostCalculator().addActivityCost(actCost);
|
||||
|
||||
if(transportCost > 10000 || actCost > 100000){
|
||||
throw new IllegalStateException("aaaääähh");
|
||||
}
|
||||
|
||||
totalOperationCost += transportCost;
|
||||
totalOperationCost += actCost;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,19 @@
|
|||
package algorithms;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import algorithms.BackwardInTimeListeners.BackwardInTimeListener;
|
||||
import algorithms.StateManager.StateImpl;
|
||||
import basics.route.End;
|
||||
import basics.route.Start;
|
||||
import basics.route.TourActivity;
|
||||
import basics.route.TourActivity.JobActivity;
|
||||
import basics.route.VehicleRoute;
|
||||
|
||||
class UpdateLatestOperationStartTimeAtActLocations implements BackwardInTimeListener{
|
||||
|
||||
private static Logger log = Logger.getLogger(UpdateLatestOperationStartTimeAtActLocations.class);
|
||||
|
||||
private StateManagerImpl states;
|
||||
|
||||
public UpdateLatestOperationStartTimeAtActLocations(StateManagerImpl states) {
|
||||
|
|
@ -21,6 +26,7 @@ class UpdateLatestOperationStartTimeAtActLocations implements BackwardInTimeList
|
|||
|
||||
@Override
|
||||
public void prevActivity(TourActivity act,double latestDepartureTime, double latestOperationStartTime) {
|
||||
// log.info(act + " jobId=" + ((JobActivity)act).getJob().getId() + " " + latestOperationStartTime);
|
||||
states.putActivityState(act, StateTypes.LATEST_OPERATION_START_TIME, new StateImpl(latestOperationStartTime));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,10 @@ import basics.route.VehicleTypeImpl;
|
|||
*/
|
||||
public class VehicleRoutingProblem {
|
||||
|
||||
public static class VehicleRoutingProblemType {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Builder to build the routing-problem.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue