mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
change interface insertion ends listener
This commit is contained in:
parent
e4b5bbf5fa
commit
a3e3d45b81
6 changed files with 12 additions and 10 deletions
|
|
@ -376,7 +376,7 @@ public class AlgorithmEventsRecorder implements RuinListener, IterationStartsLis
|
|||
}
|
||||
|
||||
@Override
|
||||
public void informInsertionEnds(Collection<VehicleRoute> vehicleRoutes) {
|
||||
public void informInsertionEnds(Collection<VehicleRoute> vehicleRoutes, Collection<Job> badJobs) {
|
||||
if (!record()) return;
|
||||
fileSink.stepBegins(graph.getId(), 0, CLEAR_SOLUTION);
|
||||
removeRoutes(vehicleRoutes);
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
package com.graphhopper.jsprit.core.algorithm;
|
||||
|
||||
import com.graphhopper.jsprit.core.algorithm.recreate.listener.InsertionEndsListener;
|
||||
import com.graphhopper.jsprit.core.problem.job.Job;
|
||||
import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleFleetManager;
|
||||
|
||||
|
|
@ -41,8 +42,8 @@ public class RemoveEmptyVehicles implements InsertionEndsListener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void informInsertionEnds(Collection<VehicleRoute> vehicleRoutes) {
|
||||
List<VehicleRoute> routes = new ArrayList<VehicleRoute>(vehicleRoutes);
|
||||
public void informInsertionEnds(Collection<VehicleRoute> vehicleRoutes, Collection<Job> badJobs) {
|
||||
List<VehicleRoute> routes = new ArrayList<>(vehicleRoutes);
|
||||
for (VehicleRoute route : routes) {
|
||||
if (route.isEmpty()) {
|
||||
fleetManager.unlock(route.getVehicle());
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ public abstract class AbstractInsertionStrategy implements InsertionStrategy {
|
|||
public Collection<Job> insertJobs(Collection<VehicleRoute> vehicleRoutes, Collection<Job> unassignedJobs) {
|
||||
insertionsListeners.informInsertionStarts(vehicleRoutes, unassignedJobs);
|
||||
Collection<Job> badJobs = insertUnassignedJobs(vehicleRoutes, unassignedJobs);
|
||||
insertionsListeners.informInsertionEndsListeners(vehicleRoutes);
|
||||
insertionsListeners.informInsertionEndsListeners(vehicleRoutes, badJobs);
|
||||
return badJobs;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
package com.graphhopper.jsprit.core.algorithm.recreate.listener;
|
||||
|
||||
import com.graphhopper.jsprit.core.problem.job.Job;
|
||||
import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute;
|
||||
|
||||
import java.util.Collection;
|
||||
|
|
@ -24,5 +25,5 @@ import java.util.Collection;
|
|||
|
||||
public interface InsertionEndsListener extends InsertionListener {
|
||||
|
||||
public void informInsertionEnds(Collection<VehicleRoute> vehicleRoutes);
|
||||
void informInsertionEnds(Collection<VehicleRoute> vehicleRoutes, Collection<Job> badJobs);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import java.util.List;
|
|||
|
||||
public class InsertionListeners {
|
||||
|
||||
private Collection<InsertionListener> listeners = new ArrayList<InsertionListener>();
|
||||
private Collection<InsertionListener> listeners = new ArrayList<>();
|
||||
|
||||
public Collection<InsertionListener> getListeners() {
|
||||
return listeners;
|
||||
|
|
@ -67,10 +67,10 @@ public class InsertionListeners {
|
|||
}
|
||||
}
|
||||
|
||||
public void informInsertionEndsListeners(Collection<VehicleRoute> vehicleRoutes) {
|
||||
public void informInsertionEndsListeners(Collection<VehicleRoute> vehicleRoutes, Collection<Job> badJobs) {
|
||||
for (InsertionListener l : listeners) {
|
||||
if (l instanceof InsertionEndsListener) {
|
||||
((InsertionEndsListener) l).informInsertionEnds(vehicleRoutes);
|
||||
((InsertionEndsListener) l).informInsertionEnds(vehicleRoutes, badJobs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -602,8 +602,8 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart
|
|||
}
|
||||
|
||||
@Override
|
||||
public void informInsertionEnds(Collection<VehicleRoute> vehicleRoutes) {
|
||||
insertionListeners.informInsertionEndsListeners(vehicleRoutes);
|
||||
public void informInsertionEnds(Collection<VehicleRoute> vehicleRoutes, Collection<Job> badJobs) {
|
||||
insertionListeners.informInsertionEndsListeners(vehicleRoutes, badJobs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue