(genome, **args)
Integer initialization function of GTree

    This initializator accepts the *rangemin* and *rangemax* genome parameters.
    It accepts the following parameters too:

    *max_depth*
       The max depth of the tree

    *max_siblings*
       The number of maximum siblings of an node

    *method*
       The method, accepts "grow", "full" or "ramped".

    .. versionadded:: 0.6
       The *GTreeInitializatorInteger* function.
Integer initialization function of GTree
Integer initialization function of GTree
def GTreeInitializatorInteger(genome, **args):
    """ Integer initialization function of GTree

    This initializator accepts the *rangemin* and *rangemax* genome parameters.
    It accepts the following parameters too:

    *max_depth*
       The max depth of the tree

    *max_siblings*
       The number of maximum siblings of an node

    *method*
       The method, accepts "grow", "full" or "ramped".

    .. versionadded:: 0.6
       The *GTreeInitializatorInteger* function.
    """
    max_depth = genome.getParam("max_depth", 5)
    max_siblings = genome.getParam("max_siblings", 2)

    range_min = genome.getParam("rangemin", 0)
    range_max = genome.getParam("rangemax", 100)

    lambda_generator = lambda: rand_randint(range_min, range_max)

    method = genome.getParam("method", "grow")

    if method == "grow":
        root = GTree.buildGTreeGrow(0, lambda_generator, max_siblings, max_depth)
    elif method == "full":
        root = GTree.buildGTreeFull(0, lambda_generator, max_siblings, max_depth)
    elif method == "ramped":
        if Util.randomFlipCoin(0.5):
            root = GTree.buildGTreeGrow(0, lambda_generator, max_siblings, max_depth)
        else:
            root = GTree.buildGTreeFull(0, lambda_generator, max_siblings, max_depth)
    else:
        Util.raiseException("Unknown tree initialization method [%s] !" % method)

    genome.setRoot(root)
    genome.processNodes()
    assert genome.getHeight() <= max_depth
def GTreeInitializatorInteger ( genome , * * args ) : max_depth = genome . getParam ( "max_depth" , 5 ) max_siblings = genome . getParam ( "max_siblings" , 2 ) range_min = genome . getParam ( "rangemin" , 0 ) range_max = genome . getParam ( "rangemax" , 100 ) lambda_generator = lambda : rand_randint ( range_min , range_max ) method = genome . getParam ( "method" , "grow" ) if method == "grow" : root = GTree . buildGTreeGrow ( 0 , lambda_generator , max_siblings , max_depth ) elif method == "full" : root = GTree . buildGTreeFull ( 0 , lambda_generator , max_siblings , max_depth ) elif method == "ramped" : if Util . randomFlipCoin ( 0.5 ) : root = GTree . buildGTreeGrow ( 0 , lambda_generator , max_siblings , max_depth ) else : root = GTree . buildGTreeFull ( 0 , lambda_generator , max_siblings , max_depth ) else : Util . raiseException ( "Unknown tree initialization method [%s] !" % method ) genome . setRoot ( root ) genome . processNodes ( ) assert genome . getHeight ( ) <= max_depth