Package org.moeaframework.algorithm
Class ReferenceVectorGuidedPopulation
java.lang.Object
org.moeaframework.core.Population
org.moeaframework.algorithm.ReferenceVectorGuidedPopulation
- All Implemented Interfaces:
Iterable<Solution>
,Stateful
,Displayable
,Formattable<Solution>
A reference vector guided population, for use with RVEA, that truncates the population using the method outlined in
[1].
References:
- R. Cheng, Y. Jin, M. Olhofer, and B. Sendhoff. "A Reference Vector Guided Evolutionary Algorithm for Many-objective Optimization." IEEE Transactions on Evolutionary Computation, Issue 99, 2016.
-
Constructor Summary
ConstructorDescriptionReferenceVectorGuidedPopulation
(int numberOfObjectives, NormalBoundaryDivisions divisions) Constructs a new populationf or RVEA using default settings.ReferenceVectorGuidedPopulation
(int numberOfObjectives, NormalBoundaryDivisions divisions, double alpha) Constructs a new population for RVEA.ReferenceVectorGuidedPopulation
(int numberOfObjectives, NormalBoundaryDivisions divisions, double alpha, Iterable<? extends Solution> iterable) Constructs a new population for RVEA. -
Method Summary
Modifier and TypeMethodDescriptionprotected static double
acosine
(double[] line, double[] point) Returns the angle between the objective vector and a reference vector.void
adapt()
Normalize the reference vectors.associateToReferencePoint
(Population population) Associates each solution to the nearest reference vector, returning a list-of-lists.protected void
Compute the ideal point.copy()
Returns a copy of this population.protected static double
cosine
(double[] line, double[] point) Returns the cosine between the objective vector and a reference vector.double
getAlpha()
Returns thealpha
parameter, which controls the rate of change in the angle-penalized distance function.Returns the number of divisions used to generate the reference vectors.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.protected Solution
Select the solution with the smallest penalized distance.void
setScalingFactor
(double scalingFactor) Scaling factor used in the angle-penalized distance function.protected double
smallestAngleBetweenWeights
(int index) Computes the smallest angle between the given reference vector and all remaining vectors.protected void
Offsets the solutions in this population by the ideal point.void
truncate()
Truncates the population so that only one solution is associated with each reference vector.void
truncate
(int size, Comparator<? super Solution> comparator) Sorts this population using the specified comparator and removes the last (maximum) solutions until this population's size is within the specified size.Methods inherited from class org.moeaframework.core.Population
add, addAll, addAll, asList, asTabularData, clear, contains, containsAll, containsAll, filter, get, getLowerBounds, getUpperBounds, indexOf, isEmpty, iterator, loadBinary, loadBinary, loadObjectives, loadObjectives, remove, remove, removeAll, removeAll, removeAll, replace, saveBinary, saveBinary, saveObjectives, saveObjectives, size, sort
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.moeaframework.util.format.Displayable
display
Methods inherited from interface org.moeaframework.util.format.Formattable
display, display, display, save, saveCSV
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
ReferenceVectorGuidedPopulation
Constructs a new populationf or RVEA using default settings.- Parameters:
numberOfObjectives
- the number of objectivesdivisions
- the number of divisions
-
ReferenceVectorGuidedPopulation
public ReferenceVectorGuidedPopulation(int numberOfObjectives, NormalBoundaryDivisions divisions, double alpha) Constructs a new population for RVEA.- Parameters:
numberOfObjectives
- the number of objectivesdivisions
- the number of divisionsalpha
- controls the rate of change in the angle-penalized distance function
-
ReferenceVectorGuidedPopulation
public ReferenceVectorGuidedPopulation(int numberOfObjectives, NormalBoundaryDivisions divisions, double alpha, Iterable<? extends Solution> iterable) Constructs a new population for RVEA.- Parameters:
numberOfObjectives
- the number of objectivesdivisions
- the number of divisionsalpha
- controls the rate of change in the angle-penalized distance functioniterable
- the solutions used to initialize this population
-
-
Method Details
-
getDivisions
Returns the number of divisions used to generate the reference vectors.- Returns:
- the number of divisions
-
getAlpha
public double getAlpha()Returns thealpha
parameter, which controls the rate of change in the angle-penalized distance function.- Returns:
- the
alpha
parameter value
-
setScalingFactor
public void setScalingFactor(double scalingFactor) Scaling factor used in the angle-penalized distance function. This should be set tocurrentGeneration / maxGenerations
. Smaller values favor convergence while larger values favor diversity.- Parameters:
scalingFactor
- the scaling factor, between 0 and 1
-
adapt
public void adapt()Normalize the reference vectors. -
calculateIdealPoint
protected void calculateIdealPoint()Compute the ideal point. -
translateByIdealPoint
protected void translateByIdealPoint()Offsets the solutions in this population by the ideal point. This method does not modify the objective values, instead it sets theNormalizedObjectives
attribute. -
cosine
protected static double cosine(double[] line, double[] point) Returns the cosine between the objective vector and a reference vector. This method assumes the line is a normalized weight vector; the point does not need to be normalized.- Parameters:
line
- the line originating from the originpoint
- the point- Returns:
- the cosine
-
acosine
protected static double acosine(double[] line, double[] point) Returns the angle between the objective vector and a reference vector. This method assumes the line is a normalized weight vector; the point does not need to be normalized.- Parameters:
line
- the line originating from the originpoint
- the point- Returns:
- the angle (acosine)
-
associateToReferencePoint
Associates each solution to the nearest reference vector, returning a list-of-lists. The outer list maps to each reference vector using their index. The inner list is an unordered collection of the solutions associated with the reference point.- Parameters:
population
- the population of solutions- Returns:
- the association of solutions to reference points
-
smallestAngleBetweenWeights
protected double smallestAngleBetweenWeights(int index) Computes the smallest angle between the given reference vector and all remaining vectors.- Parameters:
index
- the index of the reference vector- Returns:
- the smallest angle between the given reference vector and all remaining vectors
-
select
Select the solution with the smallest penalized distance.- Parameters:
solutions
- the solutionsindex
- the index of the reference vector- Returns:
- the solution with the smallest penalized distance
-
truncate
Description copied from class:Population
Sorts this population using the specified comparator and removes the last (maximum) solutions until this population's size is within the specified size.- Overrides:
truncate
in classPopulation
- Parameters:
size
- the target population size after truncationcomparator
- the comparator to be used for truncation
-
truncate
public void truncate()Truncates the population so that only one solution is associated with each reference vector. -
copy
Description copied from class:Population
Returns a copy of this population. This can be thought of as a "deep copy", which creates a copy of both the population itself and copies of the individual solutions in the population. Consequently, the returned copy is completely independent, such that any modifications to the contents or order will not impact the original.Since creating such a "deep copy" can be expensive, prefer using the constructor
Population(Iterable)
orPopulation.addAll(Iterable)
whenever possible. These alternatives are useful when filtering or reordering the solutions, but the solutions themselves are left unchanged.- Overrides:
copy
in classPopulation
- Returns:
- the copy of this population
-
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 classPopulation
- 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 classPopulation
- Parameters:
stream
- the stream- Throws:
IOException
- if an I/O error occurredClassNotFoundException
- if the stream referenced a class that is not defined
-