org.encog.ml.prg.generator
Class RampedHalfAndHalf
- java.lang.Object
-
- org.encog.ml.prg.generator.AbstractPrgGenerator
-
- org.encog.ml.prg.generator.RampedHalfAndHalf
-
- All Implemented Interfaces:
- PopulationGenerator, PrgGenerator, MultiThreadable
public class RampedHalfAndHalf extends AbstractPrgGenerator
Because neither the grow or full method provide a very wide array of sizes or shapes on their own, Koza (1992) proposed a combination called ramped half-and-half. Half the initial population is constructed using full and half is constructed using grow. This is done using a range of depth limits (hence the term "ramped") to help ensure that we generate trees having a variety of sizes and shapes. (from: A field guide to genetic programming) This algorithm was implemented as described in the following publication: Genetic programming: on the programming of computers by means of natural selection MIT Press Cambridge, MA, USA (c)1992 ISBN:0-262-11170-5
-
-
Constructor Summary
Constructors Constructor and Description RampedHalfAndHalf(EncogProgramContext theContext, int theMinDepth, int theMaxDepth)Construct the ramped half-and-half generator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description ProgramNodecreateNode(java.util.Random rnd, EncogProgram program, int depthRemaining, java.util.List<ValueType> types)Create a random node for an Encog Program.intdetermineMaxDepth(java.util.Random rnd)intgetMinDepth()-
Methods inherited from class org.encog.ml.prg.generator.AbstractPrgGenerator
addPopulationMember, attemptCreateGenome, createRandomNode, createTerminalNode, generate, generate, generateRandomOpcode, getContext, getMaxConst, getMaxDepth, getMaxGenerationErrors, getMinConst, getRandomFactory, getScore, getThreadCount, isHasEnum, setMaxConst, setMaxGenerationErrors, setMinConst, setRandomFactory, setScore, setThreadCount
-
-
-
-
Constructor Detail
-
RampedHalfAndHalf
public RampedHalfAndHalf(EncogProgramContext theContext, int theMinDepth, int theMaxDepth)
Construct the ramped half-and-half generator.- Parameters:
theContext- The context.theMinDepth- The minimum depth.theMaxDepth- The maximum depth.
-
-
Method Detail
-
createNode
public ProgramNode createNode(java.util.Random rnd, EncogProgram program, int depthRemaining, java.util.List<ValueType> types)
Create a random node for an Encog Program.- Parameters:
rnd- Random number generator.program- The program that the node should be generated for.depthRemaining- The depth remaining to generate.types- The types to generate.- Returns:
- The newly created node.
-
determineMaxDepth
public int determineMaxDepth(java.util.Random rnd)
- Overrides:
determineMaxDepthin classAbstractPrgGenerator
-
getMinDepth
public int getMinDepth()
- Returns:
- The minimum depth.
-
-
DMelt 3.0 © DataMelt by jWork.ORG