Merge pull request #9 from NicMcPhee/command-line-problem-specification

Support command-line problem specification
This commit is contained in:
Lee Spector 2020-12-04 18:49:20 -05:00 committed by GitHub
commit 7a16770cb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,18 +3,26 @@
(:require [propeller.gp :as gp]
[propeller.problems.simple-regression :as regression]
[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]])))
(defn eval-problem-var
[problem-name var-name]
(eval (symbol (str "propeller.problems." problem-name "/" var-name))))
(defn -main
"Runs propel-gp, giving it a map of arguments."
[& 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
(update-in
(merge
{:instructions number-io/instructions
:error-function number-io/error-function
{:instructions (eval-problem-var (first args) "instructions")
:error-function (eval-problem-var (first args) "error-function")
:max-generations 500
:population-size 500
:max-initial-plushy-size 100
@ -25,6 +33,6 @@
:variation {:umad 0.5 :crossover 0.5}
:elitism false}
(apply hash-map
(map read-string args)))
(map read-string (rest args))))
[:error-function]
identity)))