mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
clean up
This commit is contained in:
parent
a20db5e119
commit
267775d252
2 changed files with 11 additions and 18 deletions
|
|
@ -62,12 +62,9 @@ class InsertionDataUpdater {
|
||||||
}
|
}
|
||||||
|
|
||||||
static Comparator<VersionedInsertionData> getComparator(){
|
static Comparator<VersionedInsertionData> getComparator(){
|
||||||
return new Comparator<VersionedInsertionData>() {
|
return (o1, o2) -> {
|
||||||
@Override
|
if (o1.getiData().getInsertionCost() < o2.getiData().getInsertionCost()) return -1;
|
||||||
public int compare(VersionedInsertionData o1, VersionedInsertionData o2) {
|
return 1;
|
||||||
if(o1.getiData().getInsertionCost() < o2.getiData().getInsertionCost()) return -1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -161,7 +158,7 @@ class InsertionDataUpdater {
|
||||||
return bestScoredJob;
|
return bestScoredJob;
|
||||||
}
|
}
|
||||||
|
|
||||||
static double score(Job unassignedJob, InsertionData best, InsertionData secondBest, ScoringFunction scoringFunction) {
|
private static double score(Job unassignedJob, InsertionData best, InsertionData secondBest, ScoringFunction scoringFunction) {
|
||||||
return Scorer.score(unassignedJob,best,secondBest,scoringFunction);
|
return Scorer.score(unassignedJob,best,secondBest,scoringFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,10 @@ import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.ExecutorCompletionService;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insertion based on regret approach.
|
* Insertion based on regret approach.
|
||||||
|
|
@ -68,7 +71,7 @@ public class RegretInsertionConcurrent extends AbstractInsertionStrategy {
|
||||||
this.scoringFunction = new DefaultScorer(vehicleRoutingProblem);
|
this.scoringFunction = new DefaultScorer(vehicleRoutingProblem);
|
||||||
this.insertionCostsCalculator = jobInsertionCalculator;
|
this.insertionCostsCalculator = jobInsertionCalculator;
|
||||||
this.vrp = vehicleRoutingProblem;
|
this.vrp = vehicleRoutingProblem;
|
||||||
completionService = new ExecutorCompletionService<ScoredJob>(executorService);
|
completionService = new ExecutorCompletionService<>(executorService);
|
||||||
logger.debug("initialise " + this);
|
logger.debug("initialise " + this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -87,7 +90,7 @@ public class RegretInsertionConcurrent extends AbstractInsertionStrategy {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Collection<Job> insertUnassignedJobs(Collection<VehicleRoute> routes, Collection<Job> unassignedJobs) {
|
public Collection<Job> insertUnassignedJobs(Collection<VehicleRoute> routes, Collection<Job> unassignedJobs) {
|
||||||
List<Job> badJobs = new ArrayList<Job>(unassignedJobs.size());
|
List<Job> badJobs = new ArrayList<>(unassignedJobs.size());
|
||||||
|
|
||||||
Iterator<Job> jobIterator = unassignedJobs.iterator();
|
Iterator<Job> jobIterator = unassignedJobs.iterator();
|
||||||
while (jobIterator.hasNext()){
|
while (jobIterator.hasNext()){
|
||||||
|
|
@ -135,14 +138,7 @@ public class RegretInsertionConcurrent extends AbstractInsertionStrategy {
|
||||||
ScoredJob bestScoredJob = null;
|
ScoredJob bestScoredJob = null;
|
||||||
|
|
||||||
for (final Job unassignedJob : unassignedJobList) {
|
for (final Job unassignedJob : unassignedJobList) {
|
||||||
completionService.submit(new Callable<ScoredJob>() {
|
completionService.submit(() -> RegretInsertion.getScoredJob(routes, unassignedJob, insertionCostsCalculator, scoringFunction));
|
||||||
|
|
||||||
@Override
|
|
||||||
public ScoredJob call() throws Exception {
|
|
||||||
return RegretInsertion.getScoredJob(routes, unassignedJob, insertionCostsCalculator, scoringFunction);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue