org.apache.commons.math3.genetics

## Class FixedGenerationCount

- java.lang.Object
- - org.apache.commons.math3.genetics.FixedGenerationCount

All Implemented Interfaces:
  StoppingCondition

    public class FixedGenerationCount
    extends java.lang.Object
    implements StoppingCondition

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
Version:
  $Id: FixedGenerationCount.java 1416643 2012-12-03 19:37:14Z tn $

### Field Summary

Fields
`private int` `maxGenerations` Maximum number of generations (stopping criteria)
`private int` `numGenerations` Number of generations that have passed

### Constructor Summary

Constructors
Constructor and Description
`FixedGenerationCount(int maxGenerations)` Create a new FixedGenerationCount instance.

### Method Summary

Methods
`int` `getNumGenerations()` Returns the number of generations that have already passed.
`boolean` `isSatisfied(Population population)` Determine whether or not the given number of generations have passed.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### numGenerations

    private int numGenerations

Number of generations that have passed

#### maxGenerations

    private final int maxGenerations

Maximum number of generations (stopping criteria)

### Constructor Detail

#### FixedGenerationCount

    public FixedGenerationCount(int maxGenerations)
                         throws NumberIsTooSmallException

Create a new FixedGenerationCount instance.

Parameters:
  `maxGenerations` - number of generations to evolve
Throws:
  `NumberIsTooSmallException` - if the number of generations is < 1

### Method Detail

#### isSatisfied

    public boolean isSatisfied(Population population)

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

Specified by:
  `isSatisfied` in interface `StoppingCondition`
Parameters:
  `population` - ignored (no impact on result)
Returns:
  `true` IFF the maximum number of generations has been exceeded

#### getNumGenerations

    public int getNumGenerations()

Returns the number of generations that have already passed.

Returns:
  the number of generations that have passed