File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/ruin Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 12
12
# Eclipse
13
13
.project
14
14
.classpath
15
- /.settings /
15
+ /.settings /s
16
+
17
+ .editorconfig
Original file line number Diff line number Diff line change @@ -71,17 +71,20 @@ public Collection<Job> ruinRoutes(Collection<VehicleRoute> vehicleRoutes) {
71
71
72
72
private void ruin (Collection <VehicleRoute > vehicleRoutes , int nOfJobs2BeRemoved , List <Job > unassignedJobs ) {
73
73
int toRemove = nOfJobs2BeRemoved ;
74
+ Set <Job > tabu = new HashSet <>();
74
75
while (toRemove > 0 ) {
75
- Job worst = getWorst (vehicleRoutes );
76
+ Job worst = getWorst (vehicleRoutes , tabu );
76
77
if (worst == null ) break ;
77
78
if (removeJob (worst , vehicleRoutes )) {
78
79
unassignedJobs .add (worst );
80
+ } else {
81
+ tabu .add (worst );
79
82
}
80
83
toRemove --;
81
84
}
82
85
}
83
86
84
- private Job getWorst (Collection <VehicleRoute > routes ) {
87
+ private Job getWorst (Collection <VehicleRoute > routes , Set < Job > tabu ) {
85
88
if (routes .isEmpty ()) return null ;
86
89
87
90
Job worst = null ;
@@ -103,6 +106,10 @@ private Job getWorst(Collection<VehicleRoute> routes) {
103
106
Job job = entry .getKey ();
104
107
double savings = entry .getValue ();
105
108
109
+ if (tabu .contains (job ) || !vrp .getJobs ().containsKey (job .getId ())) {
110
+ continue ;
111
+ }
112
+
106
113
// Skip jobs that don't pass the filter
107
114
if (!jobFilter .accept (job )) {
108
115
continue ;
You can’t perform that action at this time.
0 commit comments