public abstract class Cromosoma
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected double |
fitness
chromosome fitness
|
protected int[] |
rep
this vector represents a chromosome
|
protected int |
tamCromosoma
chromosome length
|
Constructor and Description |
---|
Cromosoma(int tam)
Creates a new instance of Cromosoma
|
Modifier and Type | Method and Description |
---|---|
abstract void |
cambiarGen(int nuevoValorGen,
int posGen)
modifies the ith value of a gene
|
void |
copy(Cromosoma cr)
it copies all gens of the cr chromosome
|
abstract void |
cruzar(Cromosoma padre2,
Cromosoma hijo1,
Cromosoma hijo2)
crossover operator.
|
abstract boolean |
cruzarHUX(Cromosoma padre2,
Cromosoma hijo1,
Cromosoma hijo2,
int umbral)
uniform crossover operator (HUX)
If parents are very similar, the crossover operator doesn't apply
|
abstract boolean[] |
devolverFeaturesVector()
returns a boolean array needed for Leaving One Out, Cross Validation and other methods used in
Feature Selection Algorithm
|
abstract int |
devolverGen(int i)
return the ith gen of chromosome
|
int |
devolverTamCromosoma()
return the length of the chromosome
|
double |
getFitness()
return the fitness of the chromosome
|
abstract void |
initPlantilla(Cromosoma crPlantilla,
double ratio)
this method is used in CHC method.
|
abstract void |
initRand()
random initialization of a chromosome
|
boolean |
isEqual(Cromosoma cr)
this boolean method return true if two chromosomes are equal in all of its genes
|
abstract void |
mutar()
mutation operator
|
abstract java.lang.String |
print()
it prints a chromosome, gene by gene.
|
void |
setFitness(double calidad)
set the fitness for the chromosome
|
protected int tamCromosoma
protected int[] rep
protected double fitness
public Cromosoma(int tam)
tam
- is the chromosome lengthpublic abstract void initRand()
public abstract void initPlantilla(Cromosoma crPlantilla, double ratio)
crPlantilla
- is a chromosome templateratio
- is the ratio of random initializationpublic abstract int devolverGen(int i)
i
- is the ith positionpublic abstract void cambiarGen(int nuevoValorGen, int posGen)
nuevoValorGen
- the new value for the geneposGen
- the position what we want to change (0..tamCromsoma-1)public abstract void cruzar(Cromosoma padre2, Cromosoma hijo1, Cromosoma hijo2)
padre2
- is a parenthijo1
- is the first offspringhijo2
- is the second offspringpublic abstract boolean cruzarHUX(Cromosoma padre2, Cromosoma hijo1, Cromosoma hijo2, int umbral)
padre2
- is a parenthijo1
- is the first offspringhijo2
- is the second offspringumbral
- is the threshold, needed by the operatorpublic abstract void mutar()
public abstract java.lang.String print()
public abstract boolean[] devolverFeaturesVector()
public void setFitness(double calidad)
calidad
- this is the fitness to be appliedpublic double getFitness()
public int devolverTamCromosoma()
public boolean isEqual(Cromosoma cr)
cr
- is the other chromosome to comparepublic void copy(Cromosoma cr)
cr
- is the chromosome that will be copied