X hits on this document

73 views

0 shares

0 downloads

0 comments

24 / 30

The techniques of genetic programming provide an answer. In breve, this is implemented using Push, a stack-based genetic programming language. [32]

Non-genetic programming languages are constrained by their rigid syntax. In general, mixing up the order of tokens and operators typically results in garbage, as shown by the following list comprehension in Python which shows randomization of language tokens.

This makes sense:

L = [math.exp(val) for val in eigenvalues]

This does not:

eigenvalues ] in math.exp(val) = L ] for

In Push (which are not typically written by hand), programs are composed of instructions, literals, or sublists of the previous two. Push programs are expressions, placed entirely on the stack and evaluated recursively according to these rules:

  • 1.

    If P is an instruction then execute it

  • 2.

    Else if P is a literal then push it on to the stack

  • 3.

    Else (P must be a list) sequentially execute each of the Push programs in P

Let’s look at a simplified Push example program:

( 2 3 INTEGER. * 4.1 5.2 FLOAT.+ TRUE FALSE BOOLEAN.OR )

Each type of operation (Push is necessarily strongly-typed) gets placed on its own stack. Evaluating this from left to right we have:

2, 3, INTEGER.* (integer operator multiply) gets placed on an Integer stack.

4.1, 5.2, FLOAT.+ (floating point operator addition) gets placed on a Float stack.

TRUE, FALSE, BOOLEAN.OR (Boolean operator OR) gets placed on a Boolean stack.

Pushing onto the stack from left to right, we then pop the stack right to left :

  • First run is: BOOLEAN.OR FALSE TRUE = (TRUE) (BOOLEAN stack)

  • Next we have: FLOAT.+ 5.2 4.1 = (9.3) (FLOAT stack)

  • Finally we have INTEGER.* 2 3 = (6) (INTEGER stack)

Note that each stack has its own type, and the stack-based typing system puts each instruction appropriately. The result is that any combination remains semantically valid, and wee could re-order all of the instructions (stacks) without issue.

Document info
Document views73
Page views73
Page last viewedFri Dec 09 11:47:27 UTC 2016
Pages30
Paragraphs495
Words6732

Comments