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:
parent
dc27cacd5f
commit
904a0036b1
4 changed files with 33 additions and 26 deletions
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
||||||
|
|
|
||||||
|
|
@ -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
|
* 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
|
||||||
* 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.
|
* 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,
|
* This library is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* Lesser General Public License for more details.
|
* Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
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);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue