Package es.urjc.etsii.grafo.algorithms
Class Algorithm<S extends Solution<S,I>,I extends Instance>
java.lang.Object
es.urjc.etsii.grafo.algorithms.Algorithm<S,I>
- Type Parameters:
S
- Solution classI
- Instance class
- Direct Known Subclasses:
EmptyAlgorithm
,IteratedGreedy
,MultiStartAlgorithm
,ScatterSearch
,SimpleAlgorithm
,TestAlgorithm
,VNS
Base algorithm class, all algorithms should extend this class or any of its subclasses.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract S
Runs the algorithmprotected SolutionBuilder
<S, I> Get solution buildergetName()
Algorithm name, uniquely identifies the algorithm inside an experimentnewSolution
(I instance) Create a new solution for the given instance.void
setBuilder
(SolutionBuilder<S, I> builder) Set solution builder, used by the framework.void
Sets the algorithm name.toString()
-
Constructor Details
-
Algorithm
Initialize common algorithm fields- Parameters:
algorithmName
- algorithm name. SeesetName(String)
-
-
Method Details
-
getName
Algorithm name, uniquely identifies the algorithm inside an experiment- Returns:
- algorithm name
-
setName
Sets the algorithm name. This method can be called after the algorithm has been built, for example if we want to customize the name generated by the autoconfig module. This method CANNOT be called after the algorithm has started executing, as it would break the experiment results. The algorithm name is used to uniquely identify the algorithm inside an experiment.- Parameters:
algorithmName
- must uniquely identify the algorithm inside an experiment
-
algorithm
Runs the algorithm- Parameters:
instance
- Instance to solve- Returns:
- Built solution
-
newSolution
Create a new solution for the given instance. Solution is empty by default.- Parameters:
instance
- Instance- Returns:
- Empty solution, by default created calling the constructor Solution(Instance i)
-
getBuilder
Get solution builder- Returns:
- solution builder
-
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); }
- Parameters:
builder
- solution builder
-
toString
-