|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sourceforge.jswarm_pso.Swarm
public class 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_PARTICLE_INCREMENT
|
(package private) FitnessFunction |
fitnessFunction
Fitness function for this swarm |
(package private) double |
globalIncrement
Global increment (for velocity update), usually called 'c2' constant |
(package private) double |
inertia
Inertia (for velocity update), usually called 'w' constant |
(package private) double[] |
maxPosition
Maximum position (for each dimention) |
(package private) double[] |
maxVelocity
Maximum Velocity (for each dimention) |
(package private) double[] |
minPosition
Minimum position (for each dimention) |
(package private) double[] |
minVelocity
Minimum Velocity for each dimention. |
(package private) int |
numberOfEvaliations
How many times 'particle.evaluate()' has been called? |
(package private) int |
numberOfParticles
Number of particles in this swarm |
(package private) double |
particleIncrement
Particle's increment (for velocity update), usually called 'c1' constant |
(package private) Particle[] |
particles
Particles in this swarm |
(package private) ParticleUpdate |
particleUpdate
Particle update strategy |
(package private) Particle |
sampleParticle
A sample particles: Build other particles based on this one |
(package private) VariablesUpdate |
variablesUpdate
Variables update |
static double |
VELOCITY_GRAPH_FACTOR
|
| 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()
|
Particle |
getParticle(int i)
|
double |
getParticleIncrement()
|
Particle[] |
getParticles()
|
ParticleUpdate |
getParticleUpdate()
|
Particle |
getSampleParticle()
|
VariablesUpdate |
getVariablesUpdate()
|
void |
init()
Initialize every particle Warning: maxPosition[], minPosition[], maxVelocity[], minVelocity[] must be initialized and setted |
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 |
setParticleIncrement(double particleIncrement)
|
void |
setParticles(Particle[] particle)
|
void |
setParticleUpdate(ParticleUpdate particleUpdate)
|
void |
setSampleParticle(Particle sampleParticle)
|
void |
setVariablesUpdate(VariablesUpdate variablesUpdate)
|
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 |
int |
size()
Swarm size (number of particles) |
java.lang.String |
toString()
Printable string |
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_PARTICLE_INCREMENT
public static double VELOCITY_GRAPH_FACTOR
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 particleIncrement
Particle[] particles
ParticleUpdate particleUpdate
Particle sampleParticle
VariablesUpdate variablesUpdate
| 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 Particle getParticle(int i)
public double getParticleIncrement()
public Particle[] getParticles()
public ParticleUpdate getParticleUpdate()
public Particle getSampleParticle()
public VariablesUpdate getVariablesUpdate()
public void init()
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 setParticleIncrement(double particleIncrement)
public void setParticles(Particle[] particle)
public void setParticleUpdate(ParticleUpdate particleUpdate)
public void setSampleParticle(Particle sampleParticle)
public void setVariablesUpdate(VariablesUpdate variablesUpdate)
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 int size()
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String toStringStats()
public void update()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||