From af0e04a6397586d6397dec9ca1c37e0053b7c469 Mon Sep 17 00:00:00 2001 From: Ashley Bao Date: Fri, 20 Jan 2023 14:58:56 -0500 Subject: [PATCH] udpated docs --- docs/index.html | 18 ++++---- docs/propeller.gp.html | 2 +- docs/propeller.problems.PSB2.basement.html | 2 +- ...ropeller.problems.PSB2.bouncing-balls.html | 2 +- docs/propeller.problems.PSB2.bowling.html | 2 +- docs/propeller.problems.PSB2.camel-case.html | 2 +- docs/propeller.problems.PSB2.dice-game.html | 2 +- docs/propeller.problems.PSB2.fizz-buzz.html | 2 +- docs/propeller.problems.PSB2.fuel-cost.html | 2 +- docs/propeller.problems.PSB2.gcd.html | 2 +- docs/propeller.problems.PSB2.luhn.html | 2 +- ...peller.problems.PSB2.middle-character.html | 2 +- ...propeller.problems.PSB2.paired-digits.html | 2 +- ...propeller.problems.PSB2.shopping-list.html | 2 +- docs/propeller.problems.PSB2.snow-day.html | 2 +- ...propeller.problems.PSB2.solve-boolean.html | 2 +- docs/propeller.problems.PSB2.spin-words.html | 2 +- ...propeller.problems.PSB2.square-digits.html | 2 +- ...ler.problems.PSB2.substitution-cipher.html | 2 +- docs/propeller.problems.PSB2.twitter.html | 2 +- .../propeller.problems.simple-regression.html | 2 +- .../propeller.problems.software.smallest.html | 1 - ...opeller.push.instructions.polymorphic.html | 28 ++++++------- docs/propeller.push.instructions.string.html | 2 +- docs/propeller.push.instructions.vector.html | 42 +++++++++---------- docs/propeller.push.interpreter.html | 2 +- docs/propeller.push.state.html | 26 +++++------- docs/propeller.tools.calculus.html | 3 +- docs/propeller.tools.character.html | 2 +- docs/propeller.tools.distributions.html | 2 +- docs/propeller.tools.math.html | 6 +-- docs/propeller.tools.metrics.html | 2 +- src/propeller/gp.cljc | 1 + src/propeller/problems/PSB2/basement.cljc | 2 +- .../problems/PSB2/bouncing_balls.cljc | 2 +- src/propeller/problems/PSB2/bowling.cljc | 2 +- src/propeller/problems/PSB2/camel_case.cljc | 2 +- src/propeller/problems/PSB2/dice_game.cljc | 2 +- src/propeller/problems/PSB2/fizz_buzz.cljc | 2 +- src/propeller/problems/PSB2/fuel_cost.cljc | 2 +- src/propeller/problems/PSB2/gcd.cljc | 2 +- src/propeller/problems/PSB2/luhn.cljc | 2 +- .../problems/PSB2/middle_character.cljc | 2 +- .../problems/PSB2/paired_digits.cljc | 2 +- .../problems/PSB2/shopping_list.cljc | 2 +- src/propeller/problems/PSB2/snow_day.cljc | 2 +- .../problems/PSB2/solve_boolean.cljc | 2 +- src/propeller/problems/PSB2/spin_words.cljc | 2 +- .../problems/PSB2/square_digits.cljc | 2 +- .../problems/PSB2/substitution_cipher.cljc | 2 +- src/propeller/problems/PSB2/twitter.cljc | 2 +- src/propeller/problems/software/smallest.cljc | 3 +- .../push/instructions/polymorphic.cljc | 28 +++++++++++++ src/propeller/push/instructions/string.cljc | 2 +- src/propeller/push/instructions/vector.cljc | 42 +++++++++++++++++++ src/propeller/push/interpreter.cljc | 1 + src/propeller/push/state.cljc | 25 +++++++++-- src/propeller/tools/calculus.cljc | 5 ++- src/propeller/tools/character.cljc | 3 +- src/propeller/tools/distributions.cljc | 1 + src/propeller/tools/math.cljc | 10 +++-- src/propeller/tools/metrics.cljc | 1 + 62 files changed, 209 insertions(+), 123 deletions(-) diff --git a/docs/index.html b/docs/index.html index bca8599..8ff9ea1 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,7 +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.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

FIXME: write docs

+

Public variables and functions:

propeller.gp

Main genetic programming loop.

Public variables and functions:

propeller.problems.PSB2.bowling

BOWLING from PSB2

@@ -32,18 +32,18 @@

