Update string-classification for new problem specification scheme; remove unused PSB2 argmap items

This commit is contained in:
Lee Spector 2021-07-13 23:11:58 -04:00
parent 20be7c04e3
commit f94b991864
2 changed files with 33 additions and 33 deletions

View File

@ -27,9 +27,7 @@
:tournament-size 5 :tournament-size 5
:umad-rate 0.1 :umad-rate 0.1
:variation {:umad 0.5 :crossover 0.5} :variation {:umad 0.5 :crossover 0.5}
:elitism false :elitism false}
:PSB2-path ""
:PSB2-problem (clojure.string/replace (first args) #"PSB2." "")}
(eval-problem-var (first args) "arglist") (eval-problem-var (first args) "arglist")
(apply hash-map (apply hash-map
(map #(if (and (string? %) (not (.contains % "/"))) (read-string %) %) (map #(if (and (string? %) (not (.contains % "/"))) (read-string %) %)

View File

@ -40,8 +40,7 @@
"G" "G"
"T")) "T"))
(defn train-and-test-data (def train-and-test-data
[]
(let [train-inputs ["GCG" "GACAG" "AGAAG" "CCCA" "GATTACA" "TAGG" "GACT"] (let [train-inputs ["GCG" "GACAG" "AGAAG" "CCCA" "GATTACA" "TAGG" "GACT"]
test-inputs ["GCGT" "GACTTAG" "AGTAAG" "TCCTCA" "GAACA" "AGG" "GAC"]] test-inputs ["GCGT" "GACTTAG" "AGTAAG" "TCCTCA" "GAACA" "AGG" "GAC"]]
{:train {:inputs train-inputs {:train {:inputs train-inputs
@ -54,31 +53,34 @@
the program's selected behavior match, or 1 if they differ, or 1000000 if no the program's selected behavior match, or 1 if they differ, or 1000000 if no
behavior is produced. The behavior is here defined as the final top item on behavior is produced. The behavior is here defined as the final top item on
the BOOLEAN stack." the BOOLEAN stack."
([argmap individual] [argmap data individual]
(error-function argmap individual :train)) (let [program (genome/plushy->push (:plushy individual) argmap)
([argmap individual subset] inputs (:inputs data)
(let [program (genome/plushy->push (:plushy individual) argmap) correct-outputs (:outputs data)
data (get (train-and-test-data) subset) outputs (map (fn [input]
inputs (:inputs data) (state/peek-stack
correct-outputs (:outputs data) (interpreter/interpret-program
outputs (map (fn [input] program
(state/peek-stack (assoc state/empty-state :input {:in1 input})
(interpreter/interpret-program (:step-limit argmap))
program :boolean))
(assoc state/empty-state :input {:in1 input}) inputs)
(:step-limit argmap)) errors (map (fn [correct-output output]
:boolean)) (if (= output :no-stack-item)
inputs) 1000000
errors (map (fn [correct-output output] (if (= correct-output output)
(if (= output :no-stack-item) 0
1000000 1)))
(if (= correct-output output) correct-outputs
0 outputs)]
1))) (assoc individual
correct-outputs :behaviors outputs
outputs)] :errors errors
(assoc individual :total-error #?(:clj (apply +' errors)
:behaviors outputs :cljs (apply + errors)))))
:errors errors
:total-error #?(:clj (apply +' errors) (def arglist
:cljs (apply + errors)))))) {:instructions instructions
:error-function error-function
:training-data (:train train-and-test-data)
:testing-data (:test train-and-test-data)})