path names in argmap
This commit is contained in:
parent
6bd8a60c41
commit
8fb2f772d4
19
results.txt
19
results.txt
File diff suppressed because one or more lines are too long
@ -21,11 +21,7 @@
|
|||||||
(System/exit 1))
|
(System/exit 1))
|
||||||
|
|
||||||
;; Creates problems
|
;; Creates problems
|
||||||
;; * default params changed to PSB2 defaults *
|
|
||||||
(require (symbol (str "propeller.problems." (first args))))
|
(require (symbol (str "propeller.problems." (first args))))
|
||||||
;(when (string/includes? (first args) "PSB2")
|
|
||||||
; (spit "PSB2_path.txt" (second args))
|
|
||||||
; (println (str "Set path to PSB2 as " (second args))))
|
|
||||||
(gp/gp
|
(gp/gp
|
||||||
(update-in
|
(update-in
|
||||||
(merge
|
(merge
|
||||||
@ -40,18 +36,11 @@
|
|||||||
:umad-rate 0.1
|
:umad-rate 0.1
|
||||||
:variation {:umad 1.0 :crossover 0.0}
|
:variation {:umad 1.0 :crossover 0.0}
|
||||||
:elitism false
|
:elitism false
|
||||||
:PSB2-path "/Volumes/Samsung_T5/EvolutionaryComputing/PSB2/"}
|
:PSB2-path "/Volumes/Samsung_T5/EvolutionaryComputing/PSB2/"
|
||||||
|
:PSB2-problem (clojure.string/replace (first args) #"PSB2." "")}
|
||||||
(apply hash-map
|
(apply hash-map
|
||||||
(map #(if (string? %) (read-string %) %)
|
(map #(if (and (string? %) (not (.contains % "/"))) (read-string %) %)
|
||||||
(rest args))))
|
(rest args))))
|
||||||
;(apply hash-map
|
|
||||||
; (if (string/includes? (first args) "PSB2")
|
|
||||||
; ;; Removes PSB2 path as an arg so that it isn't included in parameter changes
|
|
||||||
; (map #(if (string? %) (read-string %) %)
|
|
||||||
; (rest (remove #(= % (second args)) args)))
|
|
||||||
; ;; Regular parameter changes
|
|
||||||
; (map #(if (string? %) (read-string %) %)
|
|
||||||
; (rest args)))))
|
|
||||||
[:error-function]
|
[:error-function]
|
||||||
identity)))
|
identity)))
|
||||||
|
|
||||||
|
@ -10,7 +10,8 @@
|
|||||||
[propeller.push.instructions.numeric]
|
[propeller.push.instructions.numeric]
|
||||||
[propeller.push.instructions.polymorphic]
|
[propeller.push.instructions.polymorphic]
|
||||||
[propeller.push.instructions.string]
|
[propeller.push.instructions.string]
|
||||||
[propeller.push.instructions.vector]))
|
[propeller.push.instructions.vector]
|
||||||
|
[psb2.core :as psb2]))
|
||||||
|
|
||||||
(defn report
|
(defn report
|
||||||
"Reports information each generation."
|
"Reports information each generation."
|
||||||
@ -27,31 +28,22 @@
|
|||||||
:average-genome-length (float (/ (reduce + (map count (map :plushy pop))) (count pop)))
|
:average-genome-length (float (/ (reduce + (map count (map :plushy pop))) (count pop)))
|
||||||
:average-total-error (float (/ (reduce + (map :total-error pop)) (count pop)))})
|
:average-total-error (float (/ (reduce + (map :total-error pop)) (count pop)))})
|
||||||
(println)))
|
(println)))
|
||||||
|
; (clojure.pprint/pprint
|
||||||
|
|
||||||
|
|
||||||
;(let [best (first pop)]
|
|
||||||
; (clojure.pprint/pprint {:generation generation
|
|
||||||
; :best-plushy (:plushy best)
|
|
||||||
; :best-program (genome/plushy->push (:plushy best) argmap)
|
|
||||||
; :best-total-error (:total-error best)
|
|
||||||
; :best-errors (:errors best)
|
|
||||||
; :best-behaviors (:behaviors best)
|
|
||||||
; :genotypic-diversity (float (/ (count (distinct (map :plushy pop))) (count pop)))
|
|
||||||
; :behavioral-diversity (float (/ (count (distinct (map :behaviors pop))) (count pop)))
|
|
||||||
; :average-genome-length (float (/ (reduce + (map count (map :plushy pop))) (count pop)))
|
|
||||||
; :average-total-error (float (/ (reduce + (map :total-error pop)) (count pop)))})
|
|
||||||
; (println)))
|
|
||||||
|
|
||||||
(defn gp
|
(defn gp
|
||||||
"Main GP loop."
|
"Main GP loop."
|
||||||
[{:keys [population-size max-generations error-function instructions
|
[{:keys [population-size max-generations error-function instructions
|
||||||
max-initial-plushy-size]
|
max-initial-plushy-size PSB2-path PSB2-problem]
|
||||||
:as argmap}]
|
:as argmap}]
|
||||||
;;
|
;;
|
||||||
(println {:starting-args argmap})
|
(println {:starting-args argmap})
|
||||||
(println)
|
(println)
|
||||||
;;
|
;;
|
||||||
(print "got here 1")
|
(let [PSB2-data (if (= PSB2-path "")
|
||||||
|
#{}
|
||||||
|
(psb2/fetch-examples PSB2-path PSB2-problem 200 2000))]
|
||||||
|
|
||||||
(loop [generation 0
|
(loop [generation 0
|
||||||
population (repeatedly
|
population (repeatedly
|
||||||
population-size
|
population-size
|
||||||
@ -61,7 +53,7 @@
|
|||||||
(let [evaluated-pop (sort-by :total-error
|
(let [evaluated-pop (sort-by :total-error
|
||||||
(#?(:clj pmap
|
(#?(:clj pmap
|
||||||
:cljs map)
|
:cljs map)
|
||||||
(partial error-function argmap) population))
|
(partial error-function (assoc argmap :train-and-test-data PSB2-data)) population))
|
||||||
best-individual (first evaluated-pop)]
|
best-individual (first evaluated-pop)]
|
||||||
(report evaluated-pop generation argmap)
|
(report evaluated-pop generation argmap)
|
||||||
(cond
|
(cond
|
||||||
@ -80,4 +72,4 @@
|
|||||||
#(variation/new-individual evaluated-pop argmap))
|
#(variation/new-individual evaluated-pop argmap))
|
||||||
(first evaluated-pop))
|
(first evaluated-pop))
|
||||||
(repeatedly population-size
|
(repeatedly population-size
|
||||||
#(variation/new-individual evaluated-pop argmap))))))))
|
#(variation/new-individual evaluated-pop argmap)))))))))
|
@ -11,9 +11,7 @@
|
|||||||
; Random integer between -100 and 100 (from smallest)
|
; Random integer between -100 and 100 (from smallest)
|
||||||
(defn random-int [] (- (rand-int 201) 100))
|
(defn random-int [] (- (rand-int 201) 100))
|
||||||
|
|
||||||
(defn train-and-test-data
|
; (def train-and-test-data (psb2/fetch-examples PSB2-path "fuel-cost" 200 2000))
|
||||||
[PSB2-path]
|
|
||||||
(psb2/fetch-examples PSB2-path "fuel-cost" 200 2000))
|
|
||||||
|
|
||||||
(def instructions
|
(def instructions
|
||||||
(utils/not-lazy
|
(utils/not-lazy
|
||||||
@ -34,7 +32,7 @@
|
|||||||
(error-function argmap individual :train))
|
(error-function argmap individual :train))
|
||||||
([argmap individual subset]
|
([argmap individual subset]
|
||||||
(let [program (genome/plushy->push (:plushy individual) argmap)
|
(let [program (genome/plushy->push (:plushy individual) argmap)
|
||||||
data (get (train-and-test-data (get argmap :PSB2-path)) subset)
|
data (get (get argmap :train-and-test-data) subset)
|
||||||
inputs (map (fn [i] (get i :input1)) data)
|
inputs (map (fn [i] (get i :input1)) data)
|
||||||
correct-outputs (map (fn [i] (get i :output1)) data)
|
correct-outputs (map (fn [i] (get i :output1)) data)
|
||||||
outputs (map (fn [input]
|
outputs (map (fn [input]
|
||||||
|
@ -8,9 +8,6 @@
|
|||||||
[propeller.tools.math :as math]
|
[propeller.tools.math :as math]
|
||||||
[propeller.tools.metrics :as metrics]))
|
[propeller.tools.metrics :as metrics]))
|
||||||
|
|
||||||
;; Get path from text file
|
|
||||||
(def PSB2-path (slurp "PSB2_path.txt"))
|
|
||||||
|
|
||||||
(defn map-vals-input
|
(defn map-vals-input
|
||||||
"Returns all the input values of a map (specific helper method for substitution-cipher)"
|
"Returns all the input values of a map (specific helper method for substitution-cipher)"
|
||||||
[i]
|
[i]
|
||||||
@ -21,7 +18,7 @@
|
|||||||
[i]
|
[i]
|
||||||
(vals (select-keys i [:output1])))
|
(vals (select-keys i [:output1])))
|
||||||
|
|
||||||
(def train-and-test-data (psb2/fetch-examples PSB2-path "substitution-cipher" 200 2000))
|
; (def train-and-test-data (psb2/fetch-examples PSB2-path "substitution-cipher" 200 2000))
|
||||||
|
|
||||||
(def instructions
|
(def instructions
|
||||||
(utils/not-lazy
|
(utils/not-lazy
|
||||||
@ -41,7 +38,7 @@
|
|||||||
(error-function argmap individual :train))
|
(error-function argmap individual :train))
|
||||||
([argmap individual subset]
|
([argmap individual subset]
|
||||||
(let [program (genome/plushy->push (:plushy individual) argmap)
|
(let [program (genome/plushy->push (:plushy individual) argmap)
|
||||||
data (get train-and-test-data subset)
|
data (get (get argmap :train-and-test-data) subset)
|
||||||
inputs (map (fn [i] (map-vals-input i)) data)
|
inputs (map (fn [i] (map-vals-input i)) data)
|
||||||
correct-outputs (map (fn [i] (map-vals-output i)) data)
|
correct-outputs (map (fn [i] (map-vals-output i)) data)
|
||||||
outputs (map (fn [input]
|
outputs (map (fn [input]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user