mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
improve RuinString
This commit is contained in:
parent
99bcbcf1e1
commit
3213765b50
1 changed files with 6 additions and 2 deletions
|
|
@ -89,7 +89,9 @@ public final class RuinString extends AbstractRuinStrategy {
|
||||||
if (vehicleRoutes.isEmpty() || vrp.getJobs().isEmpty()) {
|
if (vehicleRoutes.isEmpty() || vrp.getJobs().isEmpty()) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
int noStrings = kMin + random.nextInt((kMax - kMin));
|
int noStrings;
|
||||||
|
if (kMin == kMax) noStrings = kMax;
|
||||||
|
else noStrings = kMin + random.nextInt((kMax - kMin));
|
||||||
noStrings = Math.min(noStrings, vehicleRoutes.size());
|
noStrings = Math.min(noStrings, vehicleRoutes.size());
|
||||||
Set<Job> unassignedJobs = new HashSet<>();
|
Set<Job> unassignedJobs = new HashSet<>();
|
||||||
Set<VehicleRoute> ruinedRoutes = new HashSet<>();
|
Set<VehicleRoute> ruinedRoutes = new HashSet<>();
|
||||||
|
|
@ -121,7 +123,9 @@ public final class RuinString extends AbstractRuinStrategy {
|
||||||
|
|
||||||
private void ruinRouteWithSplitStringRuin(VehicleRoute seedRoute, Job prevJob, Set<Job> unassignedJobs) {
|
private void ruinRouteWithSplitStringRuin(VehicleRoute seedRoute, Job prevJob, Set<Job> unassignedJobs) {
|
||||||
int noActivities = seedRoute.getActivities().size();
|
int noActivities = seedRoute.getActivities().size();
|
||||||
int stringLength = lMin + random.nextInt(lMax - lMin);
|
int stringLength;
|
||||||
|
if (lMin == lMax) stringLength = lMin;
|
||||||
|
else stringLength = lMin + random.nextInt(lMax - lMin);
|
||||||
stringLength = Math.min(stringLength, seedRoute.getActivities().size());
|
stringLength = Math.min(stringLength, seedRoute.getActivities().size());
|
||||||
|
|
||||||
int preservedSubstringLength = StringUtil.determineSubstringLength(stringLength, noActivities, random);
|
int preservedSubstringLength = StringUtil.determineSubstringLength(stringLength, noActivities, random);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue