org.dishevelled.swarm
Class ParticleSwarmImpl

java.lang.Object
  extended by org.dishevelled.swarm.ParticleSwarmImpl
All Implemented Interfaces:
Iterable<Particle>, ParticleSwarm

final class ParticleSwarmImpl
extends Object
implements ParticleSwarm

Particle swarm implementation.

Version:
$Revision$ $Date$
Author:
Michael Heuer

Constructor Summary
ParticleSwarmImpl(int particles, int dimensions)
          Create a new particle swarm implementation with the specified number of particles and number of dimensions.
 
Method Summary
(package private)  double[] getCognitiveMemory(int particle)
          Return a view of the cognitive memory matrix for the specified particle.
(package private)  double getCognitiveMemory(int particle, int dimension)
          Return the cognitive memory for the specified particle and dimension.
 int getDimensions()
          Return the number of dimensions for this particle swarm.
(package private)  double getFitness(int particle)
          Return the fitness for the specified particle.
 int getParticles()
          Return the number of particles in this particle swarm.
(package private)  double[] getPosition(int particle)
          Return a view of the position matrix for the specified particle.
(package private)  double getPosition(int particle, int dimension)
          Return the position for the specified particle and dimension.
 double[] getSocialMemory()
          Return a view of the social memory matrix for this particle swarm.
(package private)  double getSocialMemory(int dimension)
          Return the social memory for this particle swarm for the specified dimension.
(package private)  double[] getVelocity(int particle)
          Return a view of the velocity matrix for the specified particle.
(package private)  double getVelocity(int particle, int dimension)
          Return the velocity for the specified particle and dimension.
 Iterator<Particle> iterator()
          
(package private)  void setFitness(int particle, double fitness)
          Set the fitness for the specified particle to fitness.
(package private)  void setPosition(int particle, int dimension, double position)
          Set the position for the specified particle and dimension to position.
(package private)  void setVelocity(int particle, int dimension, double velocity)
          Set the velocity for the specified particle and dimension to velocity.
(package private)  void updateCognitiveMemory(int particle)
          Update the cognitive memory for the specified particle.
(package private)  void updateSocialMemory(int particle)
          Update the social memory for this particle swarm from the position of the specified particle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParticleSwarmImpl

ParticleSwarmImpl(int particles,
                  int dimensions)
Create a new particle swarm implementation with the specified number of particles and number of dimensions.

Parameters:
particles - number of particles for this particle swarm implementation, must be >= 1
dimensions - number of dimensions for this particle swarm implementation, must be >= 1
Method Detail

getParticles

public int getParticles()
Return the number of particles in this particle swarm.

Specified by:
getParticles in interface ParticleSwarm
Returns:
the number of particles in this particle swarm

getDimensions

public int getDimensions()
Return the number of dimensions for this particle swarm.

Specified by:
getDimensions in interface ParticleSwarm
Returns:
the number of dimensions for this particle swarm

getPosition

double[] getPosition(int particle)
Return a view of the position matrix for the specified particle.

Parameters:
particle - particle
Returns:
a view of the position matrix for the specified particle

getPosition

double getPosition(int particle,
                   int dimension)
Return the position for the specified particle and dimension.

Parameters:
particle - particle
dimension - dimension
Returns:
the position for the specified particle and dimension

setPosition

void setPosition(int particle,
                 int dimension,
                 double position)
Set the position for the specified particle and dimension to position.

Parameters:
particle - particle
dimension - dimension
position - position

getVelocity

double[] getVelocity(int particle)
Return a view of the velocity matrix for the specified particle.

Parameters:
particle - particle
Returns:
a view of the velocity matrix for the specified particle

getVelocity

double getVelocity(int particle,
                   int dimension)
Return the velocity for the specified particle and dimension.

Parameters:
particle - particle
dimension - dimension
Returns:
the velocity for the specified particle and dimension

setVelocity

void setVelocity(int particle,
                 int dimension,
                 double velocity)
Set the velocity for the specified particle and dimension to velocity.

Parameters:
particle - particle
dimension - dimension
velocity - velocity

getCognitiveMemory

double[] getCognitiveMemory(int particle)
Return a view of the cognitive memory matrix for the specified particle.

Parameters:
particle - particle
Returns:
a view of the cognitive memory matrix for the specified particle

getCognitiveMemory

double getCognitiveMemory(int particle,
                          int dimension)
Return the cognitive memory for the specified particle and dimension.

Parameters:
particle - particle
dimension - dimension
Returns:
the cognitive memory for the specified particle and dimension

getSocialMemory

public double[] getSocialMemory()
Return a view of the social memory matrix for this particle swarm. The length of the array will be equal to the number of dimensions for this particle swarm.

Specified by:
getSocialMemory in interface ParticleSwarm
Returns:
a view of the social memory matrix for this particle swarm

getSocialMemory

double getSocialMemory(int dimension)
Return the social memory for this particle swarm for the specified dimension.

Parameters:
dimension - dimension
Returns:
the social memory for this particle swarm for the specified dimension

getFitness

double getFitness(int particle)
Return the fitness for the specified particle.

Parameters:
particle - particle
Returns:
the fitness for the specified particle

setFitness

void setFitness(int particle,
                double fitness)
Set the fitness for the specified particle to fitness.

Parameters:
particle - particle
fitness - fitness

updateCognitiveMemory

void updateCognitiveMemory(int particle)
Update the cognitive memory for the specified particle.

Parameters:
particle - particle

updateSocialMemory

void updateSocialMemory(int particle)
Update the social memory for this particle swarm from the position of the specified particle.

Parameters:
particle - particle

iterator

public Iterator<Particle> iterator()

Specified by:
iterator in interface Iterable<Particle>


Copyright © 2006-2012 dishevelled.org. All Rights Reserved.