Class Fitnesses
java.lang.Object
Abstract1DGrid
Fitnesses
- 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. |
Constructor Summary |
Fitnesses(int size)
Creates Fitnesses with the specified size. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
fitnesses
private int[] fitnesses
- Array of fitnesses.
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
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()