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 GPMutation<TYPE>

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

All Implemented Interfaces:
  GenerationListener

    public class GPMutation<TYPE>

extends java.lang.Object
implements GenerationListener

This class performs the very simple task of linking together individual selection and mutation. The actual tasks of crossover and selection are performed by `Mutation` and `ProgramSelector` implementations respectively.

See Also:
  `Mutation`, `PointMutation`, `SubtreeMutation`, `ProgramSelector`

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

Method Summary
`int` | `getRevertedCount()` After a mutation is made, the controlling model is requested to confirm the mutation by a call to `acceptMutation()`.
`CandidateProgram<TYPE>` | `mutate()` Selects a `CandidateProgram` from the population using the `ProgramSelector` returned by a call to `getProgramSelector()` on the model given at construction and submits it to the `Mutation` operator which is obtained by calling `getMutation()` on the model.
`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

### GPMutation

    public GPMutation(GPModel<TYPE> model)

  Constructs an instance of GPMutation which will setup the mutation operation. Note that the actual mutation operation will be performed by the subclass of `Mutation` returned by the models `getMutation()` method.

  Parameters:
    `model` - the GPModel which defines the Mutation operator and ProgramSelector to use to perform one act of mutation on an individual in the population.
  See Also:
    `Mutation`

Method Detail

### mutate

    public CandidateProgram<TYPE> mutate()

  Selects a `CandidateProgram` from the population using the `ProgramSelector` returned by a call to `getProgramSelector()` on the model given at construction and submits it to the `Mutation` operator which is obtained by calling `getMutation()` on the model.

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

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

  Returns:
    a CandidateProgram generated through mutation by the Mutation operator in use, or if the max depth limit was exceeded then the original selected program before mutation will be returned.

### getRevertedCount

    public int getRevertedCount()

  After a mutation is made, the controlling model is requested to confirm the mutation by a call to `acceptMutation()`. This gives the model total control over whether a mutation is allowed to proceed. If `acceptMutation()` returns `false` then the mutated program is discarded and a new `CandidateProgram` selected to undergo mutation. The number of times the mutation was reverted before being accepted is available through a call to this method.

  Returns:
    the number of times the mutation 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