net.sourceforge.cilib.pso.particle
Class AbstractParticle

java.lang.Object
  extended by net.sourceforge.cilib.entity.AbstractEntity
      extended by net.sourceforge.cilib.pso.particle.AbstractParticle
All Implemented Interfaces:
Serializable, Comparable<Entity>, CandidateSolution, Entity, Particle, SocialEntity, Cloneable
Direct Known Subclasses:
ParticleDecorator, RNAParticle, StandardParticle

public abstract class AbstractParticle
extends AbstractEntity
implements Particle

This class defines the common behaviour available for all Particle instances.

Author:
Edwin Peer, Gary Pampara
See Also:
Serialized Form

Field Summary
protected  NeighbourhoodBestUpdateStrategy neighbourhoodBestUpdateStrategy
           
protected  PersonalBestUpdateStrategy personalBestUpdateStrategy
           
protected  PositionInitialisationStrategy positionInitialisationStrategy
           
protected  PositionUpdateStrategy positionUpdateStrategy
           
protected  VelocityInitialisationStrategy velocityInitialisationStrategy
           
protected  VelocityUpdateStrategy velocityUpdateStrategy
           
 
Constructor Summary
AbstractParticle()
          Default constructor for all Particles.
AbstractParticle(AbstractParticle copy)
          Copy constructor.
 
Method Summary
 void calculateFitness()
          Calculate the fitness of the Entity incrementing the number of fitness evaluations for the algorithm.
abstract  void calculateFitness(boolean count)
          Calculate the fitness of the Entity.
 int compareTo(Entity o)
          
 boolean equals(Object object)
           It doesn;t make sense to compare the meta data of the entity.
abstract  Fitness getBestFitness()
          Return the best fitness associated with this Entity, provided a best fitness is defined on the Entity.
abstract  StructuredType getBestPosition()
          Get the best position of the Particle.
abstract  Particle getClone()
          Make a clone of the Entity the exact semantics of the clone method will be defined by the classes that implements this interface.
abstract  int getDimension()
          Returns the dimension of the Entity.
abstract  Particle getNeighbourhoodBest()
          Get the current Particle's neighbourhood best.
 NeighbourhoodBestUpdateStrategy getNeighbourhoodBestUpdateStrategy()
          Get the reference to the currently employed NeighbourhoodBestUpdateStrategy.
 PersonalBestUpdateStrategy getPersonalBestUpdateStrategy()
          Get the current strategy to perform personal best updates.
abstract  StructuredType getPosition()
          Get the position of the Particle.
 PositionInitialisationStrategy getPositionInitialisationStrategy()
          Get the current PositionInitialisationStrategy.
 PositionUpdateStrategy getPositionUpdateStrategy()
          Get the current PostionUpdateStrategy associated with this Particle.
 Fitness getSocialBestFitness()
          Get the current social best fitness.
abstract  StructuredType getVelocity()
          Get the velocity representation of the Particle.
 VelocityInitialisationStrategy getVelocityInitialisationStrategy()
          Get the VelocityInitialisationStrategy.
 VelocityUpdateStrategy getVelocityUpdateStrategy()
          Get the VelocityUpdateStrategy of the current particle.
 int hashCode()
          
abstract  void setNeighbourhoodBest(Particle particle)
          Set the neighbourhood best particle for the current Particle based on the topology of the current particle.
 void setNeighbourhoodBestUpdateStrategy(NeighbourhoodBestUpdateStrategy neighbourhoodBestUpdateStrategy)
          Set the NeighbourhoodBestUpdateStrategy to be used by the Entity.
 void setPersonalBestUpdateStrategy(PersonalBestUpdateStrategy personalBestUpdateStrategy)
          Set the strategy to perform personal best updates.
 void setPositionInitialisationStrategy(PositionInitialisationStrategy positionInitialisationStrategy)
          Set the PositionInitialisationStrategy to be used.
 void setPositionUpdateStrategy(PositionUpdateStrategy positionUpdateStrategy)
          Set the PostionUpdateStrategy for the Particle.
 void setVelocityInitialisationStrategy(VelocityInitialisationStrategy velocityInitialisationStrategy)
          Set the velocityInitialisationStrategy.
 void setVelocityUpdateStrategy(VelocityUpdateStrategy velocityUpdateStrategy)
          Set the velocity updating strategy for the particle.
abstract  void updateControlParameters()
          Update all the ControlParameters that are maintained within the Particle.
abstract  void updatePosition()
          Update the position of the Particle.
