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

View file

@ -292,7 +292,7 @@ final class RuinRadial extends AbstractRuinStrategy {
return Collections.emptyList(); return Collections.emptyList();
} }
Job randomJob = pickRandomJob(); 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 @Override
public Collection<Job> ruinRoutes(Collection<VehicleRoute> vehicleRoutes, Job targetJob, int nOfJobs2BeRemoved) { public Collection<Job> ruinRoutes(Collection<VehicleRoute> vehicleRoutes, Job targetJob, int nOfJobs2BeRemoved) {
List<Job> unassignedJobs = new ArrayList<Job>(); throw new IllegalStateException("not supported");
if(targetJob != null){ // List<Job> unassignedJobs = new ArrayList<Job>();
boolean removed = false; // if(targetJob != null){
for (VehicleRoute route : vehicleRoutes) { // boolean removed = false;
removed = removeJob(targetJob,route); // for (VehicleRoute route : vehicleRoutes) {
if (removed) { // removed = removeJob(targetJob,route);
nOfJobs2BeRemoved--; // if (removed) {
unassignedJobs.add(targetJob); // nOfJobs2BeRemoved--;
break; // unassignedJobs.add(targetJob);
} // break;
} // }
} // }
ruin(vehicleRoutes, nOfJobs2BeRemoved, unassignedJobs); // }
return unassignedJobs; // ruin(vehicleRoutes, nOfJobs2BeRemoved, unassignedJobs);
// return unassignedJobs;
} }
public void setRuinFraction(double fractionOfAllNodes2beRuined) { 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 * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -16,12 +16,12 @@
******************************************************************************/ ******************************************************************************/
package jsprit.core.algorithm.ruin; package jsprit.core.algorithm.ruin;
import java.util.Collection;
import jsprit.core.algorithm.ruin.listener.RuinListener; import jsprit.core.algorithm.ruin.listener.RuinListener;
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 java.util.Collection;
@ -46,6 +46,7 @@ public interface RuinStrategy {
/** /**
* Removes targetJob as well as its neighbors with a size of (nOfJobs2BeRemoved-1). * 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); public Collection<Job> ruin(Collection<VehicleRoute> vehicleRoutes, Job targetJob, int nOfJobs2BeRemoved);
/** /**