Package org.moeaframework.algorithm
Class RandomSearch
java.lang.Object
org.moeaframework.algorithm.AbstractAlgorithm
org.moeaframework.algorithm.RandomSearch
- All Implemented Interfaces:
Algorithm,Extensible,Configurable,Named,Stateful
Random search implementation. An
Initialization instance is used to generate random solutions, which are
evaluated and all non-dominated solutions retained. The result is the set of all non-dominated solutions.-
Field Summary
Fields inherited from class org.moeaframework.algorithm.AbstractAlgorithm
initialized, numberOfEvaluations, problem, terminated -
Constructor Summary
ConstructorsConstructorDescriptionRandomSearch(Problem problem) Constructs a new random search procedure with default settings.RandomSearch(Problem problem, int sampleSize, Initialization generator, NondominatedPopulation archive) Constructs a new random search procedure for the given problem. -
Method Summary
Modifier and TypeMethodDescriptiongetName()Returns the name of this algorithm.Returns the current best-known result.intReturns the number of solutions sampled each iteration.voidPerforms any initialization that is required by this algorithm.protected voiditerate()Performs one iteration of the algorithm.voidloadState(ObjectInputStream stream) Loads the state of this object from the stream.voidsaveState(ObjectOutputStream stream) Writes the state of this object to the stream.voidsetSampleSize(int sampleSize) Sets the number of solutions sampled each iteration.Methods inherited from class org.moeaframework.algorithm.AbstractAlgorithm
assertNotInitialized, evaluate, getExtensions, getNumberOfEvaluations, getProblem, isInitialized, isTerminated, step, terminateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.moeaframework.algorithm.Algorithm
evaluateAll, evaluateAll, run, runMethods inherited from interface org.moeaframework.core.configuration.Configurable
applyConfiguration, getConfigurationMethods inherited from interface org.moeaframework.algorithm.extension.Extensible
addExtension, removeExtension
-
Constructor Details
-
RandomSearch
Constructs a new random search procedure with default settings.- Parameters:
problem- the problem being solved
-
RandomSearch
public RandomSearch(Problem problem, int sampleSize, Initialization generator, NondominatedPopulation archive) Constructs a new random search procedure for the given problem.- Parameters:
problem- the problem being solvedsampleSize- the number of solutions sampled each iterationgenerator- the initialization routine used to generate random solutionsarchive- the archive of non-dominated solutions
-
-
Method Details
-
getName
Description copied from interface:AlgorithmReturns the name of this algorithm. Whenever possible, this name should match the name recognized byAlgorithmFactory. -
getSampleSize
public int getSampleSize()Returns the number of solutions sampled each iteration.- Returns:
- the sample size
-
setSampleSize
public void setSampleSize(int sampleSize) Sets the number of solutions sampled each iteration. The main reason to set the sample size is when distributed solution evaluations, as the sample size at least the number of threads. The default value is 100.- Parameters:
sampleSize- the sample size
-
getResult
Description copied from interface:AlgorithmReturns the current best-known result. -
initialize
public void initialize()Description copied from interface:AlgorithmPerforms any initialization that is required by this algorithm. This method should only be called once, though the specific implementation may choose to no-op or throwAlgorithmInitializationExceptionif called multiple times.Implementations should always call
super.initialize()to ensure the algorithm is initialized correctly.- Specified by:
initializein interfaceAlgorithm- Overrides:
initializein classAbstractAlgorithm
-
iterate
protected void iterate()Description copied from class:AbstractAlgorithmPerforms one iteration of the algorithm. This method should be overridden by implementations to perform each logical iteration of the algorithm.- Specified by:
iteratein classAbstractAlgorithm
-
saveState
Description copied from interface:StatefulWrites the state of this object to the stream. The order that objects are written to the stream is important. We recommend first callingsuper.saveState(stream)followed by writing each field.- Specified by:
saveStatein interfaceStateful- Overrides:
saveStatein classAbstractAlgorithm- Parameters:
stream- the stream- Throws:
IOException- if an I/O error occurred
-
loadState
Description copied from interface:StatefulLoads the state of this object from the stream. The order for reading objects from the stream must match the order they are written to the stream inStateful.saveState(ObjectOutputStream).- Specified by:
loadStatein interfaceStateful- Overrides:
loadStatein classAbstractAlgorithm- Parameters:
stream- the stream- Throws:
IOException- if an I/O error occurredClassNotFoundException- if the stream referenced a class that is not defined
-