Update bouncing-balls for new problem specification scheme

This commit is contained in:
Lee Spector 2021-07-13 22:31:59 -04:00
parent a571524dab
commit 5aaf914316
2 changed files with 61 additions and 55 deletions

View File

@ -36,7 +36,7 @@
(list random-int -1 0 1 []))))
(defn error-function
([argmap data individual]
[argmap data individual]
(let [program (genome/plushy->push (:plushy individual) argmap)
inputs (map (fn [i] (get i :input1)) data)
correct-outputs (map (fn [i] (get i :output1)) data)
@ -58,7 +58,7 @@
:behaviors outputs
:errors errors
:total-error #?(:clj (apply +' errors)
:cljs (apply + errors))))))
:cljs (apply + errors)))))
(def arglist
{:instructions instructions

View File

@ -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]
[psb2.core :as psb2]))
; =========== PROBLEM DESCRIPTION ===============================
; BOUNCING BALLS from PSB2
@ -19,6 +20,8 @@
; Source: https://arxiv.org/pdf/2106.06086.pdf
; ==================================================================
(def train-and-test-data (psb2/fetch-examples "data" "bouncing-balls" 200 2000))
(defn map-vals-input
"Returns all the input values of a map (specific helper method for bouncing-balls)"
[i]
@ -42,11 +45,8 @@
(list 0.0 1.0 2.0))))
(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 (get argmap :train-and-test-data) subset)
inputs (map (fn [i] (map-vals-input i)) data)
correct-outputs (map (fn [i] (map-vals-output i)) data)
outputs (map (fn [input]
@ -69,4 +69,10 @@
:behaviors outputs
:errors errors
:total-error #?(:clj (apply +' errors)
:cljs (apply + errors))))))
:cljs (apply + errors)))))
(def arglist
{:instructions instructions
:error-function error-function
:training-data (:train train-and-test-data)
:testing-data (:test train-and-test-data)})