mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
Replacing the termination logic to reduce run-times with marginal effect on quality.
This commit is contained in:
parent
51fe971d6d
commit
7d7efe40fb
1 changed files with 6 additions and 5 deletions
|
|
@ -47,7 +47,7 @@ public class IterationWithoutImprovementTermination implements PrematureAlgorith
|
|||
|
||||
private List<Integer> unassignedCount;
|
||||
|
||||
private int bestCost = Integer.MAX_VALUE;
|
||||
private double bestCost = Double.MAX_VALUE;
|
||||
/**
|
||||
* Constructs termination.
|
||||
*
|
||||
|
|
@ -68,8 +68,11 @@ public class IterationWithoutImprovementTermination implements PrematureAlgorith
|
|||
@Override
|
||||
public boolean isPrematureBreak(SearchStrategy.DiscoveredSolution discoveredSolution) {
|
||||
VehicleRoutingProblemSolution sol = discoveredSolution.getSolution();
|
||||
|
||||
double currentCost = sol.getCost();
|
||||
costs.add(Math.min(currentCost, bestCost));
|
||||
bestCost = Math.min(currentCost, bestCost);
|
||||
costs.add(bestCost);
|
||||
|
||||
int currentUnassigned = sol.getUnassignedJobs().size();
|
||||
unassignedCount.add(currentUnassigned);
|
||||
|
||||
|
|
@ -77,11 +80,9 @@ public class IterationWithoutImprovementTermination implements PrematureAlgorith
|
|||
if (i < noIterationWithoutImprovement)
|
||||
return false;
|
||||
|
||||
int progressPercentTerminationCondition = 1; // TODO: Move to configuration
|
||||
double progressPercentTerminationCondition = 0.1; // TODO: Move to configuration
|
||||
boolean unassignedEqual = (currentUnassigned == unassignedCount.get(i-noIterationWithoutImprovement));
|
||||
boolean progressTooSlow = (100 * Math.abs(currentCost - costs.get(i - noIterationWithoutImprovement))) / currentCost < progressPercentTerminationCondition;
|
||||
|
||||
return (unassignedEqual && progressTooSlow);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue