Class Swarm
java.lang.Object
unifeat.featureSelection.wrapper.PSOBasedMethods.BasicSwarm<Boolean,Particle>
 
unifeat.featureSelection.wrapper.PSOBasedMethods.HPSO_LS.Swarm
This java class is used to implement a swarm of particles in hybrid particle
 swarm optimization method using local search (HPSO-LS) in which the type of
 position vector is boolean and the type of particle is extended from Particle
 class.
- Author:
- Sina Tabakhi
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic doubleprivate intstatic doubleprivate Randomprivate intprivate double[][]Fields inherited from class unifeat.featureSelection.wrapper.PSOBasedMethods.BasicSwarmC1, C2, END_POS_INTERVAL, fitnessEvaluator, gBest, INERTIA_WEIGHT, MAX_VELOCITY, MIN_VELOCITY, population, POPULATION_SIZE, PROBLEM_DIMENSION, START_POS_INTERVAL
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprivate double[]This method computes the correlation of each feature to other features.private intThis method determines the size of feature subset.voidThis method evaluates the fitness of each particle in the swarm by predefined fitness function.voidThis method initializes the position and velocity vectors of each particle in the swarm.voidThis method performs a local search strategy on each particle which is based on correlation of features.voidsetDataInfo(double[][] data) This method sets the information of the dataset.private doublesigmoidFunc(double value) This method transforms a input value to the range of (0,1) using sigmoid function.private intsubtractBoolean(boolean num1, boolean num2) This method subtracts two boolean values.voidThis method updates the global best position (global best) of the swarm.voidThis method updates the position vector of each particle in the swarm.voidThis method updates the velocity vector of each particle in the swarm.voidThis method updates the best position (personal best) of each particle in the swarm.Methods inherited from class unifeat.featureSelection.wrapper.PSOBasedMethods.BasicSwarmgetGBest, getGBestFitness, setGBest, setGBestFitness
- 
Field Details- 
trainSetprivate double[][] trainSet
- 
seedValueprivate int seedValue
- 
rand
- 
EPSILONpublic static double EPSILON
- 
ALPHApublic static double ALPHA
- 
constantSubsetSizeprivate int constantSubsetSize
- 
dissimilarSet
- 
similarSet
 
- 
- 
Constructor Details- 
Swarmpublic Swarm(double epsilon, double alpha) Initializes the parameters- Parameters:
- epsilon- the epsilon parameter used in the subset size determining scheme
- alpha- the alpha parameter used in the local search operation (control similar/dissimilar)
 
 
- 
- 
Method Details- 
initializationpublic void initialization()This method initializes the position and velocity vectors of each particle in the swarm. Each particle is randomly initialized in the predefined ranges of values. The number of selected features in each particle is constant and defined by a scheme.- Specified by:
- initializationin class- BasicSwarm<Boolean,- Particle> 
 
- 
evaluateFitnesspublic 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:
- evaluateFitnessin class- BasicSwarm<Boolean,- Particle> 
 
- 
updatePersonalBestpublic 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.- Specified by:
- updatePersonalBestin class- BasicSwarm<Boolean,- Particle> 
 
- 
updateGlobalBestpublic 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.- Specified by:
- updateGlobalBestin class- BasicSwarm<Boolean,- Particle> 
 
- 
updateParticleVelocitypublic void updateParticleVelocity()This method updates the velocity vector of each particle in the swarm.- Specified by:
- updateParticleVelocityin class- BasicSwarm<Boolean,- Particle> 
 
- 
updateParticlePositionpublic void updateParticlePosition()This method updates the position vector of each particle in the swarm.- Specified by:
- updateParticlePositionin class- BasicSwarm<Boolean,- Particle> 
 
- 
operateLocalSearchpublic void operateLocalSearch()This method performs a local search strategy on each particle which is based on correlation of features.
- 
determineSubsetSizeprivate int determineSubsetSize()This method determines the size of feature subset. The number of selected features in each particle is constant and defined by this value.- Returns:
- the determined value of the size of feature subset
 
- 
computeCorrelationprivate double[] computeCorrelation()This method computes the correlation of each feature to other features.- Returns:
- computed correlation of each feature to other features
 
- 
subtractBooleanprivate int subtractBoolean(boolean num1, boolean num2) This method subtracts two boolean values.If the input value equals to true, the result will be considered as 1, otherwise 0. - Parameters:
- num1- the first input value
- num2- the second input value
- Returns:
- the result of subtraction
 
- 
sigmoidFuncprivate double sigmoidFunc(double value) This method transforms a input value to the range of (0,1) using sigmoid function.- Parameters:
- value- the input value that will be transformed
- Returns:
- the transformed value of the input value
 
- 
setDataInfopublic void setDataInfo(double[][] data) This method sets the information of the dataset.- Parameters:
- data- the input dataset values
 
 
-