liveBook · Manning

PrimitiveSet

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

PrimitiveSet is a genetic-programming configuration object that defines the primitives, arguments, and input symbols available to evolved expressions.

PrimitiveSet defines the building blocks from which genetic-programming candidates are assembled: available inputs, functions, terminals, and sometimes ephemeral constants. Its design constrains what an evolved expression or routine can represent, so it is part of the problem formulation rather than a neutral setup detail. section 12.2 section 12.4

For continuous-control equations, configure inputs to match the environment state, then add arithmetic operators and protected division. An ephemeral terminal can generate integer constants, letting evolution form parameterized equations as well as combine observations. section 12.2 section 12.3.3

A PrimitiveSet can be varied to direct the search:

  • Change input names when environments expose different observation states, so compiled functions receive the required state values. section 12.2
  • Add reusable evolved functions as higher-level operators, alongside a smaller arithmetic operator set and an environment indicator input. section 12.3.2
  • Remove reusable operators and retain protected division and ephemeral constants to test a from-scratch generalized search. section 12.3.3
  • Use zero inputs when generated routines obtain state themselves, then register conditional, sequencing, and movement primitives as executable code. section 12.4

A reusable-instinct configuration

A multi-environment controller uses inputs e, x, y, and velocity. It admits addition, subtraction, multiplication, and two previously evolved instinct functions; division and ephemeral constants are disabled because the base instincts already contain needed constants. Evaluation inserts the environment index and averages fitness across both environments. section 12.3.2

Listing 12.16 EDL_12_3_GEPPY_Instinctual.ipynb: Completing the primitive set
pset = gep.PrimitiveSet('Main', input_names=
 ['e', 'x', 'y', 'velocity'])              #1
pset.add_function(operator.add, 2)
pset.add_function(operator.sub, 2)
pset.add_function(operator.mul, 2)
#pset.add_function(protected_div, 2)         #2
pset.add_function(instinct1, 2)              #3
pset.add_function(instinct2, 3)              #4
#pset.add_ephemeral_terminal...              #5

This configuration makes the search-space tradeoff concrete: it exposes environment and state inputs, keeps basic arithmetic, and promotes two evolved instincts to callable primitives. section 12.3.2

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

How deep it goes
Walks through input, function, terminal, and constant configuration, then contrasts reusable operators with from-scratch search.
Examples
Uses Pendulum and MountainCarContinuous control equations plus a DEAP artificial ant with conditional and movement routines.
What it assumes
Assumes runnable Python notebook setup while demonstrating PrimitiveSet construction through incremental API calls.
What you can do after
Apply it via GEPPY or DEAP to constrain evolved expressions with task inputs, operators, terminals, and reusable functions.
How it connects
Connects genetic programming with gene expression programming, reinforcement learning, ephemeral constants, protected division, and reusable functions.

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.