JSwarm-PSO is a Particle swarm optimization package written in Java. PSO is an optimization technique used to find global optimum for complex problems. Roughly stated, it's in the same 'category' as Genetic algorithms or Simmilated annealing. If you don't know what PSO is, I recommend you to start reading wikipedia's definition.
JSwarm-PSO is designed to require minimum effort to use while also highly modular.
Optimization example
This example tries to minimize Rastrigin's function which has infinie local minimum and maximum
(see Matlab's page for definitions).
You can run the example just typing the command (on unix like enviroments):
java -jar jswarm-pso_1_0_3.jarOn Windows it sohuld be enough to just double click on jar file.
How to optimize your own function / model
This is a simple description of the code you'll find in jswarm-pso.example1:
import jswarm_pso.FitnessFunction;
public class MyFitnessFunction extends FitnessFunction {
public double evaluate(double position[]) {
return position[0] + position[1];
}
}
|
import jswarm_pso.Particle;
public class MyParticle extends Particle {
// Create a 2-dimentional particle
public MyParticle() { super(2); }
}
|
// Create a swarm (using 'MyParticle' as sample particle // and 'MyFitnessFunction' as finess function) Swarm swarm = new Swarm(Swarm.DEFAULT_NUMBER_OF_PARTICLES , new MyParticle() , new MyFitnessFunction()); // Set position (and velocity) constraints. // i.e.: where to look for solutions swarm.setMaxPosition(1); swarm.setMinPosition(0); // Optimize a few times for( int i = 0; i < 20; i++ ) swarm.evolve(); // Print en results System.out.println(swarm.toStringStats()) |
Usuall / Deafult settings
Optimization type:
Particle position and velocity update
Each time the swarm evolves, updates every particle's position and velocity (see jswarm-pso.Particle.update() for details).
Particle's position is updated (for each dimention i):
// Update position position[i] = position[i] + velocity[i] |
While particle's velocity is updated (for each dimention i):
// Update velocity velocity[i] = inertia * velocity[i] // Inertia + randLocal * particleIncrement * (bestPosition[i] - position[i]) // Local best + randGlobal * globalIncrement * (globalBestPosition[i] - position[i]); // Global best |
Frequently asked questions
To do: Future releases
|
Please send your comments to:
Pablo Cingolani <pcingola@users.sourceforge.net>
. |