net.openai.ai.ga.selection.common
Class SelectGreatestFitness

java.lang.Object
  |
  +--net.openai.ai.ga.selection.common.SelectGreatestFitness
All Implemented Interfaces:
SelectionAlgorithm

public class SelectGreatestFitness
extends java.lang.Object
implements SelectionAlgorithm

SelectGreatestFitness is a SelectionAlgorithm that will return a portion of the passed Population that have the greatest fitness. It will choose either a fixed number or a percentage.

Since:
JDK1.3
Version:
%I%, %G%
Author:
Jared Grubb

Constructor Summary
SelectGreatestFitness(double goalPercentage)
          Creates a new SelectGreatestFitness object for choosing the specified percentage of Cells out of the specified Population who have the greatest fitness.
SelectGreatestFitness(int goalNumber)
          Creates a new SelectGreatestFitness object for choosing the specified number of Cells out of the specified Population who have the greatest fitness.
 
Method Summary
 Population selectFromPopulation(Population pop)
          Chooses the Cells in the specified Population with the greatest fitness.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SelectGreatestFitness

public SelectGreatestFitness(int goalNumber)
Creates a new SelectGreatestFitness object for choosing the specified number of Cells out of the specified Population who have the greatest fitness.

Parameters:
goalNumber - the maximum number of Cells to allow
Throws:
ArithmeticException - on a negative goalNumber

SelectGreatestFitness

public SelectGreatestFitness(double goalPercentage)
Creates a new SelectGreatestFitness object for choosing the specified percentage of Cells out of the specified Population who have the greatest fitness. The percentage must be between 0.0 and 1.0, inclusive.

Throws:
ArithmeticException - on a negative percentage or on a percentage greater than 1.0
Method Detail

selectFromPopulation

public Population selectFromPopulation(Population pop)
Chooses the Cells in the specified Population with the greatest fitness. For a fixed number, returns a maximum number depending on the size of the population, but may return fewer if the population if the population is not that large. For a percentage, returns a percentage of the population, rounded down (i.e., percentage of 10% (0.10) on a size of 25 {0.10 * 25 = 2.5} returns a maximum of 2, not three; percentage of 10% on a size of 9 {0.10 * 9 = 0.9} will not return any objects.)

The returned population is guaranteed to return the members of the specified population such that there are no other members in that population who are greater than those returned. This means that cells who tie those already in the return population are ignored when their addition would cause the size to exceed that specified. For example, if the fitness of a population was {1,1,2,3,3,3,4,5,5} and the greatest 4 should be returned, then the returned population will be {3,4,5,5}. The cells who have fitness 5 are kept since their addition will knock less fit members out of the list. However, the other cells of fitness 3 are ignored since their addition could not knock any other cell out.

Specified by:
selectFromPopulation in interface SelectionAlgorithm
Parameters:
pop - the Population to choose from
Returns:
a selected Population in arbitrary order


Copyright - 2001 OpenAI Labs. All Rights Reserved.