Population module#
- class Population[source]#
Population Module is used to initialize the population with given methods and states.
Methods
__init__([states, module_states])Initialize the population and register the needed states.
initPop(pop_size, prog_paras[, prog_states, ...])Initialize a population using the 'methods', with a given population size.
Attributes
states- __init__(states=None, module_states=None, **kwargs)[source]#
Initialize the population and register the needed states.
- Parameters:
states (PyGP.States)
module_states (PyGP.States)
kwargs
- Returns:
a new
Populationmodule
Examples
>>> optimizer = Population()
- initPop(pop_size, prog_paras, prog_states=None, node_states=None, methods=None, indivs_type=<class 'HyperGP.libs.representation.TGP.TGPIndv'>, **kwargs)[source]#
Initialize a population using the ‘methods’, with a given population size. The population can be initialize with a single method and state or with a list of them.
- Parameters:
pop_size (int) – The population size
prog_paras (ProgBuildStates) – The paras to the ‘methods’ to initialize the individuals. If the ‘methods’ is a list-like object, the ‘prog_paras’ should be a list-like object too and its length should be equal to the pop_size.
prog_states (dict) – The states to register to the inidividuals. Also, if the ‘methods’ is a list-like object, the ‘prog_paras’ should be a list-like object and its length should be equal to the pop_size.
methods (ProgBuildMethod) – The methods used to initialize the individuals. If it is a list-like object, each individual will be initialize with the corresponding different methods.
indivs_type – The type of individuals to create.
- Returns:
The individuals initialized will be store in the ‘self.states[‘progs’].indivs’.
Examples
>>> optimizer = Population() >>> pop.initPop(pop_size=pop_size, prog_paras=ProgBuildStates(pset=pset, depth_rg=[2, 6], len_limit=1000))