parent
43768d1f96
commit
a3cf5971fb
@ -123,8 +123,8 @@ public class ANPSO extends NichePSO implements InterfaceAdditionalPopulationInfo
|
|||||||
getMainSwarm().setPhi1(2.05);
|
getMainSwarm().setPhi1(2.05);
|
||||||
getMainSwarm().setPhi2(2.05);
|
getMainSwarm().setPhi2(2.05);
|
||||||
getMainSwarm().setInertnessOrChi(0.7298437881283576);
|
getMainSwarm().setInertnessOrChi(0.7298437881283576);
|
||||||
// setMainSwarmInertness(new NoParameterAging(0.7298437881283576));
|
getMainSwarm().setAlgoType(ParticleSwarmOptimization.PSOType.Constriction);
|
||||||
setMainSwarmAlgoType(getMainSwarm().getAlgoType().setSelectedTag("Constriction")); // constriction
|
setMainSwarmAlgoType(ParticleSwarmOptimization.PSOType.Constriction); // constriction
|
||||||
setMaxInitialSubSwarmSize(0); // deactivate early reinits
|
setMaxInitialSubSwarmSize(0); // deactivate early reinits
|
||||||
setMainSwarmTopology(PSOTopology.grid);
|
setMainSwarmTopology(PSOTopology.grid);
|
||||||
setMainSwarmTopologyRange(1);
|
setMainSwarmTopologyRange(1);
|
||||||
@ -905,7 +905,8 @@ public class ANPSO extends NichePSO implements InterfaceAdditionalPopulationInfo
|
|||||||
anpso.getMainSwarm().setPhi1(2.05);
|
anpso.getMainSwarm().setPhi1(2.05);
|
||||||
anpso.getMainSwarm().setPhi2(2.05);
|
anpso.getMainSwarm().setPhi2(2.05);
|
||||||
anpso.getMainSwarm().setInertnessOrChi(0.7298437881283576);
|
anpso.getMainSwarm().setInertnessOrChi(0.7298437881283576);
|
||||||
anpso.setMainSwarmAlgoType(anpso.getMainSwarm().getAlgoType().setSelectedTag("Constriction")); // constriction
|
anpso.getMainSwarm().setAlgoType(ParticleSwarmOptimization.PSOType.Constriction);
|
||||||
|
anpso.setMainSwarmAlgoType(ParticleSwarmOptimization.PSOType.Constriction); // constriction
|
||||||
anpso.setMaxInitialSubSwarmSize(0); // deactivate early reinits
|
anpso.setMaxInitialSubSwarmSize(0); // deactivate early reinits
|
||||||
anpso.setMainSwarmTopology(PSOTopology.grid);
|
anpso.setMainSwarmTopology(PSOTopology.grid);
|
||||||
anpso.setMainSwarmTopologyRange(1);
|
anpso.setMainSwarmTopologyRange(1);
|
||||||
@ -924,7 +925,8 @@ public class ANPSO extends NichePSO implements InterfaceAdditionalPopulationInfo
|
|||||||
anpso.getMainSwarm().setParameterControl(new ParamAdaption[]{new LinearParamAdaption("inertnessOrChi", 0.7, 0.2)});
|
anpso.getMainSwarm().setParameterControl(new ParamAdaption[]{new LinearParamAdaption("inertnessOrChi", 0.7, 0.2)});
|
||||||
// anpso.setMainSwarmInertness(new LinearParameterAging(0.7, 0.2, evalCnt/anpso.getMainSwarmSize()));
|
// anpso.setMainSwarmInertness(new LinearParameterAging(0.7, 0.2, evalCnt/anpso.getMainSwarmSize()));
|
||||||
|
|
||||||
anpso.setMainSwarmAlgoType(anpso.getMainSwarm().getAlgoType().setSelectedTag("Inertness"));
|
anpso.getMainSwarm().setAlgoType(ParticleSwarmOptimization.PSOType.Inertness);
|
||||||
|
anpso.setMainSwarmAlgoType(ParticleSwarmOptimization.PSOType.Inertness); // inertness
|
||||||
anpso.getMainSwarm().setPhi1(1.2);
|
anpso.getMainSwarm().setPhi1(1.2);
|
||||||
anpso.getMainSwarm().setPhi2(0.6); // ANPSO uses communication in the main swarm
|
anpso.getMainSwarm().setPhi2(0.6); // ANPSO uses communication in the main swarm
|
||||||
//Possible topologies are: "Linear", "Grid", "Star", "Multi-Swarm", "Tree", "HPSO", "Random" in that order starting by 0.
|
//Possible topologies are: "Linear", "Grid", "Star", "Multi-Swarm", "Tree", "HPSO", "Random" in that order starting by 0.
|
||||||
@ -944,7 +946,8 @@ public class ANPSO extends NichePSO implements InterfaceAdditionalPopulationInfo
|
|||||||
|
|
||||||
anpso.getMainSwarm().setParameterControl(new ParamAdaption[]{new LinearParamAdaption("inertnessOrChi", 0.7, 0.2)});
|
anpso.getMainSwarm().setParameterControl(new ParamAdaption[]{new LinearParamAdaption("inertnessOrChi", 0.7, 0.2)});
|
||||||
|
|
||||||
anpso.setMainSwarmAlgoType(anpso.getMainSwarm().getAlgoType().setSelectedTag("Inertness"));
|
anpso.getMainSwarm().setAlgoType(ParticleSwarmOptimization.PSOType.Inertness);
|
||||||
|
anpso.setMainSwarmAlgoType(ParticleSwarmOptimization.PSOType.Inertness);
|
||||||
anpso.getMainSwarm().setPhi1(1.2);
|
anpso.getMainSwarm().setPhi1(1.2);
|
||||||
anpso.getMainSwarm().setPhi2(1.2); // ANPSO uses communication in the main swarm
|
anpso.getMainSwarm().setPhi2(1.2); // ANPSO uses communication in the main swarm
|
||||||
//Possible topologies are: "Linear", "Grid", "Star", "Multi-Swarm", "Tree", "HPSO", "Random" in that order starting by 0.
|
//Possible topologies are: "Linear", "Grid", "Star", "Multi-Swarm", "Tree", "HPSO", "Random" in that order starting by 0.
|
||||||
|
@ -33,17 +33,6 @@ public class CBNPSO extends ClusterBasedNichingEA implements Serializable {
|
|||||||
|
|
||||||
public CBNPSO(boolean threshAdaption) {
|
public CBNPSO(boolean threshAdaption) {
|
||||||
this(10, 15, 0.001, 1e-10, 15, 100, threshAdaption);
|
this(10, 15, 0.001, 1e-10, 15, 100, threshAdaption);
|
||||||
// super();
|
|
||||||
// setDifferentiationCA(new ClusteringDensityBased(getClusterDiffDist(), 10, new IndividualDataMetric(ParticleSwarmOptimization.partBestPosKey)));
|
|
||||||
// setMergingCA(new ClusteringDensityBased(0.001, 3, new IndividualDataMetric(ParticleSwarmOptimization.partBestPosKey)));
|
|
||||||
// setEpsilonBound(1e-10);
|
|
||||||
// setHaltingWindow(15);
|
|
||||||
// setMaxSpeciesSize(15);
|
|
||||||
// setOptimizer(new ParticleSwarmOptimization(100, 2.05, 2.05, PSOTopologyEnum.grid, 2));
|
|
||||||
// ParamAdaption[] defAdpt = new ParamAdaption[]{getDefaultSinusoidalAdaption()};
|
|
||||||
// setParameterControl(defAdpt);
|
|
||||||
// if (threshAdaption) addParameterControl(getDefaultThreshAdaption());
|
|
||||||
// setPopulationSize(100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CBNPSO(int minSpecSize, int maxSpecSize, double sigmaMerge, double epsilonConv, int haltingWindow, int popSize, boolean threshAdaption) {
|
public CBNPSO(int minSpecSize, int maxSpecSize, double sigmaMerge, double epsilonConv, int haltingWindow, int popSize, boolean threshAdaption) {
|
||||||
|
@ -256,7 +256,7 @@ public class DynamicParticleSwarmOptimization extends ParticleSwarmOptimization
|
|||||||
for (int i = 0; i < lastVelocity.length; i++) {
|
for (int i = 0; i < lastVelocity.length; i++) {
|
||||||
// the component from the old velocity
|
// the component from the old velocity
|
||||||
curVelocity[i] = this.inertnessOrChi * lastVelocity[i];
|
curVelocity[i] = this.inertnessOrChi * lastVelocity[i];
|
||||||
if (algType.getSelectedTag().getID() == 1) {
|
if (algType == PSOType.Constriction) {
|
||||||
chi = inertnessOrChi;
|
chi = inertnessOrChi;
|
||||||
} else {
|
} else {
|
||||||
chi = 1.;
|
chi = 1.;
|
||||||
|
@ -94,7 +94,7 @@ public class NichePSO extends AbstractOptimizer implements InterfaceAdditionalPo
|
|||||||
// protected double mainSwarmPhi2 = 0; // by default no communication in the mainswarm
|
// protected double mainSwarmPhi2 = 0; // by default no communication in the mainswarm
|
||||||
protected PSOTopology mainSwarmTopology = PSOTopology.grid; // = 1;
|
protected PSOTopology mainSwarmTopology = PSOTopology.grid; // = 1;
|
||||||
protected int mainSwarmTopologyRange = 0;
|
protected int mainSwarmTopologyRange = 0;
|
||||||
private int mainSwarmAlgoType = 0; // 0: inertness, 1: constriction
|
private ParticleSwarmOptimization.PSOType mainSwarmAlgoType = ParticleSwarmOptimization.PSOType.Inertness; // 0: inertness, 1: constriction
|
||||||
// private InterfaceParameterAging mainSwarmParamAging = new LinearParameterAging();
|
// private InterfaceParameterAging mainSwarmParamAging = new LinearParameterAging();
|
||||||
protected ParameterControlManager paramControl = new ParameterControlManager();
|
protected ParameterControlManager paramControl = new ParameterControlManager();
|
||||||
boolean returnRepresentativeSolutionsOnly = true; // if true only the representatives of every subswarm are returned, else every particles pbest
|
boolean returnRepresentativeSolutionsOnly = true; // if true only the representatives of every subswarm are returned, else every particles pbest
|
||||||
@ -237,7 +237,8 @@ public class NichePSO extends AbstractOptimizer implements InterfaceAdditionalPo
|
|||||||
getMainSwarm().setGcpso(false);
|
getMainSwarm().setGcpso(false);
|
||||||
// getMainSwarm().setAlgoType(new SelectedTag("Inertness"));
|
// getMainSwarm().setAlgoType(new SelectedTag("Inertness"));
|
||||||
getMainSwarm().setParameterControl(new ParamAdaption[]{getDefaultInertnessAdaption()});
|
getMainSwarm().setParameterControl(new ParamAdaption[]{getDefaultInertnessAdaption()});
|
||||||
setMainSwarmAlgoType(getMainSwarm().getAlgoType().setSelectedTag(mainSwarmAlgoType)); // set algo type, may influence aging
|
getMainSwarm().setAlgoType(mainSwarmAlgoType);
|
||||||
|
setMainSwarmAlgoType(mainSwarmAlgoType); // set algo type, may influence aging
|
||||||
|
|
||||||
// getMainSwarm().setPhi1(mainSwarmPhi1); // cognitive component "tendency to return to the best position visited so far"
|
// getMainSwarm().setPhi1(mainSwarmPhi1); // cognitive component "tendency to return to the best position visited so far"
|
||||||
// getMainSwarm().setPhi2(mainSwarmPhi2); // social component "tendency to be attracted towards the best position found in its neighbourhood."
|
// getMainSwarm().setPhi2(mainSwarmPhi2); // social component "tendency to be attracted towards the best position found in its neighbourhood."
|
||||||
@ -263,7 +264,7 @@ public class NichePSO extends AbstractOptimizer implements InterfaceAdditionalPo
|
|||||||
// choose PSO-type for the subswarmoptimizer
|
// choose PSO-type for the subswarmoptimizer
|
||||||
getSubswarmOptimizerTemplate().setGcpso(true);
|
getSubswarmOptimizerTemplate().setGcpso(true);
|
||||||
getSubswarmOptimizerTemplate().setRho(0.1); // on 2D Problems empirically better than default value 1
|
getSubswarmOptimizerTemplate().setRho(0.1); // on 2D Problems empirically better than default value 1
|
||||||
getSubswarmOptimizerTemplate().getAlgoType().setSelectedTag("Constriction");//setAlgoType(new SelectedTag("Inertness"));
|
getSubswarmOptimizerTemplate().setAlgoType(ParticleSwarmOptimization.PSOType.Constriction);
|
||||||
|
|
||||||
//"Several studies propose different values for these parameters" (http://tracer.uc3m.es/tws/pso/parameters.html)
|
//"Several studies propose different values for these parameters" (http://tracer.uc3m.es/tws/pso/parameters.html)
|
||||||
//Bergh2002 p.87
|
//Bergh2002 p.87
|
||||||
@ -974,16 +975,16 @@ public class NichePSO extends AbstractOptimizer implements InterfaceAdditionalPo
|
|||||||
this.mainSwarmTopologyRange = mainSwarmTopologyRange;
|
this.mainSwarmTopologyRange = mainSwarmTopologyRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SelectedTag getMainSwarmAlgoType() {
|
public ParticleSwarmOptimization.PSOType getMainSwarmAlgoType() {
|
||||||
if (mainSwarmAlgoType != getMainSwarm().getAlgoType().getSelectedTagID()) {
|
if (mainSwarmAlgoType != getMainSwarm().getAlgoType()) {
|
||||||
System.err.println("Error in NichePSO:getMainSwarmAlgoType() !!");
|
System.err.println("Error in NichePSO:getMainSwarmAlgoType() !!");
|
||||||
}
|
}
|
||||||
return getMainSwarm().getAlgoType();
|
return getMainSwarm().getAlgoType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMainSwarmAlgoType(SelectedTag st) {
|
public void setMainSwarmAlgoType(ParticleSwarmOptimization.PSOType st) {
|
||||||
getMainSwarm().setAlgoType(st);
|
getMainSwarm().setAlgoType(st);
|
||||||
mainSwarmAlgoType = st.getSelectedTagID();
|
mainSwarmAlgoType = st;
|
||||||
// mainSwarmParamAging.setStartValue(getMainSwarm().getInertnessOrChi());
|
// mainSwarmParamAging.setStartValue(getMainSwarm().getInertnessOrChi());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2048,12 +2049,12 @@ public class NichePSO extends AbstractOptimizer implements InterfaceAdditionalPo
|
|||||||
npso.setMaxAllowedSwarmRadius(0.0001); // formally limits the swarm radius of the subswarms
|
npso.setMaxAllowedSwarmRadius(0.0001); // formally limits the swarm radius of the subswarms
|
||||||
|
|
||||||
// Parameter for the mainswarm
|
// Parameter for the mainswarm
|
||||||
npso.getMainSwarmAlgoType().setSelectedTag("Inertness");
|
npso.setMainSwarmAlgoType(ParticleSwarmOptimization.PSOType.Inertness);
|
||||||
npso.getMainSwarm().setPhi1(1.2);
|
npso.getMainSwarm().setPhi1(1.2);
|
||||||
npso.getMainSwarm().setPhi2(0); // by default no communication in the mainswarm
|
npso.getMainSwarm().setPhi2(0); // by default no communication in the mainswarm
|
||||||
npso.setMainSwarmTopologyTag(0); // this doesnt have any effect due to no communication
|
npso.setMainSwarmTopologyTag(0); // this doesnt have any effect due to no communication
|
||||||
npso.setMainSwarmTopologyRange(0);
|
npso.setMainSwarmTopologyRange(0);
|
||||||
npso.mainSwarmAlgoType = 0;
|
npso.mainSwarmAlgoType = ParticleSwarmOptimization.PSOType.Inertness;
|
||||||
npso.getMainSwarm().setParameterControl(new ParamAdaption[]{getDefaultInertnessAdaption()});
|
npso.getMainSwarm().setParameterControl(new ParamAdaption[]{getDefaultInertnessAdaption()});
|
||||||
// npso.getMainSwarm().setSpeedLimit(avgRange/2.);
|
// npso.getMainSwarm().setSpeedLimit(avgRange/2.);
|
||||||
// npso.getMainSwarm().setCheckSpeedLimit(true);
|
// npso.getMainSwarm().setCheckSpeedLimit(true);
|
||||||
@ -2062,7 +2063,7 @@ public class NichePSO extends AbstractOptimizer implements InterfaceAdditionalPo
|
|||||||
npso.getSubswarmOptimizerTemplate().setGcpso(true);
|
npso.getSubswarmOptimizerTemplate().setGcpso(true);
|
||||||
npso.getSubswarmOptimizerTemplate().setRho(0.1); // on 2D Problems empirically better than default value 1
|
npso.getSubswarmOptimizerTemplate().setRho(0.1); // on 2D Problems empirically better than default value 1
|
||||||
// npso.getSubswarmOptimizerTemplate().setAlgoType(new SelectedTag("Constriction"));
|
// npso.getSubswarmOptimizerTemplate().setAlgoType(new SelectedTag("Constriction"));
|
||||||
npso.getSubswarmOptimizerTemplate().setAlgoType(npso.getSubswarmOptimizerTemplate().getAlgoType().setSelectedTag("Constriction")); // constriction
|
npso.getSubswarmOptimizerTemplate().setAlgoType(ParticleSwarmOptimization.PSOType.Constriction); // constriction
|
||||||
npso.getSubswarmOptimizerTemplate().setConstriction(2.05, 2.05);
|
npso.getSubswarmOptimizerTemplate().setConstriction(2.05, 2.05);
|
||||||
// npso.getSubswarmOptimizerTemplate().setInertnessAging(new LinearParameterAging(0.7, 0.2, evalCnt/(10*popSize))); // expect shorter
|
// npso.getSubswarmOptimizerTemplate().setInertnessAging(new LinearParameterAging(0.7, 0.2, evalCnt/(10*popSize))); // expect shorter
|
||||||
|
|
||||||
@ -2103,12 +2104,13 @@ public class NichePSO extends AbstractOptimizer implements InterfaceAdditionalPo
|
|||||||
npso.setMaxAllowedSwarmRadius(0.0001); // formally limits the swarm radius of the subswarms
|
npso.setMaxAllowedSwarmRadius(0.0001); // formally limits the swarm radius of the subswarms
|
||||||
|
|
||||||
// Parameter for the mainswarm
|
// Parameter for the mainswarm
|
||||||
npso.setMainSwarmAlgoType(npso.getMainSwarm().getAlgoType().setSelectedTag("Inertness")); // constriction
|
npso.getMainSwarm().setAlgoType(ParticleSwarmOptimization.PSOType.Inertness);
|
||||||
|
npso.setMainSwarmAlgoType(ParticleSwarmOptimization.PSOType.Inertness);
|
||||||
npso.getMainSwarm().setPhi1(1.2);
|
npso.getMainSwarm().setPhi1(1.2);
|
||||||
// npso.SetMainSwarmPhi2(0); // by default no communication in the mainswarm
|
// npso.SetMainSwarmPhi2(0); // by default no communication in the mainswarm
|
||||||
npso.setMainSwarmTopologyTag(0); // this doesnt have any effect due to no communication
|
npso.setMainSwarmTopologyTag(0); // this doesnt have any effect due to no communication
|
||||||
npso.setMainSwarmTopologyRange(0);
|
npso.setMainSwarmTopologyRange(0);
|
||||||
npso.mainSwarmAlgoType = 0;
|
npso.mainSwarmAlgoType = ParticleSwarmOptimization.PSOType.Inertness;
|
||||||
npso.getMainSwarm().setParameterControl(new ParamAdaption[]{getDefaultInertnessAdaption()});
|
npso.getMainSwarm().setParameterControl(new ParamAdaption[]{getDefaultInertnessAdaption()});
|
||||||
// npso.setMainSwarmInertness(new LinearParameterAging(0.7, 0.2, evalCnt/popSize));
|
// npso.setMainSwarmInertness(new LinearParameterAging(0.7, 0.2, evalCnt/popSize));
|
||||||
// npso.getMainSwarm().setSpeedLimit(avgRange/2.);
|
// npso.getMainSwarm().setSpeedLimit(avgRange/2.);
|
||||||
@ -2117,7 +2119,7 @@ public class NichePSO extends AbstractOptimizer implements InterfaceAdditionalPo
|
|||||||
// parameters for the subswarms
|
// parameters for the subswarms
|
||||||
npso.getSubswarmOptimizerTemplate().setGcpso(true);
|
npso.getSubswarmOptimizerTemplate().setGcpso(true);
|
||||||
npso.getSubswarmOptimizerTemplate().setRho(0.01);
|
npso.getSubswarmOptimizerTemplate().setRho(0.01);
|
||||||
npso.getSubswarmOptimizerTemplate().setAlgoType(new SelectedTag("Constriction"));
|
npso.getSubswarmOptimizerTemplate().setAlgoType(ParticleSwarmOptimization.PSOType.Constriction);
|
||||||
|
|
||||||
npso.getSubswarmOptimizerTemplate().setConstriction(2.05, 2.05);
|
npso.getSubswarmOptimizerTemplate().setConstriction(2.05, 2.05);
|
||||||
// npso.getSubswarmOptimizerTemplate().setInertnessAging(new NoParameterAging(npso.getSubswarmOptimizerTemplate().getInertnessOrChi()));
|
// npso.getSubswarmOptimizerTemplate().setInertnessAging(new NoParameterAging(npso.getSubswarmOptimizerTemplate().getInertnessOrChi()));
|
||||||
|
@ -24,6 +24,7 @@ import eva2.tools.math.Jama.Matrix;
|
|||||||
import eva2.tools.math.Mathematics;
|
import eva2.tools.math.Mathematics;
|
||||||
import eva2.tools.math.RNG;
|
import eva2.tools.math.RNG;
|
||||||
import eva2.util.annotation.Description;
|
import eva2.util.annotation.Description;
|
||||||
|
import eva2.util.annotation.Parameter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -42,10 +43,7 @@ import java.util.Vector;
|
|||||||
@Description("Particle Swarm Optimization by Kennedy and Eberhart.")
|
@Description("Particle Swarm Optimization by Kennedy and Eberhart.")
|
||||||
public class ParticleSwarmOptimization extends AbstractOptimizer implements java.io.Serializable, InterfaceAdditionalPopulationInformer {
|
public class ParticleSwarmOptimization extends AbstractOptimizer implements java.io.Serializable, InterfaceAdditionalPopulationInformer {
|
||||||
|
|
||||||
/**
|
public enum PSOType { Inertness, Constriction }
|
||||||
* Generated serial version uid.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = -149996122795669589L;
|
|
||||||
Object[] sortedPop = null;
|
Object[] sortedPop = null;
|
||||||
protected AbstractEAIndividual bestIndividual = null;
|
protected AbstractEAIndividual bestIndividual = null;
|
||||||
protected boolean checkRange = true;
|
protected boolean checkRange = true;
|
||||||
@ -56,7 +54,7 @@ public class ParticleSwarmOptimization extends AbstractOptimizer implements java
|
|||||||
* Defines which version of PSO is applied, classical inertness or
|
* Defines which version of PSO is applied, classical inertness or
|
||||||
* constriction (using chi)
|
* constriction (using chi)
|
||||||
*/
|
*/
|
||||||
protected SelectedTag algType;
|
protected PSOType algType;
|
||||||
protected int topologyRange = 2;
|
protected int topologyRange = 2;
|
||||||
protected double initialVelocity = 0.2;
|
protected double initialVelocity = 0.2;
|
||||||
protected double speedLimit = 0.1;
|
protected double speedLimit = 0.1;
|
||||||
@ -92,7 +90,6 @@ public class ParticleSwarmOptimization extends AbstractOptimizer implements java
|
|||||||
transient final static String sortedIndexKey = "sortedParticleIndex";
|
transient final static String sortedIndexKey = "sortedParticleIndex";
|
||||||
transient final static String dmsGroupIndexKey = "dmsGroupIndex";
|
transient final static String dmsGroupIndexKey = "dmsGroupIndex";
|
||||||
protected String indentifier = "";
|
protected String indentifier = "";
|
||||||
transient private Vector<InterfacePopulationChangedEventListener> changeListener;
|
|
||||||
transient private TopoPlot topoPlot = null;
|
transient private TopoPlot topoPlot = null;
|
||||||
/// sleep time so that visual plot can be followed easier
|
/// sleep time so that visual plot can be followed easier
|
||||||
protected int sleepTime = 0;
|
protected int sleepTime = 0;
|
||||||
@ -109,8 +106,7 @@ public class ParticleSwarmOptimization extends AbstractOptimizer implements java
|
|||||||
|
|
||||||
public ParticleSwarmOptimization() {
|
public ParticleSwarmOptimization() {
|
||||||
topology = PSOTopology.grid;
|
topology = PSOTopology.grid;
|
||||||
algType = new SelectedTag("Inertness", "Constriction");
|
algType = PSOType.Constriction;
|
||||||
algType.setSelectedTag(1);
|
|
||||||
|
|
||||||
setConstriction(getPhi1(), getPhi2());
|
setConstriction(getPhi1(), getPhi2());
|
||||||
hideHideable();
|
hideHideable();
|
||||||
@ -118,9 +114,7 @@ public class ParticleSwarmOptimization extends AbstractOptimizer implements java
|
|||||||
|
|
||||||
public ParticleSwarmOptimization(ParticleSwarmOptimization a) {
|
public ParticleSwarmOptimization(ParticleSwarmOptimization a) {
|
||||||
topology = a.topology;
|
topology = a.topology;
|
||||||
if (a.algType != null) {
|
this.algType = a.algType;
|
||||||
this.algType = (SelectedTag) a.algType.clone();
|
|
||||||
}
|
|
||||||
this.population = (Population) a.population.clone();
|
this.population = (Population) a.population.clone();
|
||||||
this.optimizationProblem = a.optimizationProblem;
|
this.optimizationProblem = a.optimizationProblem;
|
||||||
this.indentifier = a.indentifier;
|
this.indentifier = a.indentifier;
|
||||||
@ -145,7 +139,7 @@ public class ParticleSwarmOptimization extends AbstractOptimizer implements java
|
|||||||
*/
|
*/
|
||||||
public ParticleSwarmOptimization(int popSize, double p1, double p2, PSOTopology topo, int topoRange) {
|
public ParticleSwarmOptimization(int popSize, double p1, double p2, PSOTopology topo, int topoRange) {
|
||||||
this();
|
this();
|
||||||
algType.setSelectedTag(1); // set to constriction
|
algType = PSOType.Constriction; // set to constriction
|
||||||
population = new Population(popSize);
|
population = new Population(popSize);
|
||||||
setPhiValues(p1, p2);
|
setPhiValues(p1, p2);
|
||||||
topologyRange = topoRange;
|
topologyRange = topoRange;
|
||||||
@ -292,7 +286,7 @@ public class ParticleSwarmOptimization extends AbstractOptimizer implements java
|
|||||||
* @param requiredType optional required type identifier of the individual.
|
* @param requiredType optional required type identifier of the individual.
|
||||||
* @return double array containing the vectorial sum of particle velocities
|
* @return double array containing the vectorial sum of particle velocities
|
||||||
* or an array containing the average absolute speed
|
* or an array containing the average absolute speed
|
||||||
* @see AbstractEAIndividual.getData(String)
|
* @see AbstractEAIndividual#getData(String)
|
||||||
*/
|
*/
|
||||||
public static double[] getPopulationVelSpeed(Population pop, int calcModeSwitch, final String velocityKey, final String typeString, final Object requiredType) {
|
public static double[] getPopulationVelSpeed(Population pop, int calcModeSwitch, final String velocityKey, final String typeString, final Object requiredType) {
|
||||||
AbstractEAIndividual indy = (AbstractEAIndividual) pop.get(0);
|
AbstractEAIndividual indy = (AbstractEAIndividual) pop.get(0);
|
||||||
@ -742,7 +736,7 @@ public class ParticleSwarmOptimization extends AbstractOptimizer implements java
|
|||||||
for (int i = 0; i < personalBestPos.length; i++) {
|
for (int i = 0; i < personalBestPos.length; i++) {
|
||||||
// the component from the old velocity
|
// the component from the old velocity
|
||||||
accel[i] = 0;
|
accel[i] = 0;
|
||||||
if (algType.getSelectedTag().getID() == 1) {
|
if (algType == PSOType.Constriction) {
|
||||||
chi = inertnessOrChi;
|
chi = inertnessOrChi;
|
||||||
} else {
|
} else {
|
||||||
chi = 1.;
|
chi = 1.;
|
||||||
@ -1582,7 +1576,7 @@ public class ParticleSwarmOptimization extends AbstractOptimizer implements java
|
|||||||
if (pSum <= 4) {
|
if (pSum <= 4) {
|
||||||
System.err.println("error, invalid tauSum value in PSO::setConstriction");
|
System.err.println("error, invalid tauSum value in PSO::setConstriction");
|
||||||
} else {
|
} else {
|
||||||
if (!getAlgoType().isSelectedString("Constriction")) {
|
if (getAlgoType() != PSOType.Constriction) {
|
||||||
System.err.println("Warning, PSO algorithm variant constriction expected!");
|
System.err.println("Warning, PSO algorithm variant constriction expected!");
|
||||||
}
|
}
|
||||||
phi1 = tau1;
|
phi1 = tau1;
|
||||||
@ -1613,9 +1607,10 @@ public class ParticleSwarmOptimization extends AbstractOptimizer implements java
|
|||||||
*
|
*
|
||||||
* @param l
|
* @param l
|
||||||
*/
|
*/
|
||||||
|
@Parameter(description = "Acceleration for the cognition model.")
|
||||||
public void setPhi1(double l) {
|
public void setPhi1(double l) {
|
||||||
this.phi1 = l;
|
this.phi1 = l;
|
||||||
if (algType.getSelectedTag().getID() == 1) {
|
if (algType == PSOType.Constriction) {
|
||||||
setConstriction(getPhi1(), getPhi2());
|
setConstriction(getPhi1(), getPhi2());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1624,18 +1619,15 @@ public class ParticleSwarmOptimization extends AbstractOptimizer implements java
|
|||||||
return this.phi1;
|
return this.phi1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String phi1TipText() {
|
|
||||||
return "Acceleration for the cognition model.";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will set greediness to move towards the best social
|
* This method will set greediness to move towards the best social
|
||||||
*
|
*
|
||||||
* @param l
|
* @param l
|
||||||
*/
|
*/
|
||||||
|
@Parameter(description = "Acceleration for the social model.")
|
||||||
public void setPhi2(double l) {
|
public void setPhi2(double l) {
|
||||||
this.phi2 = l;
|
this.phi2 = l;
|
||||||
if (algType.getSelectedTag().getID() == 1) {
|
if (algType == PSOType.Constriction) {
|
||||||
setConstriction(getPhi1(), getPhi2());
|
setConstriction(getPhi1(), getPhi2());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1644,10 +1636,6 @@ public class ParticleSwarmOptimization extends AbstractOptimizer implements java
|
|||||||
return this.phi2;
|
return this.phi2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String phi2TipText() {
|
|
||||||
return "Acceleration for the social model.";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the phi1 / phi2 parameter values (and in the constriction variant,
|
* Set the phi1 / phi2 parameter values (and in the constriction variant,
|
||||||
* adapt constriction factor).
|
* adapt constriction factor).
|
||||||
@ -1658,7 +1646,7 @@ public class ParticleSwarmOptimization extends AbstractOptimizer implements java
|
|||||||
public void setPhiValues(double phi1, double phi2) {
|
public void setPhiValues(double phi1, double phi2) {
|
||||||
this.phi1 = phi1;
|
this.phi1 = phi1;
|
||||||
this.phi2 = phi2;
|
this.phi2 = phi2;
|
||||||
if (algType.isSelectedString("Constriction")) {
|
if (algType == PSOType.Constriction) {
|
||||||
setConstriction(phi1, phi2);
|
setConstriction(phi1, phi2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1682,6 +1670,7 @@ public class ParticleSwarmOptimization extends AbstractOptimizer implements java
|
|||||||
*
|
*
|
||||||
* @param t The type.
|
* @param t The type.
|
||||||
*/
|
*/
|
||||||
|
@Parameter(description = "Choose the topology type")
|
||||||
public void setTopology(PSOTopology t) {
|
public void setTopology(PSOTopology t) {
|
||||||
this.topology = t;
|
this.topology = t;
|
||||||
setGOEShowProperties(getClass());
|
setGOEShowProperties(getClass());
|
||||||
@ -1709,35 +1698,29 @@ public class ParticleSwarmOptimization extends AbstractOptimizer implements java
|
|||||||
return topology;
|
return topology;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String topologyTipText() {
|
|
||||||
return "Choose the topology type";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method allows you to choose the algorithm type.
|
* This method allows you to choose the algorithm type.
|
||||||
*
|
*
|
||||||
* @param s The type.
|
* @param s The type.
|
||||||
*/
|
*/
|
||||||
public void setAlgoType(SelectedTag s) {
|
public void setAlgoType(PSOType s) {
|
||||||
this.algType = s;
|
this.algType = s;
|
||||||
if (s.getSelectedTag().getID() == 1) {
|
if (algType == PSOType.Constriction) {
|
||||||
setConstriction(getPhi1(), getPhi2());
|
setConstriction(getPhi1(), getPhi2());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SelectedTag getAlgoType() {
|
@Parameter(description = "Choose the inertness or constriction method. Chi is calculated automatically in constriction.")
|
||||||
|
public PSOType getAlgoType() {
|
||||||
return this.algType;
|
return this.algType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String algoTypeTipText() {
|
|
||||||
return "Choose the inertness or constriction method. Chi is calculated automatically in constriction.";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The range of the local neighbourhood.
|
* The range of the local neighbourhood.
|
||||||
*
|
*
|
||||||
* @param s The range.
|
* @param s The range.
|
||||||
*/
|
*/
|
||||||
|
@Parameter(description = "The range of the neighborhood topology.")
|
||||||
public void setTopologyRange(int s) {
|
public void setTopologyRange(int s) {
|
||||||
this.topologyRange = s;
|
this.topologyRange = s;
|
||||||
}
|
}
|
||||||
@ -1746,15 +1729,12 @@ public class ParticleSwarmOptimization extends AbstractOptimizer implements java
|
|||||||
return this.topologyRange;
|
return this.topologyRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String topologyRangeTipText() {
|
|
||||||
return "The range of the neighborhood topology.";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggle Check Constraints.
|
* Toggle Check Constraints.
|
||||||
*
|
*
|
||||||
* @param s Check Constraints.
|
* @param s Check Constraints.
|
||||||
*/
|
*/
|
||||||
|
@Parameter(description = "Toggle whether particles are allowed to leave the range.")
|
||||||
public void setCheckRange(boolean s) {
|
public void setCheckRange(boolean s) {
|
||||||
this.checkRange = s;
|
this.checkRange = s;
|
||||||
}
|
}
|
||||||
@ -1763,10 +1743,6 @@ public class ParticleSwarmOptimization extends AbstractOptimizer implements java
|
|||||||
return this.checkRange;
|
return this.checkRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String checkRangeTipText() {
|
|
||||||
return "Toggle whether particles are allowed to leave the range.";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if swarm visualization is turned on
|
* @return true if swarm visualization is turned on
|
||||||
*/
|
*/
|
||||||
|
@ -10,7 +10,8 @@ public class StarANPSO extends ANPSO {
|
|||||||
super();
|
super();
|
||||||
|
|
||||||
NichePSO.starNPSO(this, defaultEvalCnt);
|
NichePSO.starNPSO(this, defaultEvalCnt);
|
||||||
setMainSwarmAlgoType(getMainSwarm().getAlgoType().setSelectedTag("Inertness"));
|
getMainSwarm().setAlgoType(ParticleSwarmOptimization.PSOType.Inertness);
|
||||||
|
setMainSwarmAlgoType(ParticleSwarmOptimization.PSOType.Inertness);
|
||||||
getMainSwarm().setParameterControl(new ParamAdaption[]{new LinearParamAdaption("inertnessOrChi", 0.7, 0.2)});
|
getMainSwarm().setParameterControl(new ParamAdaption[]{new LinearParamAdaption("inertnessOrChi", 0.7, 0.2)});
|
||||||
// setMainSwarmInertness(new LinearParameterAging(0.7, 0.2, defaultEvalCnt/getMainSwarmSize()));
|
// setMainSwarmInertness(new LinearParameterAging(0.7, 0.2, defaultEvalCnt/getMainSwarmSize()));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user