abstract  void updateVelocity()
          Update the velocity of the Particle.
 
Methods inherited from class net.sourceforge.cilib.entity.AbstractEntity
getCandidateSolution, getFitness, getFitnessCalculator, getId, getProperties, setCandidateSolution, setFitnessCalculator, setProperties
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sourceforge.cilib.entity.Particle
getFitness
 
Methods inherited from interface net.sourceforge.cilib.entity.Entity
getCandidateSolution, getFitnessCalculator, getId, getProperties, initialise, reinitialise, setCandidateSolution, setProperties
 

Field Detail

positionUpdateStrategy

protected PositionUpdateStrategy positionUpdateStrategy

velocityUpdateStrategy

protected VelocityUpdateStrategy velocityUpdateStrategy

velocityInitialisationStrategy

protected VelocityInitialisationStrategy velocityInitialisationStrategy

positionInitialisationStrategy

protected PositionInitialisationStrategy positionInitialisationStrategy

personalBestUpdateStrategy

protected PersonalBestUpdateStrategy personalBestUpdateStrategy

neighbourhoodBestUpdateStrategy

protected NeighbourhoodBestUpdateStrategy neighbourhoodBestUpdateStrategy
Constructor Detail

AbstractParticle

public AbstractParticle()
Default constructor for all Particles.


AbstractParticle

public AbstractParticle(AbstractParticle copy)
Copy constructor. Create a copy of the given instance.

Parameters:
copy - The instance to copy.
Method Detail

getClone

public abstract Particle getClone()
Make a clone of the Entity the exact semantics of the clone method will be defined by the classes that implements this interface.

Specified by:
getClone in interface Entity
Specified by:
getClone in interface Particle
Specified by:
getClone in interface Cloneable
Returns:
the cloned object
See Also:
Object.clone()

equals

public boolean equals(Object object)
It doesn;t make sense to compare the meta data of the entity. In other words, the properties of the entity may vary, but the entity is still the same entity.

Overrides:
equals in class AbstractEntity
Parameters:
object - The object to compare equality.

hashCode

public int hashCode()

Overrides:
hashCode in class AbstractEntity

calculateFitness

public void calculateFitness()
Calculate the fitness of the Entity incrementing the number of fitness evaluations for the algorithm.

Specified by:
calculateFitness in interface Entity

calculateFitness

public abstract void calculateFitness(boolean count)
Calculate the fitness of the Entity. This method may or may not increment the number of fitness evaluations of the algorithm.

Specified by:
calculateFitness in interface Entity
Parameters:
count - Add or do not add this fitness evaluation to the algorithm global count.

getBestFitness

public abstract Fitness getBestFitness()
Return the best fitness associated with this Entity, provided a best fitness is defined on the Entity. If a best fitness is not defined, the current fitness is returned as it is the best current fitness. Entity objects that need to use this method need to override it in their implementation, for example with Particle objects.

Specified by:
getBestFitness in interface Entity
Specified by:
getBestFitness in interface Particle
Overrides:
getBestFitness in class AbstractEntity
Returns:
The associated best Fitness value.

getDimension

public abstract int getDimension()
Returns the dimension of the Entity.

Specified by:
getDimension in interface Entity
Specified by:
getDimension in interface Particle
Returns:
The dimension of the Entity.

getPosition

public abstract StructuredType getPosition()
Get the position of the Particle.

Specified by:
getPosition in interface Particle
Returns:
A Type representing the Particle's position.

getBestPosition

public abstract StructuredType getBestPosition()
Get the best position of the Particle.

Specified by:
getBestPosition in interface Particle
Returns:
A Type representng the Particle's best position.

getVelocity

public abstract StructuredType getVelocity()
Get the velocity representation of the Particle.

Specified by:
getVelocity in interface Particle
Returns:
A Type representing the Particle's velocity.

setNeighbourhoodBest

public abstract void setNeighbourhoodBest(Particle particle)
Set the neighbourhood best particle for the current Particle based on the topology of the current particle.

Specified by:
setNeighbourhoodBest in interface Particle
Parameters:
particle - The particle to use as the current particle's neighhod best particle

getNeighbourhoodBest

public abstract Particle getNeighbourhoodBest()
Get the current Particle's neighbourhood best.

Specified by:
getNeighbourhoodBest in interface Particle
Returns:
The neighbourhood best of the Particle

updatePosition

public abstract void updatePosition()
Update the position of the Particle.

Specified by:
updatePosition in interface Particle

updateVelocity

public abstract void updateVelocity()
Update the velocity of the Particle.

