public class Population
extends java.lang.Object
Population of candidate rules
Modifier and Type | Field and Description |
---|---|
int |
num_used
Number of individuals really used
|
Constructor and Description |
---|
Population(Genetic AG,
int numind,
int numgen,
java.lang.String RulesRep,
TableVar Variables,
int numExamples,
int numObjectives)
Creates a population of Individual
|
Modifier and Type | Method and Description |
---|---|
void |
BsdInitPop(TableVar Variables,
float porcVar,
float porcPob)
Biased random population initialization
|
void |
CalcFitness(int max,
int num_obj)
Computes the fitness of the individuals in the population, until number max
First we compute strength, then rawFitness, distances, density and finally fitness
All the individuals are suposed to have been evaluated
We don't compute for all the population but the number inicated as a parameter
|
void |
copyIndiv(int pos,
Individual otro)
Copy the individual otro into the individual pos of this population
|
int |
delDup(int max)
Eliminates de duplicated individuals of the population
from the first individual to number max (not to the total number of individuals)
|
void |
evalIndiv(int pos,
Genetic AG,
TableVar Variables,
TableDat Examples)
Evaluates an individual of the population
|
int |
evalPop(Genetic AG,
int number,
TableVar Variables,
TableDat Examples)
Evaluates the non-evaluates individuals of the population
Evaluates individuals from 0 to this.num_used (not all the individuals)
and computes "original support"
|
int |
getCromElem(int num_indiv,
int pos)
Returns the indicated gene of the CromCAN
|
int |
getCromElemGene(int num_indiv,
int var,
int pos)
Returns the indicated gene of the CromCAN
|
Individual |
getIndiv(int pos)
Returns the indicated individual of the population
|
CromCAN |
getIndivCromCAN(int num_indiv)
Returns de hole cromosoma of the selected individual
|
CromDNF |
getIndivCromDNF(int num_indiv)
Returns de hole cromosoma of the selected individual
|
float |
getIndivDensity(int pos)
Gets the density of the individual indicated
|
boolean |
getIndivDom(int num_indiv)
Gets if the individual in the position is or not dominated
|
boolean |
getIndivEvaluated(int num_indiv)
Returns if the individual of the population has been evaluated
|
float |
getIndivFitness(int num_indiv)
Returns fitness of the indicated inidividual of the population
|
int |
getIndivRawFit(int pos)
Gets the raw fitness of the individual indicated
|
int |
getIndivStrength(int pos)
Gets the strenght of the individual indicated
|
QualityMeasures |
getMedidas(Genetic AG,
int pos,
java.lang.String nFile)
Get the measurements of a single rule
|
void |
print(java.lang.String nFile)
Prints population individuals
|
void |
RndInitPop(TableVar Variables)
Random population initialization
|
void |
setCromElem(int num_indiv,
int pos,
int val)
Sets the value of the indicated gene of the CromCAN
|
void |
setCromElemGene(int num_indiv,
int var,
int pos,
int val)
Sets the value of the indicated gene of the CromCAN
|
void |
setIndivDensity(int pos,
float value)
Sets the individual density
|
void |
setIndivDom(int num_indiv,
boolean dominated)
Sets the individual to dominated or not dominated
|
void |
setIndivEvaluated(int num_indiv,
boolean val)
Sets the state evaluated of the individual of the population
|
void |
setIndivFitness(int num_indiv,
float val)
Sets the value of fitnes for the the indicated individual
|
void |
setIndivRawFit(int pos,
int value)
Sets the individual raw fitness
|
void |
setIndivStrength(int pos,
int value)
Sets the individual strength
|
float |
volSphere(int dimensions)
VolSphere
volSphere
volSphere calculates the area of a sphere in n dimensions for use in the
SPEA2 density calculation
|
public Population(Genetic AG, int numind, int numgen, java.lang.String RulesRep, TableVar Variables, int numExamples, int numObjectives)
Creates a population of Individual
AG
- Instance of the genetic algorithmnumind
- Number of individualsnumgen
- Number of variablesRulesRep
- Rules representationVariables
- Variables structurenumExamples
- Number of examples of the datasetnumObjectives
- Number of objectives usedpublic void RndInitPop(TableVar Variables)
Random population initialization
Variables
- Variables structurepublic void BsdInitPop(TableVar Variables, float porcVar, float porcPob)
Biased random population initialization
Variables
- Variables structureporcVar
- Percentage of max number of variables in the individualporcPob
- Percentage of max number of individuals to apply this initializationpublic int evalPop(Genetic AG, int number, TableVar Variables, TableDat Examples)
Evaluates the non-evaluates individuals of the population
Evaluates individuals from 0 to this.num_used (not all the individuals) and computes "original support"AG
- Genetic algorithm used.number
- Evaluate first "number" individualsVariables
- Variables structureExamples
- Examples structurepublic void evalIndiv(int pos, Genetic AG, TableVar Variables, TableDat Examples)
Evaluates an individual of the population
pos
- Position of the individualAG
- Genetic Algorithm used.Variables
- Variables structureExamples
- Examples structurepublic QualityMeasures getMedidas(Genetic AG, int pos, java.lang.String nFile)
Get the measurements of a single rule
AG
- Instance of the genetic algorithmpos
- Position of the individualnFile
- File to write the measurespublic Individual getIndiv(int pos)
pos
- Number of the individualpublic void copyIndiv(int pos, Individual otro)
pos
- Number of the individual of "indivi" where to copy individual "otro"otro
- Individual to be copiedpublic int delDup(int max)
max
- number given.public int getCromElem(int num_indiv, int pos)
Returns the indicated gene of the CromCAN
num_indiv
- Number of individualpos
- Position of the genepublic void setCromElem(int num_indiv, int pos, int val)
Sets the value of the indicated gene of the CromCAN
num_indiv
- Number of individualpos
- Position of the geneval
- Value of the genepublic int getCromElemGene(int num_indiv, int var, int pos)
Returns the indicated gene of the CromCAN
num_indiv
- Number of individualvar
- Position of the variablepos
- Position of the genepublic void setCromElemGene(int num_indiv, int var, int pos, int val)
Sets the value of the indicated gene of the CromCAN
num_indiv
- Number of individualvar
- Position of the variablepos
- Position of the geneval
- Value of the genepublic CromCAN getIndivCromCAN(int num_indiv)
Returns de hole cromosoma of the selected individual
num_indiv
- Number of individualpublic CromDNF getIndivCromDNF(int num_indiv)
Returns de hole cromosoma of the selected individual
num_indiv
- Number of individualpublic float getIndivFitness(int num_indiv)
Returns fitness of the indicated inidividual of the population
num_indiv
- Number of individualpublic void setIndivFitness(int num_indiv, float val)
Sets the value of fitnes for the the indicated individual
num_indiv
- Number of individualval
- Value of the fitnesspublic boolean getIndivEvaluated(int num_indiv)
Returns if the individual of the population has been evaluated
num_indiv
- Number of individualpublic void setIndivEvaluated(int num_indiv, boolean val)
Sets the state evaluated of the individual of the population
num_indiv
- Number of individualval
- Value of the state of the individualpublic boolean getIndivDom(int num_indiv)
Gets if the individual in the position is or not dominated
num_indiv
- Number of individualpublic void setIndivDom(int num_indiv, boolean dominated)
Sets the individual to dominated or not dominated
num_indiv
- Number of individualdominated
- Dominated or notpublic int getIndivStrength(int pos)
Gets the strenght of the individual indicated
pos
- Number of individualpublic void setIndivStrength(int pos, int value)
Sets the individual strength
pos
- Number of the individualvalue
- Stregth valuepublic int getIndivRawFit(int pos)
Gets the raw fitness of the individual indicated
pos
- Number of individualpublic void setIndivRawFit(int pos, int value)
Sets the individual raw fitness
pos
- Number of the individualvalue
- Raw fitness valuepublic float getIndivDensity(int pos)
Gets the density of the individual indicated
pos
- Number of individualpublic void setIndivDensity(int pos, float value)
Sets the individual density
pos
- Number of the individualvalue
- Density valuepublic void CalcFitness(int max, int num_obj)
Computes the fitness of the individuals in the population, until number max
First we compute strength, then rawFitness, distances, density and finally fitness All the individuals are suposed to have been evaluated We don't compute for all the population but the number inicated as a parameter
max
- number of individuals in the population to be computednum_obj
- number of objectivespublic float volSphere(int dimensions)
VolSphere
volSphere volSphere calculates the area of a sphere in n dimensions for use in the SPEA2 density calculation
dimensions
- Number of objectivespublic void print(java.lang.String nFile)
Prints population individuals
nFile
- File to write the Population