Class Swarm
java.lang.Object
unifeat.featureSelection.wrapper.PSOBasedMethods.BasicSwarm<Double,Particle>
unifeat.featureSelection.wrapper.PSOBasedMethods.PSO42.Swarm
This java class is used to implement a swarm of particles in particle swarm
optimization version 4-2(PSO(4-2)) method in which the type of position
vector is double and the type of particle is extended from Particle class.
- Author:
- Sina Tabakhi
- See Also:
-
Field Summary
Fields inherited from class unifeat.featureSelection.wrapper.PSOBasedMethods.BasicSwarm
C1, C2, END_POS_INTERVAL, fitnessEvaluator, gBest, INERTIA_WEIGHT, MAX_VELOCITY, MIN_VELOCITY, population, POPULATION_SIZE, PROBLEM_DIMENSION, START_POS_INTERVAL
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
This method evaluates the fitness of each particle in the swarm by predefined fitness function.private Double[]
generateRandomFeatureSubset
(int numFeatures) This method generates a position for a particle in which the number of selected features is defined by input value.void
This method initializes the position and velocity vectors of each particle in the swarm.void
This method updates the global best position (global best) of the swarm.void
This method updates the position vector of each particle in the swarm.void
This method updates the velocity vector of each particle in the swarm.void
This method updates the best position (personal best) of each particle in the swarm.Methods inherited from class unifeat.featureSelection.wrapper.PSOBasedMethods.BasicSwarm
getGBest, getGBestFitness, setGBest, setGBestFitness
-
Field Details
-
seedValue
private int seedValue -
rand
-
-
Constructor Details
-
Swarm
public Swarm(double theta) Initializes the parameters- Parameters:
theta
- the threshold is used to determine whether a feature is selected or not
-
-
Method Details
-
initialization
public void initialization()This method initializes the position and velocity vectors of each particle in the swarm. Particles are initialized based on small initialization and large initialization strategies. Most of the particles are initialized using small feature subsets (2/3 of the population) and the other particles are initialized using relatively large feature subsets (1/3 of the population).- Specified by:
initialization
in classBasicSwarm<Double,
Particle>
-
evaluateFitness
public void evaluateFitness()This method evaluates the fitness of each particle in the swarm by predefined fitness function. K-fold cross validation on training set is used for evaluating the classification performance of selected feature subset by each particle.- Specified by:
evaluateFitness
in classBasicSwarm<Double,
Particle>
-
updatePersonalBest
public void updatePersonalBest()This method updates the best position (personal best) of each particle in the swarm. Personal best position is updated when the classification performance of the particle's new position is better than personal best. Also, if the classification performance of the particle's new position is same as personal best and the number of selected features is smaller, the personal best will be updated and replaced by particle's new position.- Specified by:
updatePersonalBest
in classBasicSwarm<Double,
Particle>
-
updateGlobalBest
public void updateGlobalBest()This method updates the global best position (global best) of the swarm. Global best position is updated when the classification performance of any personal best position of the particles is better than global best. Also, if the classification performance of the any personal best position is same as global best and the number of selected features is smaller, the global best will be updated and replaced by personal best position.- Specified by:
updateGlobalBest
in classBasicSwarm<Double,
Particle>
-
updateParticleVelocity
public void updateParticleVelocity()This method updates the velocity vector of each particle in the swarm.- Specified by:
updateParticleVelocity
in classBasicSwarm<Double,
Particle>
-
updateParticlePosition
public void updateParticlePosition()This method updates the position vector of each particle in the swarm.- Specified by:
updateParticlePosition
in classBasicSwarm<Double,
Particle>
-
generateRandomFeatureSubset
This method generates a position for a particle in which the number of selected features is defined by input value.- Parameters:
numFeatures
- the number of selected features for particle- Returns:
- a generated position for a particle
-