private String getSizeString(Job job) { StringBuilder builder = new StringBuilder(); builder.append("("); boolean firstDim = true; for (int i = 0; i < job.getSize().getNuOfDimensions(); i++) { if (firstDim) { builder.append(String.valueOf(job.getSize().get(i))); firstDim = false; } else { builder.append(","); builder.append(String.valueOf(job.getSize().get(i))); } } builder.append(")"); return builder.toString(); }
@Override public void visit(TourActivity activity) { if (activity instanceof PickupActivity) { pickupCounter++; pickedUp = Capacity.addup(pickedUp, ((PickupActivity) activity).getJob().getSize()); if (activity instanceof PickupService) { deliverAtEndCounter++; } } else if (activity instanceof DeliveryActivity) { deliveryCounter++; delivered = Capacity.addup(delivered, ((DeliveryActivity) activity).getJob().getSize()); if (activity instanceof DeliverService) { pickupAtBeginningCounter++; } } }
@Override public void informJobInserted(Job job2insert, VehicleRoute inRoute, double additionalCosts, double additionalTime) { if (job2insert instanceof Delivery) { Capacity loadAtDepot = stateManager.getRouteState(inRoute, InternalStates.LOAD_AT_BEGINNING, Capacity.class); if (loadAtDepot == null) loadAtDepot = defaultValue; stateManager.putTypedInternalRouteState(inRoute, InternalStates.LOAD_AT_BEGINNING, Capacity.addup(loadAtDepot, job2insert.getSize())); } else if (job2insert instanceof Pickup || job2insert instanceof Service) { Capacity loadAtEnd = stateManager.getRouteState(inRoute, InternalStates.LOAD_AT_END, Capacity.class); if (loadAtEnd == null) loadAtEnd = defaultValue; stateManager.putTypedInternalRouteState(inRoute, InternalStates.LOAD_AT_END, Capacity.addup(loadAtEnd, job2insert.getSize())); } }
void insertionStarts(VehicleRoute route) { Capacity loadAtDepot = Capacity.Builder.newInstance().build(); Capacity loadAtEnd = Capacity.Builder.newInstance().build(); for (Job j : route.getTourActivities().getJobs()) { if (j instanceof Delivery) { loadAtDepot = Capacity.addup(loadAtDepot, j.getSize()); } else if (j instanceof Pickup || j instanceof Service) { loadAtEnd = Capacity.addup(loadAtEnd, j.getSize()); } } stateManager.putTypedInternalRouteState(route, InternalStates.LOAD_AT_BEGINNING, loadAtDepot); stateManager.putTypedInternalRouteState(route, InternalStates.LOAD_AT_END, loadAtEnd); }
@Override public boolean fulfilled(JobInsertionContext insertionContext) { Capacity maxLoadAtRoute = stateManager.getRouteState(insertionContext.getRoute(), InternalStates.MAXLOAD, Capacity.class); if (maxLoadAtRoute == null) maxLoadAtRoute = defaultValue; Capacity capacityDimensions = insertionContext.getNewVehicle().getType().getCapacityDimensions(); if (!maxLoadAtRoute.isLessOrEqual(capacityDimensions)) { return false; } if (insertionContext.getJob() instanceof Delivery) { Capacity loadAtDepot = stateManager.getRouteState(insertionContext.getRoute(), InternalStates.LOAD_AT_BEGINNING, Capacity.class); if (loadAtDepot == null) loadAtDepot = defaultValue; if (!Capacity.addup(loadAtDepot, insertionContext.getJob().getSize()).isLessOrEqual(capacityDimensions)) { return false; } } else if (insertionContext.getJob() instanceof Pickup || insertionContext.getJob() instanceof Service) { Capacity loadAtEnd = stateManager.getRouteState(insertionContext.getRoute(), InternalStates.LOAD_AT_END, Capacity.class); if (loadAtEnd == null) loadAtEnd = defaultValue; if (!Capacity.addup(loadAtEnd, insertionContext.getJob().getSize()).isLessOrEqual(capacityDimensions)) { return false; } } return true; }
@Override public double getCosts(JobInsertionContext insertionContext) { VehicleRoute route = insertionContext.getRoute(); Capacity currentLoad = getCurrentMaxLoadInRoute(route); Capacity load = Capacity.addup(currentLoad, insertionContext.getJob().getSize()); double currentRelFix = 0d; if (route.getVehicle() != null && !(route.getVehicle() instanceof VehicleImpl.NoVehicle)) { currentRelFix = route.getVehicle().getType().getVehicleCostParams().fix * Capacity.divide(currentLoad, route.getVehicle().getType().getCapacityDimensions()); } double newRelFix = insertionContext.getNewVehicle().getType().getVehicleCostParams().fix * (Capacity.divide(load, insertionContext.getNewVehicle().getType().getCapacityDimensions())); double decreasingRelativeFixedCosts = (1 - solutionCompletenessRatio) * (newRelFix - currentRelFix); return weightDeltaFixCost * solutionCompletenessRatio * decreasingRelativeFixedCosts; }
private String getSizeString(Job job) { StringBuilder builder = new StringBuilder(); builder.append("("); boolean firstDim = true; for (int i = 0; i < job.getSize().getNuOfDimensions(); i++) { if (firstDim) { builder.append(String.valueOf(job.getSize().get(i))); firstDim = false; } else { builder.append(","); builder.append(String.valueOf(job.getSize().get(i))); } } builder.append(")"); return builder.toString(); }
@Override public void visit(TourActivity activity) { if (activity instanceof PickupActivity) { pickupCounter++; pickedUp = Capacity.addup(pickedUp, ((PickupActivity) activity).getJob().getSize()); if (activity instanceof PickupService) { deliverAtEndCounter++; } } else if (activity instanceof DeliveryActivity) { deliveryCounter++; delivered = Capacity.addup(delivered, ((DeliveryActivity) activity).getJob().getSize()); if (activity instanceof DeliverService) { pickupAtBeginningCounter++; } } }
@Override public void informJobInserted(Job job2insert, VehicleRoute inRoute, double additionalCosts, double additionalTime) { if (job2insert instanceof Delivery) { Capacity loadAtDepot = stateManager.getRouteState(inRoute, InternalStates.LOAD_AT_BEGINNING, Capacity.class); if (loadAtDepot == null) loadAtDepot = defaultValue; stateManager.putTypedInternalRouteState(inRoute, InternalStates.LOAD_AT_BEGINNING, Capacity.addup(loadAtDepot, job2insert.getSize())); } else if (job2insert instanceof Pickup || job2insert instanceof Service) { Capacity loadAtEnd = stateManager.getRouteState(inRoute, InternalStates.LOAD_AT_END, Capacity.class); if (loadAtEnd == null) loadAtEnd = defaultValue; stateManager.putTypedInternalRouteState(inRoute, InternalStates.LOAD_AT_END, Capacity.addup(loadAtEnd, job2insert.getSize())); } }
void insertionStarts(VehicleRoute route) { Capacity loadAtDepot = Capacity.Builder.newInstance().build(); Capacity loadAtEnd = Capacity.Builder.newInstance().build(); for (Job j : route.getTourActivities().getJobs()) { if (j instanceof Delivery) { loadAtDepot = Capacity.addup(loadAtDepot, j.getSize()); } else if (j instanceof Pickup || j instanceof Service) { loadAtEnd = Capacity.addup(loadAtEnd, j.getSize()); } } stateManager.putTypedInternalRouteState(route, InternalStates.LOAD_AT_BEGINNING, loadAtDepot); stateManager.putTypedInternalRouteState(route, InternalStates.LOAD_AT_END, loadAtEnd); }
@Override public boolean fulfilled(JobInsertionContext insertionContext) { Capacity maxLoadAtRoute = stateManager.getRouteState(insertionContext.getRoute(), InternalStates.MAXLOAD, Capacity.class); if (maxLoadAtRoute == null) maxLoadAtRoute = defaultValue; Capacity capacityDimensions = insertionContext.getNewVehicle().getType().getCapacityDimensions(); if (!maxLoadAtRoute.isLessOrEqual(capacityDimensions)) { return false; } if (insertionContext.getJob() instanceof Delivery) { Capacity loadAtDepot = stateManager.getRouteState(insertionContext.getRoute(), InternalStates.LOAD_AT_BEGINNING, Capacity.class); if (loadAtDepot == null) loadAtDepot = defaultValue; if (!Capacity.addup(loadAtDepot, insertionContext.getJob().getSize()).isLessOrEqual(capacityDimensions)) { return false; } } else if (insertionContext.getJob() instanceof Pickup || insertionContext.getJob() instanceof Service) { Capacity loadAtEnd = stateManager.getRouteState(insertionContext.getRoute(), InternalStates.LOAD_AT_END, Capacity.class); if (loadAtEnd == null) loadAtEnd = defaultValue; if (!Capacity.addup(loadAtEnd, insertionContext.getJob().getSize()).isLessOrEqual(capacityDimensions)) { return false; } } return true; }
@Override public double getCosts(JobInsertionContext insertionContext) { VehicleRoute route = insertionContext.getRoute(); Capacity currentLoad = getCurrentMaxLoadInRoute(route); Capacity load = Capacity.addup(currentLoad, insertionContext.getJob().getSize()); double currentRelFix = 0d; if (route.getVehicle() != null && !(route.getVehicle() instanceof VehicleImpl.NoVehicle)) { currentRelFix = route.getVehicle().getType().getVehicleCostParams().fix * Capacity.divide(currentLoad, route.getVehicle().getType().getCapacityDimensions()); } double newRelFix = insertionContext.getNewVehicle().getType().getVehicleCostParams().fix * (Capacity.divide(load, insertionContext.getNewVehicle().getType().getCapacityDimensions())); double decreasingRelativeFixedCosts = (1 - solutionCompletenessRatio) * (newRelFix - currentRelFix); return weightDeltaFixCost * solutionCompletenessRatio * decreasingRelativeFixedCosts; }