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
0730c465dc
commit
5530bc648a
9 changed files with 15 additions and 28 deletions
|
|
@ -21,7 +21,7 @@ public class HardPickupAndDeliveryActivityLevelConstraint implements HardActivit
|
|||
int futurePicks;
|
||||
int pastDeliveries;
|
||||
if(prevAct instanceof Start){
|
||||
loadAtPrevAct = (int)stateManager.getRouteState(iFacts.getRoute(), StateIdFactory.LOAD_AT_DEPOT).toDouble();
|
||||
loadAtPrevAct = (int)stateManager.getRouteState(iFacts.getRoute(), StateIdFactory.LOAD_AT_BEGINNING).toDouble();
|
||||
futurePicks = (int)stateManager.getRouteState(iFacts.getRoute(), StateIdFactory.LOAD).toDouble();
|
||||
pastDeliveries = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class HardPickupAndDeliveryBackhaulActivityLevelConstraint implements Har
|
|||
int futurePicks;
|
||||
int pastDeliveries;
|
||||
if(prevAct instanceof Start){
|
||||
loadAtPrevAct = (int)stateManager.getRouteState(iFacts.getRoute(), StateIdFactory.LOAD_AT_DEPOT).toDouble();
|
||||
loadAtPrevAct = (int)stateManager.getRouteState(iFacts.getRoute(), StateIdFactory.LOAD_AT_BEGINNING).toDouble();
|
||||
futurePicks = (int)stateManager.getRouteState(iFacts.getRoute(), StateIdFactory.LOAD).toDouble();
|
||||
pastDeliveries = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public class HardPickupAndDeliveryLoadConstraint implements HardRouteLevelConstr
|
|||
@Override
|
||||
public boolean fulfilled(InsertionContext insertionContext) {
|
||||
if(insertionContext.getJob() instanceof Delivery){
|
||||
int loadAtDepot = (int) stateManager.getRouteState(insertionContext.getRoute(), StateIdFactory.LOAD_AT_DEPOT).toDouble();
|
||||
int loadAtDepot = (int) stateManager.getRouteState(insertionContext.getRoute(), StateIdFactory.LOAD_AT_BEGINNING).toDouble();
|
||||
if(loadAtDepot + insertionContext.getJob().getCapacityDemand() > insertionContext.getNewVehicle().getCapacity()){
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public class InitializeLoadsAtStartAndEndOfRouteWhenInsertionStarts implements I
|
|||
loadAtEnd += j.getCapacityDemand();
|
||||
}
|
||||
}
|
||||
stateManager.putRouteState(route, StateIdFactory.LOAD_AT_DEPOT, new StateImpl(loadAtDepot));
|
||||
stateManager.putRouteState(route, StateIdFactory.LOAD_AT_BEGINNING, new StateImpl(loadAtDepot));
|
||||
stateManager.putRouteState(route, StateIdFactory.LOAD, new StateImpl(loadAtEnd));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,27 +26,14 @@ 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 LOAD_AT_BEGINNING = new StateIdImpl("loadAtBeginning");
|
||||
|
||||
final static StateId LOAD_AT_END = new StateIdImpl("loadAtEnd");
|
||||
|
||||
final static StateId DURATION = new StateIdImpl("duration");
|
||||
|
||||
|
|
@ -58,7 +45,7 @@ public class StateIdFactory {
|
|||
|
||||
final static StateId PAST_DELIVERIES = new StateIdImpl("pastDeliveries");
|
||||
|
||||
final static List<String> reservedIds = Arrays.asList("load","costs","loadAtDepot","duration","latestOST","earliestOST"
|
||||
final static List<String> reservedIds = Arrays.asList("load","costs","loadAtBeginning","loadAtEnd","duration","latestOST","earliestOST"
|
||||
,"futurePicks","pastDeliveries");
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ public class StateManagerImpl implements StateManager, IterationStartsListener,
|
|||
|
||||
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.LOAD_AT_BEGINNING)) return new StateImpl(0);
|
||||
if(stateId.equals(StateIdFactory.COSTS)) return new StateImpl(0);
|
||||
if(stateId.equals(StateIdFactory.DURATION)) return new StateImpl(0);
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class UpdateLoadAtActivityLevel implements ActivityVisitor {
|
|||
|
||||
@Override
|
||||
public void begin(VehicleRoute route) {
|
||||
currentLoad = (int) stateManager.getRouteState(route, StateIdFactory.LOAD_AT_DEPOT).toDouble();
|
||||
currentLoad = (int) stateManager.getRouteState(route, StateIdFactory.LOAD_AT_BEGINNING).toDouble();
|
||||
this.route = route;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@ 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, StateIdFactory.LOAD_AT_DEPOT).toDouble();
|
||||
int loadAtDepot = (int) stateManager.getRouteState(inRoute, StateIdFactory.LOAD_AT_BEGINNING).toDouble();
|
||||
// log.info("loadAtDepot="+loadAtDepot);
|
||||
stateManager.putRouteState(inRoute, StateIdFactory.LOAD_AT_DEPOT, new StateImpl(loadAtDepot + job2insert.getCapacityDemand()));
|
||||
stateManager.putRouteState(inRoute, StateIdFactory.LOAD_AT_BEGINNING, new StateImpl(loadAtDepot + job2insert.getCapacityDemand()));
|
||||
}
|
||||
else if(job2insert instanceof Pickup || job2insert instanceof Service){
|
||||
int loadAtEnd = (int) stateManager.getRouteState(inRoute, StateIdFactory.LOAD).toDouble();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue