1
0
Fork 0
mirror of https://github.com/graphhopper/jsprit.git synced 2020-01-24 07:45:05 +01:00

fix bug: when having problems with finite vehicles, locking and

unlocking was not consistent.

now it is
This commit is contained in:
oblonski 2013-06-18 05:15:57 +02:00
parent a48013bc0f
commit daf258e586
6 changed files with 14 additions and 19 deletions

View file

@ -51,10 +51,7 @@ final class BestInsertion extends AbstractInsertionStrategy{
private RouteAlgorithm routeAlgorithm;
private Map<String,VehicleRoute> experimentalPreferredRoute = new HashMap<String, VehicleRoute>();
public void setExperimentalPreferredRoute(Map<String, VehicleRoute> experimentalPreferredRoute) {
this.experimentalPreferredRoute = experimentalPreferredRoute;
}
private boolean allowUnassignedJobs = false;

View file

@ -112,7 +112,7 @@ class InsertionFactory {
//
// }
insertionStrategy.addListener(new RemoveEmptyVehicles());
insertionStrategy.addListener(new RemoveEmptyVehicles(vehicleFleetManager));
insertionStrategy.addListener(new ResetAndIniFleetManager(vehicleFleetManager));
insertionStrategy.addAllListener(insertionListeners);
// insertionStrategy.addListener(new FindCheaperVehicle(

View file

@ -34,6 +34,13 @@ class RemoveEmptyVehicles implements InsertionStartsListener, InsertionEndsListe
private static Logger log = Logger.getLogger(RemoveEmptyVehicles.class);
private VehicleFleetManager fleetManager;
RemoveEmptyVehicles(VehicleFleetManager fleetManager) {
super();
this.fleetManager = fleetManager;
}
@Override
public void informInsertionStarts(Collection<VehicleRoute> vehicleRoutes, int nOfJobs2Recreate) {
// List<VehicleRoute> routes = new ArrayList<VehicleRoute>(vehicleRoutes);
@ -51,7 +58,10 @@ class RemoveEmptyVehicles implements InsertionStartsListener, InsertionEndsListe
public void informInsertionEnds(Collection<VehicleRoute> vehicleRoutes) {
List<VehicleRoute> routes = new ArrayList<VehicleRoute>(vehicleRoutes);
for(VehicleRoute route : routes){
if(route.isEmpty()) { vehicleRoutes.remove(route); }
if(route.isEmpty()) {
fleetManager.unlock(route.getVehicle());
vehicleRoutes.remove(route);
}
}
}
}

View file

@ -42,12 +42,11 @@ class ResetAndIniFleetManager implements InsertionStartsListener{
public void informInsertionStarts(Collection<VehicleRoute> vehicleRoutes, int nOfJobs2Recreate) {
vehicleFleetManager.unlockAll();
for(VehicleRoute route : vehicleRoutes){
if(!route.isEmpty()){
// if(!route.isEmpty()){
vehicleFleetManager.lock(route.getVehicle());
// }
}
}
// log.info("#lockedVehicles=" + ((VehicleFleetManagerImpl)vehicleFleetManager).sizeOfLockedVehicles() + " #routes="+vehicleRoutes.size());
}
@Override
public String toString() {

View file

@ -125,9 +125,6 @@ final class RouteAlgorithmImpl implements RouteAlgorithm {
}
if(job instanceof Service) {
vehicleRoute.getTourActivities().addActivity(insertionData.getDeliveryInsertionIndex(), ServiceActivity.newInstance((Service)job));
// if(vehicleRoute.getStart().getEndTime() != insertionData.getVehicleDepartureTime()){
// logger.info("depTime switched from " + vehicleRoute.getStart().getEndTime() + " to " + insertionData.getVehicleDepartureTime());
// }
vehicleRoute.setDepartureTime(insertionData.getVehicleDepartureTime());
}
else throw new IllegalStateException("neither service nor shipment. this is not supported.");
@ -163,13 +160,6 @@ final class RouteAlgorithmImpl implements RouteAlgorithm {
return algoDescription;
}
private void insertJob(Service service, int serviceInsertionIndex, VehicleRoute vehicleRoute) {
// TourActivity del = actStates.getActivity(service,true);
vehicleRoute.getTourActivities().addActivity(serviceInsertionIndex, ServiceActivity.newInstance(service));
}
public Collection<RouteAlgorithmListener> getListeners() {
return listeners;
}

View file

@ -23,7 +23,6 @@ package algorithms;
import java.util.Collection;
import basics.route.Vehicle;
import basics.route.VehicleImpl;
import basics.route.VehicleImpl.VehicleType;
interface VehicleFleetManager {