Print average hypervariability when using autoconstructive hypervariability

This commit is contained in:
Lee Spector 2023-10-14 17:37:16 -04:00
parent 5103463cd8
commit 139e395f60

View File

@ -20,7 +20,8 @@
"Reports information for each generation." "Reports information for each generation."
[pop generation argmap] [pop generation argmap]
(let [best (first pop)] (let [best (first pop)]
(clojure.pprint/pprint {:generation generation (clojure.pprint/pprint
(merge {:generation generation
:best-plushy (:plushy best) :best-plushy (:plushy best)
:best-program (genome/plushy->push (:plushy best) argmap) :best-program (genome/plushy->push (:plushy best) argmap)
:best-total-error (:total-error best) :best-total-error (:total-error best)
@ -29,7 +30,18 @@
:genotypic-diversity (float (/ (count (distinct (map :plushy pop))) (count pop))) :genotypic-diversity (float (/ (count (distinct (map :plushy pop))) (count pop)))
:behavioral-diversity (float (/ (count (distinct (map :behaviors 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-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)))}
(if (> (or (:ah-umad (:variation argmap)) 0) 0) ;; using autoconstructive hypervariability
{:average-hypervariability
(let [variabilities (map (fn [i]
(let [p (:plushy i)]
(if (empty? p)
0
(/ (reduce + (variation/ah-rates p 0 1))
(count p)))))
pop)]
(float (/ (reduce + variabilities) (count variabilities))))}
{})))
(println))) (println)))
(defn gp (defn gp