Skip to content

Commit 11fb30e

Browse files
committed
introduce tabu list for evaluated jobs
1 parent f6a62af commit 11fb30e

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@
1212
# Eclipse
1313
.project
1414
.classpath
15-
/.settings/
15+
/.settings/s
16+
17+
.editorconfig

jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/ruin/RuinWorst.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,20 @@ public Collection<Job> ruinRoutes(Collection<VehicleRoute> vehicleRoutes) {
7171

7272
private void ruin(Collection<VehicleRoute> vehicleRoutes, int nOfJobs2BeRemoved, List<Job> unassignedJobs) {
7373
int toRemove = nOfJobs2BeRemoved;
74+
Set<Job> tabu = new HashSet<>();
7475
while (toRemove > 0) {
75-
Job worst = getWorst(vehicleRoutes);
76+
Job worst = getWorst(vehicleRoutes, tabu);
7677
if (worst == null) break;
7778
if (removeJob(worst, vehicleRoutes)) {
7879
unassignedJobs.add(worst);
80+
} else {
81+
tabu.add(worst);
7982
}
8083
toRemove--;
8184
}
8285
}
8386

84-
private Job getWorst(Collection<VehicleRoute> routes) {
87+
private Job getWorst(Collection<VehicleRoute> routes, Set<Job> tabu) {
8588
if (routes.isEmpty()) return null;
8689

8790
Job worst = null;
@@ -103,6 +106,10 @@ private Job getWorst(Collection<VehicleRoute> routes) {
103106
Job job = entry.getKey();
104107
double savings = entry.getValue();
105108

109+
if (tabu.contains(job) || !vrp.getJobs().containsKey(job.getId())) {
110+
continue;
111+
}
112+
106113
// Skip jobs that don't pass the filter
107114
if (!jobFilter.accept(job)) {
108115
continue;

0 commit comments

Comments
 (0)