FileDocCategorySizeDatePackage
Fitness.javaAPI DocExample443Thu Apr 06 17:27:56 BST 2000None

Fitness.java

// The Fitness function. 
//OneMax problem
// For the user to supply - it MUST generate a number in the range 0..1

class Fitness {
  
  public static double get(int[][] arrayBody,int row, int colMax) {
    //Let's try an easy one. The more ones, the better
    int intFit = 0;
    for(int i=0; i<colMax; i++) {
      if(arrayBody[row][i]==1) {intFit++;}
    }
    //normalise and return
    return ((double)intFit)/((double)(colMax));
  }

}