public class Chromosome extends java.lang.Object implements java.lang.Comparable<Chromosome>
Constructor and Description |
---|
Chromosome()
Default constructor.
|
Chromosome(int[] newBody)
Parameter constructor.
|
Chromosome(int[] newBody,
double fitnessValue)
Parameter constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Chromosome other) |
double |
computeRed()
Computes and returns the reduction ratio coded in the chromosome.
|
int[] |
crossPMX(int[] parent)
Crosses this chromosome with the one given as parameter with PMX operator.
|
void |
evaluate()
Function that evaluates a chromosome.
|
int |
get(int pos)
Returns the binary value (0 or 1) of the position given.
|
int[] |
getAll()
Returns the chromosome representation (array of integers).
|
double |
getFitness()
Returns the fitness of the chromosome.
|
static int |
getSize()
Returns the size of the chromosome.
|
boolean |
isEvaluated()
Checks if the chromosome has been evaluated.
|
void |
mutation()
Mutates the chromosome.
|
void |
set(int pos,
int value)
Sets the value in the chromosome of the given position with the value given.
|
static void |
setBeta(double value)
Sets the beta parameter with the value given.
|
void |
setFitness(double value)
Sets the fitness of this chromosome with the value given.
|
static void |
setInitProb(double value)
Sets the initial probability to build the chromosome.
|
static void |
setMutationProbability(double value)
Sets the mutation probability with the value given.
|
static void |
setSize(int value)
Sets the size of the chromosome with the value given as parameter.
|
java.lang.String |
toString() |
public Chromosome()
public Chromosome(int[] newBody)
newBody
- vector given to initiate the chromosome.public Chromosome(int[] newBody, double fitnessValue)
newBody
- vector given to initiate the chromosome.fitnessValue
- fitness to set.public static void setSize(int value)
value
- given size to set.public static void setInitProb(double value)
value
- probability to set.public static void setBeta(double value)
value
- beta to set.public static void setMutationProbability(double value)
value
- probability to set.public static int getSize()
public boolean isEvaluated()
public double getFitness()
public void setFitness(double value)
value
- fitness value to set.public int get(int pos)
pos
- position given.public void set(int pos, int value)
pos
- position given.value
- value to set.public int[] getAll()
public double computeRed()
public void evaluate()
fitness
will be set.public void mutation()
public int[] crossPMX(int[] parent)
parent
- given chromosome (as vector) to cross with.public int compareTo(Chromosome other)
compareTo
in interface java.lang.Comparable<Chromosome>
public java.lang.String toString()
toString
in class java.lang.Object