Skip to content

Instantly share code, notes, and snippets.

@jfinkels
Created January 13, 2010 20:08
Show Gist options
  • Save jfinkels/276536 to your computer and use it in GitHub Desktop.
Save jfinkels/276536 to your computer and use it in GitHub Desktop.
public class OnesFitnessFunction extends MaximizingFitnessFunction<List<Byte>> {
public OnesFitnessFunction(int length) {
super(length);
}
@Override
public double rawFitness(final List<Byte> individual) {
int fitness = 0;
for (Byte bit : individual) {
if (bit == 1) {
fitnesses += 1;
}
}
return fitness;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment