java.lang.Object
es.urjc.etsii.grafo.algorithms.Algorithm<S,I>
es.urjc.etsii.grafo.algorithms.multistart.MultiStartAlgorithm<S,I>
- Type Parameters:
S- Solution classI- Instance class
Example multistart algorithm, executes a user-defined algorithm until N iterations are reached, return best found.
-
Field Summary
FieldsModifier and TypeFieldDescriptionAlgorithmprotected final intMaximum number of iterationsprotected final intMaximum number of iteration without improving.protected final intMinimum number of iterationsObjective to optimize in the multistart algorithm -
Constructor Summary
ConstructorsConstructorDescriptionMultiStartAlgorithm(String algorithmName, Objective<?, S, I> objective, Algorithm<S, I> algorithm, int maxIterations, int minIterations, int maxIterationsWithoutImproving) Use theMultiStartAlgorithmBuilderclass to generate a MultiStart Algorithm -
Method Summary
Modifier and TypeMethodDescriptionRuns the algorithmprotected voidprintStatus(int iteration, S solution) Print the current status of the VNS procedure, i.e., the current iteration the best solution.voidsetBuilder(SolutionBuilder<S, I> builder) Set solution builder, used by the framework.toString()Methods inherited from class es.urjc.etsii.grafo.algorithms.Algorithm
getBuilder, getName, newSolution, setName
-
Field Details
-
algorithm
Algorithm -
maxIterations
protected final int maxIterationsMaximum number of iterations -
minIterations
protected final int minIterationsMinimum number of iterations -
maxIterationsWithoutImproving
protected final int maxIterationsWithoutImprovingMaximum number of iteration without improving. When the algorithm has been executed this number of time without finding a new best solution, the multistart procedure ends. -
objective
Objective to optimize in the multistart algorithm
-
-
Constructor Details
-
MultiStartAlgorithm
public MultiStartAlgorithm(@ProvidedParam String algorithmName, Objective<?, S, I> objective, Algorithm<S, I> algorithm, @IntegerParam(min=1,max=1000000) int maxIterations, @IntegerParam(min=1,max=1000000) int minIterations, @IntegerParam(min=1,max=1000000) int maxIterationsWithoutImproving) Use theMultiStartAlgorithmBuilderclass to generate a MultiStart Algorithm- Parameters:
algorithmName- algorithm namealgorithm- algorithmmaxIterations- maximum number of iterationsminIterations- minimum number of iteration the algorithm will be run. Must be less or equatl than the maximum number of iterations.maxIterationsWithoutImproving- number of iterations the algorithm should be run without improving before stop
-
-
Method Details
-
algorithm
Runs the algorithm Algorithm: Execute a single construction and then all the local searchs a single time. -
toString
-
printStatus
Print the current status of the VNS procedure, i.e., the current iteration the best solution.- Parameters:
iteration- current iteration of the proceduresolution- solution
-
setBuilder
Set solution builder, used by the framework. In case an algorithms contains another algorithms, this method should be overridden as follows:@Override public void setBuilder(SolutionBuilder<S, I> builder) { super.setBuilder(builder); this.algorithm.setBuilder(builder); }This method propagates the builder so that it can be used by other algorithms.
-