lio.individuals
Class Permutation

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

public class Permutation
extends Individual

This class is used to manage individuals composed by a chain of binary values.


Field Summary
 
Fields inherited from class lio.individuals.Individual
evaluated, maxSize, size, value
 
Constructor Summary
Permutation(int pSize)
          Creates a new instance of permutation using the positions as values.
Permutation(int[] pChain)
          Creates a new instance of Permutation from an array of integers.
 
Method Summary
 java.lang.Object clone()
          Clones an individual.
 int get(int pos)
          Returns the value stored in position pos.
 int[] getCopyOfElements()
          Returns a copy of the elements which form the individual.
 int[] getElements()
          Returns a reference to the elements which form the individual.
static Permutation[] intToIndividual(int[][] pSample)
          Static method which allows building an array of permutations from a matrix of integer.
 void set(int pos, int value)
          Fixes element value in this position.
 void setElements(int[] 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
 

Constructor Detail

Permutation

public Permutation(int[] pChain)
Creates a new instance of Permutation from an array of integers.

Parameters:
pChain - Array of integers containing the permutation.

Permutation

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

Parameters:
pSize - size of the permutation.
Method Detail

setElements

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

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

getCopyOfElements

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

Returns:
A vector containing the elements of the individual.

getElements

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

Returns:
A vector containing the elements of the individual.

get

public int 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,
                int value)
Fixes element value in this position.

Parameters:
pos - Position whose value must be changed.
value - for this position.

toString

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

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

intToIndividual

public static Permutation[] intToIndividual(int[][] pSample)
Static method which allows building an array of permutations from a matrix of integer.

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

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.