Package com.dna.jopt.util.costconverger
Interface ICostConverger
- All Known Implementing Classes:
AbstractCostConverger,JoinedCostConverger,JoinedCostConvergerWithFinalAutoFilterStep
public interface ICostConverger
This interface of the
converger allows to set an iteration treshold after which the
Optimisation is stopped if the cost does not change. The converger can be
customized to stop the Optimisation if the distance or time do not change
even tough the cost is still fluctuating.
Implementation example:
// Create external CostConverger
ICostConverger myJoinedCostConverger = new JoinedCostConverger(this);
myJoinedCostConverger.addExecutionAlgorithm(GeneticEvolutionAlgo.MY_TITLE);
myJoinedCostConverger.setConvergenceThreshold(5);
CompletableFuture<IOptimizationResult> resultFuture = this.startRunAsync();
// It is important to block the call, otherwise optimization will be terminated
try {
resultFuture.get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
- Since:
- 03/08/2019
- Version:
- 13/09/2019
- Author:
- DNA
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddExecutionAlgorithm(String exectutionAlgo) Defines where theOptimizationcan be stopped by theConverger.doubleonConverged(IOptimization opti) voidonDone(IOptimization opti) voidsetConvergenceThreshold(int numProgressSteps) Sets the convergence threshold X.voidsetOnConvergedTimeOut(long onConvergedtimeout, TimeUnit onConvergedTimeUnit)
-
Method Details
-
setConvergenceThreshold
void setConvergenceThreshold(int numProgressSteps) Sets the convergence threshold X. If the convergence cost did not change for X iterations in % the converger stops the optimizations.- Parameters:
numProgressSteps- the new convergence threshold
-
addExecutionAlgorithm
Defines where theOptimizationcan be stopped by theConverger. For implementation example please seeICostConverger.Possible values are
"GeneticEvolution"and"SimulatedAnnealing".- Parameters:
exectutionAlgo- the string of the algorithm in which the optimization can be stopped safely
-
getConvergenceCost
-
onDone
-
onConverged
-
setOnConvergedTimeOut
-