Public variables and functions:

    propeller.push.instructions.input-output

    INPUT and OUTPUT Instructions

    Public variables and functions:

    propeller.push.instructions.numeric

    FLOAT and INTEGER Instructions (polymorphic)

    propeller.push.instructions.polymorphic

    Polymorphic Instructions (for all stacks, with the exception of non-data ones like input and output)

    -

    propeller.push.instructions.string

    STRING Instructions, created with propeller.push.instructions/def-instruction

    Public variables and functions:

      propeller.push.instructions.vector

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

      -

      propeller.push.interpreter

      Interprets Push programs.

      Public variables and functions:

      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.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.simplification

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

      -

      propeller.tools.calculus

      FIXME: write docs

      -

      Public variables and functions:

      propeller.tools.character

      FIXME: write docs

      -

      Public variables and functions:

      propeller.tools.distributions

      FIXME: write docs

      -

      Public variables and functions:

      propeller.tools.calculus

      Functions for calculus operations

      +

      Public variables and functions:

      propeller.tools.character

      Functions for CHARs

      +

      Public variables and functions:

      propeller.tools.distributions

      Functions to calculate distribution.

      +

      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.gp.html b/docs/propeller.gp.html index b68b59b..224168b 100644 --- a/docs/propeller.gp.html +++ b/docs/propeller.gp.html @@ -1,6 +1,6 @@ -propeller.gp documentation

      propeller.gp

      FIXME: write docs

      +propeller.gp documentation

      propeller.gp

      Main genetic programming loop.

      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.

      On each iteration, it creates a population of random plushies using a mapper function and genome/make-random-plushy function, then it sorts the population by the total error using the error-function and sort-by function. It then takes the best individual from the sorted population, and if the parent selection is set to epsilon-lexicase, it adds the epsilons to the argmap.

      The function then checks if the custom-report argument is set, if so it calls that function passing the evaluated population, current generation and argmap. If not, it calls the report function passing the evaluated population, current generation and argmap.

      diff --git a/docs/propeller.problems.PSB2.basement.html b/docs/propeller.problems.PSB2.basement.html index 3f8c928..554fa4e 100644 --- a/docs/propeller.problems.PSB2.basement.html +++ b/docs/propeller.problems.PSB2.basement.html @@ -5,7 +5,7 @@

      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

      +

      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 diff --git a/docs/propeller.problems.PSB2.bouncing-balls.html b/docs/propeller.problems.PSB2.bouncing-balls.html index b020232..3f22162 100644 --- a/docs/propeller.problems.PSB2.bouncing-balls.html +++ b/docs/propeller.problems.PSB2.bouncing-balls.html @@ -5,7 +5,7 @@

      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 FLOAT stack.

      -

      instructions

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

      +

      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

      Data taken from https://zenodo.org/record/5084812

      diff --git a/docs/propeller.problems.PSB2.bowling.html b/docs/propeller.problems.PSB2.bowling.html index aa20f61..47cc4fa 100644 --- a/docs/propeller.problems.PSB2.bowling.html +++ b/docs/propeller.problems.PSB2.bowling.html @@ -5,7 +5,7 @@

      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

      +

      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 diff --git a/docs/propeller.problems.PSB2.camel-case.html b/docs/propeller.problems.PSB2.camel-case.html index 7a43f12..cb67a1e 100644 --- a/docs/propeller.problems.PSB2.camel-case.html +++ b/docs/propeller.problems.PSB2.camel-case.html @@ -6,7 +6,7 @@

      -main

      (-main & args)

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

      cleanup-length

      (cleanup-length string len)

      Remove spaces and dashes from end of string

      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

      +

      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

      Data taken from https://zenodo.org/record/5084812

      diff --git a/docs/propeller.problems.PSB2.dice-game.html b/docs/propeller.problems.PSB2.dice-game.html index ce3daa1..1b08561 100644 --- a/docs/propeller.problems.PSB2.dice-game.html +++ b/docs/propeller.problems.PSB2.dice-game.html @@ -5,7 +5,7 @@

      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 FLOAT stack.

      -

      instructions

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

      +

      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

      Data taken from https://zenodo.org/record/5084812

      diff --git a/docs/propeller.problems.PSB2.fizz-buzz.html b/docs/propeller.problems.PSB2.fizz-buzz.html index 7be4884..694c381 100644 --- a/docs/propeller.problems.PSB2.fizz-buzz.html +++ b/docs/propeller.problems.PSB2.fizz-buzz.html @@ -4,6 +4,6 @@

      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

      +

      instructions

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

      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 9bcebbb..576b2a3 100644 --- a/docs/propeller.problems.PSB2.fuel-cost.html +++ b/docs/propeller.problems.PSB2.fuel-cost.html @@ -5,7 +5,7 @@

      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

      +

      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 diff --git a/docs/propeller.problems.PSB2.gcd.html b/docs/propeller.problems.PSB2.gcd.html index 25215d1..13360a6 100644 --- a/docs/propeller.problems.PSB2.gcd.html +++ b/docs/propeller.problems.PSB2.gcd.html @@ -5,7 +5,7 @@

      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

      +

      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

      random-int

      (random-int)

      Random integer between -100 and 100

      diff --git a/docs/propeller.problems.PSB2.luhn.html b/docs/propeller.problems.PSB2.luhn.html index 06b5a66..b845e99 100644 --- a/docs/propeller.problems.PSB2.luhn.html +++ b/docs/propeller.problems.PSB2.luhn.html @@ -5,7 +5,7 @@

      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

      +

      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 diff --git a/docs/propeller.problems.PSB2.middle-character.html b/docs/propeller.problems.PSB2.middle-character.html index f128d55..207847e 100644 --- a/docs/propeller.problems.PSB2.middle-character.html +++ b/docs/propeller.problems.PSB2.middle-character.html @@ -5,7 +5,7 @@

      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

      +

      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 diff --git a/docs/propeller.problems.PSB2.paired-digits.html b/docs/propeller.problems.PSB2.paired-digits.html index 27f175d..fa166da 100644 --- a/docs/propeller.problems.PSB2.paired-digits.html +++ b/docs/propeller.problems.PSB2.paired-digits.html @@ -5,7 +5,7 @@

      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

      +

      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

      Data taken from https://zenodo.org/record/5084812

      diff --git a/docs/propeller.problems.PSB2.shopping-list.html b/docs/propeller.problems.PSB2.shopping-list.html index 1486483..92b8937 100644 --- a/docs/propeller.problems.PSB2.shopping-list.html +++ b/docs/propeller.problems.PSB2.shopping-list.html @@ -5,7 +5,7 @@

      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 FLOAT stack.

      -

      instructions

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

      +

      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

      random-float

      (random-float)

      Random float between -100 and 100

      diff --git a/docs/propeller.problems.PSB2.snow-day.html b/docs/propeller.problems.PSB2.snow-day.html index d9ebeb5..bb56a72 100644 --- a/docs/propeller.problems.PSB2.snow-day.html +++ b/docs/propeller.problems.PSB2.snow-day.html @@ -5,7 +5,7 @@

      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 FLOAT stack.

      -

      instructions

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

      +

      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

      Data taken from https://zenodo.org/record/5084812

      diff --git a/docs/propeller.problems.PSB2.solve-boolean.html b/docs/propeller.problems.PSB2.solve-boolean.html index 02d1fca..208eb0c 100644 --- a/docs/propeller.problems.PSB2.solve-boolean.html +++ b/docs/propeller.problems.PSB2.solve-boolean.html @@ -5,6 +5,6 @@

      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

      +

      instructions

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

      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 41331b7..d0b93be 100644 --- a/docs/propeller.problems.PSB2.spin-words.html +++ b/docs/propeller.problems.PSB2.spin-words.html @@ -5,7 +5,7 @@

      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

      +

      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

      Data taken from https://zenodo.org/record/5084812

      diff --git a/docs/propeller.problems.PSB2.square-digits.html b/docs/propeller.problems.PSB2.square-digits.html index 5ff09b9..2fcd276 100644 --- a/docs/propeller.problems.PSB2.square-digits.html +++ b/docs/propeller.problems.PSB2.square-digits.html @@ -5,7 +5,7 @@

      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

      +

      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 diff --git a/docs/propeller.problems.PSB2.substitution-cipher.html b/docs/propeller.problems.PSB2.substitution-cipher.html index c20b7f5..13af2d7 100644 --- a/docs/propeller.problems.PSB2.substitution-cipher.html +++ b/docs/propeller.problems.PSB2.substitution-cipher.html @@ -5,7 +5,7 @@

      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

      +

      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

      Data taken from https://zenodo.org/record/5084812

      diff --git a/docs/propeller.problems.PSB2.twitter.html b/docs/propeller.problems.PSB2.twitter.html index 74c1b6d..24f048a 100644 --- a/docs/propeller.problems.PSB2.twitter.html +++ b/docs/propeller.problems.PSB2.twitter.html @@ -4,7 +4,7 @@

      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

      +

      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 diff --git a/docs/propeller.problems.simple-regression.html b/docs/propeller.problems.simple-regression.html index cda64b8..ac75375 100644 --- a/docs/propeller.problems.simple-regression.html +++ b/docs/propeller.problems.simple-regression.html @@ -4,7 +4,7 @@

      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

      +

      instructions

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

      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.smallest.html b/docs/propeller.problems.software.smallest.html index 6e98d8d..850e16e 100644 --- a/docs/propeller.problems.software.smallest.html +++ b/docs/propeller.problems.software.smallest.html @@ -7,7 +7,6 @@ doi: 10.1109/TSE.2015.2454513

      This problem file defines the following problem: takes as input four ints, computes the smallest, and prints to the screen the smallest input.

      -

      -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. The behavior is here defined as the final top item on the PRINT stack.

      instructions

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

      diff --git a/docs/propeller.push.instructions.polymorphic.html b/docs/propeller.push.instructions.polymorphic.html index ab04446..bc69ce1 100644 --- a/docs/propeller.push.instructions.polymorphic.html +++ b/docs/propeller.push.instructions.polymorphic.html @@ -1,18 +1,18 @@ propeller.push.instructions.polymorphic documentation

      propeller.push.instructions.polymorphic

      Polymorphic Instructions (for all stacks, with the exception of non-data ones like input and output)

      -

      _deep_dup

      FIXME: write docs

      -

      _dup

      FIXME: write docs

      -

      _dup_items

      FIXME: write docs

      -

      _dup_times

      FIXME: write docs

      -

      _empty

      FIXME: write docs

      -

      _eq

      FIXME: write docs

      -

      _flush

      FIXME: write docs

      -

      _pop

      FIXME: write docs

      -

      _rot

      FIXME: write docs

      -

      _shove

      FIXME: write docs

      -

      _stack_depth

      FIXME: write docs

      -

      _swap

      FIXME: write docs

      -

      _yank

      FIXME: write docs

      -

      _yank_dup

      FIXME: write docs

      +

      _deep_dup

      Pushes a copy of an indexed item from deep in the stack, without removing it. The top INTEGER is used to determine the index from the BOTTOM of the stack.

      +

      _dup

      Duplicates the top item of the stack. Does not pop its argument (since that would negate the effect of the duplication)

      +

      _dup_items

      Duplicates the top n items on the stack, one time each. The number n is determined by the top INTEGER. If n <= 0, no items will be duplicated. If fewer than n items are on the stack, the entire stack will be duplicated. The final number of items on the stack is limited to globals/max-stack-items.

      +

      _dup_times

      Duplicates n copies of the top item (i.e leaves n copies there). Does not pop its argument (since that would negate the effect of the duplication). The number n is determined by the top INTEGER. For n = 0, equivalent to POP. For n = 1, equivalent to NOOP. For n = 2, equivalent to DUP. Negative values of n are treated as 0. The final number of items on the stack is limited to globals/max-stack-items.

      +

      _empty

      Pushes TRUE onto the BOOLEAN stack if the stack is empty. Otherwise FALSE

      +

      _eq

      Pushes TRUE onto the BOOLEAN stack if the top two items are equal. Otherwise FALSE

      +

      _flush

      Empties the given stack

      +

      _pop

      Pops the given stack

      +

      _rot

      Rotates the top three items on the stack (i.e. pulls the third item out and pushes it on top). Equivalent to (yank state stack-type 2)

      +

      _shove

      Inserts the top item deeper into the stack, using the top INTEGER to determine how deep

      +

      _stack_depth

      Pushes the given stack’s depth onto the INTEGER stack

      +

      _swap

      Swaps the top two items on the stack

      +

      _yank

      Pushes an indexed item from deep in the stack, removing it. The top INTEGER is used to determine how deep to yank from

      +

      _yank_dup

      Pushes a copy of an indexed item from deep in the stack, without removing it. The top INTEGER is used to determine how deep to yankdup from

      \ No newline at end of file diff --git a/docs/propeller.push.instructions.string.html b/docs/propeller.push.instructions.string.html index d0fc696..b15ce08 100644 --- a/docs/propeller.push.instructions.string.html +++ b/docs/propeller.push.instructions.string.html @@ -1,4 +1,4 @@ -propeller.push.instructions.string documentation

      propeller.push.instructions.string

      STRING Instructions

      +propeller.push.instructions.string documentation

      propeller.push.instructions.string

      STRING Instructions, created with propeller.push.instructions/def-instruction

      \ No newline at end of file diff --git a/docs/propeller.push.instructions.vector.html b/docs/propeller.push.instructions.vector.html index 7a247de..8a13c02 100644 --- a/docs/propeller.push.instructions.vector.html +++ b/docs/propeller.push.instructions.vector.html @@ -1,25 +1,25 @@ propeller.push.instructions.vector documentation

      propeller.push.instructions.vector

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

      -

      _butlast

      FIXME: write docs

      -

      _concat

      FIXME: write docs

      -

      _conj

      FIXME: write docs

      -

      _contains

      FIXME: write docs

      -

      _emptyvector

      FIXME: write docs

      -

      _first

      FIXME: write docs

      -

      _indexof

      FIXME: write docs

      -

      _iterate

      FIXME: write docs

      -

      _last

      FIXME: write docs

      -

      _length

      FIXME: write docs

      -

      _nth

      FIXME: write docs

      -

      _occurrencesof

      FIXME: write docs

      -

      _pushall

      FIXME: write docs

      -

      _remove

      FIXME: write docs

      -

      _replace

      FIXME: write docs

      -

      _replacefirst

      FIXME: write docs

      -

      _rest

      FIXME: write docs

      -

      _reverse

      FIXME: write docs

      -

      _set

      FIXME: write docs

      -

      _subvec

      FIXME: write docs

      -

      _take

      FIXME: write docs

      +

      _butlast

      Pushes the butlast of the top item

      +

      _concat

      Concats and pushes the top two vectors of the stack

      +

      _conj

      Conj’s the top item of the appropriately-typed literal stack onto the vector stack (e.g. pop the top INTEGER and conj it onto the top VECTOR_INTEGER)

      +

      _contains

      Pushes TRUE onto the BOOLEAN stack if the top element of the vector stack contains the top element of the appropriately-typed literal stack. Otherwise, pushes FALSE

      +

      _emptyvector

      Pushes TRUE onto the BOOLEAN stack if the top element is an empty vector. Otherwise, pushes FALSE

      +

      _first

      Pushes the first item of the top element of the vector stack onto the appropriately-typed literal stack. If the vector is empty, return :ignore-instruction so that nothing is changed on the stacks.

      +

      _indexof

      Pushes onto the INTEGER stack the index of the top element of the appropriately-typed literal stack within the top element of the vector stack

      +

      _iterate

      Iterates over the vector using the code on the exec stack

      +

      _last

      Pushes the last item of the top element of the vector stack onto the appropriately-typed literal stack

      +

      _length

      Pushes the length of the top item onto the INTEGER stack

      +

      _nth

      Pushes the Nth item of the top element of the vector stack onto the appropriately-typed literal stack, where N is taken from the INTEGER stack. To insure the index is within bounds, N is taken mod the vector length

      +

      _occurrencesof

      Pushes onto the INTEGER stack the number of occurrences of the top element of the appropriately-typed literal stack within the top element of the vector stack

      +

      _pushall

      Pushes every item of the top element onto the appropriately-typed stack

      +

      _remove

      Removes all occurrences of the top element of the appropriately-typed literal stack from the first element of the vector stack

      +

      _replace

      Replaces all occurrences of the second element of the appropriately-typed literal stack with the top element of the appropriately-typed literal stack within the top item of the vector stack

      +

      _replacefirst

      Replaces the first occurrence of the second element of the appropriately-typed literal stack with the top element of the appropriately-typed literal stack within the top item of the vector stack

      +

      _rest

      Pushes the rest of the top item

      +

      _reverse

      Pushes the reverse of the top item

      +

      _set

      Replaces in the top vector the item at index N (taken from the INTEGER stack) with the top item from the appropriately-typed literal stack. To insure the index is within bounds, N is taken mod the vector length

      +

      _subvec

      Pushes a subvector of the top item, with start and end indices determined by the second and top items of the INTEGER stack respectively

      +

      _take

      Pushes the first N items of the top element, where N is taken from the top of the INTEGER stack

      \ No newline at end of file diff --git a/docs/propeller.push.interpreter.html b/docs/propeller.push.interpreter.html index b9bab00..1c1b924 100644 --- a/docs/propeller.push.interpreter.html +++ b/docs/propeller.push.interpreter.html @@ -1,6 +1,6 @@ -propeller.push.interpreter documentation

      propeller.push.interpreter

      FIXME: write docs

      +propeller.push.interpreter documentation

      propeller.push.interpreter

      Interprets Push programs.

      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.state.html b/docs/propeller.push.state.html index f6afa3c..a361a5d 100644 --- a/docs/propeller.push.state.html +++ b/docs/propeller.push.state.html @@ -1,19 +1,15 @@ -propeller.push.state documentation

      propeller.push.state

      FIXME: write docs

      -

      empty-stack?

      (empty-stack? state stack)

      FIXME: write docs

      -

      empty-state

      FIXME: write docs

      +propeller.push.state documentation

      propeller.push.state

      FIXME: write docs

      +

      empty-stack?

      (empty-stack? state stack)

      Returns true if the stack is empty

      example-state

      FIXME: write docs

      -

      get-args-from-stacks

      (get-args-from-stacks state stacks)

      FIXME: write docs

      -

      peek-stack

      (peek-stack state stack)

      FIXME: write docs

      -

      peek-stack-many

      (peek-stack-many state stack n)

      FIXME: write docs

      -

      pop-stack

      (pop-stack state stack)

      FIXME: write docs

      -

      pop-stack-many

      (pop-stack-many state stack n)

      FIXME: write docs

      -

      print-state

      (print-state state)

      FIXME: write docs

      -

      push-to-stack

      (push-to-stack state stack item)

      FIXME: write docs

      -

      push-to-stack-many

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

      FIXME: write docs

      -

      stack-limiter

      FIXME: write docs

      -

      stack-size

      (stack-size state stack)

      FIXME: write docs

      -

      stacks

      FIXME: write docs

      -

      vec-stacks

      FIXME: write docs

      +

      get-args-from-stacks

      (get-args-from-stacks state stacks)

      Takes a state and a collection of stacks to take args from. If there are enough args on each of the desired stacks, returns a map with keys {:state :args}, where :state is the new state and :args is a list of args popped from the stacks. If there aren’t enough args on the stacks, returns :not-enough-args without popping anything

      +

      peek-stack

      (peek-stack state stack)

      Returns the top item on the stack

      +

      peek-stack-many

      (peek-stack-many state stack n)

      Returns the top n items on the stack, as a chunk. If there are less than n items on the stack, returns the entire stack

      +

      pop-stack

      (pop-stack state stack)

      Removes the top item of stack

      +

      pop-stack-many

      (pop-stack-many state stack n)

      Pops the top n items of the stack. If there are less than n items on the stack, pops the entire stack

      +

      print-state

      (print-state state)

      Pretty-print a Push state, for logging or debugging purposes

      +

      push-to-stack

      (push-to-stack state stack item)

      Pushes an item onto the stack

      +

      push-to-stack-many

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

      Pushes a collection of items onto the stack, as a chunk (i.e. leaving them in the order they are in)

      +

      stack-size

      (stack-size state stack)

      Returns the stack size

      \ No newline at end of file diff --git a/docs/propeller.tools.calculus.html b/docs/propeller.tools.calculus.html index 4fd71fc..3ece09b 100644 --- a/docs/propeller.tools.calculus.html +++ b/docs/propeller.tools.calculus.html @@ -1,7 +1,6 @@ -propeller.tools.calculus documentation

      propeller.tools.calculus

      FIXME: write docs

      +propeller.tools.calculus documentation

      propeller.tools.calculus

      Functions for calculus operations

      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

      FIXME: write docs

      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 4a800fe..8735f5f 100644 --- a/docs/propeller.tools.character.html +++ b/docs/propeller.tools.character.html @@ -1,6 +1,6 @@ -propeller.tools.character documentation

      propeller.tools.character

      FIXME: write docs

      +propeller.tools.character documentation

      propeller.tools.character

      Functions for CHARs

      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.

      diff --git a/docs/propeller.tools.distributions.html b/docs/propeller.tools.distributions.html index 6a9ca6b..fc7acc4 100644 --- a/docs/propeller.tools.distributions.html +++ b/docs/propeller.tools.distributions.html @@ -1,6 +1,6 @@ -propeller.tools.distributions documentation

      propeller.tools.distributions

      FIXME: write docs

      +propeller.tools.distributions documentation

      propeller.tools.distributions

      Functions to calculate distribution.

      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.

      diff --git a/docs/propeller.tools.math.html b/docs/propeller.tools.math.html index 6dbf522..2d97a9f 100644 --- a/docs/propeller.tools.math.html +++ b/docs/propeller.tools.math.html @@ -1,19 +1,17 @@ -propeller.tools.math documentation

      propeller.tools.math

      FIXME: write docs

      +propeller.tools.math documentation

      propeller.tools.math

      Math functions.

      abs

      (abs x)

      Returns the absolute value of a number.

      -

      approx=

      (approx= x y epsilon)

      FIXME: write docs

      +

      approx=

      (approx= x y epsilon)

      Returns true if the absolute difference between x and y is less than or equal to some specified error level, 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.

      -

      E

      FIXME: write docs

      exp

      (exp x)

      Returns Euler’s number (approx. 2.71) raised to the given power.

      floor

      (floor x)

      Returns the largest integer less than or equal to x.

      log

      (log x base)(log x)

      Returns the logarithm of x with the given base. If called with only one argument, returns the natural logarithm (base e) of the given value.

      mean

      (mean coll)

      Returns the mean.

      median

      (median coll)

      Returns the median.

      median-absolute-deviation

      (median-absolute-deviation coll)

      Returns the median absolute deviation.

      -

      PI

      FIXME: write docs

      pow

      (pow x n)

      Returns the value obtained by raising the first argument to the power of the second argument.

      root

      (root x n)

      Returns the root of x with base n.

      round

      (round x)

      Returns the value of x rounded to the nearest integer.

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

      propeller.tools.metrics

      FIXME: write docs

      +propeller.tools.metrics documentation

      propeller.tools.metrics

      Functions to measure things.

      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.

      diff --git a/src/propeller/gp.cljc b/src/propeller/gp.cljc index 33a7f42..f7a3a97 100644 --- a/src/propeller/gp.cljc +++ b/src/propeller/gp.cljc @@ -1,4 +1,5 @@ (ns propeller.gp + "Main genetic programming loop." (:require [clojure.string] [clojure.pprint] [propeller.genome :as genome] diff --git a/src/propeller/problems/PSB2/basement.cljc b/src/propeller/problems/PSB2/basement.cljc index ebecb13..f8b9b9d 100644 --- a/src/propeller/problems/PSB2/basement.cljc +++ b/src/propeller/problems/PSB2/basement.cljc @@ -24,7 +24,7 @@ [] (- (rand-int 201) 100)) (def instructions - "stack-specific instructions, input instructions, close, and constants" + "Stack-specific instructions, input instructions, close, and constants" (utils/not-lazy (concat ;;; stack-specific instructions diff --git a/src/propeller/problems/PSB2/bouncing_balls.cljc b/src/propeller/problems/PSB2/bouncing_balls.cljc index d4eff1e..449cf8f 100644 --- a/src/propeller/problems/PSB2/bouncing_balls.cljc +++ b/src/propeller/problems/PSB2/bouncing_balls.cljc @@ -33,7 +33,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" (get i :output1)) (def instructions - "stack-specific instructions, input instructions, close, and constants" + "Stack-specific instructions, input instructions, close, and constants" (utils/not-lazy (concat ;;; stack-specific instructions diff --git a/src/propeller/problems/PSB2/bowling.cljc b/src/propeller/problems/PSB2/bowling.cljc index 34c9808..8fbbaed 100644 --- a/src/propeller/problems/PSB2/bowling.cljc +++ b/src/propeller/problems/PSB2/bowling.cljc @@ -24,7 +24,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" (defn random-int "Returns random integer between -100 and 100" [] (- (rand-int 201) 100)) (def instructions - "stack-specific instructions, input instructions, close, and constants" + "Stack-specific instructions, input instructions, close, and constants" (utils/not-lazy (concat ;;; stack-specific instructions diff --git a/src/propeller/problems/PSB2/camel_case.cljc b/src/propeller/problems/PSB2/camel_case.cljc index 3b64fbb..d25c985 100644 --- a/src/propeller/problems/PSB2/camel_case.cljc +++ b/src/propeller/problems/PSB2/camel_case.cljc @@ -57,7 +57,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" (word-generator)))))) (def instructions - "stack-specific instructions, input instructions, close, and constants" + "Stack-specific instructions, input instructions, close, and constants" (utils/not-lazy (concat ;;; stack-specific instructions diff --git a/src/propeller/problems/PSB2/dice_game.cljc b/src/propeller/problems/PSB2/dice_game.cljc index cca93ce..1865798 100644 --- a/src/propeller/problems/PSB2/dice_game.cljc +++ b/src/propeller/problems/PSB2/dice_game.cljc @@ -31,7 +31,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" (get i :output1)) (def instructions - "stack-specific instructions, input instructions, close, and constants" + "Stack-specific instructions, input instructions, close, and constants" (utils/not-lazy (concat ;;; stack-specific instructions diff --git a/src/propeller/problems/PSB2/fizz_buzz.cljc b/src/propeller/problems/PSB2/fizz_buzz.cljc index e373af0..e1f93eb 100644 --- a/src/propeller/problems/PSB2/fizz_buzz.cljc +++ b/src/propeller/problems/PSB2/fizz_buzz.cljc @@ -20,7 +20,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" (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" + "Stack-specific instructions, input instructions, close, and constants" (utils/not-lazy (concat ;;; stack-specific instructions diff --git a/src/propeller/problems/PSB2/fuel_cost.cljc b/src/propeller/problems/PSB2/fuel_cost.cljc index b69ccff..2016f2d 100644 --- a/src/propeller/problems/PSB2/fuel_cost.cljc +++ b/src/propeller/problems/PSB2/fuel_cost.cljc @@ -24,7 +24,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" (defn random-int "Random integer between -100 and 100" [] (- (rand-int 201) 100)) (def instructions - "stack-specific instructions, input instructions, close, and constants" + "Stack-specific instructions, input instructions, close, and constants" (utils/not-lazy (concat ;;; stack-specific instructions diff --git a/src/propeller/problems/PSB2/gcd.cljc b/src/propeller/problems/PSB2/gcd.cljc index 5b9cb5e..7df1130 100644 --- a/src/propeller/problems/PSB2/gcd.cljc +++ b/src/propeller/problems/PSB2/gcd.cljc @@ -31,7 +31,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" (get i :output1)) (def instructions - "stack-specific instructions, input instructions, close, and constants" + "Stack-specific instructions, input instructions, close, and constants" (utils/not-lazy (concat ;;; stack-specific instructions diff --git a/src/propeller/problems/PSB2/luhn.cljc b/src/propeller/problems/PSB2/luhn.cljc index a098c1d..0856d1e 100644 --- a/src/propeller/problems/PSB2/luhn.cljc +++ b/src/propeller/problems/PSB2/luhn.cljc @@ -26,7 +26,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" (defn random-int "Random integer between -100 and 100" [] (- (rand-int 201) 100)) (def instructions - "stack-specific instructions, input instructions, close, and constants" + "Stack-specific instructions, input instructions, close, and constants" (utils/not-lazy (concat ;;; stack-specific instructions diff --git a/src/propeller/problems/PSB2/middle_character.cljc b/src/propeller/problems/PSB2/middle_character.cljc index 5c811dd..fb2ffa7 100644 --- a/src/propeller/problems/PSB2/middle_character.cljc +++ b/src/propeller/problems/PSB2/middle_character.cljc @@ -22,7 +22,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" (defn random-int "Random integer between -100 and 100" [] (- (rand-int 201) 100)) (def instructions - "stack-specific instructions, input instructions, close, and constants" + "Stack-specific instructions, input instructions, close, and constants" (utils/not-lazy (concat ;;; stack-specific instructions diff --git a/src/propeller/problems/PSB2/paired_digits.cljc b/src/propeller/problems/PSB2/paired_digits.cljc index cf577de..dfede78 100644 --- a/src/propeller/problems/PSB2/paired_digits.cljc +++ b/src/propeller/problems/PSB2/paired_digits.cljc @@ -23,7 +23,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" (defn random-char "Random character of 0-9" [] (rand-nth '(\0 \1 \2 \3 \4 \5 \6 \7 \8 \9))) (def instructions - "stack-specific instructions, input instructions, close, and constants" + "Stack-specific instructions, input instructions, close, and constants" (utils/not-lazy (concat ;;; stack-specific instructions diff --git a/src/propeller/problems/PSB2/shopping_list.cljc b/src/propeller/problems/PSB2/shopping_list.cljc index 2cf782d..bbb4dec 100644 --- a/src/propeller/problems/PSB2/shopping_list.cljc +++ b/src/propeller/problems/PSB2/shopping_list.cljc @@ -33,7 +33,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" (get i :output1)) (def instructions - "stack-specific instructions, input instructions, close, and constants" + "Stack-specific instructions, input instructions, close, and constants" (utils/not-lazy (concat ;;; stack-specific instructions diff --git a/src/propeller/problems/PSB2/snow_day.cljc b/src/propeller/problems/PSB2/snow_day.cljc index 094a930..fa23be7 100644 --- a/src/propeller/problems/PSB2/snow_day.cljc +++ b/src/propeller/problems/PSB2/snow_day.cljc @@ -34,7 +34,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" (get i :output1)) (def instructions - "stack-specific instructions, input instructions, close, and constants" + "Stack-specific instructions, input instructions, close, and constants" (utils/not-lazy (concat ;;; stack-specific instructions diff --git a/src/propeller/problems/PSB2/solve_boolean.cljc b/src/propeller/problems/PSB2/solve_boolean.cljc index 45e0a4b..40b0dd6 100644 --- a/src/propeller/problems/PSB2/solve_boolean.cljc +++ b/src/propeller/problems/PSB2/solve_boolean.cljc @@ -20,7 +20,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" (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" + "Stack-specific instructions, input instructions, close, and constants" (utils/not-lazy (concat ;;; stack-specific instructions diff --git a/src/propeller/problems/PSB2/spin_words.cljc b/src/propeller/problems/PSB2/spin_words.cljc index 38a2013..33c7760 100644 --- a/src/propeller/problems/PSB2/spin_words.cljc +++ b/src/propeller/problems/PSB2/spin_words.cljc @@ -51,7 +51,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" (apply str (butlast words))))) (def instructions - "stack-specific instructions, input instructions, close, and constants" + "Stack-specific instructions, input instructions, close, and constants" (utils/not-lazy (concat ;;; stack-specific instructions diff --git a/src/propeller/problems/PSB2/square_digits.cljc b/src/propeller/problems/PSB2/square_digits.cljc index e8bab0a..b54242e 100644 --- a/src/propeller/problems/PSB2/square_digits.cljc +++ b/src/propeller/problems/PSB2/square_digits.cljc @@ -23,7 +23,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" (defn random-int "Random integer between -100 and 100" [] (- (rand-int 201) 100)) (def instructions - "stack-specific instructions, input instructions, close, and constants" + "Stack-specific instructions, input instructions, close, and constants" (utils/not-lazy (concat ;;; stack-specific instructions diff --git a/src/propeller/problems/PSB2/substitution_cipher.cljc b/src/propeller/problems/PSB2/substitution_cipher.cljc index 369b8da..5b40955 100644 --- a/src/propeller/problems/PSB2/substitution_cipher.cljc +++ b/src/propeller/problems/PSB2/substitution_cipher.cljc @@ -32,7 +32,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" (vals (select-keys i [:output1]))) (def instructions - "stack-specific instructions, input instructions, close, and constants" + "Stack-specific instructions, input instructions, close, and constants" (utils/not-lazy (concat ;;; stack-specific instructions diff --git a/src/propeller/problems/PSB2/twitter.cljc b/src/propeller/problems/PSB2/twitter.cljc index b566fec..fb41349 100644 --- a/src/propeller/problems/PSB2/twitter.cljc +++ b/src/propeller/problems/PSB2/twitter.cljc @@ -26,7 +26,7 @@ Source: https://arxiv.org/pdf/2106.06086.pdf" (defn random-int "Random integer between -100 and 100" [] (- (rand-int 201) 100)) (def instructions - "stack-specific instructions, input instructions, close, and constants" + "Stack-specific instructions, input instructions, close, and constants" (utils/not-lazy (concat ;;; stack-specific instructions diff --git a/src/propeller/problems/software/smallest.cljc b/src/propeller/problems/software/smallest.cljc index 2009f50..5050129 100755 --- a/src/propeller/problems/software/smallest.cljc +++ b/src/propeller/problems/software/smallest.cljc @@ -6,8 +6,7 @@ doi: 10.1109/TSE.2015.2454513 This problem file defines the following problem: -takes as input four ints, computes the smallest, and prints to the screen the smallest input. -```" +takes as input four ints, computes the smallest, and prints to the screen the smallest input." (:require [propeller.genome :as genome] [propeller.push.interpreter :as interpreter] [propeller.push.state :as state] diff --git a/src/propeller/push/instructions/polymorphic.cljc b/src/propeller/push/instructions/polymorphic.cljc index 996f284..c6dd0dc 100755 --- a/src/propeller/push/instructions/polymorphic.cljc +++ b/src/propeller/push/instructions/polymorphic.cljc @@ -16,6 +16,8 @@ ;; Duplicates the top item of the stack. Does not pop its argument (since that ;; would negate the effect of the duplication) (def _dup + "Duplicates the top item of the stack. Does not pop its argument + (since that would negate the effect of the duplication)" ^{:stacks #{} :name "_dup"} (fn [stack state] @@ -31,6 +33,12 @@ ;; of n are treated as 0. The final number of items on the stack is limited to ;; globals/max-stack-items. (def _dup_times + "Duplicates n copies of the top item (i.e leaves n copies there). Does not pop + its argument (since that would negate the effect of the duplication). The + number n is determined by the top INTEGER. For n = 0, equivalent to POP. + For n = 1, equivalent to NOOP. For n = 2, equivalent to DUP. Negative values + of n are treated as 0. The final number of items on the stack is limited to + globals/max-stack-items." ^{:stacks #{:integer} :name "_dup_times"} (fn [stack state] @@ -54,6 +62,10 @@ ;; fewer than n items are on the stack, the entire stack will be duplicated. ;; The final number of items on the stack is limited to globals/max-stack-items. (def _dup_items + "Duplicates the top n items on the stack, one time each. The number n is + determined by the top INTEGER. If n <= 0, no items will be duplicated. If + fewer than n items are on the stack, the entire stack will be duplicated. + The final number of items on the stack is limited to globals/max-stack-items." ^{:stacks #{:integer} :name "_dup_items"} (fn [stack state] @@ -67,6 +79,7 @@ ;; Pushes TRUE onto the BOOLEAN stack if the stack is empty. Otherwise FALSE (def _empty + "Pushes TRUE onto the BOOLEAN stack if the stack is empty. Otherwise FALSE" ^{:stacks #{:boolean} :name "_empty"} (fn [stack state] @@ -75,6 +88,7 @@ ;; Pushes TRUE onto the BOOLEAN stack if the top two items are equal. ;; Otherwise FALSE (def _eq + "Pushes TRUE onto the BOOLEAN stack if the top two items are equal. Otherwise FALSE" ^{:stacks #{:boolean} :name "_eq"} (fn [stack state] @@ -82,6 +96,7 @@ ;; Empties the given stack (def _flush + "Empties the given stack" ^{:stacks #{} :name "_flush"} (fn [stack state] @@ -89,6 +104,7 @@ ;; Pops the given stack (def _pop + "Pops the given stack" ^{:stacks #{} :name "_pop"} (fn [stack state] @@ -97,6 +113,8 @@ ;; Rotates the top three items on the stack (i.e. pulls the third item out and ;; pushes it on top). Equivalent to (yank state stack-type 2) (def _rot + "Rotates the top three items on the stack (i.e. pulls the third item out and + pushes it on top). Equivalent to (yank state stack-type 2)" ^{:stacks #{} :name "_rot"} (fn [stack state] @@ -110,6 +128,8 @@ ;; Inserts the top item deeper into the stack, using the top INTEGER to ;; determine how deep (def _shove + "Inserts the top item deeper into the stack, using the top INTEGER to + determine how deep" ^{:stacks #{:integer} :name "_shove"} (fn [stack state] @@ -130,6 +150,7 @@ ;; Pushes the given stack's depth onto the INTEGER stack (def _stack_depth + "Pushes the given stack's depth onto the INTEGER stack" ^{:stacks #{:integer} :name "_stack_depth"} (fn [stack state] @@ -138,6 +159,7 @@ ;; Swaps the top two items on the stack (def _swap + "Swaps the top two items on the stack" ^{:stacks #{} :name "_swap"} (fn [stack state] @@ -150,6 +172,8 @@ ;; Pushes an indexed item from deep in the stack, removing it. The top INTEGER ;; is used to determine how deep to yank from (def _yank + "Pushes an indexed item from deep in the stack, removing it. The top INTEGER + is used to determine how deep to yank from" ^{:stacks #{:integer} :name "_yank"} (fn [stack state] @@ -171,6 +195,8 @@ ;; Pushes a copy of an indexed item from deep in the stack, without removing it. ;; The top INTEGER is used to determine how deep to yankdup from (def _yank_dup + "Pushes a copy of an indexed item from deep in the stack, without removing it. + The top INTEGER is used to determine how deep to yankdup from" ^{:stacks #{:integer} :name "_yank_dup"} (fn [stack state] @@ -189,6 +215,8 @@ ;; Pushes a copy of an indexed item from deep in the stack, without removing it. ;; The top INTEGER is used to determine the index from the BOTTOM of the stack. (def _deep_dup + "Pushes a copy of an indexed item from deep in the stack, without removing it. + The top INTEGER is used to determine the index from the BOTTOM of the stack." ^{:stacks #{:integer} :name "_deep_dup"} (fn [stack state] diff --git a/src/propeller/push/instructions/string.cljc b/src/propeller/push/instructions/string.cljc index c0afa4a..48acf64 100755 --- a/src/propeller/push/instructions/string.cljc +++ b/src/propeller/push/instructions/string.cljc @@ -1,5 +1,5 @@ (ns propeller.push.instructions.string - "STRING Instructions" + "STRING Instructions, created with `propeller.push.instructions/def-instruction`" (:require [clojure.string :as string] [propeller.push.state :as state] [propeller.push.instructions :refer [def-instruction diff --git a/src/propeller/push/instructions/vector.cljc b/src/propeller/push/instructions/vector.cljc index 1236716..de15ccb 100755 --- a/src/propeller/push/instructions/vector.cljc +++ b/src/propeller/push/instructions/vector.cljc @@ -15,6 +15,7 @@ ;; Pushes the butlast of the top item (def _butlast + "Pushes the butlast of the top item" ^{:stacks #{} :name "_butlast"} (fn [stack state] @@ -22,6 +23,7 @@ ;; Concats and pushes the top two vectors of the stack (def _concat + "Concats and pushes the top two vectors of the stack" ^{:stacks #{} :name "_concat"} (fn [stack state] @@ -30,6 +32,8 @@ ;; Conj's the top item of the appropriately-typed literal stack onto the vector ;; stack (e.g. pop the top INTEGER and conj it onto the top VECTOR_INTEGER) (def _conj + "Conj's the top item of the appropriately-typed literal stack onto the vector + stack (e.g. pop the top INTEGER and conj it onto the top VECTOR_INTEGER)" ^{:stacks #{:elem} :name "_conj"} (fn [stack state] @@ -40,6 +44,9 @@ ;; contains the top element of the appropriately-typed literal stack. Otherwise, ;; pushes FALSE (def _contains + "Pushes TRUE onto the BOOLEAN stack if the top element of the vector stack + contains the top element of the appropriately-typed literal stack. Otherwise, + pushes FALSE" ^{:stacks #{:boolean} :name "_contains"} (fn [stack state] @@ -49,6 +56,8 @@ ;; Pushes TRUE onto the BOOLEAN stack if the top element is an empty vector. ;; Otherwise, pushes FALSE (def _emptyvector + "Pushes TRUE onto the BOOLEAN stack if the top element is an empty vector. + Otherwise, pushes FALSE" ^{:stacks #{:boolean} :name "_emptyvector"} (fn [stack state] @@ -58,6 +67,9 @@ ;; appropriately-typed literal stack. If the vector is empty, return ;; :ignore-instruction so that nothing is changed on the stacks. (def _first + "Pushes the first item of the top element of the vector stack onto the + appropriately-typed literal stack. If the vector is empty, return + :ignore-instruction so that nothing is changed on the stacks." ^{:stacks #{:elem} :name "_first"} (fn [stack state] @@ -70,6 +82,8 @@ ;; Pushes onto the INTEGER stack the index of the top element of the ;; appropriately-typed literal stack within the top element of the vector stack (def _indexof + "Pushes onto the INTEGER stack the index of the top element of the + appropriately-typed literal stack within the top element of the vector stack" ^{:stacks #{:elem :integer} :name "_indexof"} (fn [stack state] @@ -78,6 +92,7 @@ ;; Iterates over the vector using the code on the exec stack (def _iterate + "Iterates over the vector using the code on the exec stack" ^{:stacks #{:elem :integer} :name "_iterate"} (fn [stack state] @@ -104,6 +119,8 @@ ;; Pushes the last item of the top element of the vector stack onto the ;; approrpiately-typed literal stack (def _last + "Pushes the last item of the top element of the vector stack onto the + appropriately-typed literal stack" ^{:stacks #{:elem} :name "_last"} (fn [stack state] @@ -116,6 +133,7 @@ ;; Pushes the length of the top item onto the INTEGER stack (def _length + "Pushes the length of the top item onto the INTEGER stack" ^{:stacks #{:integer} :name "_length"} (fn [stack state] @@ -125,6 +143,9 @@ ;; approrpiately-typed literal stack, where N is taken from the INTEGER stack. ;; To insure the index is within bounds, N is taken mod the vector length (def _nth + "Pushes the Nth item of the top element of the vector stack onto the + appropriately-typed literal stack, where N is taken from the INTEGER stack. + To insure the index is within bounds, N is taken mod the vector length" ^{:stacks #{:elem :integer} :name "_nth"} (fn [stack state] @@ -140,6 +161,9 @@ ;; the appropriately-typed literal stack within the top element of the vector ;; stack (def _occurrencesof + "Pushes onto the INTEGER stack the number of occurrences of the top element of + the appropriately-typed literal stack within the top element of the vector + stack" ^{:stacks #{:elem :integer} :name "_occurrencesof"} (fn [stack state] @@ -151,6 +175,7 @@ ;; Pushes every item of the top element onto the appropriately-typed stack (def _pushall + "Pushes every item of the top element onto the appropriately-typed stack" ^{:stacks #{:elem} :name "_pushall"} (fn [stack state] @@ -164,6 +189,8 @@ ;; Removes all occurrences of the top element of the appropriately-typed literal ;; stack from the first element of the vector stack (def _remove + "Removes all occurrences of the top element of the appropriately-typed literal + stack from the first element of the vector stack" ^{:stacks #{:elem} :name "_remove"} (fn [stack state] @@ -177,6 +204,9 @@ ;; literal stack with the top element of the appropriately-typed literal stack ;; within the top item of the vector stack (def _replace + "Replaces all occurrences of the second element of the appropriately-typed + literal stack with the top element of the appropriately-typed literal stack + within the top item of the vector stack" ^{:stacks #{:elem} :name "_replace"} (fn [stack state] @@ -191,6 +221,9 @@ ;; literal stack with the top element of the appropriately-typed literal stack ;; within the top item of the vector stack (def _replacefirst + "Replaces the first occurrence of the second element of the appropriately-typed + literal stack with the top element of the appropriately-typed literal stack + within the top item of the vector stack" ^{:stacks #{:elem} :name "_replacefirst"} (fn [stack state] @@ -206,6 +239,7 @@ ;; Pushes the rest of the top item (def _rest + "Pushes the rest of the top item" ^{:stacks #{} :name "_rest"} (fn [stack state] @@ -213,6 +247,7 @@ ;; Pushes the reverse of the top item (def _reverse + "Pushes the reverse of the top item" ^{:stacks #{} :name "_reverse"} (fn [stack state] @@ -222,6 +257,9 @@ ;; with the top item from the appropriately-typed literal stack. To insure the ;; index is within bounds, N is taken mod the vector length (def _set + "Replaces in the top vector the item at index N (taken from the INTEGER stack) + with the top item from the appropriately-typed literal stack. To insure the + index is within bounds, N is taken mod the vector length" ^{:stacks #{:elem :integer} :name "_set"} (fn [stack state] @@ -237,6 +275,8 @@ ;; Pushes a subvector of the top item, with start and end indices determined by ;; the second and top items of the INTEGER stack respectively (def _subvec + "Pushes a subvector of the top item, with start and end indices determined by + the second and top items of the INTEGER stack respectively" ^{:stacks #{:integer} :name "_subvec"} (fn [stack state] @@ -251,6 +291,8 @@ ;; Pushes the first N items of the top element, where N is taken from the top of ;; the INTEGER stack (def _take + "Pushes the first N items of the top element, where N is taken from the top of + the INTEGER stack" ^{:stacks #{:integer} :name "_take"} (fn [stack state] diff --git a/src/propeller/push/interpreter.cljc b/src/propeller/push/interpreter.cljc index 738537a..f811ebc 100755 --- a/src/propeller/push/interpreter.cljc +++ b/src/propeller/push/interpreter.cljc @@ -1,4 +1,5 @@ (ns propeller.push.interpreter + "Interprets Push programs." (:require [propeller.push.instructions :as instructions] [propeller.push.state :as state] [propeller.push.instructions.input-output :as io])) diff --git a/src/propeller/push/state.cljc b/src/propeller/push/state.cljc index c211198..8a9bbac 100755 --- a/src/propeller/push/state.cljc +++ b/src/propeller/push/state.cljc @@ -3,7 +3,7 @@ #?(:cljs [goog.string :as gstring]))) ;; Empty push state - all available stacks are empty -(defonce empty-state {:boolean '() +(defonce ^:no-doc empty-state {:boolean '() :char '() :code '() :exec '() @@ -19,16 +19,16 @@ :vector_string '()}) ;; All stack types available in a Push state -(defonce stacks (set (keys empty-state))) +(defonce ^:no-doc stacks (set (keys empty-state))) ;; All vector stack types available in a Push state, with their corresponding ;; element types -(defonce vec-stacks {:vector_boolean :boolean +(defonce ^:no-doc vec-stacks {:vector_boolean :boolean :vector_float :float :vector_integer :integer :vector_string :string}) -(defonce stack-limiter {:exec l/limit-code +(defonce ^:no-doc stack-limiter {:exec l/limit-code :code l/limit-code :integer #(long (l/limit-number %)) :float l/limit-number @@ -45,16 +45,19 @@ ;; Returns true if the stack is empty (defn empty-stack? + "Returns true if the stack is empty" [state stack] (empty? (get state stack))) ;; Returns the stack size (defn stack-size + "Returns the stack size" [state stack] (count (get state stack))) ;; Returns the top item on the stack (defn peek-stack + "Returns the top item on the stack" [state stack] (if (empty? (get state stack)) :no-stack-item @@ -63,22 +66,28 @@ ;; Returns the top n items on the stack, as a chunk. If there are less than n ;; items on the stack, returns the entire stack (defn peek-stack-many + "Returns the top n items on the stack, as a chunk. If there are less than n + items on the stack, returns the entire stack" [state stack n] (take n (get state stack))) ;; Removes the top item of stack (defn pop-stack + "Removes the top item of stack" [state stack] (update state stack rest)) ;; Pops the top n items of the stack. If there are less than n items on the ;; stack, pops the entire stack (defn pop-stack-many + "Pops the top n items of the stack. If there are less than n items on the + stack, pops the entire stack" [state stack n] (update state stack #(drop n %))) ;; Pushes an item onto the stack (defn push-to-stack + "Pushes an item onto the stack" [state stack item] (if (or (nil? item) (>= (stack-size state stack) l/max-stack-items)) @@ -89,6 +98,8 @@ ;; Pushes a collection of items onto the stack, as a chunk (i.e. leaving them in ;; the order they are in) (defn push-to-stack-many + "Pushes a collection of items onto the stack, as a chunk (i.e. leaving them in + the order they are in)" [state stack items] (let [items (if (coll? items) items (list items)) items-no-nil (filter #(not (nil? %)) items) @@ -102,6 +113,11 @@ ;; popped from the stacks. If there aren't enough args on the stacks, returns ;; :not-enough-args without popping anything (defn get-args-from-stacks + "Takes a state and a collection of stacks to take args from. If there are + enough args on each of the desired stacks, returns a map with keys + {:state :args}, where :state is the new state and :args is a list of args + popped from the stacks. If there aren't enough args on the stacks, returns + :not-enough-args without popping anything" [state stacks] (loop [state state stacks (reverse stacks) @@ -118,6 +134,7 @@ ;; Pretty-print a Push state, for logging or debugging purposes (defn print-state + "Pretty-print a Push state, for logging or debugging purposes" [state] (doseq [stack (keys empty-state)] #?(:clj (printf "%-15s = " stack) diff --git a/src/propeller/tools/calculus.cljc b/src/propeller/tools/calculus.cljc index 19dfc4e..295956a 100755 --- a/src/propeller/tools/calculus.cljc +++ b/src/propeller/tools/calculus.cljc @@ -1,6 +1,7 @@ -(ns propeller.tools.calculus) +(ns propeller.tools.calculus + "Functions for calculus operations") -(defonce ^:const dx 0.0001) +(defonce ^{:no-doc true :const true} dx 0.0001) (defn deriv "Returns the derivative of f evaluated at c. If called with only one argument, diff --git a/src/propeller/tools/character.cljc b/src/propeller/tools/character.cljc index 6c8b846..cd83751 100755 --- a/src/propeller/tools/character.cljc +++ b/src/propeller/tools/character.cljc @@ -1,4 +1,5 @@ -(ns propeller.tools.character) +(ns propeller.tools.character + "Functions for CHARs") (defn get-ascii "Gets the ASCII code of a char" diff --git a/src/propeller/tools/distributions.cljc b/src/propeller/tools/distributions.cljc index e6358a3..88a83ad 100755 --- a/src/propeller/tools/distributions.cljc +++ b/src/propeller/tools/distributions.cljc @@ -1,4 +1,5 @@ (ns propeller.tools.distributions + "Functions to calculate distribution." (:require [propeller.tools.calculus :as calculus] [propeller.tools.math :as math])) diff --git a/src/propeller/tools/math.cljc b/src/propeller/tools/math.cljc index c364b54..4780c2e 100755 --- a/src/propeller/tools/math.cljc +++ b/src/propeller/tools/math.cljc @@ -1,9 +1,10 @@ -(ns propeller.tools.math) +(ns propeller.tools.math + "Math functions.") -(defonce ^:no-doc PI #?(:clj Math/PI +(defonce ^{:no-doc true :const true} PI #?(:clj Math/PI :cljs js/Math.PI)) -(defonce ^:no-doc E #?(:clj Math/E +(defonce ^{:no-doc true :const true} E #?(:clj Math/E :cljs js/Math.PI)) (defn mean @@ -39,9 +40,10 @@ [x] (if (neg? x) (- x) x)) -(defn approx= [x y epsilon] +(defn approx= "Returns true if the absolute difference between x and y is less than or equal to some specified error level, epsilon." + [x y epsilon] (<= (abs (- y x)) epsilon)) (defn ceil diff --git a/src/propeller/tools/metrics.cljc b/src/propeller/tools/metrics.cljc index 156265f..9a051e1 100755 --- a/src/propeller/tools/metrics.cljc +++ b/src/propeller/tools/metrics.cljc @@ -1,4 +1,5 @@ (ns propeller.tools.metrics + "Functions to measure things." (:require [propeller.tools.math :as math])) (defn mean