com.epochx.core
Class GPReproduction<TYPE>

java.lang.Object
  extended by com.epochx.core.GPReproduction<TYPE>
All Implemented Interfaces:
GenerationListener

public class GPReproduction<TYPE>
extends java.lang.Object
implements GenerationListener

This class controls the reproduction operation.

See Also:
ProgramSelector

Constructor Summary
GPReproduction(GPModel<TYPE> model)
          Constructs an instance of GEReproduction which will setup the reproduction operation.
 
Method Summary
 int getReversions()
          Number of times the reproduction was rejected and re-attempted.
 void onGenerationStart()
          Called after each generation.
 CandidateProgram<TYPE> reproduce()
          Selects a CandidateProgram from the population using the ProgramSelector returned by a call to getProgramSelector() on the model given at construction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GPReproduction

public GPReproduction(GPModel<TYPE> model)
Constructs an instance of GEReproduction which will setup the reproduction operation. Since the actual reproduction operation requires little more than selection of a program, the actual operation is also performed here.

Parameters:
model - the GEModel which defines the ProgramSelector to use to select the program to be reproduced.
Method Detail

reproduce

public CandidateProgram<TYPE> reproduce()
Selects a CandidateProgram from the population using the ProgramSelector returned by a call to getProgramSelector() on the model given at construction.

After a program is selected for reproduction, the model's life cycle listener is requested to confirm or modify the selection by a call to onReproduction(). This gives over total control to decide whether a reproduction is allowed to proceed, and gives an opportunity for manipulation of the reproduced child program. If onReproduction() returns null then the child is discarded and a new parent is selected and reproduced. The number of times the reproduction was reverted before being accepted is available through a call to getReversions().

Returns:
a CandidateProgram selected for reproduction.

getReversions

public int getReversions()
Number of times the reproduction was rejected and re-attempted.

After a program is selected for reproduction, the model's life cycle listener is requested to confirm or modify the selection by a call to onReproduction(). This gives over total control to decide whether a reproduction is allowed to proceed, and gives an opportunity for manipulation of the reproduced child program. If onReproduction() returns null then the child is discarded and a new parent is selected and reproduced. The number of times the reproduction was reverted before being accepted is available through a call to this method.

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