These pages are auto-generated from self-documenting comments embedded in class files.
For more information on breve and steve, refer to the breve homepage.

Object : PushProgram

This class is included as part of the file Push.tz.
To use this class in a simulation, include the line "@use Push."

Class description:

Summary: a single program in the Push programming language.

A PushProgram object is a program in the Push programming language. To be used in conjunction with the class PushInterpreter.

Class methods:

Reading and writing a Push program to a file

Parsing programs and making random code

Copying and evolving Push programs

Getting information about a Push program


copy-from program otherProgram (object)

Copies the contents of otherProgram to this object.


crossover from-parent1 p1 (object) from-parent2 p2 (object) with-interpreter interpreter (object)

Sets this object to a genetic crossover of p1 and p2.


delete-random-subtree

Removes a random subtree from the code.


flatten-random-subtree

Flattens a random subtree in the code.


get-discrepancy from otherProgram (object)

Determines the discrepancy between this program and otherProgram. This is defined as the number of points (atoms and subtrees) found in this program which do not exist in otherProgram, plus the number of points found in otherProgram that do not exist in this program.

This method considers the order of points in a program, and considers all sublists found in a program. For this reason, it is a good measure of similarity between two evolved programs. For a simpler comparison operator, suitable for comparing lists in which order should be preserved, see get-top-level-difference.


get-list

Returns a list representation of this push program.


get-size

Returns the size of this push program.


get-string

Returns the string representation of this push program.


get-top-level-difference from otherProgram (object)

Determines the top level difference between this program and otherProgram. This is calculated by comparing each element of the program against the corresponding element of otherProgram, with every mismatch counting as one point of difference. Sublists are not considered; each element in the top level list is treated as an atomic element.

This method is well suited for comparing lists produced as output of push programs. Because it does not consider sublists or order, it is not well suited for determining the true level of similarity between two programs as one might with to do with evolved code. For that type of functionality, see the method get-discrepancy.


get-top-level-size

Returns the "top-level" size of this push program, meaning that sublists are counted as one item, and not counted recursively.


make-random-code max-length size = -1 (int) with-interpreter interpreter (object)

Makes a random push program of length size. Size is an optional argument with a default value of 100. The size may also be equal to -1, which indicates that the MAX-POINTS-IN-RANDOM-EXPRESSION value from the Push configuration file should be used. The interpreter provided specifies the instruction set used to generate the random code.


mutate with-interpreter interpreter (object) with-leaf-bias leafBias = 0.9 (float) with-size-scale sizeScale = 0.3 (float) with-max-new-code-size ignored = 0 (int)

Mutates this code object by adding a new subtree. The maximum size of the subtree is specified in the optional argument treeSize, which has a default value of 50. The size may also be equal to -1 (the default), indicating that the MAX-POINTS-IN-RANDOM-EXPRESSION value from the Push configuration file should be used. The interpreter argument determines the instruction set used to generate the random code.

Mutation is implemented as "fair" mutation with a range of +/- 30% of the mutated subtree.

The max-new-code-size argument is ignored, but included for backwards compatibility.


parse program codeString (string)

Sets the content of this code to the newly parsed string. The with-interpreter keyword is no longer required.


read from fileName (string)

Reads a push program from a text file.


swap-sublists at-x x (int) at-y y (int)

Swaps the positions of the top level sublists x and y.


write to fileName (string)

Writes this push program to a text file.


Documentation created Sat Jan 20 13:13:52 2007