scripts/plot_ind.py
def parse_repr(repr_):
    """Parse the string representation of the individual.
    
    Arguments:
        repr_ -- String representation of the individual.
    """

    functions = set(['+', '-', '*', "AQ"])

    labels = {}
    edges = []

    repr_ = repr_.replace('(', '')
    repr_ = repr_.split()

    n = 0
    root = repr_[0]

    if root in functions:
        labels[n] = (root, "#ff0000")
    else:
        labels[n] = (root, "#00ff00")
    parent_stack = [n]

    n += 1
    for node in repr_[1:]:
        if node == ')':
            parent_stack.pop()
            continue

        edges.append((parent_stack[-1], n))

        if node in functions:
            labels[n] = (node, "#ff0000")
            parent_stack.append(n)
        else:
            labels[n] = (node, "#00ff00")

        n += 1

    return labels, edges
Parse the string representation of the individual.
    
    Arguments:
        repr_ -- String representation of the individual.
    
Parse the string representation of the individual.
Arguments:
repr_ -- String representation of the individual.
Parse the string representation of the individual . Arguments : repr_ -- String representation of the individual .
def parse_repr(repr_):
    functions = set(['+', '-', '*', "AQ"])
    labels = {}
    edges = []
    repr_ = repr_.replace('(', '')
    repr_ = repr_.split()
    n = 0
    root = repr_[0]
    if root in functions:
        labels[n] = (root, "#ff0000")
    else:
        labels[n] = (root, "#00ff00")
    parent_stack = [n]
    n += 1
    for node in repr_[1:]:
        if node == ')':
            parent_stack.pop()
            continue
        edges.append((parent_stack[-1], n))
        if node in functions:
            labels[n] = (node, "#ff0000")
            parent_stack.append(n)
        else:
            labels[n] = (node, "#00ff00")
        n += 1
    return labels, edges
def parse_repr ( repr_ ) : functions = set ( [ '+' , '-' , '*' , "AQ" ] ) labels = { } edges = [ ] repr_ = repr_ . replace ( '(' , '' ) repr_ = repr_ . split ( ) n = 0 root = repr_ [ 0 ] if root in functions : labels [ n ] = ( root , "#ff0000" ) else : labels [ n ] = ( root , "#00ff00" ) parent_stack = [ n ] n += 1 for node in repr_ [ 1 : ] : if node == ')' : parent_stack . pop ( ) continue edges . append ( ( parent_stack [ - 1 ] , n ) ) if node in functions : labels [ n ] = ( node , "#ff0000" ) parent_stack . append ( n ) else : labels [ n ] = ( node , "#00ff00" ) n += 1 return labels , edges
Parse the string representation of the individual.
Parse the string representation of the individual .
"""Parse the string representation of the individual.
    
    Arguments:
        repr_ -- String representation of the individual.
    """
repr_