lio.individuals
Class ContChain

java.lang.Object
  extended by lio.individuals.Individual
      extended by lio.individuals.ContChain
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable

public class ContChain
extends Individual

This class is used to manage individuals represented by an array of double.


Field Summary
protected  double[] mChain
          Array which contains the elements
 
Fields inherited from class lio.individuals.Individual
evaluated, maxSize, size, value
 
Constructor Summary
ContChain(double[] pChain)
          Creates a new instance of ContChain from an array of double.
ContChain(int pSize)
          Creates a new instance of permutation using the positions as values.
 
Method Summary
 java.lang.Object clone()
          Clones an individual.
static ContChain[] doubleToIndividual(double[][] pSample)
          Static method which allows building an array of ContChain from a matrix of double.
 double get(int pos)
          Returns the value stored in position pos.
 double[] getCopyOfElements()
          Returns a copy of the elements which form the individual.
 double[] getElements()
          Returns a reference to the elements which form the individual.
 void set(int pos, double value)
          Fixes de value of element in position.
 void setElements(double[] elements)
          Sets the elements of a individual from an array of integer.
 java.lang.String toString()
          String representation of the individual.
 
Methods inherited from class lio.individuals.Individual
change, compareTo, getMaxSize, getSize, isEvaluated, setMaxSize, setSize, setValue, value
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mChain

protected double[] mChain
Array which contains the elements

Constructor Detail

ContChain

public ContChain(double[] pChain)
Creates a new instance of ContChain from an array of double.

Parameters:
pChain - Array of integers containing the permutation.

ContChain

public ContChain(int pSize)
Creates a new instance of permutation using the positions as values.

Parameters:
pSize - size of the permutation.
Method Detail

getElements

public double[] getElements()
Returns a reference to the elements which form the individual.

Returns:
A vector containing the elements of the individual.

getCopyOfElements

public double[] getCopyOfElements()
Returns a copy of the elements which form the individual.

Returns:
A vector containing the elements of the individual.

setElements

public void setElements(double[] elements)
Sets the elements of a individual from an array of integer.

Parameters:
elements - Array of double that code the individual.

get

public double get(int pos)
Returns the value stored in position pos.

Parameters:
pos - Position whose value is required.
Returns:
Value in the position pos.

set

public void set(int pos,
                double value)
Fixes de value of element in position.

Parameters:
pos - Position whose value must be changed.

toString

public java.lang.String toString()
String representation of the individual.

Specified by:
toString in class Individual
Returns:
A string representing the individual.

clone

public java.lang.Object clone()
Description copied from class: Individual
Clones an individual. It allows to copy individuals instead of references.

Specified by:
clone in class Individual
Returns:
an object similar to this.

doubleToIndividual

public static ContChain[] doubleToIndividual(double[][] pSample)
Static method which allows building an array of ContChain from a matrix of double.

Parameters:
pSample - Two dimension matrix containing the values for the individuals.
Returns:
An array of ContChain each one of them built from one of the arrays.