Skip to content

Commit

Permalink
improved the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nbro committed Feb 2, 2021
1 parent 3eab2d6 commit 01c56a4
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions deap/gp.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@


class PrimitiveTree(list):
"""Tree specifically formatted for optimization of genetic
programming operations. The tree is represented with a
list where the nodes are appended in a depth-first order.
The nodes appended to the tree are required to
have an attribute *arity* which defines the arity of the
primitive. An arity of 0 is expected from terminals nodes.
"""Tree specifically formatted for optimization of genetic programming
operations. The tree is represented with a list, where the nodes are
appended, or are assumed to have been appended when initializing an object
of this class with a list of primitives and terminals e.g. generated with
the method **gp.generate**, in a depth-first order.
The nodes appended to the tree are required to have an attribute *arity*,
which defines the arity of the primitive. An arity of 0 is expected from
terminals nodes.
"""

def __init__(self, content):
Expand Down Expand Up @@ -585,10 +587,12 @@ def genRamped(pset, min_, max_, type_=None):


def generate(pset, min_, max_, condition, type_=None):
"""Generate a tree as a list of primitives and terminals. The tree is build
from the root to the leaves, and it stops growing when the *condition* is
fulfilled. The returned list can then be passed to the constructor of the
class *PrimitiveTree* to build an actual tree object.
"""Generate a tree as a list of primitives and terminals in a depth-first
order. The tree is built from the root to the leaves, and it stops growing
the current branch when the *condition* is fulfilled: in which case, it
back-tracks, then tries to grow another branch until the *condition* is
fulfilled again, and so on. The returned list can then be passed to the
constructor of the class *PrimitiveTree* to build an actual tree object.
:param pset: Primitive set from which primitives are selected.
:param min_: Minimum height of the produced trees.
Expand Down

0 comments on commit 01c56a4

Please sign in to comment.