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

improve RuinString

This commit is contained in:
oblonski 2017-05-05 16:37:11 +02:00
parent 99bcbcf1e1
commit 3213765b50
No known key found for this signature in database
GPG key ID: 179DE487285680D1

View file

@ -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);