|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjswarm_pso.Swarm
A swarm of particles
| Field Summary | |
(package private) double |
bestFitness
Best fitness so far (global best) |
(package private) int |
bestParticleIndex
Index of best particle so far |
(package private) double[] |
bestPosition
Best position so far (global best) |
static double |
DEFAULT_GLOBAL_INCREMENT
|
static double |
DEFAULT_INERTIA
|
static int |
DEFAULT_NUMBER_OF_PARTICLES
|
static double |
DEFAULT_OTHER_PARTICLE_INCREMENT
|
static double |
DEFAULT_PARTICLE_INCREMENT
|
static double |
DEFAULT_RANDOM_INCREMENT
|
(package private) FitnessFunction |
fitnessFunction
Fitness function for this swarm |
(package private) double |
globalIncrement
Global increment (for velocity update) |
(package private) double |
inertia
Inertia (for velocity update) |
(package private) double[] |
maxPosition
Maximum position (for each dimentions) |
(package private) double[] |
maxVelocity
Maximum Velocity (for each dimentions) |
(package private) double[] |
minPosition
Minimum position (for each dimentions) |
(package private) double[] |
minVelocity
Minimum Velocity for each dimention. |
(package private) int |
numberOfEvaliations
How many times 'particle.evaluate()' is called? |
(package private) int |
numberOfParticles
Number of particles in this swarm |
(package private) double |
otherParticleIncrement
Other particle increment |
(package private) double |
particleIncrement
Particle's increment (for velocity update) |
(package private) Particle[] |
particles
Particles in this swarm |
(package private) double |
randomIncrement
Random increment |
(package private) Particle |
sampleParticle
A sample particles: Build other particles based on this one |
(package private) boolean |
useRepulsiveAlgorithm
Use Repulsive Algorithm |
| Constructor Summary | |
Swarm(int numberOfParticles,
Particle sampleParticle,
FitnessFunction fitnessFunction)
Create a Swarm and set default values |
|
| Method Summary | |
void |
evaluate()
Evaluate fitness function for every particle Warning: particles[] must be initialized and fitnessFunction must be setted |
void |
evolve()
Make an iteration: - evaluates the swarm - updates positions and velocities - applies positions and velocities constraints |
double |
getBestFitness()
|
Particle |
getBestParticle()
|
int |
getBestParticleIndex()
|
double[] |
getBestPosition()
|
FitnessFunction |
getFitnessFunction()
|
double |
getGlobalIncrement()
|
double |
getInertia()
|
double[] |
getMaxPosition()
|
double[] |
getMaxVelocity()
|
double[] |
getMinPosition()
|
double[] |
getMinVelocity()
|
int |
getNumberOfEvaliations()
|
int |
getNumberOfParticles()
|
double |
getOtherParticleIncrement()
|
double |
getParticleIncrement()
|
Particle[] |
getParticles()
|
double |
getRandomIncrement()
|
Particle |
getSampleParticle()
|
void |
init()
Initialize every particle Warning: maxPosition[], minPosition[], maxVelocity[], minVelocity[] must be initialized and setted |
boolean |
isUseRepulsiveAlgorithm()
|
void |
setBestParticleIndex(int bestParticle)
|
void |
setBestPosition(double[] bestPosition)
|
void |
setFitnessFunction(FitnessFunction fitnessFunction)
|
void |
setGlobalIncrement(double globalIncrement)
|
void |
setInertia(double inertia)
|
void |
setMaxMinVelocity(double maxVelocity)
Sets every maxVelocity[] and minVelocity[] to 'maxVelocity' and '-maxVelocity' respectively |
void |
setMaxPosition(double maxPosition)
Sets every maxPosition[] to 'maxPosition' |
void |
setMaxPosition(double[] maxPosition)
|
void |
setMaxVelocity(double[] maxVelocity)
|
void |
setMinPosition(double minPosition)
Sets every minPosition[] to 'minPosition' |
void |
setMinPosition(double[] minPosition)
|
void |
setMinVelocity(double[] minVelocity)
|
void |
setNumberOfEvaliations(int numberOfEvaliations)
|
void |
setNumberOfParticles(int numberOfParticles)
|
void |
setOtherParticleIncrement(double otherParticleIncrement)
|
void |
setParticleIncrement(double particleIncrement)
|
void |
setParticles(Particle[] particle)
|
void |
setRandomIncrement(double randomIncrement)
|
void |
setSampleParticle(Particle sampleParticle)
|
void |
setUseRepulsiveAlgorithm(boolean useRepulsiveAlgorithm)
|
void |
show(java.awt.Graphics graphics,
java.awt.Color foreground,
int width,
int height,
int dim0,
int dim1,
boolean showVelocity)
Show a swarm in a graph |
java.lang.String |
toString()
|
java.lang.String |
toStringStats()
Return a string with some (very basic) statistics |
void |
update()
Update every particle's position and velocity, also apply position and velocity constraints (if any) Warning: Particles must be already evaluated |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static double DEFAULT_GLOBAL_INCREMENT
public static double DEFAULT_INERTIA
public static int DEFAULT_NUMBER_OF_PARTICLES
public static double DEFAULT_OTHER_PARTICLE_INCREMENT
public static double DEFAULT_PARTICLE_INCREMENT
public static double DEFAULT_RANDOM_INCREMENT
double bestFitness
int bestParticleIndex
double[] bestPosition
FitnessFunction fitnessFunction
double globalIncrement
double inertia
double[] maxPosition
double[] maxVelocity
double[] minPosition
double[] minVelocity
int numberOfEvaliations
int numberOfParticles
double otherParticleIncrement
double particleIncrement
Particle[] particles
double randomIncrement
Particle sampleParticle
boolean useRepulsiveAlgorithm
| Constructor Detail |
public Swarm(int numberOfParticles,
Particle sampleParticle,
FitnessFunction fitnessFunction)
numberOfParticles - : Number of particles in this swarm (should be greater than 0).
If unsure about this parameter, try Swarm.DEFAULT_NUMBER_OF_PARTICLES or greatersampleParticle - : A particle that is a sample to build all other particlesfitnessFunction - : Fitness function used to evaluate each particle| Method Detail |
public void evaluate()
public void evolve()
public double getBestFitness()
public Particle getBestParticle()
public int getBestParticleIndex()
public double[] getBestPosition()
public FitnessFunction getFitnessFunction()
public double getGlobalIncrement()
public double getInertia()
public double[] getMaxPosition()
public double[] getMaxVelocity()
public double[] getMinPosition()
public double[] getMinVelocity()
public int getNumberOfEvaliations()
public int getNumberOfParticles()
public double getOtherParticleIncrement()
public double getParticleIncrement()
public Particle[] getParticles()
public double getRandomIncrement()
public Particle getSampleParticle()
public void init()
public boolean isUseRepulsiveAlgorithm()
public void setBestParticleIndex(int bestParticle)
public void setBestPosition(double[] bestPosition)
public void setFitnessFunction(FitnessFunction fitnessFunction)
public void setGlobalIncrement(double globalIncrement)
public void setInertia(double inertia)
public void setMaxMinVelocity(double maxVelocity)
maxVelocity - public void setMaxPosition(double maxPosition)
maxPosition - public void setMaxPosition(double[] maxPosition)
public void setMaxVelocity(double[] maxVelocity)
public void setMinPosition(double minPosition)
minPosition - public void setMinPosition(double[] minPosition)
public void setMinVelocity(double[] minVelocity)
public void setNumberOfEvaliations(int numberOfEvaliations)
public void setNumberOfParticles(int numberOfParticles)
public void setOtherParticleIncrement(double otherParticleIncrement)
public void setParticleIncrement(double particleIncrement)
public void setParticles(Particle[] particle)
public void setRandomIncrement(double randomIncrement)
public void setSampleParticle(Particle sampleParticle)
public void setUseRepulsiveAlgorithm(boolean useRepulsiveAlgorithm)
public void show(java.awt.Graphics graphics,
java.awt.Color foreground,
int width,
int height,
int dim0,
int dim1,
boolean showVelocity)
graphics - : Grapics objectforeground - : foreground colorwidth - : graphic's widthheight - : graphic's heightdim0 - : Dimention to show ('x' axis)dim1 - : Dimention to show ('y' axis)showVelocity - : Show velocity tails?public java.lang.String toString()
public java.lang.String toStringStats()
public void update()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||