Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.epochx.core
Class GPCrossover<TYPE>

    java.lang.Object
      com.epochx.core.GPCrossover<TYPE>

All Implemented Interfaces:
  GenerationListener

    public class GPCrossover<TYPE>

extends java.lang.Object
implements GenerationListener

This class performs the very simple task of linking together parent selection and crossover. The actual tasks of crossover and selection are performed by Crossover and ProgramSelector implementations respectively.

See Also:
  `Crossover`, `UniformPointCrossover`, `KozaCrossover`, `ProgramSelector`

Constructor Summary
`GPCrossover(GPModel<TYPE> model)` Constructs an instance of GPCrossover which will setup the crossover operation.

Method Summary
`CandidateProgram<TYPE>[]` | `crossover()` Selects two parents by calling `getProgramSelector()` on the instance of `GPModel` given at construction and submits them to the `Crossover` operator which is obtained by calling `getCrossover()` on the model.
`int` | `getRevertedCount()` After a crossover is made, the controlling model is requested to confirm the crossover by a call to `acceptCrossover()`.
`void` | `onGenerationStart()` Called after each generation.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### GPCrossover

    public GPCrossover(GPModel<TYPE> model)

  Constructs an instance of GPCrossover which will setup the crossover operation. Note that the actual crossover operation will be performed by the subclass of `Crossover` returned by the models getCrossover() method.

  Parameters:
    `model` - the GPModel which defines the Crossover operator and ProgramSelector to use to perform one act of crossover on a population.
  See Also:
    `Crossover`

Method Detail

### crossover

    public CandidateProgram<TYPE>[] crossover()

  Selects two parents by calling `getProgramSelector()` on the instance of `GPModel` given at construction and submits them to the `Crossover` operator which is obtained by calling `getCrossover()` on the model.

  After a crossover is made, the controlling model is requested to confirm the crossover by a call to `acceptCrossover()`. This gives the model total control over whether a crossover is allowed to proceed. If `acceptCrossover()` returns `false` then the children are discarded and two new parents are selected and attempted for crossover. The number of times the crossover was reverted before being accepted is available through a call to `getRevertedCount()`.

  Even after a crossover has been accepted by the model, it may still be prevented from proceeding if the program depth of either of the children exceeds the max depth that the model defines. In the case that the children do exceed the limit then the parents are returned as the result. This does not count towards the number of reversions.

  Returns:
    an array of CandidatePrograms generated through crossover. This is typically 2 child programs, but could in theory be any number as returned by the Crossover operator in use.

### getRevertedCount

    public int getRevertedCount()

  After a crossover is made, the controlling model is requested to confirm the crossover by a call to `acceptCrossover()`. This gives the model total control over whether a crossover is allowed to proceed. If `acceptCrossover()` returns `false` then the children are discarded and two new parents are selected and attempted for crossover. The number of times the crossover was reverted before being accepted is available through a call to this method.

  Returns:
    the number of times the crossover was rejected by the model.

### onGenerationStart

    public void onGenerationStart()

  Called after each generation. For each generation we should reset all parameters taken from the model incase they've changed. The generation event is then CONFIRMed.

  Specified by:
    `onGenerationStart` in interface `GenerationListener`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD