HyperGP.libs.TGPIndv#
- class TGPIndv[source]#
We provide the
TGPIndvclass to build the tree structure programNote
The encode list is a collection of pset elements without deep copy.
- __init__(states=None, encode=None, module_states=None, **kwargs)[source]#
Initialize the program
- Parameters:
states (HyperGP.States) – the states assign to a program.
encode – generate a new
TGPIndvwith a given encode.kwargs – the attrs assign to a program.
- Returns:
returns a new
TGPIndv
Examples
>>> from HyperGP.representation import TGPIndv >>> from HyperGP.states import States >>> ind = TGPIndv()
Initialize with states and attrs: >>> ind = TGPIndv(states=States(elim_prob=1, rk=0), win_num=0) >>> print(ind.states) xxxxx >>> print(TGPIndv.win_num) xxxxx
Methods
__init__([states, encode, module_states])Initialize the program
buildProgram(cond[, method, node_states])Build the program
copy()Returns a new
TGPIndvwith the same encode list and states.deepcopy()depth()funcRegister(func, *args, **kwargs)gen_array(node)get_encode(item)gfuncRegister(func, *args, **kwargs)gmoduleRegister(**kwargs)gstateRegister(**kwargs)list([parent, childs])Generate the preorder traversal list of the program
make(encode_array, states, pset_map, memo)moduleRegister(**kwargs)set_encode(key, value)slice([begin, end])Generate a slice object that defines the range of a subtree with the element of the 'begin' index as its root.
stateRegister(**kwargs)update(target_ind)Attributes
available_modsgmodule_statesgstatesstatesinitialize states set
module_statesinitialize states set
- __init__(states=None, encode=None, module_states=None, **kwargs)[source]#
Initialize the program
- Parameters:
states (HyperGP.States) – the states assign to a program.
encode – generate a new
TGPIndvwith a given encode.kwargs – the attrs assign to a program.
- Returns:
returns a new
TGPIndv
Examples
>>> from HyperGP.representation import TGPIndv >>> from HyperGP.states import States >>> ind = TGPIndv()
Initialize with states and attrs: >>> ind = TGPIndv(states=States(elim_prob=1, rk=0), win_num=0) >>> print(ind.states) xxxxx >>> print(TGPIndv.win_num) xxxxx
- __new__(**kwargs)#