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 List<Integer> unassignedCount;
|
||||||
|
|
||||||
private int bestCost = Integer.MAX_VALUE;
|
private double bestCost = Double.MAX_VALUE;
|
||||||
/**
|
/**
|
||||||
* Constructs termination.
|
* Constructs termination.
|
||||||
*
|
*
|
||||||
|
|
@ -68,8 +68,11 @@ public class IterationWithoutImprovementTermination implements PrematureAlgorith
|
||||||
@Override
|
@Override
|
||||||
public boolean isPrematureBreak(SearchStrategy.DiscoveredSolution discoveredSolution) {
|
public boolean isPrematureBreak(SearchStrategy.DiscoveredSolution discoveredSolution) {
|
||||||
VehicleRoutingProblemSolution sol = discoveredSolution.getSolution();
|
VehicleRoutingProblemSolution sol = discoveredSolution.getSolution();
|
||||||
|
|
||||||
double currentCost = sol.getCost();
|
double currentCost = sol.getCost();
|
||||||
costs.add(Math.min(currentCost, bestCost));
|
bestCost = Math.min(currentCost, bestCost);
|
||||||
|
costs.add(bestCost);
|
||||||
|
|
||||||
int currentUnassigned = sol.getUnassignedJobs().size();
|
int currentUnassigned = sol.getUnassignedJobs().size();
|
||||||
unassignedCount.add(currentUnassigned);
|
unassignedCount.add(currentUnassigned);
|
||||||
|
|
||||||
|
|
@ -77,11 +80,9 @@ public class IterationWithoutImprovementTermination implements PrematureAlgorith
|
||||||
if (i < noIterationWithoutImprovement)
|
if (i < noIterationWithoutImprovement)
|
||||||
return false;
|
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 unassignedEqual = (currentUnassigned == unassignedCount.get(i-noIterationWithoutImprovement));
|
||||||
boolean progressTooSlow = (100 * Math.abs(currentCost - costs.get(i - noIterationWithoutImprovement))) / currentCost < progressPercentTerminationCondition;
|
boolean progressTooSlow = (100 * Math.abs(currentCost - costs.get(i - noIterationWithoutImprovement))) / currentCost < progressPercentTerminationCondition;
|
||||||
|
|
||||||
return (unassignedEqual && progressTooSlow);
|
return (unassignedEqual && progressTooSlow);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue