|
@@ -13,7 +13,7 @@ public class PsoAlgorithm extends AlgorithmFrameworkFlex{
|
|
private int swarmSize = 20;
|
|
private int swarmSize = 20;
|
|
private int maxIterations = 100;
|
|
private int maxIterations = 100;
|
|
private double dependency = 2.07;
|
|
private double dependency = 2.07;
|
|
- private int mutationInterval = 1;
|
|
|
|
|
|
+ private int mutationIteration = 1;
|
|
private boolean useIntervalMutation = true;
|
|
private boolean useIntervalMutation = true;
|
|
private double mutationRate = 0.01;
|
|
private double mutationRate = 0.01;
|
|
private double mutateProbabilityInterval = 0.01;
|
|
private double mutateProbabilityInterval = 0.01;
|
|
@@ -37,17 +37,17 @@ public class PsoAlgorithm extends AlgorithmFrameworkFlex{
|
|
|
|
|
|
public PsoAlgorithm() {
|
|
public PsoAlgorithm() {
|
|
super();
|
|
super();
|
|
- addIntParameter("swarmSize", swarmSize, intValue -> swarmSize = intValue, () -> swarmSize, 1);
|
|
|
|
- addIntParameter("maxIterations", maxIterations, intValue -> maxIterations = intValue, () -> maxIterations, 1);
|
|
|
|
- addDoubleParameter("dependency", dependency, doubleValue -> dependency = doubleValue, () -> dependency, 2.001, 2.4);
|
|
|
|
- addIntParameter("mutationInterval", mutationInterval, intValue -> mutationInterval = intValue, () -> mutationInterval, 0);
|
|
|
|
- addBooleanParameter("useIntervalMutation", useIntervalMutation, booleanValue -> useIntervalMutation = booleanValue);
|
|
|
|
- addDoubleParameter("mutateProbabilityInterval", mutateProbabilityInterval, doubleValue -> mutateProbabilityInterval = doubleValue, () -> mutateProbabilityInterval, 0.0, 1.0);
|
|
|
|
- addDoubleParameter("mutationRate", mutationRate, doubleValue -> mutationRate = doubleValue, () -> mutationRate, 0.0, 1.0);
|
|
|
|
- addDoubleParameter("maxMutationPercent", maxMutationPercent, doubleValue -> maxMutationPercent = doubleValue, () -> maxMutationPercent, 0.0, 1.0);
|
|
|
|
- addDoubleParameter("maxVelocity", maxVelocity, doubleValue -> maxVelocity = doubleValue, () -> maxVelocity, 0.0);
|
|
|
|
|
|
+ addIntParameter("Particles", swarmSize, intValue -> swarmSize = intValue, () -> swarmSize, 1);
|
|
|
|
+ addIntParameter("Iterations", maxIterations, intValue -> maxIterations = intValue, () -> maxIterations, 1);
|
|
|
|
+ addDoubleParameter("Dependency", dependency, doubleValue -> dependency = doubleValue, () -> dependency, 2.001, 2.4);
|
|
|
|
+ addIntParameter("Mutation iteration", mutationIteration, intValue -> mutationIteration = intValue, () -> mutationIteration, 0);
|
|
|
|
+ addBooleanParameter("Interval-based mutation", useIntervalMutation, booleanValue -> useIntervalMutation = booleanValue);
|
|
|
|
+ addDoubleParameter("Mutation probability (%)", mutateProbabilityInterval, doubleValue -> mutateProbabilityInterval = doubleValue, () -> mutateProbabilityInterval, 0.0, 1.0);
|
|
|
|
+ // addDoubleParameter("mutationRate", mutationRate, doubleValue -> mutationRate = doubleValue, () -> mutationRate, 0.0, 1.0);
|
|
|
|
+ addDoubleParameter("Mutation severity (% of problem size)", maxMutationPercent, doubleValue -> maxMutationPercent = doubleValue, () -> maxMutationPercent, 0.0, 1.0);
|
|
|
|
+ addDoubleParameter("Velocity", maxVelocity, doubleValue -> maxVelocity = doubleValue, () -> maxVelocity, 0.0);
|
|
|
|
|
|
- addBooleanParameter("moreInformation", moreInformation , booleanValue -> moreInformation = booleanValue);
|
|
|
|
|
|
+ addBooleanParameter("Detailed information", moreInformation , booleanValue -> moreInformation = booleanValue);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -103,7 +103,7 @@ public class PsoAlgorithm extends AlgorithmFrameworkFlex{
|
|
evaluation(globalBest, swarm);
|
|
evaluation(globalBest, swarm);
|
|
runList.add(globalBest.fitness);
|
|
runList.add(globalBest.fitness);
|
|
for (int iteration = 0; iteration < maxIterations ; iteration++) {
|
|
for (int iteration = 0; iteration < maxIterations ; iteration++) {
|
|
- int mutationAllowed = iteration % mutationInterval;
|
|
|
|
|
|
+ int mutationAllowed = iteration % mutationIteration;
|
|
double bitsFlipped = 0;
|
|
double bitsFlipped = 0;
|
|
for (int particleNumber = 0; particleNumber < swarmSize; particleNumber++) {
|
|
for (int particleNumber = 0; particleNumber < swarmSize; particleNumber++) {
|
|
Particle particle = swarm.get(particleNumber);
|
|
Particle particle = swarm.get(particleNumber);
|
|
@@ -123,7 +123,7 @@ public class PsoAlgorithm extends AlgorithmFrameworkFlex{
|
|
for(int index = 0; index < dimensions; index++) {
|
|
for(int index = 0; index < dimensions; index++) {
|
|
updateVelocity(particle, index, globalBest);
|
|
updateVelocity(particle, index, globalBest);
|
|
updateGenotype(particle, index);
|
|
updateGenotype(particle, index);
|
|
- if(mutationAllowed == 0 && iteration != 0 && Random.nextDouble() < mutationRate) {
|
|
|
|
|
|
+ if(mutationAllowed == 0 && iteration != 0 && Random.nextDouble() < mutateProbabilityInterval) {
|
|
count++;
|
|
count++;
|
|
mutation(particle, index);
|
|
mutation(particle, index);
|
|
}
|
|
}
|
|
@@ -264,7 +264,7 @@ public class PsoAlgorithm extends AlgorithmFrameworkFlex{
|
|
+ " maxIterations:" + maxIterations
|
|
+ " maxIterations:" + maxIterations
|
|
+ " swarmSize:" + swarmSize
|
|
+ " swarmSize:" + swarmSize
|
|
+ " dependency:" + dependency
|
|
+ " dependency:" + dependency
|
|
- + " mutationInterval:" + mutationInterval
|
|
|
|
|
|
+ + " mutationInterval:" + mutationIteration
|
|
+ " maxVelocity: " + maxVelocity
|
|
+ " maxVelocity: " + maxVelocity
|
|
+ (useIntervalMutation?
|
|
+ (useIntervalMutation?
|
|
(" mutateProbabilityInterval:" + mutateProbabilityInterval
|
|
(" mutateProbabilityInterval:" + mutateProbabilityInterval
|