public class Cromosoma
extends java.lang.Object
implements java.lang.Comparable
| Constructor and Description |
|---|
Cromosoma(int size) |
Cromosoma(int size,
int nClases,
double[][] datosTrain,
double[][] realTrain,
int[][] nominalTrain,
boolean[][] nulosTrain,
int[] clasesTrain,
int kNeigh,
boolean distanceEu)
Construct a random chromosome of specified size and evaluate it.
|
| Modifier and Type | Method and Description |
|---|---|
void |
borrar()
Marks a chromosome for deletion
|
int |
compareTo(java.lang.Object o1) |
int |
differenceAtOne(Cromosoma a)
Test if two chromosome differ in only one gene.
|
boolean |
estaEvaluado()
Tests if the chromosome is already evaluated
|
boolean |
esValido() |
void |
evalua(int[] clases,
int kNeigh,
int nClases)
Function that evaluates a chromosome
|
int |
genesActivos() |
double |
getCalidad()
Get the quality of a chromosome
|
boolean |
getGen(int indice)
Get the value of a gene
|
void |
mutacion(int nClus,
int[] clusters,
int size,
int nClases,
double[][] datosTrain,
double[][] realTrain,
int[][] nominalTrain,
boolean[][] nulosTrain,
int[] clasesTrain,
int kNeigh,
boolean distanceEu)
Function that does the mutation
|
void |
prepare(int size,
int nClases,
double[][] datosTrain,
double[][] realTrain,
int[][] nominalTrain,
boolean[][] nulosTrain,
int[] clasesTrain,
int kNeigh,
boolean distanceEu)
Construct a random chromosome of specified size and it is prepared to be evaluated.
|
void |
setGen(int indice,
boolean valor)
Set the value of a gene
|
java.lang.String |
toString() |
public Cromosoma(int size,
int nClases,
double[][] datosTrain,
double[][] realTrain,
int[][] nominalTrain,
boolean[][] nulosTrain,
int[] clasesTrain,
int kNeigh,
boolean distanceEu)
size - Size of the chromosomenClases - Number of classes of the problemdatosTrain - Reference to the training setrealTrain - Reference to the training set (real valued)nominalTrain - Reference to the training set (nominal valued)nulosTrain - Reference to the training set (null values)clasesTrain - Output attribute of each instancekNeigh - Number of neighbors for the KNN algorithmdistanceEu - True= Euclidean distance; False= HVDMpublic Cromosoma(int size)
size - public 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 prepare(int size,
int nClases,
double[][] datosTrain,
double[][] realTrain,
int[][] nominalTrain,
boolean[][] nulosTrain,
int[] clasesTrain,
int kNeigh,
boolean distanceEu)
size - Size of the chromosomenClases - Number of classes of the problemdatosTrain - Reference to the training setrealTrain - Reference to the training set (real valued)nominalTrain - Reference to the training set (nominal valued)nulosTrain - Reference to the training set (null values)clasesTrain - Output attribute of each instancekNeigh - Number of neighbors for the KNN algorithmdistanceEu - True= Euclidean distance; False= HVDMpublic void evalua(int[] clases,
int kNeigh,
int nClases)
clases - Output attribute of each instancekNeigh - Number of neighbors for the KNN algorithmnClases - Number of classes of the problempublic void mutacion(int nClus,
int[] clusters,
int size,
int nClases,
double[][] datosTrain,
double[][] realTrain,
int[][] nominalTrain,
boolean[][] nulosTrain,
int[] clasesTrain,
int kNeigh,
boolean distanceEu)
nClus - cluster considered to mutate.clusters - clusters information.size - number of clustersnClases - Number of classes of the problemdatosTrain - Reference to the training setrealTrain - Reference to the training set (real valued)nominalTrain - Reference to the training set (nominal valued)nulosTrain - Reference to the training set (null values)clasesTrain - Output attribute of each instancekNeigh - Number of neighbors for the KNN algorithmdistanceEu - True= Euclidean distance; False= HVDMpublic boolean estaEvaluado()
public int genesActivos()
public boolean esValido()
public void borrar()
public int compareTo(java.lang.Object o1)
compareTo in interface java.lang.Comparableo1 - public int differenceAtOne(Cromosoma a)
a - Chromosome to comparepublic java.lang.String toString()
toString in class java.lang.Object