mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
internal ruinStrat improvement
This commit is contained in:
parent
d9391c6d45
commit
f78886767b
3 changed files with 41 additions and 10 deletions
|
|
@ -0,0 +1,22 @@
|
|||
package algorithms;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import basics.Job;
|
||||
import basics.route.VehicleRoute;
|
||||
|
||||
abstract class AbstractRuinStrategy implements RuinStrategy{
|
||||
|
||||
public void ruinStarts(Collection<VehicleRoute> routes){
|
||||
|
||||
}
|
||||
|
||||
public void ruinEnds(Collection<VehicleRoute> routes){
|
||||
|
||||
}
|
||||
|
||||
public void jobRemoved(Job job, VehicleRoute fromRoute){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -82,10 +82,6 @@ final class RuinRadial implements RuinStrategy {
|
|||
|
||||
private JobDistance jobDistance;
|
||||
|
||||
private JobRemover jobRemover;
|
||||
|
||||
private VehicleRouteUpdater routeUpdater;
|
||||
|
||||
public void setRandom(Random random) {
|
||||
this.random = random;
|
||||
}
|
||||
|
|
@ -154,6 +150,7 @@ final class RuinRadial implements RuinStrategy {
|
|||
}
|
||||
|
||||
public Collection<Job> ruin(Collection<VehicleRoute> vehicleRoutes, Job targetJob, int nOfJobs2BeRemoved){
|
||||
ruinStarts(vehicleRoutes);
|
||||
List<Job> unassignedJobs = new ArrayList<Job>();
|
||||
TreeSet<ReferencedJob> tree = distanceNodeTree.get(targetJob.getId());
|
||||
Iterator<ReferencedJob> descendingIterator = tree.descendingIterator();
|
||||
|
|
@ -165,18 +162,32 @@ final class RuinRadial implements RuinStrategy {
|
|||
counter++;
|
||||
boolean removed = false;
|
||||
for (VehicleRoute route : vehicleRoutes) {
|
||||
removed = jobRemover.removeJobWithoutTourUpdate(job, route);
|
||||
removed = route.getTourActivities().removeJob(job);;
|
||||
if (removed) {
|
||||
jobRemoved(job,route);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(VehicleRoute route : vehicleRoutes){
|
||||
routeUpdater.updateRoute(route);
|
||||
}
|
||||
ruinEnds(vehicleRoutes);
|
||||
return unassignedJobs;
|
||||
}
|
||||
|
||||
private void ruinEnds(Collection<VehicleRoute> vehicleRoutes) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
private void jobRemoved(Job job, VehicleRoute route) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
private void ruinStarts(Collection<VehicleRoute> vehicleRoutes) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
private Job pickRandomJob() {
|
||||
int totNuOfJobs = vrp.getJobs().values().size();
|
||||
int randomIndex = random.nextInt(totNuOfJobs);
|
||||
|
|
|
|||
|
|
@ -73,11 +73,9 @@ final class RuinRandom implements RuinStrategy {
|
|||
*/
|
||||
@Override
|
||||
public Collection<Job> ruin(Collection<VehicleRoute> vehicleRoutes) {
|
||||
|
||||
List<Job> unassignedJobs = new ArrayList<Job>();
|
||||
int nOfJobs2BeRemoved = selectNuOfJobs2BeRemoved();
|
||||
ruin(vehicleRoutes, nOfJobs2BeRemoved, unassignedJobs);
|
||||
|
||||
return unassignedJobs;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue