diff --git a/docs/A_Guide_To_Propeller.html b/docs/A_Guide_To_Propeller.html new file mode 100644 index 0000000..597a5cc --- /dev/null +++ b/docs/A_Guide_To_Propeller.html @@ -0,0 +1,134 @@ + +A Guide to Propeller

A Guide to Propeller

+

Propeller is an implementation of the Push programming language and the PushGP genetic programming system in Clojure.

+

For more information on Push and PushGP see http://pushlanguage.org.

+

Overview

+

Propeller is a Push-based genetic programming system in Clojure.

+ + + +

What can you do with Propeller?

+

You can evolve a Push program to solve a problem. You can also use the Push interpreter to evaluate Push programs in other projects, for example in agent-based evolutionary simulations in which agents are controlled by evolving Push programs.

+

Installation

+

If you have installed leiningen, which is a tool for running Clojure programs, then you can run Propeller on a genetic programming problem that is defined within this project from the command line with the command lein run -m <namespace>, replacing <namespace> with the actual namespace that you will find at the top of the problem file.

+

If you have installed Clojure, you can run Propeller on a genetic programming problem with the command clj -m <namespace>, replacing <namespace> with the actual namespace that you will find at the top of the problem file. The examples below use leiningen, but you can replace lein run -m with clj --main to run the same problem.

+

A specific example is provided later below.

+

How do I run Propeller on a problem?

+

To run a problem in Propeller, you want to call the -main function in the problem file using leiningen. The -main function will create a map of arguments from the input and run the main genetic programming loop.

+

Below is the general format to run a problem through the command-line:

+
lein run -m [namespace of the problem file you want to test]
+
+

Additional command-line arguments may be provided to override the default key/value pairs specified in the problem file,

+
lein run -m [namespace of the problem file you want to test] [key and value] [key and value]...
+
+

The possible keys come from the table below:

+ + + + + + + + + + + + + + + + + + + +
Key Description
:instructions List of possible Push instructions used to create a plushy
:error-function The error function used to evaluate individuals, specified in the given problem’s namespace
:training-data Map of inputs and desired outputs used to evaluate individuals of the form: {:input1 first-input :input2 second-input … :output1 first-output …}
:testing-data Map of inputs and desired outputs not in the training-data to test generalizability of a program that fits the training-data. The map is of the form: {:input1 first-input :input2 second-input … :output1 first-output …}
:max-generations Maximum number of generations
:population-size Size of population in a generation
:max-initial-plushy-size Maximum number of Push instructions in the initial plushy
:step-limit The maximum number of steps that a Push program will be executed by interpret-program
:parent-selection Function from propeller.selection that determines method of parent selection method. Propeller includes :tournament-selection, :lexicase-selection, and :epsilon-lexicase-selection.
:tournament-size If using a tournament selection method, the number of individuals in each tournaments used to determine parents
:umad-rate Rate (decimal between 0 and 1) of uniform mutation by addition and deletion (UMAD) genetic operator
:variation Map with genetic operators as keys and probabilities as values. For example, {:umad 0.3 :crossover 0.7}. This would mean that when the system needs to generate a child, it will use UMAD 30% of the time and crossover 70% of the time. The probabilities should sum to 1.
:elitism When true, will cause the individual with the lowest error in the population to survive, without variation, into the next generation.
+

When you run a problem, you will get a report each generation with the following information:

+
:generation            
+ :best-plushy 
+ :best-program          
+ :best-total-error      
+ :best-errors        
+ :best-behaviors        
+ :genotypic-diversity   
+ :behavioral-diversity  
+ :average-genome-length 
+ :average-total-error 
+
+
+

An Example

+

For example, you can run the simple-regression genetic programming problem with:

+
lein run -m propeller.problems.simple-regression
+
+

This will run simple-regression with the default set of arguments in the simple-regression problem file.

+
{:instructions             instructions
+:error-function           error-function
+:training-data            (:train train-and-test-data)
+:testing-data             (:test train-and-test-data)
+:max-generations          500
+:population-size          500
+:max-initial-plushy-size  100
+:step-limit               200
+:parent-selection         :lexicase
+:tournament-size          5
+:umad-rate                0.1
+:variation                {:umad 0.5 :crossover 0.5}
+:elitism                  false}
+
+

You can override the default key/value pairs with additional arguments. For example:

+
lein run -m propeller.problems.simple-regression :population-size 100
+
+

On Unix operating systems, including MacOS, you can use something like the following to send output both to the terminal and to a text file (called outfile in this example):

+
lein run -m propeller.problems.simple-regression | tee outfile
+
+

If you want to provide command line arguments that include characters that may be interpreted by your command line shell before they get to Clojure, then enclose those in double quotes, like in this example that provides a non-default value for the :variation argument, which is a clojure map containing curly brackets that may confuse your shell:

+
lein run -m propeller.problems.simple-regression :variation "{:umad 1.0}"
+
+

Can you use a REPL?

+

Yes!

+

To run a genetic programming problem from a REPL, start your REPL for the project (e.g. with lein repl at the command line when in the project directory, or through your IDE) and then do something like the following (which in this case runs the simple-regression problem with :population-size 100):

+
(require 'propeller.problems.simple-regression)
+(in-ns 'propeller.problems.simple-regression)
+(-main :population-size 100 :variation {:umad 1.0})
+
+

If you want to run the problem with the default parameters, then you should call -main without arguments, as `(-main).

+

Tutorials

+
    +
  • Adding genetic operators
  • +
  • Adding selection methods
  • +
  • Adding a new problem
  • +
  • Using Propeller for Experiments
  • +
+

Contributing

+

You can report a bug on the GitHub issues page.

+

The best way to contribute to Propeller is to fork the main GitHub repository and submit a pull request.

+

License

+

Eclipse Public License 2.0

+

This commercially-friendly copyleft license provides the ability to commercially license binaries; a modern royalty-free patent license grant; and the ability for linked works to use other licenses, including commercial ones.

+

Citation

+

We are in the process of creating a DOI, but in the meantime, we ask that you cite the link to the repository if you use Propeller.

+

About Propeller

+

Propeller was created by

+

Contact

+

To discuss Propeller, Push, and PushGP, you can join the Push-Language Discourse.

+
\ No newline at end of file diff --git a/docs/Adding_Genetic_Operators.html b/docs/Adding_Genetic_Operators.html index 3ab38b2..966c6fd 100644 --- a/docs/Adding_Genetic_Operators.html +++ b/docs/Adding_Genetic_Operators.html @@ -1,6 +1,6 @@ -Adding Genetic Operators

Adding Genetic Operators

+Adding Genetic Operators

Adding Genetic Operators

In addition to the already-included genetic operators, you can add your own!

Variation Genetic Operators

    diff --git a/docs/Adding_Problem.html b/docs/Adding_Problem.html index 112ca54..d676b4e 100644 --- a/docs/Adding_Problem.html +++ b/docs/Adding_Problem.html @@ -1,27 +1,27 @@ -Adding a Problem

    Adding a Problem

    +Adding a Problem

    Adding a Problem

    In general, a problem file has 3 components: train-and-test-data, instructions, error-function, and -main.

    1. To add a new problem, you need training and test data. For Problem Synthesis Benchmark Problems (PSB2), you can fetch datasets using psb2.core/fetch-examples.
    (defn fetch-examples
    -   "Fetches and returns training and test data from a PSB2 problem.
    -    Returns a map of the form {:train training-examples :test testing-examples}
    -    where training-examples and testing-examples are lists of training and test
    -    data. The elements of these lists are maps of the form:
    -    {:input1 first-input :input2 second-input ... :output1 first-output ...}
    -    The training examples will include all hard-coded edge cases included in the suite,
    -    along with enough random cases to include `n-train` cases.
    -    Note that this function loads large datasets and can be slow, 30-120 seconds.
    -    Parameters:
    -      `datasets-directory` - Location of the PSB2 datasets as downloaded from https://zenodo.org/record/4678739
    -      `problem-name` - Name of the PSB2 problem, lowercase and seperated by dashes.
    -          - Ex: indices-of-substring
    -      `n-train` - Number of training cases to return
    -      `n-test` - Number of test cases to return"
    -   [datasets-directory problem-name n-train n-test]
    -   )
    +  "Fetches and returns training and test data from a PSB2 problem.
    +   Returns a map of the form {:train training-examples :test testing-examples}
    +   where training-examples and testing-examples are lists of training and test
    +   data. The elements of these lists are maps of the form:
    +   {:input1 first-input :input2 second-input ... :output1 first-output ...}
    +   The training examples will include all hard-coded edge cases included in the suite,
    +   along with enough random cases to include `n-train` cases.
    +   Note that this function loads large datasets and can be slow, 30-120 seconds.
    +   Parameters:
    +     `datasets-directory` - Location of the PSB2 datasets as downloaded from https://zenodo.org/record/4678739
    +     `problem-name` - Name of the PSB2 problem, lowercase and seperated by dashes.
    +         - Ex: indices-of-substring
    +     `n-train` - Number of training cases to return
    +     `n-test` - Number of test cases to return"
    +  [datasets-directory problem-name n-train n-test]
    +
     
    1. Define the possible Push instructions to be used to create plushys. It should be a non-lazy list of instructions from push/instructions
    2. diff --git a/docs/Adding_Selection_Method.html b/docs/Adding_Selection_Method.html index 25309b6..848020e 100644 --- a/docs/Adding_Selection_Method.html +++ b/docs/Adding_Selection_Method.html @@ -1,6 +1,6 @@ -Adding a Selection Method

      Adding a Selection Method

      +Adding a Selection Method

      Adding a Selection Method

      1. Define a selection method function in propeller.selection that selects an individual from the population
      2. Add the selection method in propeller.selection/select-parent under the case call:
      3. diff --git a/docs/Library_Reference.html b/docs/Library_Reference.html deleted file mode 100644 index 5c421bb..0000000 --- a/docs/Library_Reference.html +++ /dev/null @@ -1,32 +0,0 @@ - -Library Reference

        Library Reference

        -

        An overly-detailed description of (almost) all the functions contained within propeller.

        - - - -

        Genetic Operators

        -

        https://en.wikipedia.org/wiki/Genetic_operator

        -

        Variation

        -

        Selection

        -

        Genetic Programming Loop

        -

        gp.cljc

        -

        Genome

        -

        Utility Functions

        -

        Found in propeller.utils.cljc, these are functions just to make life easier when writing other functions.

        -

        Push

        -

        simplification

        -

        Problems

        -
        \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index fee48aa..7cf4c10 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,6 +1,7 @@ -Propeller 0.3.0

        Propeller 0.3.0

        Released under the EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0

        Yet another Push-based genetic programming system in Clojure.

        Installation

        To install, add the following dependency to your project or build file:

        [net.clojars.lspector/propeller "0.3.0"]

        Topics

        Namespaces

        propeller.core

        Public variables and functions:

        propeller.genome

        Public variables and functions:

        propeller.gp

        Public variables and functions:

        propeller.problems.PSB2.basement

        BASEMENT from PSB2

        +Propeller 0.3.0

        Propeller 0.3.0

        Released under the EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0

        Yet another Push-based genetic programming system in Clojure.

        Installation

        To install, add the following dependency to your project or build file:

        [net.clojars.lspector/propeller "0.3.0"]

        Topics

        Namespaces

        propeller.core

        Public variables and functions:

        propeller.genome

        The genetic material in Propeller. A plushy is a list of Push instructions that represent a Push program. They hold the genetic material for an individual. In the initial population, we create random plushys.

        +

        Public variables and functions:

        propeller.gp

        Public variables and functions:

        propeller.problems.PSB2.camel-case

        CAMEL CASE from PSB2

        @@ -16,11 +17,19 @@

        propeller.problems.PSB2.solve-boolean

        SOLVE BOOLEAN from PSB2

        Public variables and functions:

        propeller.problems.PSB2.substitution-cipher

        =========== PROBLEM DESCRIPTION ========================= SUBSTITUTION CIPHER from PSB2 This problem gives 3 strings. The first two represent a cipher, mapping each character in one string to the one at the same index in the other string. The program must apply this cipher to the third string and return the deciphered message.

        -

        propeller.problems.PSB2.twitter

        =========== PROBLEM DESCRIPTION ============================= TWITTER from PSB2 Given a string representing a tweet, validate whether the tweet meets Twitter’s original character requirements. If the tweet has more than 140 characters, return the string “Too many characters”. If the tweet is empty, return the string “You didn’t type anything”. Otherwise, return “Your tweet has X characters”, where the X is the number of characters in the tweet.

        -

        propeller.problems.simple-regression

        =========== PROBLEM DESCRIPTION ============================= Simple Regression: Given inputs and outputs, find the target function.

        -

        Public variables and functions:

        propeller.problems.string-classification

        =========== PROBLEM DESCRIPTION ============================= String Classification: Given a string, return true if it contains A, C, G, and T. Else return false.

        +

        propeller.problems.PSB2.twitter

        TWITTER from PSB2 Given a string representing a tweet, validate whether the tweet meets Twitter’s original character requirements. If the tweet has more than 140 characters, return the string “Too many characters”. If the tweet is empty, return the string “You didn’t type anything”. Otherwise, return “Your tweet has X characters”, where the X is the number of characters in the tweet.

        +

        propeller.problems.valiant

        Possibly impossible to solve with genetic programming. Stems from the work of Leslie Valiant and involves determining the parity of an unknown subsequence of a larger sequence of bits.

        -

        propeller.push.instructions.bool

        Public variables and functions:

          propeller.push.instructions.character

          Public variables and functions:

            propeller.push.instructions.code

            Public variables and functions:

              propeller.push.instructions.string

              Public variables and functions:

                propeller.session

                Public variables and functions:

                  propeller.tools.calculus

                  Public variables and functions:

                  propeller.push.instructions.bool

                  Public variables and functions:

                    propeller.push.instructions.character

                    Push instructions for CHARs.

                    +

                    Public variables and functions:

                      propeller.push.instructions.code

                      Push instructions for code.

                      +

                      Public variables and functions:

                        propeller.push.instructions.input-output

                        Push instructions for input and output.

                        +

                        Public variables and functions:

                        propeller.push.instructions.string

                        Public variables and functions:

                          propeller.push.instructions.vector

                          Vector instructions for all vector element subtypes: BOOLEAN, FLOAT, INTEGER, and STRING.

                          +

                          propeller.push.limits

                          Values used by the Push instructions to keep the stack sizes within reasonable limits and values used by the Push instructions to keep computed values within reasonable size limits.

                          +

                          propeller.selection

                          Propeller includes many kinds of genetic operators to select parents within the population such as tournament selection, lexicase selection, and epsilon lexicase selection.

                          +

                          propeller.session

                          The “session” namespace is for trying things out interactively. For example, you can use it to test a new Push instruction by running a program that uses it and seeing the result. You might just want to do this interactively in the REPL, but the session file makes it a little easier since it already requires most of the namespaces you’ll want to refer to.

                          +

                          Public variables and functions:

                            propeller.simplification

                            To use Propeller’s auto-simplification system, simply include the following four command line arguments when running a problem:

                            +

                            propeller.tools.calculus

                            Public variables and functions:

                            propeller.variation

                            Propeller includes many kinds of genetic operators to create variation within the population. You can specify the rate of the variation genetic operators with the :variation map.

                            \ No newline at end of file diff --git a/docs/propeller.core.html b/docs/propeller.core.html index 5d2ad5a..5b80353 100644 --- a/docs/propeller.core.html +++ b/docs/propeller.core.html @@ -1,4 +1,4 @@ -propeller.core documentation

                            propeller.core

                            -main

                            (-main & _)

                            Not intended to be run; just print a message.

                            +propeller.core documentation

                            propeller.core

                            -main

                            (-main & _)

                            Not intended to be run; just print a message.

                            \ No newline at end of file diff --git a/docs/propeller.genome.html b/docs/propeller.genome.html index 839a4a8..01ae1c1 100644 --- a/docs/propeller.genome.html +++ b/docs/propeller.genome.html @@ -1,5 +1,6 @@ -propeller.genome documentation

                            propeller.genome

                            make-random-plushy

                            (make-random-plushy instructions max-initial-plushy-size)

                            Creates and returns a new plushy made of random instructions and of a maximum size of max-initial-plushy-size.

                            +propeller.genome documentation

                            propeller.genome

                            The genetic material in Propeller. A plushy is a list of Push instructions that represent a Push program. They hold the genetic material for an individual. In the initial population, we create random plushys.

                            +

                            make-random-plushy

                            (make-random-plushy instructions max-initial-plushy-size)

                            Creates and returns a new plushy made of random instructions and of a maximum size of max-initial-plushy-size.

                            plushy->push

                            (plushy->push plushy)(plushy->push plushy argmap)

                            Returns the Push program expressed by the given plushy representation.

                            \ No newline at end of file diff --git a/docs/propeller.gp.html b/docs/propeller.gp.html index 276d920..07b47a1 100644 --- a/docs/propeller.gp.html +++ b/docs/propeller.gp.html @@ -1,5 +1,5 @@ -propeller.gp documentation

                            propeller.gp

                            gp

                            (gp {:keys [population-size max-generations error-function instructions max-initial-plushy-size solution-error-threshold mapper], :or {solution-error-threshold 0.0, mapper pmap}, :as argmap})

                            Main GP loop.

                            +propeller.gp documentation

                            propeller.gp

                            gp

                            (gp {:keys [population-size max-generations error-function instructions max-initial-plushy-size solution-error-threshold mapper], :or {solution-error-threshold 0.0, mapper pmap}, :as argmap})

                            Main GP loop.

                            report

                            (report pop generation argmap)

                            Reports information each generation.

                            \ No newline at end of file diff --git a/docs/propeller.problems.PSB2.basement.html b/docs/propeller.problems.PSB2.basement.html index e5b8e76..6989da4 100644 --- a/docs/propeller.problems.PSB2.basement.html +++ b/docs/propeller.problems.PSB2.basement.html @@ -1,10 +1,11 @@ -propeller.problems.PSB2.basement documentation

                            propeller.problems.PSB2.basement

                            BASEMENT from PSB2

                            +propeller.problems.PSB2.basement documentation

                            propeller.problems.PSB2.basement

                            BASEMENT from PSB2

                            Given a vector of integers, return the first index such that the sum of all integers from the start of the vector to that index (inclusive) is negative.

                            Source: https://arxiv.org/pdf/2106.06086.pdf

                            -main

                            (-main & args)

                            Runs propel-gp, giving it a map of arguments.

                            error-function

                            (error-function argmap data individual)

                            Finds the behaviors and errors of an individual: Error is 0 if the value and the program’s selected behavior match, or 1 if they differ, or 1000000 if no behavior is produced. The behavior is here defined as the final top item on the INTEGER stack.

                            instructions

                            stack-specific instructions, input instructions, close, and constants

                            random-int

                            (random-int)

                            Random integer between -100 and 100 (from smallest)

                            -

                            train-and-test-data

                            \ No newline at end of file +

                            train-and-test-data

                            \ No newline at end of file diff --git a/docs/propeller.problems.PSB2.bouncing-balls.html b/docs/propeller.problems.PSB2.bouncing-balls.html index 569318b..557fc98 100644 --- a/docs/propeller.problems.PSB2.bouncing-balls.html +++ b/docs/propeller.problems.PSB2.bouncing-balls.html @@ -1,6 +1,6 @@ -propeller.problems.PSB2.bouncing-balls documentation

                            propeller.problems.PSB2.bouncing-balls

                            BOUNCING BALLS from PSB2

                            +propeller.problems.PSB2.bouncing-balls documentation

                            propeller.problems.PSB2.bouncing-balls

                            BOUNCING BALLS from PSB2

                            Given a starting height and a height after the first bounce of a dropped ball, calculate the bounciness index (height of first bounce / starting height). Then, given a number of bounces, use the bounciness index to calculate the total distance that the ball travels across those bounces.

                            Source: https://arxiv.org/pdf/2106.06086.pdf

                            -main

                            (-main & args)

                            Runs propel-gp, giving it a map of arguments.

                            @@ -8,4 +8,5 @@

                            instructions

                            stack-specific instructions, input instructions, close, and constants

                            map-vals-input

                            (map-vals-input i)

                            Returns all the input values of a map (specific helper method for bouncing-balls)

                            map-vals-output

                            (map-vals-output i)

                            Returns the output values of a map (specific helper method for bouncing-balls)

                            -

                            train-and-test-data

                            \ No newline at end of file +

                            train-and-test-data

                            \ No newline at end of file diff --git a/docs/propeller.problems.PSB2.bowling.html b/docs/propeller.problems.PSB2.bowling.html index ea658ee..fddeaf5 100644 --- a/docs/propeller.problems.PSB2.bowling.html +++ b/docs/propeller.problems.PSB2.bowling.html @@ -1,10 +1,11 @@ -propeller.problems.PSB2.bowling documentation

                            propeller.problems.PSB2.bowling

                            BOWLING from PSB2

                            +propeller.problems.PSB2.bowling documentation

                            propeller.problems.PSB2.bowling

                            BOWLING from PSB2

                            Given a string representing the individual bowls in a 10-frame round of 10 pin bowling, return the score of that round.

                            Source: https://arxiv.org/pdf/2106.06086.pdf

                            -main

                            (-main & args)

                            Runs propel-gp, giving it a map of arguments.

                            error-function

                            (error-function argmap data individual)

                            Finds the behaviors and errors of an individual: Error is 0 if the value and the program’s selected behavior match, or 1 if they differ, or 1000000 if no behavior is produced. The behavior is here defined as the final top item on the INTEGER stack.

                            instructions

                            stack-specific instructions, input instructions, close, and constants

                            random-int

                            (random-int)

                            Returns random integer between -100 and 100

                            -

                            train-and-test-data

                            \ No newline at end of file +

                            train-and-test-data

                            \ No newline at end of file diff --git a/docs/propeller.problems.PSB2.camel-case.html b/docs/propeller.problems.PSB2.camel-case.html index 5daf147..ce15ca4 100644 --- a/docs/propeller.problems.PSB2.camel-case.html +++ b/docs/propeller.problems.PSB2.camel-case.html @@ -1,6 +1,6 @@ -propeller.problems.PSB2.camel-case documentation

                            propeller.problems.PSB2.camel-case

                            CAMEL CASE from PSB2

                            +propeller.problems.PSB2.camel-case documentation

                            propeller.problems.PSB2.camel-case

                            CAMEL CASE from PSB2

                            Take a string in kebab-case and convert all of the words to camelCase. Each group of words to convert is delimited by “-”, and each grouping is separated by a space. For example: “camel-case example-test-string” → “camelCase exampleTestString”

                            Source: https://arxiv.org/pdf/2106.06086.pdf

                            -main

                            (-main & args)

                            Runs propel-gp, giving it a map of arguments.

                            @@ -9,5 +9,6 @@

                            instructions

                            stack-specific instructions, input instructions, close, and constants

                            random-char

                            (random-char)

                            Return visible character ERC

                            random-input

                            (random-input len)

                            Returns random string ERCs

                            -

                            train-and-test-data

                            word-generator

                            (word-generator)

                            Word generator for string ERC

                            +

                            train-and-test-data

                            word-generator

                            (word-generator)

                            Word generator for string ERC

                            \ No newline at end of file diff --git a/docs/propeller.problems.PSB2.dice-game.html b/docs/propeller.problems.PSB2.dice-game.html index ee8c0dc..b4b739e 100644 --- a/docs/propeller.problems.PSB2.dice-game.html +++ b/docs/propeller.problems.PSB2.dice-game.html @@ -1,6 +1,6 @@ -propeller.problems.PSB2.dice-game documentation

                            propeller.problems.PSB2.dice-game

                            DICE GAME from PSB2

                            +propeller.problems.PSB2.dice-game documentation

                            propeller.problems.PSB2.dice-game

                            DICE GAME from PSB2

                            Peter has an n sided die and Colin has an m sided die. If they both roll their dice at the same time, return the probability that Peter rolls strictly higher than Colin.

                            Source: https://arxiv.org/pdf/2106.06086.pdf

                            -main

                            (-main & args)

                            Runs propel-gp, giving it a map of arguments.

                            @@ -8,4 +8,5 @@

                            instructions

                            stack-specific instructions, input instructions, close, and constants

                            map-vals-input

                            (map-vals-input i)

                            Returns all the input values of a map

                            map-vals-output

                            (map-vals-output i)

                            Returns the output values of a map

                            -

                            train-and-test-data

                            \ No newline at end of file +

                            train-and-test-data

                            \ No newline at end of file diff --git a/docs/propeller.problems.PSB2.fizz-buzz.html b/docs/propeller.problems.PSB2.fizz-buzz.html index 3579ca6..256a169 100644 --- a/docs/propeller.problems.PSB2.fizz-buzz.html +++ b/docs/propeller.problems.PSB2.fizz-buzz.html @@ -1,8 +1,9 @@ -propeller.problems.PSB2.fizz-buzz documentation

                            propeller.problems.PSB2.fizz-buzz

                            FIZZ BUZZ from PSB2 Given an integer x, return “Fizz” if x is divisible by 3, “Buzz” if x is divisible by 5, “FizzBuzz” if x is divisible by 3 and 5, and a string version of x if none of the above hold.

                            +propeller.problems.PSB2.fizz-buzz documentation

                            propeller.problems.PSB2.fizz-buzz

                            FIZZ BUZZ from PSB2 Given an integer x, return “Fizz” if x is divisible by 3, “Buzz” if x is divisible by 5, “FizzBuzz” if x is divisible by 3 and 5, and a string version of x if none of the above hold.

                            Source: https://arxiv.org/pdf/2106.06086.pdf

                            -main

                            (-main & args)

                            Runs propel-gp, giving it a map of arguments.

                            error-function

                            (error-function argmap data individual)

                            Finds the behaviors and errors of an individual: Error is 0 if the value and the program’s selected behavior match, or 1 if they differ, or 1000000 if no behavior is produced. The behavior is here defined as the final top item on the STRING stack.

                            instructions

                            stack-specific instructions, input instructions, close, and constants

                            -

                            train-and-test-data

                            \ No newline at end of file +

                            train-and-test-data

                            \ No newline at end of file diff --git a/docs/propeller.problems.PSB2.fuel-cost.html b/docs/propeller.problems.PSB2.fuel-cost.html index 172094c..65bf2ed 100644 --- a/docs/propeller.problems.PSB2.fuel-cost.html +++ b/docs/propeller.problems.PSB2.fuel-cost.html @@ -1,10 +1,11 @@ -propeller.problems.PSB2.fuel-cost documentation

                            propeller.problems.PSB2.fuel-cost

                            FUEL COST from PSB2

                            +propeller.problems.PSB2.fuel-cost documentation

                            propeller.problems.PSB2.fuel-cost

                            FUEL COST from PSB2

                            Given a vector of positive integers, divide each by 3, round the result down to the nearest integer, and subtract 2. Return the sum of all of the new integers in the vector

                            Source: https://arxiv.org/pdf/2106.06086.pdf

                            -main

                            (-main & args)

                            Runs propel-gp, giving it a map of arguments.

                            error-function

                            (error-function argmap data individual)

                            Finds the behaviors and errors of an individual: Error is 0 if the value and the program’s selected behavior match, or 1 if they differ, or 1000000 if no behavior is produced. The behavior is here defined as the final top item on the INTEGER stack.

                            instructions

                            stack-specific instructions, input instructions, close, and constants

                            random-int

                            (random-int)

                            Random integer between -100 and 100

                            -

                            train-and-test-data

                            \ No newline at end of file +

                            train-and-test-data

                            \ No newline at end of file diff --git a/docs/propeller.problems.PSB2.gcd.html b/docs/propeller.problems.PSB2.gcd.html index 2e17864..e9fc928 100644 --- a/docs/propeller.problems.PSB2.gcd.html +++ b/docs/propeller.problems.PSB2.gcd.html @@ -1,6 +1,6 @@ -propeller.problems.PSB2.gcd documentation

                            propeller.problems.PSB2.gcd

                            GCD GREATEST COMMON DIVISOR from PSB2

                            +propeller.problems.PSB2.gcd documentation

                            propeller.problems.PSB2.gcd

                            GCD GREATEST COMMON DIVISOR from PSB2

                            Given two integers, return the largest integer that divides each of the integers evenly

                            Source: https://arxiv.org/pdf/2106.06086.pdf

                            -main

                            (-main & args)

                            Runs propel-gp, giving it a map of arguments.

                            @@ -9,4 +9,5 @@

                            map-vals-input

                            (map-vals-input i)

                            Returns all the input values of a map

                            map-vals-output

                            (map-vals-output i)

                            Returns the output values of a map

                            random-int

                            (random-int)

                            Random integer between -100 and 100

                            -

                            train-and-test-data

                            \ No newline at end of file +

                            train-and-test-data

                            \ No newline at end of file diff --git a/docs/propeller.problems.PSB2.luhn.html b/docs/propeller.problems.PSB2.luhn.html index e63efc6..3afcc1a 100644 --- a/docs/propeller.problems.PSB2.luhn.html +++ b/docs/propeller.problems.PSB2.luhn.html @@ -1,10 +1,11 @@ -propeller.problems.PSB2.luhn documentation

                            propeller.problems.PSB2.luhn

                            LUHN from PSB2

                            +propeller.problems.PSB2.luhn documentation

                            propeller.problems.PSB2.luhn

                            LUHN from PSB2

                            Given a vector of 16 digits, implement Luhn’s algorithm to verify a credit card number, such that it follows the following rules: double every other digit starting with the second digit. If any of the results are over 9, subtract 9 from them. Return the sum of all of the new digits.

                            Source: https://arxiv.org/pdf/2106.06086.pdf

                            -main

                            (-main & args)

                            Runs propel-gp, giving it a map of arguments.

                            error-function

                            (error-function argmap data individual)

                            Finds the behaviors and errors of an individual: Error is 0 if the value and the program’s selected behavior match, or 1 if they differ, or 1000000 if no behavior is produced. The behavior is here defined as the final top item on the INTEGER stack.

                            instructions

                            stack-specific instructions, input instructions, close, and constants

                            random-int

                            (random-int)

                            Random integer between -100 and 100

                            -

                            train-and-test-data

                            \ No newline at end of file +

                            train-and-test-data

                            \ No newline at end of file diff --git a/docs/propeller.problems.PSB2.middle-character.html b/docs/propeller.problems.PSB2.middle-character.html index d2cb250..19b9c1f 100644 --- a/docs/propeller.problems.PSB2.middle-character.html +++ b/docs/propeller.problems.PSB2.middle-character.html @@ -1,10 +1,11 @@ -propeller.problems.PSB2.middle-character documentation

                            propeller.problems.PSB2.middle-character

                            MIDDLE CHARACTER from PSB2

                            +propeller.problems.PSB2.middle-character documentation

                            propeller.problems.PSB2.middle-character

                            MIDDLE CHARACTER from PSB2

                            Given a string, return the middle character as a string if it is odd length; return the two middle characters as a string if it is even length.

                            Source: https://arxiv.org/pdf/2106.06086.pdf

                            -main

                            (-main & args)

                            Runs propel-gp, giving it a map of arguments.

                            error-function

                            (error-function argmap data individual)

                            Finds the behaviors and errors of an individual: Error is 0 if the value and the program’s selected behavior match, or 1 if they differ, or 1000000 if no behavior is produced. The behavior is here defined as the final top item on the STRING stack.

                            instructions

                            stack-specific instructions, input instructions, close, and constants

                            random-int

                            (random-int)

                            Random integer between -100 and 100

                            -

                            train-and-test-data

                            \ No newline at end of file +

                            train-and-test-data

                            \ No newline at end of file diff --git a/docs/propeller.problems.PSB2.paired-digits.html b/docs/propeller.problems.PSB2.paired-digits.html index a78a2a0..a19161f 100644 --- a/docs/propeller.problems.PSB2.paired-digits.html +++ b/docs/propeller.problems.PSB2.paired-digits.html @@ -1,6 +1,6 @@ -propeller.problems.PSB2.paired-digits documentation

                            propeller.problems.PSB2.paired-digits

                            PAIRED DIGITS from PSB2

                            +propeller.problems.PSB2.paired-digits documentation

                            propeller.problems.PSB2.paired-digits

                            PAIRED DIGITS from PSB2

                            Given a string of digits, return the sum of the digits whose following digit is the same.

                            Source: https://arxiv.org/pdf/2106.06086.pdf

                            -main

                            (-main & args)

                            Runs propel-gp, giving it a map of arguments.

                            @@ -8,4 +8,5 @@

                            instructions

                            stack-specific instructions, input instructions, close, and constants

                            random-char

                            (random-char)

                            Random character of 0-9

                            random-int

                            (random-int)

                            Random integer between -100 and 100

                            -

                            train-and-test-data

                            \ No newline at end of file +

                            train-and-test-data

                            \ No newline at end of file diff --git a/docs/propeller.problems.PSB2.shopping-list.html b/docs/propeller.problems.PSB2.shopping-list.html index 82e08db..8c81bcd 100644 --- a/docs/propeller.problems.PSB2.shopping-list.html +++ b/docs/propeller.problems.PSB2.shopping-list.html @@ -1,6 +1,6 @@ -propeller.problems.PSB2.shopping-list documentation

                            propeller.problems.PSB2.shopping-list

                            DICE GAME from PSB2

                            +propeller.problems.PSB2.shopping-list documentation

                            propeller.problems.PSB2.shopping-list

                            DICE GAME from PSB2

                            Peter has an n sided die and Colin has an m sided die. If they both roll their dice at the same time, return the probability that Peter rolls strictly higher than Colin.

                            Source: https://arxiv.org/pdf/2106.06086.pdf

                            -main

                            (-main & args)

                            Runs propel-gp, giving it a map of arguments.

                            @@ -9,4 +9,5 @@

                            map-vals-input

                            (map-vals-input i)

                            Returns all the input values of a map

                            map-vals-output

                            (map-vals-output i)

                            Returns the output values of a map

                            random-float

                            (random-float)

                            Random float between -100 and 100

                            -

                            train-and-test-data

                            \ No newline at end of file +

                            train-and-test-data

                            \ No newline at end of file diff --git a/docs/propeller.problems.PSB2.snow-day.html b/docs/propeller.problems.PSB2.snow-day.html index 636ff29..fe725bf 100644 --- a/docs/propeller.problems.PSB2.snow-day.html +++ b/docs/propeller.problems.PSB2.snow-day.html @@ -1,6 +1,6 @@ -propeller.problems.PSB2.snow-day documentation

                            propeller.problems.PSB2.snow-day

                            SNOW DAY from PSB2

                            +propeller.problems.PSB2.snow-day documentation

                            propeller.problems.PSB2.snow-day

                            SNOW DAY from PSB2

                            Given an integer representing a number of hours and 3 floats representing how much snow is on the ground, the rate of snow fall, and the proportion of snow melting per hour, return the amount of snow on the ground after the amount of hours given. Each hour is considered a discrete event of adding snow and then melting, not a continuous process.

                            Source: https://arxiv.org/pdf/2106.06086.pdf

                            -main

                            (-main & args)

                            Runs propel-gp, giving it a map of arguments.

                            @@ -8,4 +8,5 @@

                            instructions

                            stack-specific instructions, input instructions, close, and constants

                            map-vals-input

                            (map-vals-input i)

                            Returns all the input values of a map

                            map-vals-output

                            (map-vals-output i)

                            Returns the output values of a map

                            -

                            train-and-test-data

                            \ No newline at end of file +

                            train-and-test-data

                            \ No newline at end of file diff --git a/docs/propeller.problems.PSB2.solve-boolean.html b/docs/propeller.problems.PSB2.solve-boolean.html index db89f1c..aef5199 100644 --- a/docs/propeller.problems.PSB2.solve-boolean.html +++ b/docs/propeller.problems.PSB2.solve-boolean.html @@ -1,9 +1,10 @@ -propeller.problems.PSB2.solve-boolean documentation

                            propeller.problems.PSB2.solve-boolean

                            SOLVE BOOLEAN from PSB2

                            +propeller.problems.PSB2.solve-boolean documentation

                            propeller.problems.PSB2.solve-boolean

                            SOLVE BOOLEAN from PSB2

                            Given a string representing a Boolean expression consisting of T, F, |, and &, evaluate it and return the resulting Boolean.

                            Source: https://arxiv.org/pdf/2106.06086.pdf

                            -main

                            (-main & args)

                            Runs propel-gp, giving it a map of arguments.

                            error-function

                            (error-function argmap data individual)

                            Finds the behaviors and errors of an individual: Error is 0 if the value and the program’s selected behavior match, or 1 if they differ, or 1000000 if no behavior is produced. The behavior is here defined as the final top item on the BOOLEAN stack.

                            instructions

                            stack-specific instructions, input instructions, close, and constants

                            -

                            train-and-test-data

                            \ No newline at end of file +

                            train-and-test-data

                            \ No newline at end of file diff --git a/docs/propeller.problems.PSB2.spin-words.html b/docs/propeller.problems.PSB2.spin-words.html index 52b4b7e..d25b7f3 100644 --- a/docs/propeller.problems.PSB2.spin-words.html +++ b/docs/propeller.problems.PSB2.spin-words.html @@ -1,6 +1,6 @@ -propeller.problems.PSB2.spin-words documentation

                            propeller.problems.PSB2.spin-words

                            SPIN WORDS from PSB2

                            +propeller.problems.PSB2.spin-words documentation

                            propeller.problems.PSB2.spin-words

                            SPIN WORDS from PSB2

                            Given a string of one or more words (separated by spaces), reverse all of the words that are five or more letters long and return the resulting string.

                            Source: https://arxiv.org/pdf/2106.06086.pdf

                            -main

                            (-main & args)

                            Runs propel-gp, giving it a map of arguments.

                            @@ -8,5 +8,6 @@

                            instructions

                            stack-specific instructions, input instructions, close, and constants

                            random-char

                            (random-char)

                            Generates random character

                            random-input

                            (random-input len)

                            Makes a Spin Words input of length len, which is just a string of words, where the words that are length 5 or greater are reversed

                            -

                            train-and-test-data

                            word-generator

                            (word-generator)

                            train-and-test-data

                            word-generator

                            (word-generator)
                            \ No newline at end of file diff --git a/docs/propeller.problems.PSB2.square-digits.html b/docs/propeller.problems.PSB2.square-digits.html index ec1d724..0fa9d37 100644 --- a/docs/propeller.problems.PSB2.square-digits.html +++ b/docs/propeller.problems.PSB2.square-digits.html @@ -1,10 +1,11 @@ -propeller.problems.PSB2.square-digits documentation

                            propeller.problems.PSB2.square-digits

                            SQUARE DIGITS from PSB2

                            +propeller.problems.PSB2.square-digits documentation

                            propeller.problems.PSB2.square-digits

                            SQUARE DIGITS from PSB2

                            Given a positive integer, square each digit and concatenate the squares into a returned string.

                            Source: https://arxiv.org/pdf/2106.06086.pdf

                            -main

                            (-main & args)

                            Runs propel-gp, giving it a map of arguments.

                            error-function

                            (error-function argmap data individual)

                            Finds the behaviors and errors of an individual: Error is 0 if the value and the program’s selected behavior match, or 1 if they differ, or 1000000 if no behavior is produced. The behavior is here defined as the final top item on the STRING stack.

                            instructions

                            stack-specific instructions, input instructions, close, and constants

                            random-int

                            (random-int)

                            Random integer between -100 and 100

                            -

                            train-and-test-data

                            \ No newline at end of file +

                            train-and-test-data

                            \ No newline at end of file diff --git a/docs/propeller.problems.PSB2.substitution-cipher.html b/docs/propeller.problems.PSB2.substitution-cipher.html index ff60bd3..6e115b1 100644 --- a/docs/propeller.problems.PSB2.substitution-cipher.html +++ b/docs/propeller.problems.PSB2.substitution-cipher.html @@ -1,10 +1,12 @@ -propeller.problems.PSB2.substitution-cipher documentation

                            propeller.problems.PSB2.substitution-cipher

                            =========== PROBLEM DESCRIPTION ========================= SUBSTITUTION CIPHER from PSB2 This problem gives 3 strings. The first two represent a cipher, mapping each character in one string to the one at the same index in the other string. The program must apply this cipher to the third string and return the deciphered message.

                            -

                            Source: https://arxiv.org/pdf/2106.06086.pdf

                            +propeller.problems.PSB2.substitution-cipher documentation

                            propeller.problems.PSB2.substitution-cipher

                            SUBSTITUTION CIPHER from PSB2

                            +

                            This problem gives 3 strings. The first two represent a cipher, mapping each character in one string to the one at the same index in the other string. The program must apply this cipher to the third string and return the deciphered message.

                            +

                            Source: https://arxiv.org/pdf/2106.06086.pdf

                            -main

                            (-main & args)

                            Runs propel-gp, giving it a map of arguments.

                            error-function

                            (error-function argmap data individual)

                            Finds the behaviors and errors of an individual: Error is 0 if the value and the program’s selected behavior match, or 1 if they differ, or 1000000 if no behavior is produced. The behavior is here defined as the final top item on the STRING stack.

                            instructions

                            stack-specific instructions, input instructions, close, and constants

                            map-vals-input

                            (map-vals-input i)

                            Returns all the input values of a map

                            map-vals-output

                            (map-vals-output i)

                            Returns the output values of a map

                            -

                            train-and-test-data

                            \ No newline at end of file +

                            train-and-test-data

                            \ No newline at end of file diff --git a/docs/propeller.problems.PSB2.twitter.html b/docs/propeller.problems.PSB2.twitter.html index 516b12e..48c4af8 100644 --- a/docs/propeller.problems.PSB2.twitter.html +++ b/docs/propeller.problems.PSB2.twitter.html @@ -1,9 +1,10 @@ -propeller.problems.PSB2.twitter documentation

                            propeller.problems.PSB2.twitter

                            =========== PROBLEM DESCRIPTION ============================= TWITTER from PSB2 Given a string representing a tweet, validate whether the tweet meets Twitter’s original character requirements. If the tweet has more than 140 characters, return the string “Too many characters”. If the tweet is empty, return the string “You didn’t type anything”. Otherwise, return “Your tweet has X characters”, where the X is the number of characters in the tweet.

                            -

                            Source: https://arxiv.org/pdf/2106.06086.pdf

                            +propeller.problems.PSB2.twitter documentation

                            propeller.problems.PSB2.twitter

                            TWITTER from PSB2 Given a string representing a tweet, validate whether the tweet meets Twitter’s original character requirements. If the tweet has more than 140 characters, return the string “Too many characters”. If the tweet is empty, return the string “You didn’t type anything”. Otherwise, return “Your tweet has X characters”, where the X is the number of characters in the tweet.

                            +

                            Source: https://arxiv.org/pdf/2106.06086.pdf

                            -main

                            (-main & args)

                            Runs propel-gp, giving it a map of arguments.

                            error-function

                            (error-function argmap data individual)

                            Finds the behaviors and errors of an individual: Error is 0 if the value and the program’s selected behavior match, or 1 if they differ, or 1000000 if no behavior is produced. The behavior is here defined as the final top item on the STRING stack.

                            instructions

                            stack-specific instructions, input instructions, close, and constants

                            random-int

                            (random-int)

                            Random integer between -100 and 100

                            -

                            train-and-test-data

                            \ No newline at end of file +

                            train-and-test-data

                            \ No newline at end of file diff --git a/docs/propeller.problems.simple-regression.html b/docs/propeller.problems.simple-regression.html index 85195e7..6b7e287 100644 --- a/docs/propeller.problems.simple-regression.html +++ b/docs/propeller.problems.simple-regression.html @@ -1,7 +1,10 @@ -propeller.problems.simple-regression documentation

                            propeller.problems.simple-regression

                            =========== PROBLEM DESCRIPTION ============================= Simple Regression: Given inputs and outputs, find the target function.

                            +propeller.problems.simple-regression documentation

                            propeller.problems.simple-regression

                            Simple Regression:

                            +

                            Given inputs and outputs, find the target function.

                            -main

                            (-main & args)

                            Runs propel-gp, giving it a map of arguments.

                            error-function

                            (error-function argmap data individual)

                            Finds the behaviors and errors of an individual. The error is the absolute deviation between the target output value and the program’s selected behavior, or 1000000 if no behavior is produced. The behavior is here defined as the final top item on the INTEGER stack.

                            instructions

                            stack-specific instructions, input instructions, close, and constants

                            -

                            train-and-test-data

                            \ No newline at end of file +

                            train-and-test-data

                            Training data: Inputs and outputs with -10 <= x < 11

                            +

                            Test data: Inputs and outputs of -20 <= x < -10 and 11 <= x < 21

                            +
                            \ No newline at end of file diff --git a/docs/propeller.problems.software.fizz-buzz.html b/docs/propeller.problems.software.fizz-buzz.html index bc309aa..9c01b6f 100644 --- a/docs/propeller.problems.software.fizz-buzz.html +++ b/docs/propeller.problems.software.fizz-buzz.html @@ -1,3 +1,3 @@ -propeller.problems.software.fizz-buzz documentation

                            propeller.problems.software.fizz-buzz

                            train-and-test

                            \ No newline at end of file +propeller.problems.software.fizz-buzz documentation

                            propeller.problems.software.fizz-buzz

                            train-and-test

                            \ No newline at end of file diff --git a/docs/propeller.problems.software.number-io.html b/docs/propeller.problems.software.number-io.html index 839773c..4942151 100644 --- a/docs/propeller.problems.software.number-io.html +++ b/docs/propeller.problems.software.number-io.html @@ -1,4 +1,4 @@ -propeller.problems.software.number-io documentation

                            propeller.problems.software.number-io

                            -main

                            (-main & args)

                            Runs propel-gp, giving it a map of arguments.

                            +propeller.problems.software.number-io documentation

                            propeller.problems.software.number-io

                            -main

                            (-main & args)

                            Runs propel-gp, giving it a map of arguments.

                            error-function

                            (error-function argmap data individual)

                            instructions

                            random-float

                            (random-float)

                            random-int

                            (random-int)

                            train-and-test-data

                            \ No newline at end of file diff --git a/docs/propeller.problems.software.smallest.html b/docs/propeller.problems.software.smallest.html index ebaf36e..336a2f6 100644 --- a/docs/propeller.problems.software.smallest.html +++ b/docs/propeller.problems.software.smallest.html @@ -1,4 +1,4 @@ -propeller.problems.software.smallest documentation

                            propeller.problems.software.smallest

                            -main

                            (-main & args)

                            Runs propel-gp, giving it a map of arguments.

                            +propeller.problems.software.smallest documentation

                            propeller.problems.software.smallest

                            -main

                            (-main & args)

                            Runs propel-gp, giving it a map of arguments.

                            error-function

                            (error-function argmap data individual)

                            instructions

                            random-int

                            (random-int)

                            train-and-test-data

                            \ No newline at end of file diff --git a/docs/propeller.problems.string-classification.html b/docs/propeller.problems.string-classification.html index 57b1240..e39ba1a 100644 --- a/docs/propeller.problems.string-classification.html +++ b/docs/propeller.problems.string-classification.html @@ -1,7 +1,10 @@ -propeller.problems.string-classification documentation

                            propeller.problems.string-classification

                            =========== PROBLEM DESCRIPTION ============================= String Classification: Given a string, return true if it contains A, C, G, and T. Else return false.

                            +propeller.problems.string-classification documentation

                            propeller.problems.string-classification

                            String Classification:

                            +

                            Given a string, return true if it contains A, C, G, and T. Else return false.

                            -main

                            (-main & args)

                            Runs propel-gp, giving it a map of arguments.

                            error-function

                            (error-function argmap data individual)

                            Finds the behaviors and errors of an individual: Error is 0 if the value and the program’s selected behavior match, or 1 if they differ, or 1000000 if no behavior is produced. The behavior is here defined as the final top item on the BOOLEAN stack.

                            instructions

                            stack-specific instructions, input instructions, close, and constants

                            -

                            train-and-test-data

                            \ No newline at end of file +

                            train-and-test-data

                            Training data: “GCG” “GACAG” “AGAAG” “CCCA” “GATTACA” “TAGG” “GACT” with associated boolean values based on problem definition.

                            +

                            Test data: “GCGT” “GACTTAG” “AGTAAG” “TCCTCA” “GAACA” “AGG” “GAC” with associated boolean values based on problem definition.

                            +
                            \ No newline at end of file diff --git a/docs/propeller.problems.valiant.html b/docs/propeller.problems.valiant.html index d9a380c..f462cb8 100644 --- a/docs/propeller.problems.valiant.html +++ b/docs/propeller.problems.valiant.html @@ -1,5 +1,5 @@ -propeller.problems.valiant documentation

                            propeller.problems.valiant

                            Possibly impossible to solve with genetic programming. Stems from the work of Leslie Valiant and involves determining the parity of an unknown subsequence of a larger sequence of bits.

                            +propeller.problems.valiant documentation

                            propeller.problems.valiant

                            Possibly impossible to solve with genetic programming. Stems from the work of Leslie Valiant and involves determining the parity of an unknown subsequence of a larger sequence of bits.

                            -main

                            (-main & args)

                            Runs propel-gp, giving it a map of arguments.

                            error-function

                            (error-function argmap data individual)

                            instructions

                            num-inputs

                            num-test

                            num-train

                            num-vars

                            train-and-test-data

                            \ No newline at end of file diff --git a/docs/propeller.push.instructions.bool.html b/docs/propeller.push.instructions.bool.html index cbbe648..a93f52e 100644 --- a/docs/propeller.push.instructions.bool.html +++ b/docs/propeller.push.instructions.bool.html @@ -1,3 +1,3 @@ -propeller.push.instructions.bool documentation

                            propeller.push.instructions.bool

                            \ No newline at end of file +propeller.push.instructions.bool documentation

                            propeller.push.instructions.bool

                            \ No newline at end of file diff --git a/docs/propeller.push.instructions.character.html b/docs/propeller.push.instructions.character.html index 5b215ef..bef784e 100644 --- a/docs/propeller.push.instructions.character.html +++ b/docs/propeller.push.instructions.character.html @@ -1,3 +1,4 @@ -propeller.push.instructions.character documentation

                            propeller.push.instructions.character

                            \ No newline at end of file +propeller.push.instructions.character documentation

                            propeller.push.instructions.character

                            Push instructions for CHARs.

                            +
                            \ No newline at end of file diff --git a/docs/propeller.push.instructions.code.html b/docs/propeller.push.instructions.code.html index 4bb8481..2599120 100644 --- a/docs/propeller.push.instructions.code.html +++ b/docs/propeller.push.instructions.code.html @@ -1,3 +1,4 @@ -propeller.push.instructions.code documentation

                            propeller.push.instructions.code

                            \ No newline at end of file +propeller.push.instructions.code documentation

                            propeller.push.instructions.code

                            Push instructions for code.

                            +
                            \ No newline at end of file diff --git a/docs/propeller.push.instructions.html b/docs/propeller.push.instructions.html index 5374258..9e9dfad 100644 --- a/docs/propeller.push.instructions.html +++ b/docs/propeller.push.instructions.html @@ -1,11 +1,13 @@ -propeller.push.instructions documentation

                            propeller.push.instructions

                            cls->type

                            def-instruction

                            (def-instruction instruction function)

                            Defines a Push instruction as a keyword-function pair, and adds it to the instruction table

                            +propeller.push.instructions documentation

                            propeller.push.instructions

                            cls->type

                            def-instruction

                            (def-instruction instruction function)

                            Defines a Push instruction as a keyword-function pair, and adds it to the instruction table

                            generate-instructions

                            (generate-instructions stacks functions)

                            Given a sequence of stacks, e.g. :float :integer, and a sequence of suffix function strings, e.g. _add, _mult, _eq, automates the generation of all possible combination instructions, which here would be :float_add, :float_mult, :float_eq, :integer_add, :integer_mult, and :integer_eq, also transferring and updating the generic function’s stack-type metadata. For some vector instructions, the placeholder :elem will be replaced with the stack of the corresponding element type (e.g. for :vector_integer, with :integer)

                            get-literal-type

                            (get-literal-type data)

                            If a piece of data is a literal, return its corresponding stack name e.g. :integer. Otherwise, return nil.

                            get-stack-instructions

                            (get-stack-instructions stacks)

                            Given a set of stacks, returns all instructions that operate on those stacks only. Won’t include random instructions unless :random is in the set as well

                            get-vector-literal-type

                            (get-vector-literal-type vector-stack)

                            Returns the literal stack corresponding to some vector stack.

                            -

                            instruction-table

                            make-instruction

                            (make-instruction state function arg-stacks return-stack)

                            A utility function for making Push instructions. Takes a state, a function to apply to the args, the stacks to take the args from, and the stack to return the result to. Applies the function to the args (popped from the given stacks), and pushes the result onto the return-stack.

                            +

                            instruction-table

                            PushGP instructions are represented as keywords, and stored in an atom. They can be either constant literals or functions that take and return a Push state

                            +

                            make-instruction

                            (make-instruction state function arg-stacks return-stack)

                            A utility function for making Push instructions. Takes a state, a function to apply to the args, the stacks to take the args from, and the stack to return the result to. Applies the function to the args (popped from the given stacks), and pushes the result onto the return-stack.

                            If the function returns :ignore-instruction, then we will return the initial state unchanged. This allows instructions to fail gracefully without consuming stack values.

                            make-metadata

                            (make-metadata function stack)

                            Given a generic function, e.g. _dup, and a stack type to instantiate it for, e.g. :char, returns the appropriate stack metadata for that function instance

                            -

                            opens

                            \ No newline at end of file +

                            opens

                            Number of blocks opened by instructions. The default is 0.

                            +
                            \ No newline at end of file diff --git a/docs/propeller.push.instructions.input-output.html b/docs/propeller.push.instructions.input-output.html index 845a484..3332791 100644 --- a/docs/propeller.push.instructions.input-output.html +++ b/docs/propeller.push.instructions.input-output.html @@ -1,3 +1,4 @@ -propeller.push.instructions.input-output documentation

                            propeller.push.instructions.input-output

                            _print

                            handle-input-instruction

                            (handle-input-instruction state instruction)
                            \ No newline at end of file +propeller.push.instructions.input-output documentation

                            propeller.push.instructions.input-output

                            Push instructions for input and output.

                            +

                            _print

                            handle-input-instruction

                            (handle-input-instruction state instruction)
                            \ No newline at end of file diff --git a/docs/propeller.push.instructions.numeric.html b/docs/propeller.push.instructions.numeric.html index 747e7a8..e1b5a73 100644 --- a/docs/propeller.push.instructions.numeric.html +++ b/docs/propeller.push.instructions.numeric.html @@ -1,3 +1,3 @@ -propeller.push.instructions.numeric documentation

                            propeller.push.instructions.numeric

                            _add

                            _dec

                            _from_boolean

                            _from_char

                            _from_string

                            _gt

                            _gte

                            _inc

                            _lt

                            _lte

                            _max

                            _min

                            _mod

                            _mult

                            _quot

                            _subtract

                            \ No newline at end of file +propeller.push.instructions.numeric documentation

                            propeller.push.instructions.numeric

                            _add

                            _dec

                            _from_boolean

                            _from_char

                            _from_string

                            _gt

                            _gte

                            _inc

                            _lt

                            _lte

                            _max

                            _min

                            _mod

                            _mult

                            _quot

                            _subtract

                            \ No newline at end of file diff --git a/docs/propeller.push.instructions.polymorphic.html b/docs/propeller.push.instructions.polymorphic.html index b2e28f4..4c776cf 100644 --- a/docs/propeller.push.instructions.polymorphic.html +++ b/docs/propeller.push.instructions.polymorphic.html @@ -1,3 +1,3 @@ -propeller.push.instructions.polymorphic documentation

                            propeller.push.instructions.polymorphic

                            _deep_dup

                            _dup

                            _dup_items

                            _dup_times

                            _empty

                            _eq

                            _flush

                            _pop

                            _rot

                            _shove

                            _stack_depth

                            _swap

                            _yank

                            _yank_dup

                            \ No newline at end of file +propeller.push.instructions.polymorphic documentation

                            propeller.push.instructions.polymorphic

                            _deep_dup

                            _dup

                            _dup_items

                            _dup_times

                            _empty

                            _eq

                            _flush

                            _pop

                            _rot

                            _shove

                            _stack_depth

                            _swap

                            _yank

                            _yank_dup

                            \ No newline at end of file diff --git a/docs/propeller.push.instructions.string.html b/docs/propeller.push.instructions.string.html index 06b1f51..6f378c7 100644 --- a/docs/propeller.push.instructions.string.html +++ b/docs/propeller.push.instructions.string.html @@ -1,3 +1,3 @@ -propeller.push.instructions.string documentation

                            propeller.push.instructions.string

                            \ No newline at end of file +propeller.push.instructions.string documentation

                            propeller.push.instructions.string

                            \ No newline at end of file diff --git a/docs/propeller.push.instructions.vector.html b/docs/propeller.push.instructions.vector.html index 45922d4..0d9612c 100644 --- a/docs/propeller.push.instructions.vector.html +++ b/docs/propeller.push.instructions.vector.html @@ -1,3 +1,4 @@ -propeller.push.instructions.vector documentation

                            propeller.push.instructions.vector

                            _butlast

                            _concat

                            _conj

                            _contains

                            _emptyvector

                            _first

                            _indexof

                            _iterate

                            _last

                            _length

                            _nth

                            _occurrencesof

                            _pushall

                            _remove

                            _replace

                            _replacefirst

                            _rest

                            _reverse

                            _set

                            _subvec

                            _take

                            \ No newline at end of file +propeller.push.instructions.vector documentation

                            propeller.push.instructions.vector

                            Vector instructions for all vector element subtypes: BOOLEAN, FLOAT, INTEGER, and STRING.

                            +

                            _butlast

                            _concat

                            _conj

                            _contains

                            _emptyvector

                            _first

                            _indexof

                            _iterate

                            _last

                            _length

                            _nth

                            _occurrencesof

                            _pushall

                            _remove

                            _replace

                            _replacefirst

                            _rest

                            _reverse

                            _set

                            _subvec

                            _take

                            \ No newline at end of file diff --git a/docs/propeller.push.interpreter.html b/docs/propeller.push.interpreter.html index 9331c89..b4724dc 100644 --- a/docs/propeller.push.interpreter.html +++ b/docs/propeller.push.interpreter.html @@ -1,5 +1,5 @@ -propeller.push.interpreter documentation

                            propeller.push.interpreter

                            interpret-one-step

                            (interpret-one-step state)

                            Takes a Push state and executes the next instruction on the exec stack.

                            +propeller.push.interpreter documentation

                            propeller.push.interpreter

                            interpret-one-step

                            (interpret-one-step state)

                            Takes a Push state and executes the next instruction on the exec stack.

                            interpret-program

                            (interpret-program program start-state step-limit)

                            Runs the given problem starting with the stacks in start-state. If the start-state includes the key :keep-history with a truthy value, then the returned state will include the key :history with a value that is a vector containing all states prior to the final state.

                            \ No newline at end of file diff --git a/docs/propeller.push.limits.html b/docs/propeller.push.limits.html index ed689f4..11a9b51 100644 --- a/docs/propeller.push.limits.html +++ b/docs/propeller.push.limits.html @@ -1,3 +1,15 @@ -propeller.push.limits documentation

                            propeller.push.limits

                            limit-code

                            (limit-code code)

                            limit-number

                            (limit-number n)

                            limit-string

                            (limit-string s)

                            limit-vector

                            (limit-vector v)

                            max-code-depth

                            dynamic

                            max-code-points

                            dynamic

                            max-number-magnitude

                            max-stack-items

                            max-string-length

                            max-vector-length

                            min-number-magnitude

                            \ No newline at end of file +propeller.push.limits documentation

                            propeller.push.limits

                            Values used by the Push instructions to keep the stack sizes within reasonable limits and values used by the Push instructions to keep computed values within reasonable size limits.

                            +

                            limit-code

                            (limit-code code)

                            Limits code to max-code-points and max-code-depth.

                            +

                            limit-number

                            (limit-number n)

                            Returns a version of the number n that is within reasonable size bounds.

                            +

                            limit-string

                            (limit-string s)

                            Limits string length to max-string-length.

                            +

                            limit-vector

                            (limit-vector v)

                            Limits vector length to max-vector-length.

                            +

                            max-code-depth

                            dynamic

                            Used to ensure that the depth of nesting for Push expressions doesn’t get too deep. Set as dynamic for testing purposes.

                            +

                            max-code-points

                            dynamic

                            Used to ensure that total code points don’t get too large. Set as dynamic for testing purposes.

                            +

                            max-number-magnitude

                            Used as the maximum magnitude of any integer/float.

                            +

                            max-stack-items

                            Limits the number of items that can be duplicated onto a stack at once. We might want to extend this to limit all the different that things may be placed on a stack.

                            +

                            max-string-length

                            Used to ensure that strings don’t get too large.

                            +

                            max-vector-length

                            Used to ensure that vectors don’t get too large.

                            +

                            min-number-magnitude

                            Used as the minimum magnitude of any float.

                            +
                            \ No newline at end of file diff --git a/docs/propeller.push.state.html b/docs/propeller.push.state.html index 9c44211..bab20b8 100644 --- a/docs/propeller.push.state.html +++ b/docs/propeller.push.state.html @@ -1,3 +1,3 @@ -propeller.push.state documentation

                            propeller.push.state

                            empty-stack?

                            (empty-stack? state stack)

                            empty-state

                            example-state

                            get-args-from-stacks

                            (get-args-from-stacks state stacks)

                            peek-stack

                            (peek-stack state stack)

                            peek-stack-many

                            (peek-stack-many state stack n)

                            pop-stack

                            (pop-stack state stack)

                            pop-stack-many

                            (pop-stack-many state stack n)

                            print-state

                            (print-state state)

                            push-to-stack

                            (push-to-stack state stack item)

                            push-to-stack-many

                            (push-to-stack-many state stack items)

                            stack-limiter

                            stack-size

                            (stack-size state stack)

                            stacks

                            vec-stacks

                            \ No newline at end of file +propeller.push.state documentation

                            propeller.push.state

                            empty-stack?

                            (empty-stack? state stack)

                            empty-state

                            example-state

                            get-args-from-stacks

                            (get-args-from-stacks state stacks)

                            peek-stack

                            (peek-stack state stack)

                            peek-stack-many

                            (peek-stack-many state stack n)

                            pop-stack

                            (pop-stack state stack)

                            pop-stack-many

                            (pop-stack-many state stack n)

                            print-state

                            (print-state state)

                            push-to-stack

                            (push-to-stack state stack item)

                            push-to-stack-many

                            (push-to-stack-many state stack items)

                            stack-limiter

                            stack-size

                            (stack-size state stack)

                            stacks

                            vec-stacks

                            \ No newline at end of file diff --git a/docs/propeller.selection.html b/docs/propeller.selection.html index 46fcddd..84467d0 100644 --- a/docs/propeller.selection.html +++ b/docs/propeller.selection.html @@ -1,6 +1,7 @@ -propeller.selection documentation

                            propeller.selection

                            epsilon-lexicase-selection

                            (epsilon-lexicase-selection pop argmap)

                            Selects an individual from the population using epsilon-lexicase selection. Epsilon lexicase selection follows the same process as lexicase selection except, for a test case, only individuals with an error outside of a predefined epsilon are filtered.

                            +propeller.selection documentation

                            propeller.selection

                            Propeller includes many kinds of genetic operators to select parents within the population such as tournament selection, lexicase selection, and epsilon lexicase selection.

                            +

                            epsilon-lexicase-selection

                            (epsilon-lexicase-selection pop argmap)

                            Selects an individual from the population using epsilon-lexicase selection. Epsilon lexicase selection follows the same process as lexicase selection except, for a test case, only individuals with an error outside of a predefined epsilon are filtered.

                            epsilon-list

                            (epsilon-list pop)

                            List of epsilons for each training case based on median absolute deviation of errors.

                            lexicase-selection

                            (lexicase-selection pop argmap)

                            Selects an individual from the population using lexicase selection. Lexicase parent selection filters the population by considering one random training case at a time, eliminating any individuals with errors for the current case that are worse than the best error in the selection pool, until a single individual remains.

                            select-parent

                            (select-parent pop argmap)

                            Selects a parent from the population using the specified method.

                            diff --git a/docs/propeller.session.html b/docs/propeller.session.html index be3bc2e..7a5a4b3 100644 --- a/docs/propeller.session.html +++ b/docs/propeller.session.html @@ -1,3 +1,4 @@ -propeller.session documentation

                            propeller.session

                            \ No newline at end of file +propeller.session documentation

                            propeller.session

                            The “session” namespace is for trying things out interactively. For example, you can use it to test a new Push instruction by running a program that uses it and seeing the result. You might just want to do this interactively in the REPL, but the session file makes it a little easier since it already requires most of the namespaces you’ll want to refer to.

                            +
                            \ No newline at end of file diff --git a/docs/propeller.simplification.html b/docs/propeller.simplification.html index 1c4fa5f..d417876 100644 --- a/docs/propeller.simplification.html +++ b/docs/propeller.simplification.html @@ -1,6 +1,22 @@ -propeller.simplification documentation

                            propeller.simplification

                            auto-simplify-plushy

                            (auto-simplify-plushy plushy error-function {:keys [simplification-steps training-data simplification-k simplification-verbose?], :as argmap})

                            simplifies plushy by deleting instructions that have no impact on errors. naive auto-simplification

                            +propeller.simplification documentation

                            propeller.simplification

                            To use Propeller’s auto-simplification system, simply include the following four command line arguments when running a problem:

                            +
                            :simplification? true
                            +
                            +

                            Toggle auto-simplification

                            +
                            :simplification-k 4
                            +
                            +

                            This is the upper bound for elements deleted from the plushy every step. Every step, a number in 1, k of elements is deleted from the plushy representation of the solution.

                            +
                            :simplification-steps 1000
                            +
                            +

                            Number of simplification steps to perform

                            +
                            :simplification-verbose? true
                            +
                            +

                            Whether or not to output simplification info into the output of the evolutionary run. The output with verbose adds the following lines to the output:

                            +
                            {:start-plushy-length 42, :k 4}
                            +{:final-plushy-length 13, :final-plushy (:in1 :in1 :integer_quot :in1 :in1 :exec_dup :in1 :integer_mult close :exec_dup :integer_add 1 :integer_add)}
                            +
                            +

                            auto-simplify-plushy

                            (auto-simplify-plushy plushy error-function {:keys [simplification-steps training-data simplification-k simplification-verbose?], :as argmap})

                            simplifies plushy by deleting instructions that have no impact on errors. naive auto-simplification

                            choose-random-k

                            (choose-random-k k indices)

                            Takes k random indices

                            delete-at-indices

                            (delete-at-indices indices plushy)

                            deletes the values at given set of indices

                            delete-k-random

                            (delete-k-random k plushy)

                            Deletes k random instructions from the plushy

                            diff --git a/docs/propeller.tools.calculus.html b/docs/propeller.tools.calculus.html index 6684917..4b9cd8b 100644 --- a/docs/propeller.tools.calculus.html +++ b/docs/propeller.tools.calculus.html @@ -1,5 +1,5 @@ -propeller.tools.calculus documentation

                            propeller.tools.calculus

                            deriv

                            (deriv f c)(deriv f)

                            Returns the derivative of f evaluated at c. If called with only one argument, it returns the derivative function.

                            +propeller.tools.calculus documentation

                            propeller.tools.calculus

                            deriv

                            (deriv f c)(deriv f)

                            Returns the derivative of f evaluated at c. If called with only one argument, it returns the derivative function.

                            dx

                            integrate

                            (integrate f)(integrate f a b)

                            Returns the definite integral of f over a, b using Simpson’s method. If called with only one argument (the function), returns the indefinite integral, which takes as input a value x and (optionally) a constant c.

                            \ No newline at end of file diff --git a/docs/propeller.tools.character.html b/docs/propeller.tools.character.html index cb99586..e178dea 100644 --- a/docs/propeller.tools.character.html +++ b/docs/propeller.tools.character.html @@ -1,6 +1,6 @@ -propeller.tools.character documentation

                            propeller.tools.character

                            get-ascii

                            (get-ascii c)

                            Gets the ASCII code of a char

                            +propeller.tools.character documentation

                            propeller.tools.character

                            get-ascii

                            (get-ascii c)

                            Gets the ASCII code of a char

                            is-digit

                            (is-digit c)

                            Returns true if the given character is a digit, 0-9.

                            is-letter

                            (is-letter c)

                            Returns true if the given character is a letter, A-Z or a-z.

                            is-whitespace

                            (is-whitespace c)

                            Returns true if the given character is whitespace (newline, space, tab).

                            diff --git a/docs/propeller.tools.distributions.html b/docs/propeller.tools.distributions.html index 4e6e0c7..27c6295 100644 --- a/docs/propeller.tools.distributions.html +++ b/docs/propeller.tools.distributions.html @@ -1,6 +1,6 @@ -propeller.tools.distributions documentation

                            propeller.tools.distributions

                            cdf-norm

                            (cdf-norm {:keys [x mu sigma], :or {mu 0, sigma 1}})

                            Parameters: {:keys x mu sigma} Returns the value of the Normal Cumulative Distribution Function at a particular value x. If no distributional parameters are provided, defaults to the Standard Normal CDF. Accepts an argument map with keys :x, and optionally :mu and :sigma.

                            +propeller.tools.distributions documentation

                            propeller.tools.distributions

                            cdf-norm

                            (cdf-norm {:keys [x mu sigma], :or {mu 0, sigma 1}})

                            Parameters: {:keys x mu sigma} Returns the value of the Normal Cumulative Distribution Function at a particular value x. If no distributional parameters are provided, defaults to the Standard Normal CDF. Accepts an argument map with keys :x, and optionally :mu and :sigma.

                            pdf-norm

                            (pdf-norm {:keys [x mu sigma], :or {mu 0, sigma 1}})

                            Returns the value of the Normal Probability Distribution Function at a particular value x. If no distributional parameters are provided, defaults to the Standard Normal PDF. Accepts an argument map with keys :x, and optionally :mu and :sigma.

                            quant-norm

                            (quant-norm {:keys [p mu sigma], :or {mu 0, sigma 1}})

                            For a given probability p, returns the corresponding value of the quantile function (i.e. the inverse Cumulative Distribution Function). If no distributional parameters are provided, defaults to Standard Normal quantiles. Accepts an argument map with keys :p, and optionally :mu and :sigma.

                            rand-norm

                            (rand-norm {:keys [n mu sigma], :or {n 1, mu 0, sigma 1}})

                            Generates n Normally-distributed random variables with given mean and standard deviation. If no parameters are provided, defaults to a single random observation from a Standard Normal distribution. Accepts an argument map with optional keys :n, :mu, and :sigma.

                            diff --git a/docs/propeller.tools.math.html b/docs/propeller.tools.math.html index 4e0ade6..229bfe7 100644 --- a/docs/propeller.tools.math.html +++ b/docs/propeller.tools.math.html @@ -1,6 +1,6 @@ -propeller.tools.math documentation

                            propeller.tools.math

                            abs

                            (abs x)

                            Returns the absolute value of a number.

                            +propeller.tools.math documentation

                            propeller.tools.math

                            abs

                            (abs x)

                            Returns the absolute value of a number.

                            approx=

                            (approx= x y epsilon)

                            ceil

                            (ceil x)

                            Returns the smallest integer greater than or equal to x.

                            cos

                            (cos x)

                            Returns the cosine of an angle (specified in radians).

                            div

                            (div x y)

                            Returns the result of floating point division between x and y.

                            diff --git a/docs/propeller.tools.metrics.html b/docs/propeller.tools.metrics.html index e067d55..07bb163 100644 --- a/docs/propeller.tools.metrics.html +++ b/docs/propeller.tools.metrics.html @@ -1,6 +1,6 @@ -propeller.tools.metrics documentation

                            propeller.tools.metrics

                            compute-next-row

                            (compute-next-row prev-row current-element other-seq pred)

                            computes the next row using the prev-row current-element and the other seq

                            +propeller.tools.metrics documentation

                            propeller.tools.metrics

                            compute-next-row

                            (compute-next-row prev-row current-element other-seq pred)

                            computes the next row using the prev-row current-element and the other seq

                            hamming-distance

                            (hamming-distance seq1 seq2)

                            Calculates the Hamming distance between two sequences, including strings.

                            levenshtein-distance

                            (levenshtein-distance a b & {p :predicate, :or {p =}})

                            Levenshtein Distance - http://en.wikipedia.org/wiki/Levenshtein_distance In Information Theory and Computer Science, the Levenshtein distance is a metric for measuring the amount of difference between two sequences. This is a functional implementation of the Levenshtein edit distance with as little mutability as possible. Still maintains the O(nm) guarantee.

                            mean

                            (mean coll)

                            Returns the mean of a collection.

                            diff --git a/docs/propeller.utils.html b/docs/propeller.utils.html index 9c42acb..fc50fe4 100644 --- a/docs/propeller.utils.html +++ b/docs/propeller.utils.html @@ -1,6 +1,6 @@ -propeller.utils documentation

                            propeller.utils

                            Useful functions

                            +propeller.utils documentation

                            propeller.utils

                            Useful functions.

                            count-points

                            (count-points tree)

                            Returns the number of points in tree, where each atom and each pair of parentheses counts as a point.

                            depth

                            (depth tree)

                            Returns the height of the nested list called tree. Borrowed idea from here: https://stackoverflow.com/a/36865180/2023312 Works by looking at the path from each node in the tree to the root, and finding the longest one. Note: does not treat an empty list as having any height.

                            ensure-list

                            (ensure-list thing)

                            Returns a non-lazy list if passed a seq argument. Otherwise, returns a list containing the argument.

                            diff --git a/docs/propeller.variation.html b/docs/propeller.variation.html index cba3155..11c2611 100644 --- a/docs/propeller.variation.html +++ b/docs/propeller.variation.html @@ -1,6 +1,6 @@ -propeller.variation documentation

                            propeller.variation

                            Propeller includes many kinds of genetic operators to create variation within the population. You can specify the rate of the variation genetic operators with the :variation map.

                            +propeller.variation documentation

                            propeller.variation

                            Propeller includes many kinds of genetic operators to create variation within the population. You can specify the rate of the variation genetic operators with the :variation map.

                            Variation

                            Propeller includes many kinds of genetic operators to create variation within the population. You can specify the rate of the variation genetic operators with the :variation map.

                            Crossover

                            diff --git a/project.clj b/project.clj index aefb09f..b1bbe31 100644 --- a/project.clj +++ b/project.clj @@ -12,5 +12,6 @@ :repl-options {:init-ns propeller.core} :jvm-opts ^:replace [] :plugins [[lein-codox "0.10.8"]] - :codox {:output-path "codox" - :metadata {:doc/format :markdown}}) + :codox {:output-path "docs" + :metadata {:doc/format :markdown} + :doc-paths ["src/docs_src"]}) diff --git a/src/docs_src/A_Guide_To_Propeller.md b/src/docs_src/A_Guide_To_Propeller.md new file mode 100644 index 0000000..778aba4 --- /dev/null +++ b/src/docs_src/A_Guide_To_Propeller.md @@ -0,0 +1,204 @@ +# A Guide to Propeller + +**Propeller** is an implementation of the Push programming language and the PushGP genetic programming system in Clojure. + +For more information on Push and PushGP see http://pushlanguage.org. + +## Overview + +**Propeller** is a Push-based genetic programming system in Clojure. + + +* [A Guide to Propeller](#a-guide-to-propeller) + * [Overview](#overview) + * [What can you do with Propeller?](#what-can-you-do-with-propeller) + * [Installation](#installation) + * [How do I run Propeller on a problem?](#how-do-i-run-propeller-on-a-problem) + * [An Example](#an-example) + * [Can you use a REPL?](#can-you-use-a-repl) + * [Tutorials](#tutorials) + * [Contributing](#contributing) + * [License](#license) + * [Citation](#citation) + * [About Propeller](#about-propeller) + * [Contact](#contact) + + +### What can you do with Propeller? + +You can evolve a Push program to solve a problem. +You can also use the Push interpreter to evaluate Push programs in other projects, +for example in agent-based evolutionary simulations in which +agents are controlled by evolving Push programs. + +## Installation + +If you have installed [leiningen](https://leiningen.org), which is a tool +for running Clojure programs, then you can run Propeller on a genetic +programming problem that is defined within this project from the command +line with the command `lein run -m `, replacing `` +with the actual namespace that you will find at the top of the problem file. + +If you have installed [Clojure](https://clojure.org/guides/install_clojure#java), you can run Propeller on a genetic programming +problem with the command `clj -m `, replacing `` with +the actual namespace that you will find at the top of the problem file. +The examples below use leiningen, but you can replace `lein run -m` with `clj --main` to run the same problem. + +A specific example is provided later below. + +## How do I run Propeller on a problem? + +To run a problem in Propeller, you want to call the `-main` function in the problem file using leiningen. +The `-main` function will create a map of arguments from the input and run the main genetic programming loop. + +Below is the general format to run a problem through the command-line: + +``` +lein run -m [namespace of the problem file you want to test] +``` + +Additional command-line arguments may +be provided to override the default key/value pairs specified in the +problem file, + +``` +lein run -m [namespace of the problem file you want to test] [key and value] [key and value]... +``` + +The possible keys come from the table below: + +| Key | Description | +|----------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `:instructions` | List of possible Push instructions used to create a plushy | +| `:error-function` | The error function used to evaluate individuals, specified in the given problem's namespace | +| `:training-data` | Map of inputs and desired outputs used to evaluate individuals of the form: {:input1 first-input :input2 second-input ... :output1 first-output ...} | +| `:testing-data` | Map of inputs and desired outputs not in the training-data to test generalizability of a program that fits the `training-data`. The map is of the form: {:input1 first-input :input2 second-input ... :output1 first-output ...} | +| `:max-generations` | Maximum number of generations | +| `:population-size` | Size of population in a generation | +| `:max-initial-plushy-size` | Maximum number of Push instructions in the initial plushy | +| `:step-limit` | The maximum number of steps that a Push program will be executed by `interpret-program` | +| `:parent-selection` | Function from `propeller.selection` that determines method of parent selection method. Propeller includes `:tournament-selection`, `:lexicase-selection`, and `:epsilon-lexicase-selection`. | +| `:tournament-size` | If using a tournament selection method, the number of individuals in each tournaments used to determine parents | +| `:umad-rate` | Rate (decimal between 0 and 1) of uniform mutation by addition and deletion (UMAD) genetic operator | +| `:variation` | Map with genetic operators as keys and probabilities as values. For example, {:umad 0.3 :crossover 0.7}. This would mean that when the system needs to generate a child, it will use UMAD 30% of the time and crossover 70% of the time. The probabilities should sum to 1. | +| `:elitism` | When true, will cause the individual with the lowest error in the population to survive, without variation, into the next generation. | + +When you run a problem, you will get a report each generation with the following information: + +``` +:generation + :best-plushy + :best-program + :best-total-error + :best-errors + :best-behaviors + :genotypic-diversity + :behavioral-diversity + :average-genome-length + :average-total-error + +``` + +### An Example + +For example, you can run the simple-regression genetic programming problem with: + +``` +lein run -m propeller.problems.simple-regression +``` + +This will run simple-regression with the default set of arguments in the `simple-regression` problem file. + +``` +{:instructions instructions +:error-function error-function +:training-data (:train train-and-test-data) +:testing-data (:test train-and-test-data) +:max-generations 500 +:population-size 500 +:max-initial-plushy-size 100 +:step-limit 200 +:parent-selection :lexicase +:tournament-size 5 +:umad-rate 0.1 +:variation {:umad 0.5 :crossover 0.5} +:elitism false} +``` + +You can override the default key/value pairs with additional arguments. For example: + +``` +lein run -m propeller.problems.simple-regression :population-size 100 +``` + +On Unix operating systems, including MacOS, you can use something +like the following to send output both to the terminal +and to a text file (called `outfile` in this example): + +``` +lein run -m propeller.problems.simple-regression | tee outfile +``` + +If you want to provide command line arguments that include +characters that may be interpreted by your command line shell +before they get to Clojure, then enclose those in double +quotes, like in this example that provides a non-default +value for the `:variation` argument, which is a clojure map +containing curly brackets that may confuse your shell: + +``` +lein run -m propeller.problems.simple-regression :variation "{:umad 1.0}" +``` + +### Can you use a REPL? + +Yes! + +To run a genetic programming problem from a REPL, start +your REPL for the project (e.g. with `lein repl` at the +command line when in the project directory, or through your +IDE) and then do something like the following (which in +this case runs the simple-regression problem with +`:population-size` 100): + +``` +(require 'propeller.problems.simple-regression) +(in-ns 'propeller.problems.simple-regression) +(-main :population-size 100 :variation {:umad 1.0}) +``` + +If you want to run the problem with the default parameters, +then you should call `-main` without arguments, as `(-main). + +## Tutorials + +- Adding genetic operators +- Adding selection methods +- Adding a new problem +- Using Propeller for Experiments + +## Contributing + +You can report a bug on the [GitHub issues page](https://github.com/lspector/propeller/issues). + +The best way to contribute to Propeller is to fork the [main GitHub repository](https://github.com/lspector/propeller) and submit a pull request. + +## License + +**Eclipse Public License 2.0** + +This commercially-friendly copyleft license provides the ability to commercially license binaries; +a modern royalty-free patent license grant; and the ability for linked works to use other licenses, including commercial ones. + +## Citation + +We are in the process of creating a DOI, but in the meantime, +we ask that you cite the [link to the repository](https://github.com/lspector/propeller) if you use Propeller. + +## About Propeller + +Propeller was created by + +## Contact + +To discuss Propeller, Push, and PushGP, you can join the [Push-Language Discourse](https://discourse.pushlanguage.org/). \ No newline at end of file diff --git a/src/docs_src/Adding_Genetic_Operators.md b/src/docs_src/Adding_Genetic_Operators.md new file mode 100644 index 0000000..5bea4b7 --- /dev/null +++ b/src/docs_src/Adding_Genetic_Operators.md @@ -0,0 +1,62 @@ +# Adding Genetic Operators + +In addition to the already-included genetic operators, you can add your own! + +## Variation Genetic Operators + +1. Go to `propeller.variation.cljc` +2. Define a genetic operator function +3. In `propeller.variation/new-individual`, add the new genetic operator in the `new-individual` function under the `case` call + +``` clojure +(defn new-individual + "Returns a new individual produced by selection and variation of + individuals in the population." + [pop argmap] + ... + (case op + ... + + :new-genetic-operator + (-> (:plushy (selection/select-parent pop argmap)) + (new-genetic-operator )) + ... + :else + (throw #?(:clj (Exception. (str "No match in new-individual for " op)) + :cljs (js/Error + (str "No match in new-individual for " op))))))}) +``` + +4. When running a problem, specify the genetic operator in `:variation`. +For example: +``` +lein run -m propeller.problems.simple-regression :variation "{:new-genetic-operator 1.0}" + +``` + +## Selection Genetic Operators + +1. Go to `propeller.selection.cljc` +2. Define a genetic operator function +3. In `propeller.selection.cljc`, add the new genetic operator in the `select-parent` function under the `case` call. + +```clojure +(defn select-parent + "Selects a parent from the population using the specified method." + [pop argmap] + (case (:parent-selection argmap) + ... + :new-genetic-operator (:new-genetic-operator ) + ... + )) +``` + +4. When running a problem, specify the selection method in `:parent-selection` + +For example: + +``` +lein run -m propeller.problems.simple-regression :parent-selection :new-genetic-operator + +``` + diff --git a/src/docs_src/Adding_Problem.md b/src/docs_src/Adding_Problem.md new file mode 100644 index 0000000..32aa81d --- /dev/null +++ b/src/docs_src/Adding_Problem.md @@ -0,0 +1,122 @@ +# Adding a Problem + +In general, a problem file has 3 components: `train-and-test-data`, `instructions`, `error-function`, and `-main`. + +1. To add a new problem, you need training and test data. For Problem Synthesis Benchmark Problems (PSB2), +you can fetch datasets using `psb2.core/fetch-examples`. + +```clojure +(defn fetch-examples + "Fetches and returns training and test data from a PSB2 problem. + Returns a map of the form {:train training-examples :test testing-examples} + where training-examples and testing-examples are lists of training and test + data. The elements of these lists are maps of the form: + {:input1 first-input :input2 second-input ... :output1 first-output ...} + The training examples will include all hard-coded edge cases included in the suite, + along with enough random cases to include `n-train` cases. + Note that this function loads large datasets and can be slow, 30-120 seconds. + Parameters: + `datasets-directory` - Location of the PSB2 datasets as downloaded from https://zenodo.org/record/4678739 + `problem-name` - Name of the PSB2 problem, lowercase and seperated by dashes. + - Ex: indices-of-substring + `n-train` - Number of training cases to return + `n-test` - Number of test cases to return" + [datasets-directory problem-name n-train n-test] + +``` +2. Define the possible Push instructions to be used to create plushys. It should be a non-lazy list of +instructions from `push/instructions` +3. Define an error function that will evaluate plushys and add `:behaviors parsed-outputs`, + `:errors`, and `:total-error` to the individual +4. Define the function `-main` with a map of default arguments. + +## Example of a Problem + +```clojure +(ns propeller.problems.PSB2.solve-boolean + (:require [psb2.core :as psb2] + [propeller.genome :as genome] + [propeller.push.interpreter :as interpreter] + [propeller.utils :as utils] + [propeller.push.instructions :refer [get-stack-instructions]] + [propeller.push.state :as state] + [propeller.gp :as gp] + #?(:cljs [cljs.reader :refer [read-string]]))) + +; =========== PROBLEM DESCRIPTION ================================ +; SOLVE BOOLEAN from PSB2 +; Given a string representing a Boolean +; expression consisting of T, F, |, and &, evaluate it and return +; the resulting Boolean. +; +; Source: https://arxiv.org/pdf/2106.06086.pdf +; ================================================================== + +(def train-and-test-data (psb2/fetch-examples "data" "solve-boolean" 200 2000)) + +(def instructions + (utils/not-lazy + (concat + ;;; stack-specific instructions + (get-stack-instructions #{:exec :integer :boolean :char :string :print}) + ;;; input instructions + (list :in1) + ;;; close + (list 'close) + ;;; ERCs (constants) + (list true false \t \f \& \|)))) + +(defn error-function + [argmap data individual] + (let [program (genome/plushy->push (:plushy individual) argmap) + inputs (map (fn [i] (get i :input1)) data) + correct-outputs (map (fn [i] (get i :output1)) data) + outputs (map (fn [input] + (state/peek-stack + (interpreter/interpret-program + program + (assoc state/empty-state :input {:in1 input}) + (:step-limit argmap)) + :boolean)) + inputs) + parsed-outputs (map (fn [output] + (try (read-string output) + #?(:clj (catch Exception e 1000.0) + :cljs (catch js/Error. e 1000.0)))) + outputs) + errors (map (fn [correct-output output] + (if (= output :no-stack-item) + 10000 + (if (= correct-output output) + 0 + 1))) + correct-outputs + parsed-outputs)] + (assoc individual + :behaviors parsed-outputs + :errors errors + :total-error #?(:clj (apply +' errors) + :cljs (apply + errors))))) + +(defn -main + "Runs propel-gp, giving it a map of arguments." + [& args] + (gp/gp + (merge + {:instructions instructions + :error-function error-function + :training-data (:train train-and-test-data) + :testing-data (:test train-and-test-data) + :max-generations 300 + :population-size 1000 + :max-initial-plushy-size 250 + :step-limit 2000 + :parent-selection :lexicase + :tournament-size 5 + :umad-rate 0.1 + :variation {:umad 1.0 :crossover 0.0} + :elitism false} + (apply hash-map (map #(if (string? %) (read-string %) %) args)))) + (#?(:clj shutdown-agents))) + +``` \ No newline at end of file diff --git a/src/docs_src/Adding_Selection_Method.md b/src/docs_src/Adding_Selection_Method.md new file mode 100644 index 0000000..8c57b01 --- /dev/null +++ b/src/docs_src/Adding_Selection_Method.md @@ -0,0 +1,20 @@ +# Adding a Selection Method + +1. Define a selection method function in `propeller.selection` that selects an individual from the population +2. Add the selection method in `propeller.selection/select-parent` under the `case` call: + +```clojure +(defn select-parent + "Selects a parent from the population using the specified method." + [pop argmap] + (case (:parent-selection argmap) + :new-selection-method (new-selection-method ))) +``` + +3. When runnning a problem, specify the selection method in `:parent-selection`. +For example: +``` +lein run -m propeller.problems.simple-regression :parent-selection :new-selection-method" +``` + + diff --git a/src/propeller/core.cljc b/src/propeller/core.cljc index 8a72779..413e348 100755 --- a/src/propeller/core.cljc +++ b/src/propeller/core.cljc @@ -7,4 +7,4 @@ ;; Exception for when no args were passed (println "To run a genetic programming problem, provide a the problem's") (println "namespace as specified in the Propeller README file at") - (println "https://github.com/lspector/propeller/blob/master/README.md")) \ No newline at end of file + (println "https://github.com/lspector/propeller/blob/master/A_Guide_To_Propeller.md")) \ No newline at end of file diff --git a/src/propeller/genome.cljc b/src/propeller/genome.cljc index e2485c5..d6f10b4 100755 --- a/src/propeller/genome.cljc +++ b/src/propeller/genome.cljc @@ -1,4 +1,7 @@ (ns propeller.genome + "The genetic material in Propeller. A `plushy` is a list of Push instructions that represent a Push program. +They hold the genetic material for an `individual`. In the initial population, we create random plushys." + {:doc/format :markdown} (:require [propeller.push.instructions :as instructions] [propeller.utils :as utils])) diff --git a/src/propeller/problems/PSB2/basement.cljc b/src/propeller/problems/PSB2/basement.cljc index 9294534..ebecb13 100644 --- a/src/propeller/problems/PSB2/basement.cljc +++ b/src/propeller/problems/PSB2/basement.cljc @@ -17,7 +17,7 @@ [propeller.gp :as gp] #?(:cljs [cljs.reader :refer [read-string]]))) -(def train-and-test-data (psb2/fetch-examples "data" "basement" 200 2000)) +(def train-and-test-data "Data taken from https://zenodo.org/record/5084812" (psb2/fetch-examples "data" "basement" 200 2000)) (defn random-int "Random integer between -100 and 100 (from smallest)" diff --git a/src/propeller/problems/PSB2/bouncing_balls.cljc b/src/propeller/problems/PSB2/bouncing_balls.cljc index f470155..d4eff1e 100644 --- a/src/propeller/problems/PSB2/bouncing_balls.cljc +++ b/src/propeller/problems/PSB2/bouncing_balls.cljc @@ -20,7 +20,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" #?(:cljs [cljs.reader :refer [read-string]]))) -(def train-and-test-data (psb2/fetch-examples "data" "bouncing-balls" 200 2000)) +(def train-and-test-data "Data taken from https://zenodo.org/record/5084812" (psb2/fetch-examples "data" "bouncing-balls" 200 2000)) (defn map-vals-input "Returns all the input values of a map (specific helper method for bouncing-balls)" diff --git a/src/propeller/problems/PSB2/bowling.cljc b/src/propeller/problems/PSB2/bowling.cljc index 89cf1a6..34c9808 100644 --- a/src/propeller/problems/PSB2/bowling.cljc +++ b/src/propeller/problems/PSB2/bowling.cljc @@ -19,7 +19,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" -(def train-and-test-data (psb2/fetch-examples "data" "bowling" 200 2000)) +(def train-and-test-data "Data taken from https://zenodo.org/record/5084812" (psb2/fetch-examples "data" "bowling" 200 2000)) (defn random-int "Returns random integer between -100 and 100" [] (- (rand-int 201) 100)) diff --git a/src/propeller/problems/PSB2/camel_case.cljc b/src/propeller/problems/PSB2/camel_case.cljc index 8d42ab4..3b64fbb 100644 --- a/src/propeller/problems/PSB2/camel_case.cljc +++ b/src/propeller/problems/PSB2/camel_case.cljc @@ -19,7 +19,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" #?(:cljs [cljs.reader :refer [read-string]]))) -(def train-and-test-data (psb2/fetch-examples "data" "camel-case" 200 2000)) +(def train-and-test-data "Data taken from https://zenodo.org/record/5084812" (psb2/fetch-examples "data" "camel-case" 200 2000)) ; Visible character ERC (defn random-char diff --git a/src/propeller/problems/PSB2/dice_game.cljc b/src/propeller/problems/PSB2/dice_game.cljc index 91ab178..cca93ce 100644 --- a/src/propeller/problems/PSB2/dice_game.cljc +++ b/src/propeller/problems/PSB2/dice_game.cljc @@ -18,7 +18,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" #?(:cljs [cljs.reader :refer [read-string]]))) -(def train-and-test-data (psb2/fetch-examples "data" "dice-game" 200 2000)) +(def train-and-test-data "Data taken from https://zenodo.org/record/5084812" (psb2/fetch-examples "data" "dice-game" 200 2000)) (defn map-vals-input "Returns all the input values of a map" diff --git a/src/propeller/problems/PSB2/fizz_buzz.cljc b/src/propeller/problems/PSB2/fizz_buzz.cljc index 3f8ee89..e373af0 100644 --- a/src/propeller/problems/PSB2/fizz_buzz.cljc +++ b/src/propeller/problems/PSB2/fizz_buzz.cljc @@ -17,7 +17,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" [propeller.gp :as gp] #?(:cljs [cljs.reader :refer [read-string]]))) -(def train-and-test-data (psb2/fetch-examples "data" "fizz-buzz" 200 2000)) +(def train-and-test-data "Data taken from https://zenodo.org/record/5084812" (psb2/fetch-examples "data" "fizz-buzz" 200 2000)) (def instructions "stack-specific instructions, input instructions, close, and constants" diff --git a/src/propeller/problems/PSB2/fuel_cost.cljc b/src/propeller/problems/PSB2/fuel_cost.cljc index 2e9a52d..b69ccff 100644 --- a/src/propeller/problems/PSB2/fuel_cost.cljc +++ b/src/propeller/problems/PSB2/fuel_cost.cljc @@ -18,7 +18,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" [propeller.gp :as gp] #?(:cljs [cljs.reader :refer [read-string]]))) -(def train-and-test-data (psb2/fetch-examples "data" "fuel-cost" 200 2000)) +(def train-and-test-data "Data taken from https://zenodo.org/record/5084812" (psb2/fetch-examples "data" "fuel-cost" 200 2000)) ; Random integer between -100 and 100 (from smallest) (defn random-int "Random integer between -100 and 100" [] (- (rand-int 201) 100)) diff --git a/src/propeller/problems/PSB2/gcd.cljc b/src/propeller/problems/PSB2/gcd.cljc index 093bf76..5b9cb5e 100644 --- a/src/propeller/problems/PSB2/gcd.cljc +++ b/src/propeller/problems/PSB2/gcd.cljc @@ -16,7 +16,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" [propeller.gp :as gp] #?(:cljs [cljs.reader :refer [read-string]]))) -(def train-and-test-data (psb2/fetch-examples "data" "gcd" 200 2000)) +(def train-and-test-data "Data taken from https://zenodo.org/record/5084812" (psb2/fetch-examples "data" "gcd" 200 2000)) (defn random-int "Random integer between -100 and 100" [] (- (rand-int 201) 100)) diff --git a/src/propeller/problems/PSB2/luhn.cljc b/src/propeller/problems/PSB2/luhn.cljc index a39753f..a098c1d 100644 --- a/src/propeller/problems/PSB2/luhn.cljc +++ b/src/propeller/problems/PSB2/luhn.cljc @@ -20,7 +20,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" #?(:cljs [cljs.reader :refer [read-string]]))) -(def train-and-test-data (psb2/fetch-examples "data" "luhn" 200 2000)) +(def train-and-test-data "Data taken from https://zenodo.org/record/5084812" (psb2/fetch-examples "data" "luhn" 200 2000)) ; Random integer between -100 and 100 (from smallest) (defn random-int "Random integer between -100 and 100" [] (- (rand-int 201) 100)) diff --git a/src/propeller/problems/PSB2/middle_character.cljc b/src/propeller/problems/PSB2/middle_character.cljc index 0b75963..5c811dd 100644 --- a/src/propeller/problems/PSB2/middle_character.cljc +++ b/src/propeller/problems/PSB2/middle_character.cljc @@ -17,7 +17,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" [propeller.gp :as gp] #?(:cljs [cljs.reader :refer [read-string]]))) -(def train-and-test-data (psb2/fetch-examples "data" "middle-character" 200 2000)) +(def train-and-test-data "Data taken from https://zenodo.org/record/5084812" (psb2/fetch-examples "data" "middle-character" 200 2000)) (defn random-int "Random integer between -100 and 100" [] (- (rand-int 201) 100)) diff --git a/src/propeller/problems/PSB2/paired_digits.cljc b/src/propeller/problems/PSB2/paired_digits.cljc index ce264ec..cf577de 100644 --- a/src/propeller/problems/PSB2/paired_digits.cljc +++ b/src/propeller/problems/PSB2/paired_digits.cljc @@ -16,7 +16,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" [propeller.gp :as gp] #?(:cljs [cljs.reader :refer [read-string]]))) -(def train-and-test-data (psb2/fetch-examples "data" "paired-digits" 200 2000)) +(def train-and-test-data "Data taken from https://zenodo.org/record/5084812" (psb2/fetch-examples "data" "paired-digits" 200 2000)) (defn random-int "Random integer between -100 and 100" [] (- (rand-int 201) 100)) diff --git a/src/propeller/problems/PSB2/shopping_list.cljc b/src/propeller/problems/PSB2/shopping_list.cljc index 69d2688..2cf782d 100644 --- a/src/propeller/problems/PSB2/shopping_list.cljc +++ b/src/propeller/problems/PSB2/shopping_list.cljc @@ -18,7 +18,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" #?(:cljs [cljs.reader :refer [read-string]]))) -(def train-and-test-data (psb2/fetch-examples "data" "shopping-list" 200 2000)) +(def train-and-test-data "Data taken from https://zenodo.org/record/5084812" (psb2/fetch-examples "data" "shopping-list" 200 2000)) (defn random-float "Random float between -100 and 100" [] (- (rand 201) 100)) diff --git a/src/propeller/problems/PSB2/snow_day.cljc b/src/propeller/problems/PSB2/snow_day.cljc index 813094d..094a930 100644 --- a/src/propeller/problems/PSB2/snow_day.cljc +++ b/src/propeller/problems/PSB2/snow_day.cljc @@ -21,7 +21,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" [propeller.gp :as gp] #?(:cljs [cljs.reader :refer [read-string]]))) -(def train-and-test-data (psb2/fetch-examples "data" "snow-day" 200 2000)) +(def train-and-test-data "Data taken from https://zenodo.org/record/5084812" (psb2/fetch-examples "data" "snow-day" 200 2000)) (defn map-vals-input "Returns all the input values of a map" diff --git a/src/propeller/problems/PSB2/solve_boolean.cljc b/src/propeller/problems/PSB2/solve_boolean.cljc index 25afa3a..45e0a4b 100644 --- a/src/propeller/problems/PSB2/solve_boolean.cljc +++ b/src/propeller/problems/PSB2/solve_boolean.cljc @@ -17,7 +17,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" #?(:cljs [cljs.reader :refer [read-string]]))) -(def train-and-test-data (psb2/fetch-examples "data" "solve-boolean" 200 2000)) +(def train-and-test-data "Data taken from https://zenodo.org/record/5084812" (psb2/fetch-examples "data" "solve-boolean" 200 2000)) (def instructions "stack-specific instructions, input instructions, close, and constants" diff --git a/src/propeller/problems/PSB2/spin_words.cljc b/src/propeller/problems/PSB2/spin_words.cljc index a4ec7e3..38a2013 100644 --- a/src/propeller/problems/PSB2/spin_words.cljc +++ b/src/propeller/problems/PSB2/spin_words.cljc @@ -17,7 +17,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" [propeller.gp :as gp] #?(:cljs [cljs.reader :refer [read-string]]))) -(def train-and-test-data (psb2/fetch-examples "data" "spin-words" 200 2000)) +(def train-and-test-data "Data taken from https://zenodo.org/record/5084812" (psb2/fetch-examples "data" "spin-words" 200 2000)) ; Visible character ERC (defn random-char diff --git a/src/propeller/problems/PSB2/square_digits.cljc b/src/propeller/problems/PSB2/square_digits.cljc index a01cbe5..e8bab0a 100644 --- a/src/propeller/problems/PSB2/square_digits.cljc +++ b/src/propeller/problems/PSB2/square_digits.cljc @@ -18,7 +18,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" -(def train-and-test-data (psb2/fetch-examples "data" "square-digits" 200 2000)) +(def train-and-test-data "Data taken from https://zenodo.org/record/5084812" (psb2/fetch-examples "data" "square-digits" 200 2000)) (defn random-int "Random integer between -100 and 100" [] (- (rand-int 201) 100)) diff --git a/src/propeller/problems/PSB2/substitution_cipher.cljc b/src/propeller/problems/PSB2/substitution_cipher.cljc index c8ee6de..369b8da 100644 --- a/src/propeller/problems/PSB2/substitution_cipher.cljc +++ b/src/propeller/problems/PSB2/substitution_cipher.cljc @@ -19,7 +19,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" [propeller.gp :as gp] #?(:cljs [cljs.reader :refer [read-string]]))) -(def train-and-test-data (psb2/fetch-examples "data" "substitution-cipher" 200 2000)) +(def train-and-test-data "Data taken from https://zenodo.org/record/5084812" (psb2/fetch-examples "data" "substitution-cipher" 200 2000)) (defn map-vals-input "Returns all the input values of a map" diff --git a/src/propeller/problems/PSB2/twitter.cljc b/src/propeller/problems/PSB2/twitter.cljc index 88e102d..b566fec 100644 --- a/src/propeller/problems/PSB2/twitter.cljc +++ b/src/propeller/problems/PSB2/twitter.cljc @@ -21,7 +21,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" -(def train-and-test-data (psb2/fetch-examples "data" "twitter" 200 2000)) +(def train-and-test-data "Data taken from https://zenodo.org/record/5084812" (psb2/fetch-examples "data" "twitter" 200 2000)) (defn random-int "Random integer between -100 and 100" [] (- (rand-int 201) 100)) diff --git a/src/propeller/problems/simple_regression.cljc b/src/propeller/problems/simple_regression.cljc index de21797..19741ed 100755 --- a/src/propeller/problems/simple_regression.cljc +++ b/src/propeller/problems/simple_regression.cljc @@ -16,6 +16,9 @@ Given inputs and outputs, find the target function." (+ (* x x x) x 3)) (def train-and-test-data + "Training data: Inputs and outputs with -10 <= x < 11 + + Test data: Inputs and outputs of -20 <= x < -10 and 11 <= x < 21" (let [train-inputs (range -10 11) test-inputs (concat (range -20 -10) (range 11 21))] {:train (map (fn [x] {:input1 (vector x) :output1 (vector (target-function x))}) train-inputs) diff --git a/src/propeller/problems/string_classification.cljc b/src/propeller/problems/string_classification.cljc index 58a0379..480c7c5 100755 --- a/src/propeller/problems/string_classification.cljc +++ b/src/propeller/problems/string_classification.cljc @@ -46,6 +46,9 @@ Given a string, return true if it contains A, C, G, and T. Else return false." "T")) (def train-and-test-data + "Training data: \"GCG\" \"GACAG\" \"AGAAG\" \"CCCA\" \"GATTACA\" \"TAGG\" \"GACT\" with associated boolean values based on problem definition. + + Test data: \"GCGT\" \"GACTTAG\" \"AGTAAG\" \"TCCTCA\" \"GAACA\" \"AGG\" \"GAC\" with associated boolean values based on problem definition." (let [train-inputs ["GCG" "GACAG" "AGAAG" "CCCA" "GATTACA" "TAGG" "GACT"] test-inputs ["GCGT" "GACTTAG" "AGTAAG" "TCCTCA" "GAACA" "AGG" "GAC"] train-outputs [false false false false true true true] diff --git a/src/propeller/push/instructions.cljc b/src/propeller/push/instructions.cljc index 361c28b..7a66236 100644 --- a/src/propeller/push/instructions.cljc +++ b/src/propeller/push/instructions.cljc @@ -5,12 +5,16 @@ #?(:cljs [goog.string :as gstring]) #?(:cljs [goog.string.format]))) -;; PushGP instructions are represented as keywords, and stored in an atom. They -;; can be either constant literals or functions that take and return a Push state -(def instruction-table (atom (hash-map))) + +(def instruction-table + "PushGP instructions are represented as keywords, and stored in an atom. They +can be either constant literals or functions that take and return a Push state" + (atom (hash-map))) ;; Number of blocks opened by instructions (default = 0) -(def opens {:exec_dup 1 +(def opens + "Number of blocks opened by instructions. The default is 0." + {:exec_dup 1 :exec_dup_times 1 :exec_dup_items 0 ; explicitly set to 0 to make it clear that this is intended :exec_eq 0 ; explicitly set to 0 to make it clear that this is intended diff --git a/src/propeller/push/instructions/character.cljc b/src/propeller/push/instructions/character.cljc index 33e064a..4d967dc 100755 --- a/src/propeller/push/instructions/character.cljc +++ b/src/propeller/push/instructions/character.cljc @@ -1,4 +1,5 @@ (ns propeller.push.instructions.character + "Push instructions for CHARs." (:require [propeller.push.state :as state] [propeller.tools.character :as char] [propeller.push.instructions :refer [def-instruction diff --git a/src/propeller/push/instructions/code.cljc b/src/propeller/push/instructions/code.cljc index 424e558..d022b72 100755 --- a/src/propeller/push/instructions/code.cljc +++ b/src/propeller/push/instructions/code.cljc @@ -1,4 +1,5 @@ (ns propeller.push.instructions.code + "Push instructions for code." (:require [propeller.utils :as utils] [propeller.push.state :as state] [propeller.push.instructions :refer [def-instruction diff --git a/src/propeller/push/instructions/input_output.cljc b/src/propeller/push/instructions/input_output.cljc index 6dc4799..4c2aa18 100755 --- a/src/propeller/push/instructions/input_output.cljc +++ b/src/propeller/push/instructions/input_output.cljc @@ -1,4 +1,5 @@ (ns propeller.push.instructions.input-output + "Push instructions for input and output." (:require [propeller.push.state :as state] [propeller.push.instructions :refer [def-instruction generate-instructions]])) diff --git a/src/propeller/push/instructions/vector.cljc b/src/propeller/push/instructions/vector.cljc index 4e4687b..342cf95 100755 --- a/src/propeller/push/instructions/vector.cljc +++ b/src/propeller/push/instructions/vector.cljc @@ -1,4 +1,5 @@ (ns propeller.push.instructions.vector + "Vector instructions for all vector element subtypes: BOOLEAN, FLOAT, INTEGER, and STRING." (:require [clojure.string] [propeller.utils :as utils] [propeller.push.state :as state] diff --git a/src/propeller/push/limits.cljc b/src/propeller/push/limits.cljc index 611b13e..c1265ff 100644 --- a/src/propeller/push/limits.cljc +++ b/src/propeller/push/limits.cljc @@ -1,4 +1,6 @@ (ns propeller.push.limits + "Values used by the Push instructions to keep the stack sizes within reasonable limits + and values used by the Push instructions to keep computed values within reasonable size limits." (:require [propeller.utils :as u])) ;; ============================================================================= @@ -9,7 +11,11 @@ ;; Limits the number of items that can be duplicated onto a stack at once. ;; We might want to extend this to limit all the different that things may be ;; placed on a stack. -(def max-stack-items 100) +(def max-stack-items + "Limits the number of items that can be duplicated onto a stack at once. +We might want to extend this to limit all the different that things may +be placed on a stack." + 100) ;; ============================================================================= ;; Values used by the Push instructions to keep computed values within @@ -17,27 +23,32 @@ ;; ============================================================================= ;; Used as the maximum magnitude of any integer/float -(def max-number-magnitude 1.0E6) +(def max-number-magnitude + "Used as the maximum magnitude of any integer/float." + 1.0E6) ;; Used as the minimum magnitude of any float -(def min-number-magnitude 1.0E-6) +(def min-number-magnitude + "Used as the minimum magnitude of any float." + 1.0E-6) ;; Used to ensure that strings don't get too large -(def max-string-length 1000) +(def max-string-length "Used to ensure that strings don't get too large." 1000) ;; Used to ensure that vectors don't get too large -(def max-vector-length 1000) +(def max-vector-length "Used to ensure that vectors don't get too large." 1000) ;; Used to ensure that total ;; Set as dynamic for testing purposes. -(def ^:dynamic max-code-points 100) +(def ^:dynamic max-code-points "Used to ensure that total code points don't get too large. Set as dynamic for testing purposes." 100) ;; Used to ensure that the depth of nesting for Push expressions doesn't get too deep. ;; Set as dynamic for testing purposes. -(def ^:dynamic max-code-depth 200) +(def ^:dynamic max-code-depth "Used to ensure that the depth of nesting for Push expressions doesn't get too deep. Set as dynamic for testing purposes." 200) ;; Returns a version of the number n that is within reasonable size bounds (defn limit-number + "Returns a version of the number n that is within reasonable size bounds." [n] (if (int? n) (cond @@ -57,14 +68,17 @@ :else n))) (defn limit-string + "Limits string length to max-string-length." [s] (apply str (take max-string-length s))) (defn limit-vector + "Limits vector length to max-vector-length." [v] (vec (take max-vector-length v))) (defn limit-code + "Limits code to max-code-points and max-code-depth." [code] (if (or (> (u/count-points code) max-code-points) (> (u/depth code) max-code-depth)) diff --git a/src/propeller/selection.cljc b/src/propeller/selection.cljc index f04579c..3d5b4af 100755 --- a/src/propeller/selection.cljc +++ b/src/propeller/selection.cljc @@ -1,4 +1,7 @@ (ns propeller.selection + "Propeller includes many kinds of genetic operators to select parents within the population such as tournament selection, + lexicase selection, and epsilon lexicase selection." + {:doc/format :markdown} (:require [propeller.tools.math :as math-tools])) (defn tournament-selection diff --git a/src/propeller/session.cljc b/src/propeller/session.cljc index 4ef6f5d..ad1ebd3 100755 --- a/src/propeller/session.cljc +++ b/src/propeller/session.cljc @@ -1,11 +1,15 @@ ; The "session" namespace is for trying things out interactively. ; For example, you can use it to test a new Push instruction by running a program that uses it and seeing the result. -; You might just want to do this interactively in the REPL, but the session file makes it a little easier since it alerady +; You might just want to do this interactively in the REPL, but the session file makes it a little easier since it already ; requires most of the namespaces you'll want to refer to. ; The commented-out stuff is a reminder of how to do some basic things. (ns propeller.session + "The \"session\" namespace is for trying things out interactively. + For example, you can use it to test a new Push instruction by running a program that uses it and seeing the result. + You might just want to do this interactively in the REPL, but the session file makes it a little easier since it already + requires most of the namespaces you'll want to refer to." (:require [propeller.genome :as genome] [propeller.gp :as gp] [propeller.selection :as selection] diff --git a/src/propeller/simplification.cljc b/src/propeller/simplification.cljc index 2e37888..828ff93 100644 --- a/src/propeller/simplification.cljc +++ b/src/propeller/simplification.cljc @@ -1,4 +1,28 @@ (ns propeller.simplification + "To use Propeller's auto-simplification system, simply include the following four command line arguments when running a problem: + +```clojure +:simplification? true +``` +Toggle auto-simplification +```clojure +:simplification-k 4 +``` +This is the upper bound for elements deleted from the plushy every step. Every step, a number in [1, k] of elements is deleted from the plushy representation of the solution. +```clojure +:simplification-steps 1000 +``` +Number of simplification steps to perform +```clojure +:simplification-verbose? true +``` +Whether or not to output simplification info into the output of the evolutionary run. +The output with verbose adds the following lines to the output: +```clojure +{:start-plushy-length 42, :k 4} +{:final-plushy-length 13, :final-plushy (:in1 :in1 :integer_quot :in1 :in1 :exec_dup :in1 :integer_mult close :exec_dup :integer_add 1 :integer_add)} +```" + {:doc/format :markdown} (:require [propeller.genome :as genome] [propeller.push.interpreter :as interpreter] [propeller.push.state :as state] diff --git a/src/propeller/utils.cljc b/src/propeller/utils.cljc index 7bdc2c1..5035f02 100755 --- a/src/propeller/utils.cljc +++ b/src/propeller/utils.cljc @@ -1,5 +1,5 @@ (ns propeller.utils - "Useful functions" + "Useful functions." (:require [clojure.zip :as zip])) (defn first-non-nil