Package org.moeaframework.core.spi
Class AlgorithmFactory
java.lang.Object
org.moeaframework.core.spi.AbstractFactory<AlgorithmProvider>
org.moeaframework.core.spi.AlgorithmFactory
- All Implemented Interfaces:
Iterable<AlgorithmProvider>
Factory for creating algorithm instances. See
AlgorithmProvider for details on adding new providers.
This class is thread safe.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAlgorithm(String name, TypedProperties properties, Problem problem) Searches through all discoveredAlgorithmProviderinstances, returning an instance of the algorithm with the registered name.getAlgorithm(String name, Problem problem) Searches through all discoveredAlgorithmProviderinstances, returning an instance of the algorithm with the registered name.Returns the names of all algorithms that have been registered to appear in the diagnostic tool.static AlgorithmFactoryReturns the default algorithm factory.static voidsetInstance(AlgorithmFactory instance) Sets the default algorithm factory.Methods inherited from class org.moeaframework.core.spi.AbstractFactory
addProvider, hasProvider, iteratorMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
AlgorithmFactory
public AlgorithmFactory()Constructs a new algorithm factory.
-
-
Method Details
-
getInstance
Returns the default algorithm factory.- Returns:
- the default algorithm factory
-
setInstance
Sets the default algorithm factory.- Parameters:
instance- the default algorithm factory
-
getAlgorithm
Searches through all discoveredAlgorithmProviderinstances, returning an instance of the algorithm with the registered name. The algorithm is initialized using implementation-specific properties. This method must throw anProviderNotFoundExceptionif no suitable algorithm is found.- Parameters:
name- the name identifying the algorithmproblem- the problem to be solved- Returns:
- an instance of the algorithm with the registered name
- Throws:
ProviderNotFoundException- if no provider for the algorithm is available
-
getAlgorithm
Searches through all discoveredAlgorithmProviderinstances, returning an instance of the algorithm with the registered name. The algorithm is initialized using implementation-specific properties. This method must throw anProviderNotFoundExceptionif no suitable algorithm is found.- Parameters:
name- the name identifying the algorithmproperties- the implementation-specific propertiesproblem- the problem to be solved- Returns:
- an instance of the algorithm with the registered name
- Throws:
ProviderNotFoundException- if no provider for the algorithm is available
-
getAllDiagnosticToolAlgorithms
Returns the names of all algorithms that have been registered to appear in the diagnostic tool.- Returns:
- all diagnostic tool algorithm names
-