liveBook · Manning

Expression tree

As explained in Evolutionary Deep Learning: Genetic algorithms and neural networks

An expression tree is a hierarchical data structure whose nodes represent operators, functions, or values in a mathematical or executable expression.

An expression tree represents an executable or mathematical expression as a hierarchy. Operators occupy internal nodes; constants and inputs occupy terminal nodes. Node placement fixes the order in which the expression is evaluated. section 4.1.1 section 1.1.1

In genetic programming, a gene sequence can encode a reusable function or code routine. In gene expression programming, the sequence represents a mathematical expression tree whose evaluated output is compared with a target to assign error or fitness. section 4.1.1 section 1.1.1

Build a simple numerical tree by defining:

  • A primitive set of allowed operators, such as addition, subtraction, multiplication, protected division, sine, cosine, and negation. section 4.1.1
  • Terminals for inputs and generated constants; inputs may be scalars, arrays, or tensors. section 4.1.1
  • Operator arity, because unary, binary, ternary, or n-ary operators determine how many child nodes each operator receives. section 4.1.1
  • A compiled evaluation function and fitness calculation against target outputs. section 4.1.1

Symbolic regression

A tree rooted at multiplication can branch to addition and square-root operators, then to subtraction, inputs, and constants. Compiling the individual turns that structure into a callable function; squared error against generated targets measures its fitness. section 4.1.1

Expression trees need not be numerical equations. A GP tree can encode an agent routine: sequencing and conditional operators combine terminals such as move forward, turn left, and turn right. Executing the compiled routine in a grid environment yields fitness from food collected. section 12.4

For GEP, Geppy organizes sequences into genes and chromosomes, allowing complex components to be isolated and swapped during crossover. A linear target function can be evolved, compiled, simplified, and displayed as an equation tree. section 12.1

Figure 4.1 Example GP individual to expression tree to equation to fitness

Trace how an individual gene sequence becomes an expression tree, evaluates as an equation, and receives fitness. section 4.1.1

How Evolutionary Deep Learning: Genetic algorithms and neural networks covers it

How deep it goes
Explains node types, arity, sequence-to-tree mapping, compilation, and fitness, without formal tree algorithms.
Examples
Uses a numerical regression equation, an evolved linear function, and an ant-navigation control routine.
What you can do after
Apply DEAP or Geppy to define primitives, compile evolved trees, evaluate fitness, simplify functions, and visualize results.
How it connects
Connects genetic programming, gene expression programming, symbolic regression, primitive sets, fitness, mutation, and crossover.

Also explained in

Compare how 2 books explain expression tree →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Evolutionary Deep Learning: Genetic algorithms and neural networks. The section links point to the parts of the book it draws on.