Top Description Fields Constructors Methods
org.apache.commons.math3.genetics

public Class FixedGenerationCount

extends Object
implements StoppingCondition
Class Inheritance
All Implemented Interfaces
org.apache.commons.math3.genetics.StoppingCondition
Imports
org.apache.commons.math3.exception.NumberIsTooSmallException

Stops after a fixed number of generations. Each time isSatisfied(Population) is invoked, a generation counter is incremented. Once the counter reaches the configured maxGenerations value, isSatisfied(Population) returns true.
Since
2.0

Field Summary

Modifier and TypeField and Description
private final int
maxGenerations

Maximum number of generations (stopping criteria)

private int
numGenerations

Number of generations that have passed

Constructor Summary

AccessConstructor and Description
public
FixedGenerationCount(final int
number of generations to evolve
maxGenerations
)

Create a new FixedGenerationCount instance.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the number of generations that have passed
getNumGenerations
()

Returns the number of generations that have already passed.

public boolean

Returns:

true IFF the maximum number of generations has been exceeded
isSatisfied
(final Population
ignored (no impact on result)
population
)

Implements org.apache.commons.math3.genetics.StoppingCondition.isSatisfied.

Determine whether or not the given number of generations have passed.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

maxGenerationsback to summary
private final int maxGenerations

Maximum number of generations (stopping criteria)

numGenerationsback to summary
private int numGenerations

Number of generations that have passed

Constructor Detail

FixedGenerationCountback to summary
public FixedGenerationCount(final int maxGenerations) throws NumberIsTooSmallException

Create a new FixedGenerationCount instance.

Parameters
maxGenerations:int

number of generations to evolve

Exceptions
NumberIsTooSmallException:
if the number of generations is < 1

Method Detail

getNumGenerationsback to summary
public int getNumGenerations()

Returns the number of generations that have already passed.

Returns:int

the number of generations that have passed

isSatisfiedback to summary
public boolean isSatisfied(final Population population)

Implements org.apache.commons.math3.genetics.StoppingCondition.isSatisfied.

Determine whether or not the given number of generations have passed. Increments the number of generations counter if the maximum has not been reached.

Parameters
population:Population

ignored (no impact on result)

Returns:boolean

true IFF the maximum number of generations has been exceeded