Class Fitnesses

java.lang.Object
  extended byAbstract1DGrid
      extended byFitnesses

public class Fitnesses
extends Abstract1DGrid

The 1 dimensional grid for storing cell fitnesses with some utilities.

Since:
1.0
Version:
1.1, 2007-05-29
Author:
TineL

Field Summary
private  int[] fitnesses
          Array of fitnesses.
 
Fields inherited from class Abstract1DGrid
 
Constructor Summary
Fitnesses(int size)
          Creates Fitnesses with the specified size.
 
Method Summary
 int biggerNeighbours(int index)
          Computes how many fitnesses around the specified one has bigger values.
 int get(int index)
           
 int getLeft(int index)
           
 int getRight(int index)
           
 void inc(int index)
          Increments the fitness at the specified index for one.
 boolean isLeftBigger(int index)
           
 boolean isRightBigger(int index)
           
 int sum()
           
 java.lang.String toString()
           
 
Methods inherited from class Abstract1DGrid
getLeftIndex, getRightIndex, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

fitnesses

private int[] fitnesses
Array of fitnesses.

Constructor Detail

Fitnesses

public Fitnesses(int size)
Creates Fitnesses with the specified size. All fitnesses are set to 0.

Parameters:
size - the grid size (number of fitnesses).
Since:
1.0
Method Detail

get

public int get(int index)
Parameters:
index - the fitness index.
Returns:
the fitness.
Since:
1.0

inc

public void inc(int index)
Increments the fitness at the specified index for one.

Parameters:
index - the fitness index.
Since:
1.0

sum

public int sum()
Returns:
the sum of all fitnesses in the grid.
Since:
1.0

getLeft

public int getLeft(int index)
Parameters:
index - the fitness index.
Returns:
the left fitness.
Since:
1.0

getRight

public int getRight(int index)
Parameters:
index - the fitness index.
Returns:
the right fitness.
Since:
1.0

biggerNeighbours

public int biggerNeighbours(int index)
Computes how many fitnesses around the specified one has bigger values. Neighbour fitnesses are one left and one right.

Parameters:
index - the fitness index.
Returns:
the number of bigger fitnesses around (only 0, 1 or 2).
Since:
1.0

isLeftBigger

public boolean isLeftBigger(int index)
Parameters:
index - the fitness index.
Returns:
true if left fitness is bigger.
Since:
1.0

isRightBigger

public boolean isRightBigger(int index)
Parameters:
index - the fitness index.
Returns:
true if right fitness is bigger.
Since:
1.0

toString

public java.lang.String toString()