Class RepeatedSingleObjective
java.lang.Object
org.moeaframework.algorithm.AbstractAlgorithm
org.moeaframework.algorithm.single.RepeatedSingleObjective
- All Implemented Interfaces:
Extensible
,Algorithm
,Stateful
Instantiates and runs several instances of a single objective algorithm. This is intended to be used with
single-objective optimizers that use weighted aggregation of the objectives. This is based on the Repeated Single
Objective (RSO) algorithm by E. J. Hughes [1], where they investigate running many single-objective optimizers
(one many) compared to running a single many-objective optimizer (many once).
Be mindful of how running multiple instances affects the AbstractAlgorithm.step()
. Each step performs one iteration of each
instance. Thus, given 50 instances of an algorithm with a population size of 100, then 5000 evaluations will occur
each step. In [1], they decrease the population size for the single objective optimizers.
References:
- E. J. Hughes. "Evolutionary many-objective optimization: many once or one many." 2005 IEEE Congress on Evolutionary Computation, pp. 222-227.
-
Field Summary
Fields inherited from class org.moeaframework.algorithm.AbstractAlgorithm
initialized, numberOfEvaluations, problem, terminated
-
Constructor Summary
ConstructorDescriptionRepeatedSingleObjective
(Problem problem, int instances, String algorithmName, TypedProperties properties) Constructs a new instance of the RSO algorithm using the given single-objective algorithm.RepeatedSingleObjective
(Problem problem, int instances, BiFunction<Problem, double[], Algorithm> creator) Constructs a new instance of the RSO algorithm using randomly-generated weights.RepeatedSingleObjective
(Problem problem, WeightGenerator weightGenerator, BiFunction<Problem, double[], Algorithm> creator) Constructs a new instance of the RSO algorithm. -
Method Summary
Modifier and TypeMethodDescriptionint
Returns the number of times theevaluate
method was invoked.Returns the current best-known result.void
Performs any initialization that is required by this algorithm.protected void
iterate()
Performs one iteration of the algorithm.void
loadState
(ObjectInputStream stream) Loads the state of this object from the stream.void
saveState
(ObjectOutputStream stream) Writes the state of this object to the stream.Methods inherited from class org.moeaframework.algorithm.AbstractAlgorithm
assertNotInitialized, evaluate, getExtensions, getProblem, isInitialized, isTerminated, step, terminate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.moeaframework.core.Algorithm
evaluateAll, evaluateAll, run, run
Methods inherited from interface org.moeaframework.algorithm.extension.Extensible
addExtension, removeExtension
-
Constructor Details
-
RepeatedSingleObjective
public RepeatedSingleObjective(Problem problem, int instances, String algorithmName, TypedProperties properties) Constructs a new instance of the RSO algorithm using the given single-objective algorithm. The properties are passed to each individual algorithm with the addition of a"weights"
parameter, which is randomly-generated for each instance.- Parameters:
problem
- the problem to solvealgorithmName
- the algorithm nameproperties
- the algorithm propertiesinstances
- the number of instances
-
RepeatedSingleObjective
public RepeatedSingleObjective(Problem problem, int instances, BiFunction<Problem, double[], Algorithm> creator) Constructs a new instance of the RSO algorithm using randomly-generated weights.- Parameters:
problem
- the problem to solveinstances
- the number of single-objective algorithm instances to create using random weightscreator
- function that creates a single-objective algorithm for the given weight vector
-
RepeatedSingleObjective
public RepeatedSingleObjective(Problem problem, WeightGenerator weightGenerator, BiFunction<Problem, double[], Algorithm> creator) Constructs a new instance of the RSO algorithm. The weight generator defines the number of instances.- Parameters:
problem
- the problem to solveweightGenerator
- generates the weight vectors used to configure each single-objective algorithmcreator
- function that creates a single-objective algorithm for the given weight vector
-
-
Method Details
-
getNumberOfEvaluations
public int getNumberOfEvaluations()Description copied from interface:Algorithm
Returns the number of times theevaluate
method was invoked. This is the primary measure of runtime for optimization algorithms.- Specified by:
getNumberOfEvaluations
in interfaceAlgorithm
- Overrides:
getNumberOfEvaluations
in classAbstractAlgorithm
- Returns:
- the number of times the
evaluate
method was invoked
-
getResult
Description copied from interface:Algorithm
Returns the current best-known result.- Returns:
- the current best-known result
-
initialize
public void initialize()Description copied from interface:Algorithm
Performs 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 throwAlgorithmInitializationException
if called multiple times.Implementations should always call
super.initialize()
to ensure the algorithm is initialized correctly.- Specified by:
initialize
in interfaceAlgorithm
- Overrides:
initialize
in classAbstractAlgorithm
-
iterate
protected void iterate()Description copied from class:AbstractAlgorithm
Performs one iteration of the algorithm. This method should be overridden by implementations to perform each logical iteration of the algorithm.- Specified by:
iterate
in classAbstractAlgorithm
-
saveState
Description copied from interface:Stateful
Writes 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:
saveState
in interfaceStateful
- Overrides:
saveState
in classAbstractAlgorithm
- Parameters:
stream
- the stream- Throws:
IOException
- if an I/O error occurred
-
loadState
Description copied from interface:Stateful
Loads 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:
loadState
in interfaceStateful
- Overrides:
loadState
in classAbstractAlgorithm
- Parameters:
stream
- the stream- Throws:
IOException
- if an I/O error occurredClassNotFoundException
- if the stream referenced a class that is not defined
-