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
-
Method Summary
Modifier and TypeMethodDescriptiongetAlgorithm
(String name, Problem problem) Searches through all discoveredAlgorithmProvider
instances, returning an instance of the algorithm with the registered name.getAlgorithm
(String name, TypedProperties properties, Problem problem) Searches through all discoveredAlgorithmProvider
instances, 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 AlgorithmFactory
Returns the default algorithm factory.static void
setInstance
(AlgorithmFactory instance) Sets the default algorithm factory.Methods inherited from class org.moeaframework.core.spi.AbstractFactory
addProvider, hasProvider, iterator
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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 discoveredAlgorithmProvider
instances, returning an instance of the algorithm with the registered name. The algorithm is initialized using implementation-specific properties. This method must throw anProviderNotFoundException
if 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 discoveredAlgorithmProvider
instances, returning an instance of the algorithm with the registered name. The algorithm is initialized using implementation-specific properties. This method must throw anProviderNotFoundException
if 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
-