Merge pull request #9 from NicMcPhee/command-line-problem-specification
Support command-line problem specification
This commit is contained in:
commit
7a16770cb9
@ -3,18 +3,26 @@
|
|||||||
(:require [propeller.gp :as gp]
|
(:require [propeller.gp :as gp]
|
||||||
[propeller.problems.simple-regression :as regression]
|
[propeller.problems.simple-regression :as regression]
|
||||||
[propeller.problems.string-classification :as string-classif]
|
[propeller.problems.string-classification :as string-classif]
|
||||||
[propeller.problems.software.number-io :as number-io]
|
|
||||||
[propeller.problems.software.smallest :as smallest]
|
|
||||||
#?(:cljs [cljs.reader :refer [read-string]])))
|
#?(:cljs [cljs.reader :refer [read-string]])))
|
||||||
|
|
||||||
|
(defn eval-problem-var
|
||||||
|
[problem-name var-name]
|
||||||
|
(eval (symbol (str "propeller.problems." problem-name "/" var-name))))
|
||||||
|
|
||||||
(defn -main
|
(defn -main
|
||||||
"Runs propel-gp, giving it a map of arguments."
|
"Runs propel-gp, giving it a map of arguments."
|
||||||
[& args]
|
[& args]
|
||||||
|
(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
|
(gp/gp
|
||||||
(update-in
|
(update-in
|
||||||
(merge
|
(merge
|
||||||
{:instructions number-io/instructions
|
{:instructions (eval-problem-var (first args) "instructions")
|
||||||
:error-function number-io/error-function
|
:error-function (eval-problem-var (first args) "error-function")
|
||||||
:max-generations 500
|
:max-generations 500
|
||||||
:population-size 500
|
:population-size 500
|
||||||
:max-initial-plushy-size 100
|
:max-initial-plushy-size 100
|
||||||
@ -25,6 +33,6 @@
|
|||||||
:variation {:umad 0.5 :crossover 0.5}
|
:variation {:umad 0.5 :crossover 0.5}
|
||||||
:elitism false}
|
:elitism false}
|
||||||
(apply hash-map
|
(apply hash-map
|
||||||
(map read-string args)))
|
(map read-string (rest args))))
|
||||||
[:error-function]
|
[:error-function]
|
||||||
identity)))
|
identity)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user