public abstract class AbstractPSOAlgorithm extends AbstractAlgorithm implements Configurable
Modifier and Type | Field and Description |
---|---|
protected NondominatedPopulation |
archive
The archive of non-dominated solutions; or
null of no external
archive is used. |
protected DominanceComparator |
dominanceComparator
Comparator for updating the local best particles.
|
protected DominanceComparator |
leaderComparator
Comparator for selecting leaders.
|
protected FitnessBasedArchive |
leaders
The leaders.
|
protected Solution[] |
localBestParticles
The local best particles.
|
protected Mutation |
mutation
Mutation operator, or
null if no mutation is defined. |
protected Solution[] |
particles
The particles.
|
protected double[][] |
velocities
The speed / velocity of each particle.
|
initialized, numberOfEvaluations, problem, terminated
Constructor and Description |
---|
AbstractPSOAlgorithm(Problem problem,
int swarmSize,
int leaderSize,
DominanceComparator leaderComparator,
DominanceComparator dominanceComparator,
FitnessBasedArchive leaders,
NondominatedPopulation archive,
Mutation mutation)
Constructs a new abstract PSO algorithm.
|
Modifier and Type | Method and Description |
---|---|
protected static java.util.List<Solution> |
copyToList(Solution[] solutions)
Converts an array of solutions to a list of solutions, creating copies of each solution.
|
protected NondominatedPopulation |
getArchive()
Returns the archive of non-dominated solutions; or
null of no external archive is used. |
java.util.List<Solution> |
getLeaders()
Returns the current leaders.
|
int |
getLeaderSize()
Returns the number of leaders, which tracks the best particles according to some fitness criteria.
|
java.util.List<Solution> |
getLocalBestParticles()
Returns the local best particles.
|
Mutation |
getMutation()
Returns the mutation operator, or
null if no mutation is defined. |
java.util.List<Solution> |
getParticles()
Returns the current particles.
|
NondominatedPopulation |
getResult()
Returns the current best-known result.
|
int |
getSwarmSize()
Returns the number of particles (aka swarm size or population size).
|
protected void |
initialize()
Performs any initialization that is required by this algorithm.
|
protected void |
iterate()
Performs one iteration of the algorithm.
|
void |
loadState(java.io.ObjectInputStream stream)
Loads the state of this object from the stream.
|
protected void |
mutate()
Applies the mutation operator to all particles.
|
protected void |
mutate(int i)
Applies the mutation operator to an individual particle.
|
void |
saveState(java.io.ObjectOutputStream stream)
Writes the state of this object to the stream.
|
protected Solution |
selectLeader()
Randomly select a leader.
|
protected void |
setArchive(NondominatedPopulation archive)
Sets the archive of non-dominated solutions; or
null of no external archive is used. |
void |
setLeaderSize(int leaderSize)
Sets the number of leaders, which tracks the best particles according to some fitness criteria.
|
void |
setSwarmSize(int swarmSize)
Sets the number of particles (aka swarm size or population size).
|
protected void |
updateLocalBest()
Updates the local best particles.
|
protected void |
updatePosition(int i)
Update the position of an individual particle.
|
protected void |
updatePositions()
Update the positions of all particles.
|
protected void |
updateVelocities()
Update the speeds of all particles.
|
protected void |
updateVelocity(int i)
Update the speed of an individual particle.
|
assertNotInitialized, evaluate, evaluateAll, evaluateAll, getNumberOfEvaluations, getProblem, isInitialized, isTerminated, step, terminate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
applyConfiguration, getConfiguration
checkTypeSafety, getState, setState, writeTypeSafety
protected Solution[] particles
protected Solution[] localBestParticles
protected FitnessBasedArchive leaders
protected NondominatedPopulation archive
null
of no external
archive is used.protected double[][] velocities
protected DominanceComparator leaderComparator
protected DominanceComparator dominanceComparator
protected Mutation mutation
null
if no mutation is defined.public AbstractPSOAlgorithm(Problem problem, int swarmSize, int leaderSize, DominanceComparator leaderComparator, DominanceComparator dominanceComparator, FitnessBasedArchive leaders, NondominatedPopulation archive, Mutation mutation)
problem
- the problemswarmSize
- the number of particlesleaderSize
- the number of leadersleaderComparator
- comparator for selecting leadersdominanceComparator
- comparator for updating the local best particlesleaders
- non-dominated population for storing the leadersarchive
- non-dominated population for storing the external archive;
or null
if no external archive is definedmutation
- mutation operator, or null
if no mutation is definedpublic int getSwarmSize()
public void setSwarmSize(int swarmSize)
swarmSize
- the swarm sizepublic int getLeaderSize()
public void setLeaderSize(int leaderSize)
leaderSize
- the leader sizepublic Mutation getMutation()
null
if no mutation is defined.null
protected NondominatedPopulation getArchive()
null
of no external archive is used.null
protected void setArchive(NondominatedPopulation archive)
null
of no external archive is used. This value
can only be set before initialization.archive
- the archive or null
.protected void updateVelocities()
protected void updateVelocity(int i)
i
- the index of the particleprotected void updatePositions()
protected void updatePosition(int i)
i
- the index of the particleprotected Solution selectLeader()
protected void updateLocalBest()
protected void mutate()
protected void mutate(int i)
i
- the index of the particlepublic NondominatedPopulation getResult()
Algorithm
protected void initialize()
AbstractAlgorithm
AbstractAlgorithm.step()
. Implementations should always invoke
super.initialize()
to ensure the algorithm is initialized
correctly.initialize
in class AbstractAlgorithm
protected void iterate()
AbstractAlgorithm
iterate
in class AbstractAlgorithm
public java.util.List<Solution> getParticles()
public java.util.List<Solution> getLocalBestParticles()
public java.util.List<Solution> getLeaders()
public void saveState(java.io.ObjectOutputStream stream) throws java.io.IOException
Stateful
super.saveState(stream)
followed by writing each
field.saveState
in interface Stateful
saveState
in class AbstractAlgorithm
stream
- the streamjava.io.IOException
- if an I/O error occurredpublic void loadState(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundException
Stateful
Stateful.saveState(ObjectOutputStream)
.loadState
in interface Stateful
loadState
in class AbstractAlgorithm
stream
- the streamjava.io.IOException
- if an I/O error occurredjava.lang.ClassNotFoundException
- if the stream referenced a class that is not definedCopyright 2009-2024 David Hadka and other contributors. All rights reserved.
Licensed under the GNU Lesser General Public License.
Return to the MOEA Framework homepage.