Merge branch 'master' of github.com:dafg05/propeller
This commit is contained in:
commit
ffc218046c
2
.idea/.gitignore
generated
vendored
2
.idea/.gitignore
generated
vendored
@ -1,2 +0,0 @@
|
||||
# Default ignored files
|
||||
/workspace.xml
|
6
.idea/ClojureProjectResolveSettings.xml
generated
6
.idea/ClojureProjectResolveSettings.xml
generated
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ClojureProjectResolveSettings">
|
||||
<currentScheme>IDE</currentScheme>
|
||||
</component>
|
||||
</project>
|
18
.idea/compiler.xml
generated
18
.idea/compiler.xml
generated
@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<wildcardResourcePatterns>
|
||||
<entry name="!dev-resources:*" />
|
||||
<entry name="!resources:*" />
|
||||
<entry name="!?*.java" />
|
||||
<entry name="!?*.form" />
|
||||
<entry name="!?*.class" />
|
||||
<entry name="!?*.groovy" />
|
||||
<entry name="!?*.scala" />
|
||||
<entry name="!?*.flex" />
|
||||
<entry name="!?*.kt" />
|
||||
<entry name="!?*.clj" />
|
||||
<entry name="!?*.aj" />
|
||||
</wildcardResourcePatterns>
|
||||
</component>
|
||||
</project>
|
@ -1,9 +0,0 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Leiningen: clojure-complete:0.2.5">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/clojure-complete/clojure-complete/0.2.5/clojure-complete-0.2.5.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
9
.idea/libraries/Leiningen__nrepl_0_6_0.xml
generated
9
.idea/libraries/Leiningen__nrepl_0_6_0.xml
generated
@ -1,9 +0,0 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Leiningen: nrepl:0.6.0">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/nrepl/nrepl/0.6.0/nrepl-0.6.0.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
@ -1,9 +0,0 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Leiningen: org.clojure/clojure:1.10.0">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/clojure/clojure/1.10.0/clojure-1.10.0.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
@ -1,9 +0,0 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Leiningen: org.clojure/core.specs.alpha:0.2.44">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/clojure/core.specs.alpha/0.2.44/core.specs.alpha-0.2.44.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
@ -1,9 +0,0 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Leiningen: org.clojure/spec.alpha:0.2.176">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/clojure/spec.alpha/0.2.176/spec.alpha-0.2.176.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
13
.idea/misc.xml
generated
13
.idea/misc.xml
generated
@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="LeiningenProjectsManager">
|
||||
<option name="projectFiles">
|
||||
<list>
|
||||
<option value="file://$PROJECT_DIR$/project.clj" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_13" project-jdk-name="openjdk-15" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
8
.idea/modules.xml
generated
8
.idea/modules.xml
generated
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/propeller.iml" filepath="$PROJECT_DIR$/propeller.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
generated
6
.idea/vcs.xml
generated
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
64
README.md
64
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 <namespace>`, replacing `<namespace>`
|
||||
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
|
||||
|
||||
|
@ -1,34 +1,10 @@
|
||||
(ns propeller.core
|
||||
#?(:clj (:gen-class))
|
||||
(:require [propeller.gp :as gp]
|
||||
#?(:cljs [cljs.reader :refer [read-string]])))
|
||||
|
||||
(defn eval-problem-var
|
||||
[problem-name var-name]
|
||||
(eval (symbol (str "propeller.problems." problem-name "/" var-name))))
|
||||
#?(:clj (:gen-class)))
|
||||
|
||||
(defn -main
|
||||
"Runs propel-gp, giving it a map of arguments."
|
||||
"Not intended to be run; just print a message."
|
||||
[& args]
|
||||
;; Exception for when no args were passed
|
||||
(when (empty? args)
|
||||
(println "You must specify a problem to run.")
|
||||
(println "Try, for example:")
|
||||
(println " lein run software.smallest")
|
||||
(System/exit 1))
|
||||
(require (symbol (str "propeller.problems." (first args))))
|
||||
(gp/gp
|
||||
(merge
|
||||
{: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}
|
||||
(eval-problem-var (first args) "arglist")
|
||||
(apply hash-map
|
||||
(map #(if (and (string? %) (not (.contains % "/"))) (read-string %) %)
|
||||
(rest args))))))
|
||||
(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"))
|
@ -5,8 +5,8 @@
|
||||
[propeller.utils :as utils]
|
||||
[propeller.push.utils.helpers :refer [get-stack-instructions]]
|
||||
[propeller.push.state :as state]
|
||||
[clojure.pprint :as pprint]
|
||||
[propeller.tools.math :as math]))
|
||||
[propeller.tools.math :as math]
|
||||
[propeller.gp :as gp]))
|
||||
|
||||
; =========== PROBLEM DESCRIPTION ============================
|
||||
; BASEMENT from PSB2
|
||||
@ -59,9 +59,23 @@
|
||||
:total-error #?(:clj (apply +' errors)
|
||||
:cljs (apply + errors)))))
|
||||
|
||||
(def arglist
|
||||
(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)})
|
||||
: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}
|
||||
(apply hash-map (map #(if (string? %) (read-string %) %) args)))))
|
||||
|
||||
|
@ -6,7 +6,8 @@
|
||||
[propeller.push.utils.helpers :refer [get-stack-instructions]]
|
||||
[propeller.push.state :as state]
|
||||
[clojure.pprint :as pprint]
|
||||
[propeller.tools.math :as math]))
|
||||
[propeller.tools.math :as math]
|
||||
[propeller.gp :as gp]))
|
||||
|
||||
; =========== PROBLEM DESCRIPTION ===============================
|
||||
; BOUNCING BALLS from PSB2
|
||||
@ -70,8 +71,22 @@
|
||||
:total-error #?(:clj (apply +' errors)
|
||||
:cljs (apply + errors)))))
|
||||
|
||||
(def arglist
|
||||
(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)})
|
||||
: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}
|
||||
(apply hash-map (map #(if (string? %) (read-string %) %) args)))))
|
||||
|
@ -6,7 +6,8 @@
|
||||
[propeller.push.utils.helpers :refer [get-stack-instructions]]
|
||||
[propeller.push.state :as state]
|
||||
[clojure.pprint :as pprint]
|
||||
[propeller.tools.math :as math]))
|
||||
[propeller.tools.math :as math]
|
||||
[propeller.gp :as gp]))
|
||||
|
||||
; =========== PROBLEM DESCRIPTION ======================
|
||||
; BOWLING from PSB2
|
||||
@ -58,8 +59,22 @@
|
||||
:total-error #?(:clj (apply +' errors)
|
||||
:cljs (apply + errors)))))
|
||||
|
||||
(def arglist
|
||||
(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)})
|
||||
: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}
|
||||
(apply hash-map (map #(if (string? %) (read-string %) %) args)))))
|
@ -6,7 +6,8 @@
|
||||
[propeller.push.utils.helpers :refer [get-stack-instructions]]
|
||||
[propeller.push.state :as state]
|
||||
[propeller.tools.math :as math]
|
||||
[propeller.tools.metrics :as metrics]))
|
||||
[propeller.tools.metrics :as metrics]
|
||||
[propeller.gp :as gp]))
|
||||
|
||||
; =========== PROBLEM DESCRIPTION =====================================
|
||||
; CAMEL CASE from PSB2
|
||||
@ -94,8 +95,22 @@
|
||||
:total-error #?(:clj (apply +' errors)
|
||||
:cljs (apply + errors)))))
|
||||
|
||||
(def arglist
|
||||
(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)})
|
||||
: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}
|
||||
(apply hash-map (map #(if (string? %) (read-string %) %) args)))))
|
||||
|
@ -6,7 +6,8 @@
|
||||
[propeller.push.utils.helpers :refer [get-stack-instructions]]
|
||||
[propeller.push.state :as state]
|
||||
[clojure.pprint :as pprint]
|
||||
[propeller.tools.math :as math]))
|
||||
[propeller.tools.math :as math]
|
||||
[propeller.gp :as gp]))
|
||||
|
||||
; =========== PROBLEM DESCRIPTION ===============================
|
||||
; DICE GAME from PSB2
|
||||
@ -67,8 +68,22 @@
|
||||
:total-error #?(:clj (apply +' errors)
|
||||
:cljs (apply + errors)))))
|
||||
|
||||
(def arglist
|
||||
(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)})
|
||||
: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}
|
||||
(apply hash-map (map #(if (string? %) (read-string %) %) args)))))
|
||||
|
@ -6,7 +6,8 @@
|
||||
[propeller.push.utils.helpers :refer [get-stack-instructions]]
|
||||
[propeller.push.state :as state]
|
||||
[clojure.pprint :as pprint]
|
||||
[propeller.tools.math :as math]))
|
||||
[propeller.tools.math :as math]
|
||||
[propeller.gp :as gp]))
|
||||
|
||||
; =========== PROBLEM DESCRIPTION =========================
|
||||
; FUEL COST from PSB2
|
||||
@ -60,9 +61,23 @@
|
||||
:total-error #?(:clj (apply +' errors)
|
||||
:cljs (apply + errors)))))
|
||||
|
||||
(def arglist
|
||||
(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)})
|
||||
: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}
|
||||
(apply hash-map (map #(if (string? %) (read-string %) %) args)))))
|
||||
|
||||
|
@ -6,7 +6,8 @@
|
||||
[propeller.push.utils.helpers :refer [get-stack-instructions]]
|
||||
[propeller.push.state :as state]
|
||||
[propeller.tools.math :as math]
|
||||
[propeller.tools.metrics :as metrics]))
|
||||
[propeller.tools.metrics :as metrics]
|
||||
[propeller.gp :as gp]))
|
||||
|
||||
; =========== PROBLEM DESCRIPTION =============================
|
||||
; MIDDLE CHARACTER from PSB2
|
||||
@ -63,8 +64,22 @@
|
||||
:total-error #?(:clj (apply +' errors)
|
||||
:cljs (apply + errors)))))
|
||||
|
||||
(def arglist
|
||||
(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)})
|
||||
: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}
|
||||
(apply hash-map (map #(if (string? %) (read-string %) %) args)))))
|
||||
|
@ -6,7 +6,8 @@
|
||||
[propeller.push.utils.helpers :refer [get-stack-instructions]]
|
||||
[propeller.push.state :as state]
|
||||
[propeller.tools.math :as math]
|
||||
[propeller.tools.metrics :as metrics]))
|
||||
[propeller.tools.metrics :as metrics]
|
||||
[propeller.gp :as gp]))
|
||||
|
||||
; =========== PROBLEM DESCRIPTION =========================
|
||||
; SUBSTITUTION CIPHER from PSB2
|
||||
@ -75,8 +76,22 @@
|
||||
:total-error #?(:clj (apply +' errors)
|
||||
:cljs (apply + errors)))))
|
||||
|
||||
(def arglist
|
||||
(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)})
|
||||
: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}
|
||||
(apply hash-map (map #(if (string? %) (read-string %) %) args)))))
|
@ -6,7 +6,8 @@
|
||||
[propeller.push.utils.helpers :refer [get-stack-instructions]]
|
||||
[propeller.push.state :as state]
|
||||
[propeller.tools.math :as math]
|
||||
[propeller.tools.metrics :as metrics]))
|
||||
[propeller.tools.metrics :as metrics]
|
||||
[propeller.gp :as gp]))
|
||||
|
||||
; =========== PROBLEM DESCRIPTION =============================
|
||||
; TWITTER from PSB2
|
||||
@ -66,8 +67,22 @@
|
||||
:total-error #?(:clj (apply +' errors)
|
||||
:cljs (apply + errors)))))
|
||||
|
||||
(def arglist
|
||||
(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)})
|
||||
: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}
|
||||
(apply hash-map (map #(if (string? %) (read-string %) %) args)))))
|
@ -2,7 +2,8 @@
|
||||
(:require [propeller.genome :as genome]
|
||||
[propeller.push.interpreter :as interpreter]
|
||||
[propeller.push.state :as state]
|
||||
[propeller.tools.math :as math]))
|
||||
[propeller.tools.math :as math]
|
||||
[propeller.gp :as gp]))
|
||||
|
||||
(defn- target-function
|
||||
"Target function: f(x) = x^3 + x + 3"
|
||||
@ -59,8 +60,22 @@
|
||||
:total-error #?(:clj (apply +' errors)
|
||||
:cljs (apply + errors))))))
|
||||
|
||||
(def arglist
|
||||
(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)})
|
||||
: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}
|
||||
(apply hash-map (map #(if (string? %) (read-string %) %) args)))))
|
@ -6,6 +6,7 @@
|
||||
[propeller.utils :as utils]
|
||||
[propeller.push.state :as state]
|
||||
[propeller.tools.math :as math]
|
||||
[propeller.gp :as gp]
|
||||
#?(:cljs [cljs.reader :refer [read-string]])))
|
||||
|
||||
;; =============================================================================
|
||||
@ -60,11 +61,8 @@
|
||||
:test test-set}))
|
||||
|
||||
(defn error-function
|
||||
([argmap individual]
|
||||
(error-function argmap individual :train))
|
||||
([argmap individual subset]
|
||||
[argmap data individual]
|
||||
(let [program (genome/plushy->push (:plushy individual) argmap)
|
||||
data (get train-and-test-data subset)
|
||||
inputs (:inputs data)
|
||||
correct-outputs (:outputs data)
|
||||
outputs (map (fn [input]
|
||||
@ -90,4 +88,24 @@
|
||||
:behaviors parsed-outputs
|
||||
:errors errors
|
||||
:total-error #?(:clj (apply +' errors)
|
||||
:cljs (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 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}
|
||||
(apply hash-map (map #(if (string? %) (read-string %) %) args)))))
|
@ -5,6 +5,7 @@
|
||||
[propeller.push.utils.helpers :refer [get-stack-instructions]]
|
||||
[propeller.utils :as utils]
|
||||
[propeller.push.state :as state]
|
||||
[propeller.gp :as gp]
|
||||
#?(:cljs [cljs.reader :refer [read-string]])))
|
||||
|
||||
;; =============================================================================
|
||||
@ -62,11 +63,8 @@
|
||||
:test test-set}))
|
||||
|
||||
(defn error-function
|
||||
([argmap individual]
|
||||
(error-function argmap individual :train))
|
||||
([argmap individual subset]
|
||||
[argmap data individual]
|
||||
(let [program (genome/plushy->push (:plushy individual) argmap)
|
||||
data (get train-and-test-data subset)
|
||||
inputs (:inputs data)
|
||||
correct-outputs (:outputs data)
|
||||
outputs (map (fn [input]
|
||||
@ -92,4 +90,24 @@
|
||||
:behaviors outputs
|
||||
:errors errors
|
||||
:total-error #?(:clj (apply +' errors)
|
||||
:cljs (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 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}
|
||||
(apply hash-map (map #(if (string? %) (read-string %) %) args)))))
|
@ -1,7 +1,8 @@
|
||||
(ns propeller.problems.string-classification
|
||||
(:require [propeller.genome :as genome]
|
||||
[propeller.push.interpreter :as interpreter]
|
||||
[propeller.push.state :as state]))
|
||||
[propeller.push.state :as state]
|
||||
[propeller.gp :as gp]))
|
||||
|
||||
;; =============================================================================
|
||||
;; String classification
|
||||
@ -79,8 +80,22 @@
|
||||
:total-error #?(:clj (apply +' errors)
|
||||
:cljs (apply + errors)))))
|
||||
|
||||
(def arglist
|
||||
(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)})
|
||||
: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}
|
||||
(apply hash-map (map #(if (string? %) (read-string %) %) args)))))
|
@ -1,7 +1,8 @@
|
||||
(ns propeller.problems.valiant
|
||||
(:require [propeller.genome :as genome]
|
||||
[propeller.push.interpreter :as interpreter]
|
||||
[propeller.push.state :as state]))
|
||||
[propeller.push.state :as state]
|
||||
[propeller.gp :as gp]))
|
||||
|
||||
(def num-vars 100) ;10) ;100) ;1000)
|
||||
(def num-inputs 50) ;5) ; 50) ;500)
|
||||
@ -58,8 +59,22 @@
|
||||
:total-error #?(:clj (apply +' errors)
|
||||
:cljs (apply + errors)))))
|
||||
|
||||
(def arglist
|
||||
(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)})
|
||||
: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}
|
||||
(apply hash-map (map #(if (string? %) (read-string %) %) args)))))
|
||||
|
Loading…
x
Reference in New Issue
Block a user