Package ec.gp.build
Class PTCFunctionSet
java.lang.Object
ec.gp.GPFunctionSet
ec.gp.build.PTCFunctionSet
- All Implemented Interfaces:
Clique,PTCFunctionSetForm,Setup,Serializable
PTCFunctionSet is a GPFunctionSet which adheres to PTCFunctionSetForm, and thus
can be used with the PTC1 and PTC2 methods. Terminal and nonterminal probabilities
for nodes used in this function set are determined by the prob parameter
for the nodes' GPNodeConstraints object. That's not the greatest solution,
because it could require making a lot of different GPNodeConstraints, customized for each
node, but it's the best I can do for now.
The nonterminalSelectionProbabilities() method computes nonterminal selection
probability using the probabilities above, per type, for the size requested.
If the size is small enough (smaller than CACHE_SIZE), then the result is
memoized so it doesn't need to be computed again next time.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intdouble[][]cache of nonterminal selection probabilities -- dense array [size-1][type].double[][]nonterminal probabilities[type][thenodes], in organized formdouble[][]terminal probabilities[type][thenodes], in organized formFields inherited from class ec.gp.GPFunctionSet
name, nodes, nodes_h, nodesByArity, nodesByName, nonterminals, nonterminals_h, nonterminalsOverArity, nonterminalsUnderArity, P_FUNC, P_NAME, P_SIZE, terminals, terminals_h -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble[]computeNonterminalSelectionProbabilities(int expectedTreeSize) double[]nonterminalProbabilities(int type) Returns an organized distribution (see ec.util.RandomChoice) of likelihoods that various nonterminals in the function set will be chosen over other nonterminals with the same return type.double[]nonterminalSelectionProbabilities(int expectedTreeSize) Returns an array (by return type) of the probability that PTC1 must pick a nonterminal over a terminal in order to guarantee the expectedTreeSize.voidsetup(EvolutionState state, Parameter base) Must be done after GPType and GPNodeConstraints have been set updouble[]terminalProbabilities(int type) Returns an organized distribution (see ec.util.RandomChoice) of likelihoods that various terminals in the function set will be chosen over other terminals with the same return type.Methods inherited from class ec.gp.GPFunctionSet
functionSetFor, postProcessFunctionSet, toString
-
Field Details
-
q_ty
public double[][] q_tyterminal probabilities[type][thenodes], in organized form -
q_ny
public double[][] q_nynonterminal probabilities[type][thenodes], in organized form -
CACHE_SIZE
public static final int CACHE_SIZE- See Also:
-
p_y
public double[][] p_ycache of nonterminal selection probabilities -- dense array [size-1][type]. If any items are null, they're not in the dense cache.
-
-
Constructor Details
-
PTCFunctionSet
public PTCFunctionSet()
-
-
Method Details
-
terminalProbabilities
public double[] terminalProbabilities(int type) Description copied from interface:PTCFunctionSetFormReturns an organized distribution (see ec.util.RandomChoice) of likelihoods that various terminals in the function set will be chosen over other terminals with the same return type. The ordering of the array is the same as the terminals[type][...] array in GPFunctionSet.- Specified by:
terminalProbabilitiesin interfacePTCFunctionSetForm
-
nonterminalProbabilities
public double[] nonterminalProbabilities(int type) Description copied from interface:PTCFunctionSetFormReturns an organized distribution (see ec.util.RandomChoice) of likelihoods that various nonterminals in the function set will be chosen over other nonterminals with the same return type. The ordering of the array is the same as the nonterminals[type][...] array in GPFunctionSet.- Specified by:
nonterminalProbabilitiesin interfacePTCFunctionSetForm
-
setup
Description copied from class:GPFunctionSetMust be done after GPType and GPNodeConstraints have been set up- Specified by:
setupin interfaceSetup- Overrides:
setupin classGPFunctionSet
-
nonterminalSelectionProbabilities
public double[] nonterminalSelectionProbabilities(int expectedTreeSize) Description copied from interface:PTCFunctionSetFormReturns an array (by return type) of the probability that PTC1 must pick a nonterminal over a terminal in order to guarantee the expectedTreeSize. Only used by PTC1, not by PTC2.- Specified by:
nonterminalSelectionProbabilitiesin interfacePTCFunctionSetForm
-
computeNonterminalSelectionProbabilities
public double[] computeNonterminalSelectionProbabilities(int expectedTreeSize)
-