mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
replace .getRandomJob with helper
This commit is contained in:
parent
3402bb413e
commit
44f734cbdd
1 changed files with 2 additions and 7 deletions
|
|
@ -20,6 +20,7 @@ import jsprit.core.algorithm.ruin.distance.JobDistance;
|
||||||
import jsprit.core.problem.VehicleRoutingProblem;
|
import jsprit.core.problem.VehicleRoutingProblem;
|
||||||
import jsprit.core.problem.job.Job;
|
import jsprit.core.problem.job.Job;
|
||||||
import jsprit.core.problem.solution.route.VehicleRoute;
|
import jsprit.core.problem.solution.route.VehicleRoute;
|
||||||
|
import jsprit.core.util.RandomUtils;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
|
@ -107,7 +108,7 @@ public final class RuinRadial extends AbstractRuinStrategy {
|
||||||
if (nOfJobs2BeRemoved == 0) {
|
if (nOfJobs2BeRemoved == 0) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
Job randomJob = pickRandomJob();
|
Job randomJob = RandomUtils.nextJob(vrp.getJobs().values(),random);
|
||||||
return ruinRoutes(vehicleRoutes, randomJob, nOfJobs2BeRemoved);
|
return ruinRoutes(vehicleRoutes, randomJob, nOfJobs2BeRemoved);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -130,10 +131,4 @@ public final class RuinRadial extends AbstractRuinStrategy {
|
||||||
return unassignedJobs;
|
return unassignedJobs;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Job pickRandomJob() {
|
|
||||||
int totNuOfJobs = vrp.getJobs().values().size();
|
|
||||||
int randomIndex = random.nextInt(totNuOfJobs);
|
|
||||||
return new ArrayList<Job>(vrp.getJobs().values()).get(randomIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue