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

deprecate ruin method

This commit is contained in:
oblonski 2014-11-24 13:19:14 +01:00
parent dc27cacd5f
commit 904a0036b1
4 changed files with 33 additions and 26 deletions

View file

@ -51,7 +51,9 @@ public abstract class AbstractRuinStrategy implements RuinStrategy{
public abstract Collection<Job> ruinRoutes(Collection<VehicleRoute> vehicleRoutes);
@Override
@Deprecated
public Collection<Job> ruin(Collection<VehicleRoute> vehicleRoutes, Job targetJob, int nOfJobs2BeRemoved){
ruinListeners.ruinStarts(vehicleRoutes);
Collection<Job> unassigned = ruinRoutes(vehicleRoutes, targetJob, nOfJobs2BeRemoved);
@ -59,6 +61,7 @@ public abstract class AbstractRuinStrategy implements RuinStrategy{
return unassigned;
}
@Deprecated
public abstract Collection<Job> ruinRoutes(Collection<VehicleRoute> vehicleRoutes, Job targetJob, int nOfJobs2BeRemoved);
@Override
@ -76,15 +79,17 @@ public abstract class AbstractRuinStrategy implements RuinStrategy{
return ruinListeners.getListeners();
}
protected void removeJob(Job job, Collection<VehicleRoute> vehicleRoutes) {
protected boolean removeJob(Job job, Collection<VehicleRoute> vehicleRoutes) {
for (VehicleRoute route : vehicleRoutes) {
if (removeJob(job, route)) break;
if (removeJob(job, route)) {
return true;
}
}
return false;
}
protected boolean removeJob(Job job, VehicleRoute route) {
boolean removed;
removed = route.getTourActivities().removeJob(job);
boolean removed = route.getTourActivities().removeJob(job);
if (removed) {
ruinListeners.removed(job,route);
return true;

View file

@ -292,7 +292,7 @@ final class RuinRadial extends AbstractRuinStrategy {
return Collections.emptyList();
}
Job randomJob = pickRandomJob();
return ruin(vehicleRoutes,randomJob,nOfJobs2BeRemoved);
return ruinRoutes(vehicleRoutes, randomJob, nOfJobs2BeRemoved);
}
/**

View file

@ -76,20 +76,21 @@ final class RuinRandom extends AbstractRuinStrategy {
*/
@Override
public Collection<Job> ruinRoutes(Collection<VehicleRoute> vehicleRoutes, Job targetJob, int nOfJobs2BeRemoved) {
List<Job> unassignedJobs = new ArrayList<Job>();
if(targetJob != null){
boolean removed = false;
for (VehicleRoute route : vehicleRoutes) {
removed = removeJob(targetJob,route);
if (removed) {
nOfJobs2BeRemoved--;
unassignedJobs.add(targetJob);
break;
}
}
}
ruin(vehicleRoutes, nOfJobs2BeRemoved, unassignedJobs);
return unassignedJobs;
throw new IllegalStateException("not supported");
// List<Job> unassignedJobs = new ArrayList<Job>();
// if(targetJob != null){
// boolean removed = false;
// for (VehicleRoute route : vehicleRoutes) {
// removed = removeJob(targetJob,route);
// if (removed) {
// nOfJobs2BeRemoved--;
// unassignedJobs.add(targetJob);
// break;
// }
// }
// }
// ruin(vehicleRoutes, nOfJobs2BeRemoved, unassignedJobs);
// return unassignedJobs;
}
public void setRuinFraction(double fractionOfAllNodes2beRuined) {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (C) 2013 Stefan Schroeder
* Copyright (C) 2014 Stefan Schroeder
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -16,12 +16,12 @@
******************************************************************************/
package jsprit.core.algorithm.ruin;
import java.util.Collection;
import jsprit.core.algorithm.ruin.listener.RuinListener;
import jsprit.core.problem.job.Job;
import jsprit.core.problem.solution.route.VehicleRoute;
import java.util.Collection;
@ -46,6 +46,7 @@ public interface RuinStrategy {
/**
* Removes targetJob as well as its neighbors with a size of (nOfJobs2BeRemoved-1).
*/
@Deprecated
public Collection<Job> ruin(Collection<VehicleRoute> vehicleRoutes, Job targetJob, int nOfJobs2BeRemoved);
/**