diff --git a/README.md b/README.md index 56511eb..6debf61 100644 --- a/README.md +++ b/README.md @@ -4,16 +4,62 @@ Yet another Push-based genetic programming system in Clojure. ## Usage -To run PushGP from a REPL, load propel.core into your REPL (i.e. `lein repl`), -and run `-main` with arguments including, first, the problem name, for example: -`(-main 'simple-regression)` or `(-main 'simple-regression :population-size 100)`. +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. + +For example, you can run the simple-regression genetic programming problem with: + +``` +lein run -m propeller.problems.simple-regression +``` + +Additional command-line arguments may +be provided to override the default key/value pairs specified in the +problem file, 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}" +``` + +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)`. -To run PushGP on the genetic programming problem p from the -command line, execute `lein run p`. For example `lein run simple-regression`. Additional command-line arguments may -be provided to override the default key/value pairs specified in `-main`, for -example, `lein run simple-regression :population-size 100`. You can use something -like `lein run simple-regression | tee outfile` to send output both to the terminal -and to `outfile`. ## CLJS Usage diff --git a/src/propeller/problems/PSB2/basement.cljc b/src/propeller/problems/PSB2/basement.cljc index 4c7abad..fa80357 100644 --- a/src/propeller/problems/PSB2/basement.cljc +++ b/src/propeller/problems/PSB2/basement.cljc @@ -78,5 +78,5 @@ :umad-rate 0.1 :variation {:umad 0.5 :crossover 0.5} :elitism false} - (apply hash-map (map read-string (rest args)))))) + (apply hash-map (map #(if (string? %) (read-string %) %) args))))) diff --git a/src/propeller/problems/PSB2/bouncing_balls.cljc b/src/propeller/problems/PSB2/bouncing_balls.cljc index 0e2dc0b..0cab515 100644 --- a/src/propeller/problems/PSB2/bouncing_balls.cljc +++ b/src/propeller/problems/PSB2/bouncing_balls.cljc @@ -89,4 +89,4 @@ :umad-rate 0.1 :variation {:umad 0.5 :crossover 0.5} :elitism false} - (apply hash-map (map read-string (rest args)))))) + (apply hash-map (map #(if (string? %) (read-string %) %) args))))) diff --git a/src/propeller/problems/PSB2/bowling.cljc b/src/propeller/problems/PSB2/bowling.cljc index 20a15d0..6fd63b8 100644 --- a/src/propeller/problems/PSB2/bowling.cljc +++ b/src/propeller/problems/PSB2/bowling.cljc @@ -77,4 +77,4 @@ :umad-rate 0.1 :variation {:umad 0.5 :crossover 0.5} :elitism false} - (apply hash-map (map read-string (rest args)))))) \ No newline at end of file + (apply hash-map (map #(if (string? %) (read-string %) %) args))))) \ No newline at end of file diff --git a/src/propeller/problems/PSB2/camel_case.cljc b/src/propeller/problems/PSB2/camel_case.cljc index a82f54b..3bc2447 100644 --- a/src/propeller/problems/PSB2/camel_case.cljc +++ b/src/propeller/problems/PSB2/camel_case.cljc @@ -113,4 +113,4 @@ :umad-rate 0.1 :variation {:umad 0.5 :crossover 0.5} :elitism false} - (apply hash-map (map read-string (rest args)))))) + (apply hash-map (map #(if (string? %) (read-string %) %) args))))) diff --git a/src/propeller/problems/PSB2/dice_game.cljc b/src/propeller/problems/PSB2/dice_game.cljc index 3672695..db669b5 100644 --- a/src/propeller/problems/PSB2/dice_game.cljc +++ b/src/propeller/problems/PSB2/dice_game.cljc @@ -86,4 +86,4 @@ :umad-rate 0.1 :variation {:umad 0.5 :crossover 0.5} :elitism false} - (apply hash-map (map read-string (rest args)))))) + (apply hash-map (map #(if (string? %) (read-string %) %) args))))) diff --git a/src/propeller/problems/PSB2/fuel_cost.cljc b/src/propeller/problems/PSB2/fuel_cost.cljc index 162b7e3..0f1592a 100644 --- a/src/propeller/problems/PSB2/fuel_cost.cljc +++ b/src/propeller/problems/PSB2/fuel_cost.cljc @@ -79,5 +79,5 @@ :umad-rate 0.1 :variation {:umad 0.5 :crossover 0.5} :elitism false} - (apply hash-map (map read-string (rest args)))))) + (apply hash-map (map #(if (string? %) (read-string %) %) args))))) diff --git a/src/propeller/problems/PSB2/middle_character.cljc b/src/propeller/problems/PSB2/middle_character.cljc index e935b5a..8b7e123 100644 --- a/src/propeller/problems/PSB2/middle_character.cljc +++ b/src/propeller/problems/PSB2/middle_character.cljc @@ -82,4 +82,4 @@ :umad-rate 0.1 :variation {:umad 0.5 :crossover 0.5} :elitism false} - (apply hash-map (map read-string (rest args)))))) + (apply hash-map (map #(if (string? %) (read-string %) %) args))))) diff --git a/src/propeller/problems/PSB2/substitution_cipher.cljc b/src/propeller/problems/PSB2/substitution_cipher.cljc index b6b2a88..554c203 100644 --- a/src/propeller/problems/PSB2/substitution_cipher.cljc +++ b/src/propeller/problems/PSB2/substitution_cipher.cljc @@ -94,4 +94,4 @@ :umad-rate 0.1 :variation {:umad 0.5 :crossover 0.5} :elitism false} - (apply hash-map (map read-string (rest args)))))) \ No newline at end of file + (apply hash-map (map #(if (string? %) (read-string %) %) args))))) \ No newline at end of file diff --git a/src/propeller/problems/PSB2/twitter.cljc b/src/propeller/problems/PSB2/twitter.cljc index 17bc755..bdf35f7 100644 --- a/src/propeller/problems/PSB2/twitter.cljc +++ b/src/propeller/problems/PSB2/twitter.cljc @@ -85,4 +85,4 @@ :umad-rate 0.1 :variation {:umad 0.5 :crossover 0.5} :elitism false} - (apply hash-map (map read-string (rest args)))))) \ No newline at end of file + (apply hash-map (map #(if (string? %) (read-string %) %) args))))) \ No newline at end of file diff --git a/src/propeller/problems/simple_regression.cljc b/src/propeller/problems/simple_regression.cljc index 2f96ffa..e0ed37d 100755 --- a/src/propeller/problems/simple_regression.cljc +++ b/src/propeller/problems/simple_regression.cljc @@ -78,4 +78,4 @@ :umad-rate 0.1 :variation {:umad 0.5 :crossover 0.5} :elitism false} - (apply hash-map (map read-string (rest args)))))) \ No newline at end of file + (apply hash-map (map #(if (string? %) (read-string %) %) args))))) \ No newline at end of file diff --git a/src/propeller/problems/software/number_io.cljc b/src/propeller/problems/software/number_io.cljc index f3e3191..2acae61 100755 --- a/src/propeller/problems/software/number_io.cljc +++ b/src/propeller/problems/software/number_io.cljc @@ -108,4 +108,4 @@ :umad-rate 0.1 :variation {:umad 0.5 :crossover 0.5} :elitism false} - (apply hash-map (map read-string (rest args)))))) \ No newline at end of file + (apply hash-map (map #(if (string? %) (read-string %) %) args))))) \ No newline at end of file diff --git a/src/propeller/problems/software/smallest.cljc b/src/propeller/problems/software/smallest.cljc index 4ee6280..a70ac59 100755 --- a/src/propeller/problems/software/smallest.cljc +++ b/src/propeller/problems/software/smallest.cljc @@ -110,4 +110,4 @@ :umad-rate 0.1 :variation {:umad 0.5 :crossover 0.5} :elitism false} - (apply hash-map (map read-string (rest args)))))) \ No newline at end of file + (apply hash-map (map #(if (string? %) (read-string %) %) args))))) \ No newline at end of file diff --git a/src/propeller/problems/string_classification.cljc b/src/propeller/problems/string_classification.cljc index 70fa252..a06490d 100755 --- a/src/propeller/problems/string_classification.cljc +++ b/src/propeller/problems/string_classification.cljc @@ -98,4 +98,4 @@ :umad-rate 0.1 :variation {:umad 0.5 :crossover 0.5} :elitism false} - (apply hash-map (map read-string (rest args)))))) \ No newline at end of file + (apply hash-map (map #(if (string? %) (read-string %) %) args))))) \ No newline at end of file diff --git a/src/propeller/problems/valiant.cljc b/src/propeller/problems/valiant.cljc index 0c05192..a98410a 100644 --- a/src/propeller/problems/valiant.cljc +++ b/src/propeller/problems/valiant.cljc @@ -77,4 +77,4 @@ :umad-rate 0.1 :variation {:umad 0.5 :crossover 0.5} :elitism false} - (apply hash-map (map read-string (rest args)))))) + (apply hash-map (map #(if (string? %) (read-string %) %) args)))))