public class Chromosome
extends java.lang.Object
implements java.lang.Comparable
This class implements a binary chromosome as specified in the COGIN algorithm
Constructor and Description |
---|
Chromosome()
Default constructor
|
Chromosome(Chromosome ch)
Copy constructor.
|
Chromosome(int nGenes)
Builds up a new chromosome with specified number of genes
|
Modifier and Type | Method and Description |
---|---|
int |
classify(Instance inst)
classifies the provided instance with this chromosome
|
int |
compareTo(java.lang.Object o)
Implements the Comparator method to sort chromosomes by
its fitness.
|
boolean |
covers(Instance inst)
Test if the instances is covered by the rule
|
int |
getClas()
Gets the class output associated to this individual
|
int |
getCoveredInstances()
Gets the number of instances covered by this chromosome
|
double |
getFitness()
Gives the fitness of the chromosome
|
Gene |
getGene(int whichGene)
Gets the gene at specified position
|
int |
getNumGenes()
the number of genes of this individual
|
void |
makeCover(Instance inst)
Forces this individual to cover the provided instance
|
void |
setClass(int c)
Set the class of this chromosome
|
void |
setCoveredInstances(int cov)
Set the number of covered instances
|
void |
setFitness(double fit)
Set the fitness of this individual
|
void |
setGene(int pos,
Gene gen)
Set the value of the specified gene
|
void |
swapOnePoint(Chromosome ch)
Crossover between chromosomes, using the swap from one point approach
|
public Chromosome()
Default constructor
public Chromosome(int nGenes)
Builds up a new chromosome with specified number of genes
nGenes
- number of genes of this chromosomepublic Chromosome(Chromosome ch)
Copy constructor. Performs a deep-copy
ch
- the original chromosomepublic int getClas()
Gets the class output associated to this individual
public double getFitness()
Gives the fitness of the chromosome
public Gene getGene(int whichGene)
Gets the gene at specified position
whichGene
- the index of the genepublic int getNumGenes()
the number of genes of this individual
public int getCoveredInstances()
Gets the number of instances covered by this chromosome
public void setClass(int c)
Set the class of this chromosome
c
- the new classpublic void setGene(int pos, Gene gen)
Set the value of the specified gene
pos
- the index of the gene to be changedgen
- The new gene valuepublic void setFitness(double fit)
Set the fitness of this individual
fit
- the new fitnesspublic void setCoveredInstances(int cov)
Set the number of covered instances
cov
- the new count of covered instancespublic boolean covers(Instance inst)
Test if the instances is covered by the rule
inst
- The instance to be testedpublic void makeCover(Instance inst)
Forces this individual to cover the provided instance
inst
- the instance to be coveredpublic void swapOnePoint(Chromosome ch)
Crossover between chromosomes, using the swap from one point approach
ch
- the chromosome to be coupled withpublic int classify(Instance inst)
classifies the provided instance with this chromosome
inst
- the instance to be classifiedpublic int compareTo(java.lang.Object o)
compareTo
in interface java.lang.Comparable