mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
relax api
This commit is contained in:
parent
e68df7a874
commit
0730c465dc
447 changed files with 100795 additions and 270 deletions
|
|
@ -1,6 +1,5 @@
|
|||
package algorithms.states;
|
||||
package algorithms;
|
||||
|
||||
import algorithms.ActivityVisitor;
|
||||
import basics.costs.ForwardTransportTime;
|
||||
import basics.route.Driver;
|
||||
import basics.route.TourActivity;
|
||||
|
|
@ -1,8 +1,5 @@
|
|||
package algorithms;
|
||||
|
||||
import algorithms.constraints.ConstraintManager;
|
||||
import algorithms.constraints.HardActivityLevelConstraint;
|
||||
import algorithms.constraints.HardRouteLevelConstraint;
|
||||
import basics.VehicleRoutingProblem;
|
||||
import basics.VehicleRoutingProblem.FleetSize;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ import org.apache.log4j.Logger;
|
|||
|
||||
import util.Neighborhood;
|
||||
import algorithms.ActivityInsertionCostCalculator.Marginals;
|
||||
import algorithms.constraints.HardRouteLevelConstraint;
|
||||
import basics.Job;
|
||||
import basics.Service;
|
||||
import basics.costs.VehicleRoutingTransportCosts;
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ final class CalculatesServiceInsertionConsideringFixCost implements JobInsertion
|
|||
}
|
||||
|
||||
private int getCurrentLoad(VehicleRoute route) {
|
||||
return (int) states.getRouteState(route, StateTypes.LOAD).toDouble();
|
||||
return (int) states.getRouteState(route, StateIdFactory.LOAD).toDouble();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ final class CalculatesServiceInsertionOnRouteLevel implements JobInsertionCalcul
|
|||
/**
|
||||
* pre-check whether vehicle-capacity of new vehicle is sufficient to load service.
|
||||
*/
|
||||
if(states.getRouteState(currentRoute, StateTypes.LOAD).toDouble() + service.getCapacityDemand() > newVehicle.getCapacity()){
|
||||
if(states.getRouteState(currentRoute, StateIdFactory.LOAD).toDouble() + service.getCapacityDemand() > newVehicle.getCapacity()){
|
||||
return InsertionData.noInsertionFound();
|
||||
}
|
||||
|
||||
|
|
@ -271,7 +271,7 @@ final class CalculatesServiceInsertionOnRouteLevel implements JobInsertionCalcul
|
|||
/**
|
||||
* compute cost-diff of tour with and without new activity --> insertion_costs
|
||||
*/
|
||||
double insertion_costs = auxilliaryPathCostCalculator.costOfPath(wholeTour, start.getEndTime(), newDriver, newVehicle) - states.getRouteState(currentRoute,StateTypes.COSTS).toDouble();
|
||||
double insertion_costs = auxilliaryPathCostCalculator.costOfPath(wholeTour, start.getEndTime(), newDriver, newVehicle) - states.getRouteState(currentRoute,StateIdFactory.COSTS).toDouble();
|
||||
|
||||
/**
|
||||
* if better than best known, make it the best known
|
||||
|
|
@ -316,9 +316,9 @@ final class CalculatesServiceInsertionOnRouteLevel implements JobInsertionCalcul
|
|||
private double pathCost_oldVehicle(VehicleRoute vehicleRoute, List<TourActivity> path) {
|
||||
TourActivity act = path.get(path.size()-1);
|
||||
if(act instanceof End){
|
||||
return states.getRouteState(vehicleRoute,StateTypes.COSTS).toDouble();
|
||||
return states.getRouteState(vehicleRoute,StateIdFactory.COSTS).toDouble();
|
||||
}
|
||||
return states.getActivityState(act,StateTypes.COSTS).toDouble();
|
||||
return states.getActivityState(act,StateIdFactory.COSTS).toDouble();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ package algorithms;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import algorithms.constraints.ConstraintManager;
|
||||
import basics.VehicleRoutingProblem;
|
||||
import basics.algo.InsertionListener;
|
||||
import basics.algo.VehicleRoutingAlgorithmListeners.PrioritizedVRAListener;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package algorithms.constraints;
|
||||
package algorithms;
|
||||
|
||||
import algorithms.InsertionContext;
|
||||
import basics.route.TourActivity;
|
||||
|
||||
public class ConstraintManager implements HardActivityLevelConstraint, HardRouteLevelConstraint{
|
||||
|
|
@ -83,11 +83,11 @@ final class FindCheaperVehicleAlgo {
|
|||
if(vehicle.getType().getTypeId().equals(vehicleRoute.getVehicle().getType().getTypeId())){
|
||||
continue;
|
||||
}
|
||||
if(states.getRouteState(vehicleRoute,StateTypes.LOAD).toDouble() <= vehicle.getCapacity()){
|
||||
if(states.getRouteState(vehicleRoute,StateIdFactory.LOAD).toDouble() <= vehicle.getCapacity()){
|
||||
double fixCostSaving = vehicleRoute.getVehicle().getType().getVehicleCostParams().fix - vehicle.getType().getVehicleCostParams().fix;
|
||||
double departureTime = vehicleRoute.getStart().getEndTime();
|
||||
double newCost = auxilliaryCostCalculator.costOfPath(path, departureTime, vehicleRoute.getDriver(), vehicle);
|
||||
double varCostSaving = states.getRouteState(vehicleRoute, StateTypes.COSTS).toDouble() - newCost;
|
||||
double varCostSaving = states.getRouteState(vehicleRoute, StateIdFactory.COSTS).toDouble() - newCost;
|
||||
double totalCostSaving = varCostSaving + weightFixCosts*fixCostSaving;
|
||||
if(totalCostSaving > bestSaving){
|
||||
bestSaving = totalCostSaving;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package algorithms.constraints;
|
||||
package algorithms;
|
||||
|
||||
import algorithms.InsertionContext;
|
||||
import basics.route.TourActivity;
|
||||
|
||||
public interface HardActivityLevelConstraint {
|
||||
|
|
@ -1,9 +1,8 @@
|
|||
package algorithms.constraints;
|
||||
package algorithms;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import algorithms.InsertionContext;
|
||||
import basics.route.TourActivity;
|
||||
|
||||
class HardActivityLevelConstraintManager implements HardActivityLevelConstraint {
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
* Contributors:
|
||||
* Stefan Schroeder - initial API and implementation
|
||||
******************************************************************************/
|
||||
package algorithms.constraints;
|
||||
package algorithms;
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,8 +1,5 @@
|
|||
package algorithms.constraints;
|
||||
package algorithms;
|
||||
|
||||
import algorithms.InsertionContext;
|
||||
import algorithms.StateManager;
|
||||
import algorithms.StateTypes;
|
||||
import basics.Service;
|
||||
|
||||
public class HardLoadConstraint implements HardRouteLevelConstraint{
|
||||
|
|
@ -16,7 +13,7 @@ public class HardLoadConstraint implements HardRouteLevelConstraint{
|
|||
|
||||
@Override
|
||||
public boolean fulfilled(InsertionContext insertionContext) {
|
||||
int currentLoad = (int) states.getRouteState(insertionContext.getRoute(), StateTypes.LOAD).toDouble();
|
||||
int currentLoad = (int) states.getRouteState(insertionContext.getRoute(), StateIdFactory.LOAD).toDouble();
|
||||
Service service = (Service) insertionContext.getJob();
|
||||
if(currentLoad + service.getCapacityDemand() > insertionContext.getNewVehicle().getCapacity()){
|
||||
return false;
|
||||
|
|
@ -1,8 +1,5 @@
|
|||
package algorithms.constraints;
|
||||
package algorithms;
|
||||
|
||||
import algorithms.InsertionContext;
|
||||
import algorithms.StateManager;
|
||||
import algorithms.StateTypes;
|
||||
import basics.route.DeliveryActivity;
|
||||
import basics.route.PickupActivity;
|
||||
import basics.route.ServiceActivity;
|
||||
|
|
@ -24,14 +21,14 @@ public class HardPickupAndDeliveryActivityLevelConstraint implements HardActivit
|
|||
int futurePicks;
|
||||
int pastDeliveries;
|
||||
if(prevAct instanceof Start){
|
||||
loadAtPrevAct = (int)stateManager.getRouteState(iFacts.getRoute(), StateTypes.LOAD_AT_DEPOT).toDouble();
|
||||
futurePicks = (int)stateManager.getRouteState(iFacts.getRoute(), StateTypes.LOAD).toDouble();
|
||||
loadAtPrevAct = (int)stateManager.getRouteState(iFacts.getRoute(), StateIdFactory.LOAD_AT_DEPOT).toDouble();
|
||||
futurePicks = (int)stateManager.getRouteState(iFacts.getRoute(), StateIdFactory.LOAD).toDouble();
|
||||
pastDeliveries = 0;
|
||||
}
|
||||
else{
|
||||
loadAtPrevAct = (int) stateManager.getActivityState(prevAct, StateTypes.LOAD).toDouble();
|
||||
futurePicks = (int) stateManager.getActivityState(prevAct, StateTypes.FUTURE_PICKS).toDouble();
|
||||
pastDeliveries = (int) stateManager.getActivityState(prevAct, StateTypes.PAST_DELIVERIES).toDouble();
|
||||
loadAtPrevAct = (int) stateManager.getActivityState(prevAct, StateIdFactory.LOAD).toDouble();
|
||||
futurePicks = (int) stateManager.getActivityState(prevAct, StateIdFactory.FUTURE_PICKS).toDouble();
|
||||
pastDeliveries = (int) stateManager.getActivityState(prevAct, StateIdFactory.PAST_DELIVERIES).toDouble();
|
||||
}
|
||||
if(newAct instanceof PickupActivity || newAct instanceof ServiceActivity){
|
||||
if(loadAtPrevAct + newAct.getCapacityDemand() + futurePicks > iFacts.getNewVehicle().getCapacity()){
|
||||
|
|
@ -1,8 +1,5 @@
|
|||
package algorithms.constraints;
|
||||
package algorithms;
|
||||
|
||||
import algorithms.InsertionContext;
|
||||
import algorithms.StateManager;
|
||||
import algorithms.StateTypes;
|
||||
import basics.route.DeliveryActivity;
|
||||
import basics.route.PickupActivity;
|
||||
import basics.route.ServiceActivity;
|
||||
|
|
@ -28,14 +25,14 @@ public class HardPickupAndDeliveryBackhaulActivityLevelConstraint implements Har
|
|||
int futurePicks;
|
||||
int pastDeliveries;
|
||||
if(prevAct instanceof Start){
|
||||
loadAtPrevAct = (int)stateManager.getRouteState(iFacts.getRoute(), StateTypes.LOAD_AT_DEPOT).toDouble();
|
||||
futurePicks = (int)stateManager.getRouteState(iFacts.getRoute(), StateTypes.LOAD).toDouble();
|
||||
loadAtPrevAct = (int)stateManager.getRouteState(iFacts.getRoute(), StateIdFactory.LOAD_AT_DEPOT).toDouble();
|
||||
futurePicks = (int)stateManager.getRouteState(iFacts.getRoute(), StateIdFactory.LOAD).toDouble();
|
||||
pastDeliveries = 0;
|
||||
}
|
||||
else{
|
||||
loadAtPrevAct = (int) stateManager.getActivityState(prevAct, StateTypes.LOAD).toDouble();
|
||||
futurePicks = (int) stateManager.getActivityState(prevAct, StateTypes.FUTURE_PICKS).toDouble();
|
||||
pastDeliveries = (int) stateManager.getActivityState(prevAct, StateTypes.PAST_DELIVERIES).toDouble();
|
||||
loadAtPrevAct = (int) stateManager.getActivityState(prevAct, StateIdFactory.LOAD).toDouble();
|
||||
futurePicks = (int) stateManager.getActivityState(prevAct, StateIdFactory.FUTURE_PICKS).toDouble();
|
||||
pastDeliveries = (int) stateManager.getActivityState(prevAct, StateIdFactory.PAST_DELIVERIES).toDouble();
|
||||
}
|
||||
if(newAct instanceof PickupActivity || newAct instanceof ServiceActivity){
|
||||
if(loadAtPrevAct + newAct.getCapacityDemand() + futurePicks > iFacts.getNewVehicle().getCapacity()){
|
||||
|
|
@ -1,8 +1,5 @@
|
|||
package algorithms.constraints;
|
||||
package algorithms;
|
||||
|
||||
import algorithms.InsertionContext;
|
||||
import algorithms.StateManager;
|
||||
import algorithms.StateTypes;
|
||||
import basics.Delivery;
|
||||
import basics.Pickup;
|
||||
import basics.Service;
|
||||
|
|
@ -25,13 +22,13 @@ public class HardPickupAndDeliveryLoadConstraint implements HardRouteLevelConstr
|
|||
@Override
|
||||
public boolean fulfilled(InsertionContext insertionContext) {
|
||||
if(insertionContext.getJob() instanceof Delivery){
|
||||
int loadAtDepot = (int) stateManager.getRouteState(insertionContext.getRoute(), StateTypes.LOAD_AT_DEPOT).toDouble();
|
||||
int loadAtDepot = (int) stateManager.getRouteState(insertionContext.getRoute(), StateIdFactory.LOAD_AT_DEPOT).toDouble();
|
||||
if(loadAtDepot + insertionContext.getJob().getCapacityDemand() > insertionContext.getNewVehicle().getCapacity()){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(insertionContext.getJob() instanceof Pickup || insertionContext.getJob() instanceof Service){
|
||||
int loadAtEnd = (int) stateManager.getRouteState(insertionContext.getRoute(), StateTypes.LOAD).toDouble();
|
||||
int loadAtEnd = (int) stateManager.getRouteState(insertionContext.getRoute(), StateIdFactory.LOAD).toDouble();
|
||||
if(loadAtEnd + insertionContext.getJob().getCapacityDemand() > insertionContext.getNewVehicle().getCapacity()){
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
package algorithms.constraints;
|
||||
package algorithms;
|
||||
|
||||
import algorithms.InsertionContext;
|
||||
|
||||
public interface HardRouteLevelConstraint {
|
||||
|
||||
|
|
@ -1,9 +1,8 @@
|
|||
package algorithms.constraints;
|
||||
package algorithms;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import algorithms.InsertionContext;
|
||||
|
||||
class HardRouteLevelConstraintManager implements HardRouteLevelConstraint {
|
||||
|
||||
|
|
@ -1,11 +1,7 @@
|
|||
package algorithms.constraints;
|
||||
package algorithms;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import algorithms.CalculationUtils;
|
||||
import algorithms.InsertionContext;
|
||||
import algorithms.StateManager;
|
||||
import algorithms.StateTypes;
|
||||
import basics.costs.VehicleRoutingTransportCosts;
|
||||
import basics.route.TourActivity;
|
||||
|
||||
|
|
@ -32,14 +28,14 @@ import basics.route.TourActivity;
|
|||
public boolean fulfilled(InsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime) {
|
||||
// log.info("check insertion of " + newAct + " between " + prevAct + " and " + nextAct + ". prevActDepTime=" + prevActDepTime);
|
||||
double arrTimeAtNewAct = prevActDepTime + routingCosts.getTransportTime(prevAct.getLocationId(), newAct.getLocationId(), prevActDepTime, iFacts.getNewDriver(), iFacts.getNewVehicle());
|
||||
double latestArrTimeAtNewAct = states.getActivityState(newAct, StateTypes.LATEST_OPERATION_START_TIME).toDouble();
|
||||
double latestArrTimeAtNewAct = states.getActivityState(newAct, StateIdFactory.LATEST_OPERATION_START_TIME).toDouble();
|
||||
if(arrTimeAtNewAct > latestArrTimeAtNewAct){
|
||||
return false;
|
||||
}
|
||||
// log.info(newAct + " arrTime=" + arrTimeAtNewAct);
|
||||
double endTimeAtNewAct = CalculationUtils.getActivityEndTime(arrTimeAtNewAct, newAct);
|
||||
double arrTimeAtNextAct = endTimeAtNewAct + routingCosts.getTransportTime(newAct.getLocationId(), nextAct.getLocationId(), endTimeAtNewAct, iFacts.getNewDriver(), iFacts.getNewVehicle());
|
||||
double latestArrTimeAtNextAct = states.getActivityState(nextAct, StateTypes.LATEST_OPERATION_START_TIME).toDouble();
|
||||
double latestArrTimeAtNextAct = states.getActivityState(nextAct, StateIdFactory.LATEST_OPERATION_START_TIME).toDouble();
|
||||
if(arrTimeAtNextAct > latestArrTimeAtNextAct){
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
package algorithms.states;
|
||||
package algorithms;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import algorithms.StateManagerImpl;
|
||||
import algorithms.StateManagerImpl.StateImpl;
|
||||
import algorithms.StateTypes;
|
||||
import basics.Delivery;
|
||||
import basics.Job;
|
||||
import basics.Pickup;
|
||||
|
|
@ -52,8 +50,8 @@ public class InitializeLoadsAtStartAndEndOfRouteWhenInsertionStarts implements I
|
|||
loadAtEnd += j.getCapacityDemand();
|
||||
}
|
||||
}
|
||||
stateManager.putRouteState(route, StateTypes.LOAD_AT_DEPOT, new StateImpl(loadAtDepot));
|
||||
stateManager.putRouteState(route, StateTypes.LOAD, new StateImpl(loadAtEnd));
|
||||
stateManager.putRouteState(route, StateIdFactory.LOAD_AT_DEPOT, new StateImpl(loadAtDepot));
|
||||
stateManager.putRouteState(route, StateIdFactory.LOAD, new StateImpl(loadAtEnd));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -27,7 +27,6 @@ import java.util.concurrent.ExecutorService;
|
|||
import org.apache.commons.configuration.HierarchicalConfiguration;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import algorithms.constraints.ConstraintManager;
|
||||
import basics.VehicleRoutingProblem;
|
||||
import basics.algo.InsertionListener;
|
||||
import basics.algo.VehicleRoutingAlgorithmListeners.PrioritizedVRAListener;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
******************************************************************************/
|
||||
package algorithms;
|
||||
|
||||
import algorithms.constraints.HardActivityLevelConstraint;
|
||||
import basics.costs.VehicleRoutingActivityCosts;
|
||||
import basics.costs.VehicleRoutingTransportCosts;
|
||||
import basics.route.TourActivity;
|
||||
|
|
|
|||
119
jsprit-core/src/main/java/algorithms/StateIdFactory.java
Normal file
119
jsprit-core/src/main/java/algorithms/StateIdFactory.java
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2013 Stefan Schroeder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* Contributors:
|
||||
* Stefan Schroeder - initial API and implementation
|
||||
******************************************************************************/
|
||||
package algorithms;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import algorithms.StateManager.StateId;
|
||||
|
||||
public class StateIdFactory {
|
||||
// public final static String LOAD = "load";
|
||||
|
||||
// public final static String LOAD_AT_DEPOT = "loadAtDepot";
|
||||
|
||||
// public final static String DURATION = "duration";
|
||||
|
||||
// public final static String LATEST_OPERATION_START_TIME = "latestOST";
|
||||
|
||||
// public final static String EARLIEST_OPERATION_START_TIME = "earliestOST";
|
||||
|
||||
// public static final String COSTS = "costs";
|
||||
|
||||
// public final static String FUTURE_PICKS = "futurePicks";
|
||||
|
||||
// public final static String PAST_DELIVERIES = "pastDeliveries";
|
||||
|
||||
final static StateId LOAD = new StateIdImpl("load");
|
||||
|
||||
final static StateId COSTS = new StateIdImpl("costs");
|
||||
|
||||
final static StateId LOAD_AT_DEPOT = new StateIdImpl("loadAtDepot");
|
||||
|
||||
final static StateId DURATION = new StateIdImpl("duration");
|
||||
|
||||
final static StateId LATEST_OPERATION_START_TIME = new StateIdImpl("latestOST");
|
||||
|
||||
final static StateId EARLIEST_OPERATION_START_TIME = new StateIdImpl("earliestOST");
|
||||
|
||||
final static StateId FUTURE_PICKS = new StateIdImpl("futurePicks");
|
||||
|
||||
final static StateId PAST_DELIVERIES = new StateIdImpl("pastDeliveries");
|
||||
|
||||
final static List<String> reservedIds = Arrays.asList("load","costs","loadAtDepot","duration","latestOST","earliestOST"
|
||||
,"futurePicks","pastDeliveries");
|
||||
|
||||
|
||||
public static StateId createId(String name){
|
||||
if(reservedIds.contains(name)){ throwException(name); }
|
||||
return new StateIdImpl(name);
|
||||
}
|
||||
|
||||
private static void throwException(String name) {
|
||||
throw new IllegalStateException("state-id with name '" + name + "' cannot be created. it is already reserved internally.");
|
||||
}
|
||||
|
||||
|
||||
static class StateIdImpl implements StateId {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
StateIdImpl other = (StateIdImpl) obj;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private String name;
|
||||
|
||||
public StateIdImpl(String name) {
|
||||
super();
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -25,12 +25,16 @@ import basics.route.VehicleRoute;
|
|||
|
||||
public interface StateManager {
|
||||
|
||||
interface State {
|
||||
public interface StateId {
|
||||
|
||||
}
|
||||
|
||||
public interface State {
|
||||
double toDouble();
|
||||
}
|
||||
|
||||
State getActivityState(TourActivity act, String stateType);
|
||||
State getActivityState(TourActivity act, StateId stateId);
|
||||
|
||||
State getRouteState(VehicleRoute route, String stateType);
|
||||
State getRouteState(VehicleRoute route, StateId stateId);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import java.util.Collection;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import algorithms.StateManager.State;
|
||||
import basics.Job;
|
||||
import basics.VehicleRoutingProblem;
|
||||
import basics.VehicleRoutingProblemSolution;
|
||||
|
|
@ -44,7 +43,7 @@ public class StateManagerImpl implements StateManager, IterationStartsListener,
|
|||
|
||||
private interface States {
|
||||
|
||||
State getState(String key);
|
||||
State getState(StateId key);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -65,14 +64,14 @@ public class StateManagerImpl implements StateManager, IterationStartsListener,
|
|||
|
||||
private static class StatesImpl implements States{
|
||||
|
||||
private Map<String,State> states = new HashMap<String, State>();
|
||||
private Map<StateId,State> states = new HashMap<StateId, State>();
|
||||
|
||||
public void putState(String key, State state) {
|
||||
public void putState(StateId key, State state) {
|
||||
states.put(key, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public State getState(String key) {
|
||||
public State getState(StateId key) {
|
||||
return states.get(key);
|
||||
}
|
||||
|
||||
|
|
@ -115,65 +114,65 @@ public class StateManagerImpl implements StateManager, IterationStartsListener,
|
|||
}
|
||||
|
||||
@Override
|
||||
public State getActivityState(TourActivity act, String stateType) {
|
||||
public State getActivityState(TourActivity act, StateId stateId) {
|
||||
if(!activityStates.containsKey(act)){
|
||||
return getDefaultActState(stateType,act);
|
||||
return getDefaultActState(stateId,act);
|
||||
}
|
||||
StatesImpl actStates = (StatesImpl) activityStates.get(act);
|
||||
State state = actStates.getState(stateType);
|
||||
State state = actStates.getState(stateId);
|
||||
if(state == null){
|
||||
return getDefaultActState(stateType,act);
|
||||
return getDefaultActState(stateId,act);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
public void putActivityState(TourActivity act, String stateType, State state){
|
||||
public void putActivityState(TourActivity act, StateId stateId, State state){
|
||||
if(!activityStates.containsKey(act)){
|
||||
activityStates.put(act, new StatesImpl());
|
||||
}
|
||||
StatesImpl actStates = (StatesImpl) activityStates.get(act);
|
||||
actStates.putState(stateType, state);
|
||||
actStates.putState(stateId, state);
|
||||
}
|
||||
|
||||
|
||||
private State getDefaultActState(String stateType, TourActivity act){
|
||||
if(stateType.equals(StateTypes.LOAD)) return new StateImpl(0);
|
||||
if(stateType.equals(StateTypes.COSTS)) return new StateImpl(0);
|
||||
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);
|
||||
private State getDefaultActState(StateId stateId, TourActivity act){
|
||||
if(stateId.equals(StateIdFactory.LOAD)) return new StateImpl(0);
|
||||
if(stateId.equals(StateIdFactory.COSTS)) return new StateImpl(0);
|
||||
if(stateId.equals(StateIdFactory.DURATION)) return new StateImpl(0);
|
||||
if(stateId.equals(StateIdFactory.EARLIEST_OPERATION_START_TIME)) return new StateImpl(act.getTheoreticalEarliestOperationStartTime());
|
||||
if(stateId.equals(StateIdFactory.LATEST_OPERATION_START_TIME)) return new StateImpl(act.getTheoreticalLatestOperationStartTime());
|
||||
if(stateId.equals(StateIdFactory.FUTURE_PICKS)) return new StateImpl(0);
|
||||
if(stateId.equals(StateIdFactory.PAST_DELIVERIES)) return new StateImpl(0);
|
||||
return null;
|
||||
}
|
||||
|
||||
private State getDefaultRouteState(String stateType, VehicleRoute route){
|
||||
if(stateType.equals(StateTypes.LOAD)) return new StateImpl(0);
|
||||
if(stateType.equals(StateTypes.LOAD_AT_DEPOT)) return new StateImpl(0);
|
||||
if(stateType.equals(StateTypes.COSTS)) return new StateImpl(0);
|
||||
if(stateType.equals(StateTypes.DURATION)) return new StateImpl(0);
|
||||
private State getDefaultRouteState(StateId stateId, VehicleRoute route){
|
||||
if(stateId.equals(StateIdFactory.LOAD)) return new StateImpl(0);
|
||||
if(stateId.equals(StateIdFactory.LOAD_AT_DEPOT)) return new StateImpl(0);
|
||||
if(stateId.equals(StateIdFactory.COSTS)) return new StateImpl(0);
|
||||
if(stateId.equals(StateIdFactory.DURATION)) return new StateImpl(0);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public State getRouteState(VehicleRoute route, String stateType) {
|
||||
public State getRouteState(VehicleRoute route, StateId stateId) {
|
||||
if(!vehicleRouteStates.containsKey(route)){
|
||||
return getDefaultRouteState(stateType,route);
|
||||
return getDefaultRouteState(stateId,route);
|
||||
}
|
||||
StatesImpl routeStates = (StatesImpl) vehicleRouteStates.get(route);
|
||||
State state = routeStates.getState(stateType);
|
||||
State state = routeStates.getState(stateId);
|
||||
if(state == null){
|
||||
return getDefaultRouteState(stateType, route);
|
||||
return getDefaultRouteState(stateId, route);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
public void putRouteState(VehicleRoute route, String stateType, State state){
|
||||
public void putRouteState(VehicleRoute route, StateId stateId, State state){
|
||||
if(!vehicleRouteStates.containsKey(route)){
|
||||
vehicleRouteStates.put(route, new StatesImpl());
|
||||
}
|
||||
StatesImpl routeStates = (StatesImpl) vehicleRouteStates.get(route);
|
||||
routeStates.putState(stateType, state);
|
||||
routeStates.putState(stateId, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,39 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2013 Stefan Schroeder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* Contributors:
|
||||
* Stefan Schroeder - initial API and implementation
|
||||
******************************************************************************/
|
||||
package algorithms;
|
||||
|
||||
public class StateTypes {
|
||||
public final static String LOAD = "load";
|
||||
|
||||
public final static String LOAD_AT_DEPOT = "loadAtDepot";
|
||||
|
||||
public final static String DURATION = "duration";
|
||||
|
||||
public final static String LATEST_OPERATION_START_TIME = "latestOST";
|
||||
|
||||
public final static String EARLIEST_OPERATION_START_TIME = "earliestOST";
|
||||
|
||||
public static final String COSTS = "costs";
|
||||
|
||||
public final static String FUTURE_PICKS = "futurePicks";
|
||||
|
||||
public final static String PAST_DELIVERIES = "pastDeliveries";
|
||||
}
|
||||
|
|
@ -18,17 +18,12 @@
|
|||
* Contributors:
|
||||
* Stefan Schroeder - initial API and implementation
|
||||
******************************************************************************/
|
||||
package algorithms.states;
|
||||
package algorithms;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
import algorithms.ActivityVisitor;
|
||||
import algorithms.ReverseActivityVisitor;
|
||||
import algorithms.ReverseRouteActivityVisitor;
|
||||
import algorithms.RouteActivityVisitor;
|
||||
import algorithms.StateManagerImpl;
|
||||
import basics.Job;
|
||||
import basics.VehicleRoutingProblem;
|
||||
import basics.VehicleRoutingProblemSolution;
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
package algorithms.states;
|
||||
package algorithms;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import algorithms.ActivityVisitor;
|
||||
import basics.costs.ForwardTransportTime;
|
||||
import basics.route.TourActivity;
|
||||
import basics.route.VehicleRoute;
|
||||
|
|
@ -1,11 +1,8 @@
|
|||
package algorithms.states;
|
||||
package algorithms;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import algorithms.ActivityVisitor;
|
||||
import algorithms.StateManagerImpl;
|
||||
import algorithms.StateManagerImpl.StateImpl;
|
||||
import algorithms.StateTypes;
|
||||
import basics.costs.ForwardTransportCost;
|
||||
import basics.costs.VehicleRoutingActivityCosts;
|
||||
import basics.costs.VehicleRoutingTransportCosts;
|
||||
|
|
@ -84,7 +81,7 @@ public class UpdateCostsAtAllLevels implements ActivityVisitor{
|
|||
totalOperationCost += transportCost;
|
||||
totalOperationCost += actCost;
|
||||
|
||||
states.putActivityState(act, StateTypes.COSTS, new StateImpl(totalOperationCost));
|
||||
states.putActivityState(act, StateIdFactory.COSTS, new StateImpl(totalOperationCost));
|
||||
|
||||
prevAct = act;
|
||||
startTimeAtPrevAct = timeTracker.getActEndTime();
|
||||
|
|
@ -102,7 +99,7 @@ public class UpdateCostsAtAllLevels implements ActivityVisitor{
|
|||
totalOperationCost += transportCost;
|
||||
totalOperationCost += actCost;
|
||||
|
||||
states.putRouteState(vehicleRoute, StateTypes.COSTS, new StateImpl(totalOperationCost));
|
||||
states.putRouteState(vehicleRoute, StateIdFactory.COSTS, new StateImpl(totalOperationCost));
|
||||
|
||||
//this is rather strange and likely to change
|
||||
vehicleRoute.getVehicleRouteCostCalculator().price(vehicleRoute.getDriver());
|
||||
|
|
@ -1,11 +1,8 @@
|
|||
package algorithms.states;
|
||||
package algorithms;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import algorithms.RouteActivityVisitor;
|
||||
import algorithms.StateManagerImpl;
|
||||
import algorithms.StateManagerImpl.StateImpl;
|
||||
import algorithms.StateTypes;
|
||||
import basics.Job;
|
||||
import basics.algo.InsertionEndsListener;
|
||||
import basics.algo.InsertionStartsListener;
|
||||
|
|
@ -32,9 +29,9 @@ public class UpdateCostsAtRouteLevel implements JobInsertedListener, InsertionSt
|
|||
@Override
|
||||
public void informJobInserted(Job job2insert, VehicleRoute inRoute, double additionalCosts, double additionalTime) {
|
||||
// inRoute.getVehicleRouteCostCalculator().addTransportCost(additionalCosts);
|
||||
double oldCosts = states.getRouteState(inRoute, StateTypes.COSTS).toDouble();
|
||||
double oldCosts = states.getRouteState(inRoute, StateIdFactory.COSTS).toDouble();
|
||||
oldCosts += additionalCosts;
|
||||
states.putRouteState(inRoute, StateTypes.COSTS, new StateImpl(oldCosts));
|
||||
states.putRouteState(inRoute, StateIdFactory.COSTS, new StateImpl(oldCosts));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -55,7 +52,7 @@ public class UpdateCostsAtRouteLevel implements JobInsertedListener, InsertionSt
|
|||
for(VehicleRoute route : vehicleRoutes){
|
||||
if(route.isEmpty()) continue;
|
||||
route.getVehicleRouteCostCalculator().reset();
|
||||
route.getVehicleRouteCostCalculator().addOtherCost(states.getRouteState(route, StateTypes.COSTS).toDouble());
|
||||
route.getVehicleRouteCostCalculator().addOtherCost(states.getRouteState(route, StateIdFactory.COSTS).toDouble());
|
||||
route.getVehicleRouteCostCalculator().price(route.getVehicle());
|
||||
// forwardInTime.iterate(route);
|
||||
}
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
package algorithms.states;
|
||||
package algorithms;
|
||||
|
||||
import algorithms.ActivityVisitor;
|
||||
import algorithms.StateManagerImpl;
|
||||
import algorithms.StateManagerImpl.StateImpl;
|
||||
import algorithms.StateTypes;
|
||||
import basics.costs.VehicleRoutingTransportCosts;
|
||||
import basics.route.TourActivity;
|
||||
import basics.route.VehicleRoute;
|
||||
|
|
@ -28,7 +25,7 @@ public class UpdateEarliestStartTimeWindowAtActLocations implements ActivityVisi
|
|||
@Override
|
||||
public void visit(TourActivity activity) {
|
||||
timeTracker.visit(activity);
|
||||
states.putActivityState(activity, StateTypes.EARLIEST_OPERATION_START_TIME, new StateImpl(Math.max(timeTracker.getActArrTime(), activity.getTheoreticalEarliestOperationStartTime())));
|
||||
states.putActivityState(activity, StateIdFactory.EARLIEST_OPERATION_START_TIME, new StateImpl(Math.max(timeTracker.getActArrTime(), activity.getTheoreticalEarliestOperationStartTime())));
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
package algorithms.states;
|
||||
package algorithms;
|
||||
|
||||
import algorithms.ReverseActivityVisitor;
|
||||
import algorithms.StateManagerImpl;
|
||||
import algorithms.StateManagerImpl.StateImpl;
|
||||
import algorithms.StateTypes;
|
||||
import basics.route.PickupActivity;
|
||||
import basics.route.ServiceActivity;
|
||||
import basics.route.TourActivity;
|
||||
|
|
@ -26,7 +23,7 @@ public class UpdateFuturePickupsAtActivityLevel implements ReverseActivityVisito
|
|||
|
||||
@Override
|
||||
public void visit(TourActivity act) {
|
||||
stateManager.putActivityState(act, StateTypes.FUTURE_PICKS, new StateImpl(futurePicks));
|
||||
stateManager.putActivityState(act, StateIdFactory.FUTURE_PICKS, new StateImpl(futurePicks));
|
||||
if(act instanceof PickupActivity || act instanceof ServiceActivity){
|
||||
futurePicks += act.getCapacityDemand();
|
||||
}
|
||||
|
|
@ -1,11 +1,8 @@
|
|||
package algorithms.states;
|
||||
package algorithms;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import algorithms.ReverseActivityVisitor;
|
||||
import algorithms.StateManagerImpl;
|
||||
import algorithms.StateManagerImpl.StateImpl;
|
||||
import algorithms.StateTypes;
|
||||
import basics.costs.VehicleRoutingTransportCosts;
|
||||
import basics.route.TourActivity;
|
||||
import basics.route.VehicleRoute;
|
||||
|
|
@ -42,7 +39,7 @@ public class UpdateLatestOperationStartTimeAtActLocations implements ReverseActi
|
|||
double potentialLatestArrivalTimeAtCurrAct = latestArrTimeAtPrevAct - transportCosts.getBackwardTransportTime(activity.getLocationId(), prevAct.getLocationId(), latestArrTimeAtPrevAct, route.getDriver(),route.getVehicle()) - activity.getOperationTime();
|
||||
double latestArrivalTime = Math.min(activity.getTheoreticalLatestOperationStartTime(), potentialLatestArrivalTimeAtCurrAct);
|
||||
|
||||
states.putActivityState(activity, StateTypes.LATEST_OPERATION_START_TIME, new StateImpl(latestArrivalTime));
|
||||
states.putActivityState(activity, StateIdFactory.LATEST_OPERATION_START_TIME, new StateImpl(latestArrivalTime));
|
||||
|
||||
latestArrTimeAtPrevAct = latestArrivalTime;
|
||||
prevAct = activity;
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
package algorithms.states;
|
||||
package algorithms;
|
||||
|
||||
import algorithms.ActivityVisitor;
|
||||
import algorithms.StateManagerImpl;
|
||||
import algorithms.StateManagerImpl.StateImpl;
|
||||
import algorithms.StateTypes;
|
||||
import basics.route.TourActivity;
|
||||
import basics.route.VehicleRoute;
|
||||
|
||||
|
|
@ -49,14 +46,14 @@ public class UpdateLoadAtActivityLevel implements ActivityVisitor {
|
|||
|
||||
@Override
|
||||
public void begin(VehicleRoute route) {
|
||||
currentLoad = (int) stateManager.getRouteState(route, StateTypes.LOAD_AT_DEPOT).toDouble();
|
||||
currentLoad = (int) stateManager.getRouteState(route, StateIdFactory.LOAD_AT_DEPOT).toDouble();
|
||||
this.route = route;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(TourActivity act) {
|
||||
currentLoad += act.getCapacityDemand();
|
||||
stateManager.putActivityState(act, StateTypes.LOAD, new StateImpl(currentLoad));
|
||||
stateManager.putActivityState(act, StateIdFactory.LOAD, new StateImpl(currentLoad));
|
||||
assert currentLoad <= route.getVehicle().getCapacity() : "currentLoad at activity must not be > vehicleCapacity";
|
||||
assert currentLoad >= 0 : "currentLoad at act must not be < 0";
|
||||
}
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
package algorithms.states;
|
||||
package algorithms;
|
||||
|
||||
import algorithms.ActivityVisitor;
|
||||
import algorithms.StateManagerImpl;
|
||||
import algorithms.StateManagerImpl.StateImpl;
|
||||
import algorithms.StateTypes;
|
||||
import basics.route.TourActivity;
|
||||
import basics.route.VehicleRoute;
|
||||
|
||||
|
|
@ -28,12 +25,12 @@ public class UpdateLoadAtAllLevels implements ActivityVisitor{
|
|||
@Override
|
||||
public void visit(TourActivity activity) {
|
||||
load += (double)activity.getCapacityDemand();
|
||||
states.putActivityState(activity, StateTypes.LOAD, new StateImpl(load));
|
||||
states.putActivityState(activity, StateIdFactory.LOAD, new StateImpl(load));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
states.putRouteState(vehicleRoute, StateTypes.LOAD, new StateImpl(load));
|
||||
states.putRouteState(vehicleRoute, StateIdFactory.LOAD, new StateImpl(load));
|
||||
load=0;
|
||||
vehicleRoute = null;
|
||||
}
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
package algorithms.states;
|
||||
package algorithms;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import algorithms.StateManagerImpl;
|
||||
import algorithms.StateManagerImpl.StateImpl;
|
||||
import algorithms.StateTypes;
|
||||
import basics.Job;
|
||||
import basics.Service;
|
||||
import basics.algo.InsertionStartsListener;
|
||||
|
|
@ -37,8 +35,8 @@ public class UpdateLoadAtRouteLevel implements JobInsertedListener, InsertionSta
|
|||
if(!(job2insert instanceof Service)){
|
||||
return;
|
||||
}
|
||||
double oldLoad = states.getRouteState(inRoute, StateTypes.LOAD).toDouble();
|
||||
states.putRouteState(inRoute, StateTypes.LOAD, new StateImpl(oldLoad + job2insert.getCapacityDemand()));
|
||||
double oldLoad = states.getRouteState(inRoute, StateIdFactory.LOAD).toDouble();
|
||||
states.putRouteState(inRoute, StateIdFactory.LOAD, new StateImpl(oldLoad + job2insert.getCapacityDemand()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -48,7 +46,7 @@ public class UpdateLoadAtRouteLevel implements JobInsertedListener, InsertionSta
|
|||
for(Job j : route.getTourActivities().getJobs()){
|
||||
load += j.getCapacityDemand();
|
||||
}
|
||||
states.putRouteState(route, StateTypes.LOAD, new StateImpl(load));
|
||||
states.putRouteState(route, StateIdFactory.LOAD, new StateImpl(load));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
package algorithms.states;
|
||||
package algorithms;
|
||||
|
||||
import algorithms.StateManagerImpl;
|
||||
import algorithms.StateManagerImpl.StateImpl;
|
||||
import algorithms.StateTypes;
|
||||
import basics.Delivery;
|
||||
import basics.Job;
|
||||
import basics.Pickup;
|
||||
|
|
@ -40,14 +38,14 @@ public class UpdateLoadsAtStartAndEndOfRouteWhenJobHasBeenInserted implements Jo
|
|||
@Override
|
||||
public void informJobInserted(Job job2insert, VehicleRoute inRoute, double additionalCosts, double additionalTime) {
|
||||
if(job2insert instanceof Delivery){
|
||||
int loadAtDepot = (int) stateManager.getRouteState(inRoute, StateTypes.LOAD_AT_DEPOT).toDouble();
|
||||
int loadAtDepot = (int) stateManager.getRouteState(inRoute, StateIdFactory.LOAD_AT_DEPOT).toDouble();
|
||||
// log.info("loadAtDepot="+loadAtDepot);
|
||||
stateManager.putRouteState(inRoute, StateTypes.LOAD_AT_DEPOT, new StateImpl(loadAtDepot + job2insert.getCapacityDemand()));
|
||||
stateManager.putRouteState(inRoute, StateIdFactory.LOAD_AT_DEPOT, new StateImpl(loadAtDepot + job2insert.getCapacityDemand()));
|
||||
}
|
||||
else if(job2insert instanceof Pickup || job2insert instanceof Service){
|
||||
int loadAtEnd = (int) stateManager.getRouteState(inRoute, StateTypes.LOAD).toDouble();
|
||||
int loadAtEnd = (int) stateManager.getRouteState(inRoute, StateIdFactory.LOAD).toDouble();
|
||||
// log.info("loadAtEnd="+loadAtEnd);
|
||||
stateManager.putRouteState(inRoute, StateTypes.LOAD, new StateImpl(loadAtEnd + job2insert.getCapacityDemand()));
|
||||
stateManager.putRouteState(inRoute, StateIdFactory.LOAD, new StateImpl(loadAtEnd + job2insert.getCapacityDemand()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
package algorithms.states;
|
||||
package algorithms;
|
||||
|
||||
import algorithms.ActivityVisitor;
|
||||
import algorithms.StateManagerImpl;
|
||||
import algorithms.StateManagerImpl.StateImpl;
|
||||
import algorithms.StateTypes;
|
||||
import basics.route.DeliveryActivity;
|
||||
import basics.route.TourActivity;
|
||||
import basics.route.VehicleRoute;
|
||||
|
|
@ -28,7 +25,7 @@ public class UpdateOccuredDeliveriesAtActivityLevel implements ActivityVisitor {
|
|||
if(act instanceof DeliveryActivity){
|
||||
deliveries += Math.abs(act.getCapacityDemand());
|
||||
}
|
||||
stateManager.putActivityState(act, StateTypes.PAST_DELIVERIES, new StateImpl(deliveries));
|
||||
stateManager.putActivityState(act, StateIdFactory.PAST_DELIVERIES, new StateImpl(deliveries));
|
||||
assert deliveries >= 0 : "deliveries < 0";
|
||||
assert deliveries <= route.getVehicle().getCapacity() : "deliveries > vehicleCap";
|
||||
}
|
||||
|
|
@ -45,22 +45,9 @@ import algorithms.acceptors.AcceptNewIfBetterThanWorst;
|
|||
import algorithms.acceptors.AcceptNewRemoveFirst;
|
||||
import algorithms.acceptors.SchrimpfAcceptance;
|
||||
import algorithms.acceptors.SolutionAcceptor;
|
||||
import algorithms.constraints.ConstraintManager;
|
||||
import algorithms.constraints.HardPickupAndDeliveryActivityLevelConstraint;
|
||||
import algorithms.constraints.HardPickupAndDeliveryBackhaulActivityLevelConstraint;
|
||||
import algorithms.constraints.HardPickupAndDeliveryLoadConstraint;
|
||||
import algorithms.constraints.HardTimeWindowActivityLevelConstraint;
|
||||
import algorithms.selectors.SelectBest;
|
||||
import algorithms.selectors.SelectRandomly;
|
||||
import algorithms.selectors.SolutionSelector;
|
||||
import algorithms.states.InitializeLoadsAtStartAndEndOfRouteWhenInsertionStarts;
|
||||
import algorithms.states.UpdateActivityTimes;
|
||||
import algorithms.states.UpdateCostsAtAllLevels;
|
||||
import algorithms.states.UpdateFuturePickupsAtActivityLevel;
|
||||
import algorithms.states.UpdateLatestOperationStartTimeAtActLocations;
|
||||
import algorithms.states.UpdateLoadAtActivityLevel;
|
||||
import algorithms.states.UpdateLoadsAtStartAndEndOfRouteWhenJobHasBeenInserted;
|
||||
import algorithms.states.UpdateOccuredDeliveriesAtActivityLevel;
|
||||
import basics.VehicleRoutingAlgorithm;
|
||||
import basics.VehicleRoutingProblem;
|
||||
import basics.VehicleRoutingProblem.Constraint;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue