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(){
|
||||
return new Comparator<VersionedInsertionData>() {
|
||||
@Override
|
||||
public int compare(VersionedInsertionData o1, VersionedInsertionData o2) {
|
||||
if(o1.getiData().getInsertionCost() < o2.getiData().getInsertionCost()) return -1;
|
||||
return 1;
|
||||
}
|
||||
return (o1, o2) -> {
|
||||
if (o1.getiData().getInsertionCost() < o2.getiData().getInsertionCost()) return -1;
|
||||
return 1;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -161,7 +158,7 @@ class InsertionDataUpdater {
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,10 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
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.
|
||||
|
|
@ -68,7 +71,7 @@ public class RegretInsertionConcurrent extends AbstractInsertionStrategy {
|
|||
this.scoringFunction = new DefaultScorer(vehicleRoutingProblem);
|
||||
this.insertionCostsCalculator = jobInsertionCalculator;
|
||||
this.vrp = vehicleRoutingProblem;
|
||||
completionService = new ExecutorCompletionService<ScoredJob>(executorService);
|
||||
completionService = new ExecutorCompletionService<>(executorService);
|
||||
logger.debug("initialise " + this);
|
||||
}
|
||||
|
||||
|
|
@ -87,7 +90,7 @@ public class RegretInsertionConcurrent extends AbstractInsertionStrategy {
|
|||
*/
|
||||
@Override
|
||||
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();
|
||||
while (jobIterator.hasNext()){
|
||||
|
|
@ -135,14 +138,7 @@ public class RegretInsertionConcurrent extends AbstractInsertionStrategy {
|
|||
ScoredJob bestScoredJob = null;
|
||||
|
||||
for (final Job unassignedJob : unassignedJobList) {
|
||||
completionService.submit(new Callable<ScoredJob>() {
|
||||
|
||||
@Override
|
||||
public ScoredJob call() throws Exception {
|
||||
return RegretInsertion.getScoredJob(routes, unassignedJob, insertionCostsCalculator, scoringFunction);
|
||||
}
|
||||
|
||||
});
|
||||
completionService.submit(() -> RegretInsertion.getScoredJob(routes, unassignedJob, insertionCostsCalculator, scoringFunction));
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue