public class Cromosoma
extends java.lang.Object
implements java.lang.Comparable
Constructor and Description |
---|
Cromosoma(boolean[] datos)
Builder.
|
Cromosoma(int size)
Builder.
|
Cromosoma(int size,
Cromosoma a)
Builder.
|
Modifier and Type | Method and Description |
---|---|
void |
borrar()
Marks a chromosome for deletion
|
int |
compareTo(java.lang.Object o1)
Compare to Method
|
int |
differenceAtOne(Cromosoma a)
Test if two chromosome differ in only one gene
|
void |
divergeCHC(double r,
Cromosoma mejor,
double prob)
Reinitializes the chromosome by using CHC diverge procedure
|
boolean |
estaEvaluado()
Tests if the chromosome is already evaluated
|
boolean |
esValido()
Tests if the chromosome is valid
|
void |
evalua(double[][] datos,
double[][] real,
int[][] nominal,
boolean[][] nulos,
int[] clases,
double alfa,
int kNeigh,
int nClases,
boolean distanceEu)
Evaluates a chromosome
|
int |
genesActivos()
Count the number of genes set to 1
|
double |
getCalidad()
Get the quality of a chromosome
|
boolean |
getGen(int indice)
Get the value of a gene
|
void |
mutacion(double pMutacion1to0,
double pMutacion0to1)
Mutation operator
|
void |
setGen(int indice,
boolean valor)
Set the value of a gene
|
java.lang.String |
toString()
To String Method
|
public Cromosoma(int size)
size
- Size of the chromosomepublic Cromosoma(int size, Cromosoma a)
size
- Size of the chromosomea
- Chromosome to copypublic Cromosoma(boolean[] datos)
datos
- Initial data of the chromosomepublic boolean getGen(int indice)
indice
- Index of the genepublic double getCalidad()
public void setGen(int indice, boolean valor)
indice
- Index of the genevalor
- Value to setpublic void evalua(double[][] datos, double[][] real, int[][] nominal, boolean[][] nulos, int[] clases, double alfa, int kNeigh, int nClases, boolean distanceEu)
datos
- Reference to the training setreal
- Reference to the training set (real valued)nominal
- Reference to the training set (nominal valued)nulos
- Reference to the training set (null values)clases
- Output attribute of each instancealfa
- Alpha value of the fitness functionkNeigh
- Number of neighbors for the KNN algorithmnClases
- Number of classes of the problemdistanceEu
- True= Euclidean distance; False= HVDMpublic void mutacion(double pMutacion1to0, double pMutacion0to1)
pMutacion1to0
- Probability of change 1 to 0pMutacion0to1
- Probability of change 0 to 1public void divergeCHC(double r, Cromosoma mejor, double prob)
r
- R factor of divergemejor
- Best chromosome found so farprob
- Probability of setting a gen to 1public boolean estaEvaluado()
public int genesActivos()
public boolean esValido()
public void borrar()
public int compareTo(java.lang.Object o1)
compareTo
in interface java.lang.Comparable
o1
- Chromosome to comparepublic int differenceAtOne(Cromosoma a)
a
- Chromosome to comparepublic java.lang.String toString()
toString
in class java.lang.Object