diff --git a/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/AbstractRuinStrategy.java b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/AbstractRuinStrategy.java index 0583830e..b3635644 100644 --- a/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/AbstractRuinStrategy.java +++ b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/AbstractRuinStrategy.java @@ -51,7 +51,9 @@ public abstract class AbstractRuinStrategy implements RuinStrategy{ public abstract Collection ruinRoutes(Collection vehicleRoutes); + @Override + @Deprecated public Collection ruin(Collection vehicleRoutes, Job targetJob, int nOfJobs2BeRemoved){ ruinListeners.ruinStarts(vehicleRoutes); Collection unassigned = ruinRoutes(vehicleRoutes, targetJob, nOfJobs2BeRemoved); @@ -59,6 +61,7 @@ public abstract class AbstractRuinStrategy implements RuinStrategy{ return unassigned; } + @Deprecated public abstract Collection ruinRoutes(Collection 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 vehicleRoutes) { + protected boolean removeJob(Job job, Collection 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; diff --git a/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/RuinRadial.java b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/RuinRadial.java index 2c2653f4..cf6c8c93 100644 --- a/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/RuinRadial.java +++ b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/RuinRadial.java @@ -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); } /** diff --git a/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/RuinRandom.java b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/RuinRandom.java index d15e6a10..2f810cf1 100644 --- a/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/RuinRandom.java +++ b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/RuinRandom.java @@ -76,20 +76,21 @@ final class RuinRandom extends AbstractRuinStrategy { */ @Override public Collection ruinRoutes(Collection vehicleRoutes, Job targetJob, int nOfJobs2BeRemoved) { - List unassignedJobs = new ArrayList(); - 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 unassignedJobs = new ArrayList(); +// 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) { diff --git a/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/RuinStrategy.java b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/RuinStrategy.java index 2e485268..88c35a74 100644 --- a/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/RuinStrategy.java +++ b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/RuinStrategy.java @@ -1,27 +1,27 @@ /******************************************************************************* - * 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 - * License as published by the Free Software Foundation; either + * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . ******************************************************************************/ 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 ruin(Collection vehicleRoutes, Job targetJob, int nOfJobs2BeRemoved); /**