Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
oblonski committed Mar 28, 2020
1 parent 0cade3b commit a3a4e6f
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

public final class RuinRandom extends AbstractRuinStrategy {

private Logger logger = LoggerFactory.getLogger(RuinRandom.class);
private static Logger logger = LoggerFactory.getLogger(RuinRandom.class);

private VehicleRoutingProblem vrp;

Expand All @@ -54,12 +54,7 @@ public RuinRandom(VehicleRoutingProblem vrp, double fraction) {
super(vrp);
this.vrp = vrp;
this.fractionOfAllNodes2beRuined = fraction;
setRuinShareFactory(new RuinShareFactory() {
@Override
public int createNumberToBeRemoved() {
return selectNuOfJobs2BeRemoved();
}
});
setRuinShareFactory(this::selectNuOfJobs2BeRemoved);
logger.debug("initialise {}", this);
}

Expand All @@ -70,14 +65,14 @@ public int createNumberToBeRemoved() {
*/
@Override
public Collection<Job> ruinRoutes(Collection<VehicleRoute> vehicleRoutes) {
List<Job> unassignedJobs = new ArrayList<Job>();
List<Job> unassignedJobs = new ArrayList<>();
int nOfJobs2BeRemoved = getRuinShareFactory().createNumberToBeRemoved();
ruin(vehicleRoutes, nOfJobs2BeRemoved, unassignedJobs);
return unassignedJobs;
}

private void ruin(Collection<VehicleRoute> vehicleRoutes, int nOfJobs2BeRemoved, List<Job> unassignedJobs) {
ArrayList<Job> availableJobs = new ArrayList<Job>(vrp.getJobs().values());
ArrayList<Job> availableJobs = new ArrayList<>(vrp.getJobs().values());
Collections.shuffle(availableJobs, random);
int removed = 0;
for (Job job : availableJobs) {
Expand Down

0 comments on commit a3a4e6f

Please sign in to comment.