Specified by:
updateVelocity in interface Particle

updateControlParameters

public abstract void updateControlParameters()
Update all the ControlParameters that are maintained within the Particle.

Specified by:
updateControlParameters in interface Particle

getPositionUpdateStrategy

public PositionUpdateStrategy getPositionUpdateStrategy()
Get the current PostionUpdateStrategy associated with this Particle.

Specified by:
getPositionUpdateStrategy in interface Particle
Returns:
The currently associated PositionUpdateStrategy.

setPositionUpdateStrategy

public void setPositionUpdateStrategy(PositionUpdateStrategy positionUpdateStrategy)
Set the PostionUpdateStrategy for the Particle.

Specified by:
setPositionUpdateStrategy in interface Particle
Parameters:
positionUpdateStrategy - The PositionUpdateStrategy to use.

getVelocityUpdateStrategy

public VelocityUpdateStrategy getVelocityUpdateStrategy()
Get the VelocityUpdateStrategy of the current particle.

Specified by:
getVelocityUpdateStrategy in interface Particle
Returns:
Returns the velocityUpdateStrategy.

setVelocityUpdateStrategy

public void setVelocityUpdateStrategy(VelocityUpdateStrategy velocityUpdateStrategy)
Set the velocity updating strategy for the particle.

Specified by:
setVelocityUpdateStrategy in interface Particle
Parameters:
velocityUpdateStrategy - The velocityUpdateStrategy to set.

getVelocityInitialisationStrategy

public VelocityInitialisationStrategy getVelocityInitialisationStrategy()
Get the VelocityInitialisationStrategy.

Specified by:
getVelocityInitialisationStrategy in interface Particle
Returns:
The current VelocityInitialisationStrategy.

setVelocityInitialisationStrategy

public void setVelocityInitialisationStrategy(VelocityInitialisationStrategy velocityInitialisationStrategy)
Set the velocityInitialisationStrategy.

Specified by:
setVelocityInitialisationStrategy in interface Particle
Parameters:
velocityInitialisationStrategy - The value to set.

getPositionInitialisationStrategy

public PositionInitialisationStrategy getPositionInitialisationStrategy()
Get the current PositionInitialisationStrategy.

Returns:
The current PositionInitialisationStrategy.

setPositionInitialisationStrategy

public void setPositionInitialisationStrategy(PositionInitialisationStrategy positionInitialisationStrategy)
Set the PositionInitialisationStrategy to be used.

Parameters:
positionInitialisationStrategy - The value to set.

getNeighbourhoodBestUpdateStrategy

public NeighbourhoodBestUpdateStrategy getNeighbourhoodBestUpdateStrategy()
Get the reference to the currently employed NeighbourhoodBestUpdateStrategy.

Specified by:
getNeighbourhoodBestUpdateStrategy in interface SocialEntity
Returns:
A reference to the current NeighbourhoodBestUpdateStrategy object

setNeighbourhoodBestUpdateStrategy

public void setNeighbourhoodBestUpdateStrategy(NeighbourhoodBestUpdateStrategy neighbourhoodBestUpdateStrategy)
Set the NeighbourhoodBestUpdateStrategy to be used by the Entity.

Specified by:
setNeighbourhoodBestUpdateStrategy in interface SocialEntity
Parameters:
neighbourhoodBestUpdateStrategy - The NeighbourhoodBestUpdateStrategy to be used

getSocialBestFitness

public Fitness getSocialBestFitness()
Get the current social best fitness. This Fitness value is dependent on the current NeighbourhoodBestUpdateStrategy.

Specified by:
getSocialBestFitness in interface SocialEntity
Returns:
The fitness based on the currently set NeighbourhoodBestUpdateStrategy.

compareTo

public int compareTo(Entity o)

Specified by:
compareTo in interface Comparable<Entity>
Specified by:
compareTo in interface Entity

getPersonalBestUpdateStrategy

public PersonalBestUpdateStrategy getPersonalBestUpdateStrategy()
Get the current strategy to perform personal best updates.

Specified by:
getPersonalBestUpdateStrategy in interface Particle
Returns:
The current PersonalBestUpdateStrategy.

setPersonalBestUpdateStrategy

public void setPersonalBestUpdateStrategy(PersonalBestUpdateStrategy personalBestUpdateStrategy)
Set the strategy to perform personal best updates.

Specified by:
setPersonalBestUpdateStrategy in interface Particle
Parameters:
personalBestUpdateStrategy - The instance to set.


Copyright © 2009 CIRG. All Rights Reserved.