Add uniform-replacement; pass argmap to plushy->push in report

This commit is contained in:
Lee Spector 2020-12-09 10:42:05 -05:00
parent 180a7fdbe0
commit 0af6aa095e
3 changed files with 22 additions and 8 deletions

View File

@ -19,7 +19,7 @@
(println " Report for Generation" generation)
(println "-------------------------------------------------------")
(print "Best plushy: ") (prn (:plushy best))
(print "Best program: ") (prn (genome/plushy->push (:plushy best)))
(print "Best program: ") (prn (genome/plushy->push (:plushy best) argmap))
(println "Best total error:" (:total-error best))
(println "Best errors:" (:errors best))
(println "Best behaviors:" (:behaviors best))

View File

@ -212,16 +212,18 @@
(gp/gp {:instructions propeller.problems.valiant/instructions
:error-function propeller.problems.valiant/error-function
:max-generations 500
:population-size 50
:max-initial-plushy-size 50
:step-limit 2000
:population-size 1000
:max-initial-plushy-size 10
:step-limit 1000
:parent-selection :lexicase
:tournament-size 2
:umad-rate 0.01
:replacement-rate 0.01
:diploid-flip-rate 0.01
:variation {:diploid-umad 0.5
:variation {:diploid-umad 0.25
:diploid-crossover 0.25
:diploid-flip 0.25
:uniform-replacement 0.25
}
:elitism false
:diploid true})

View File

@ -42,6 +42,15 @@
[%])
plushy)))
(defn uniform-replacement
"Returns plushy with new instructions possibly replacing existing
instructions."
[plushy instructions replacement-rate]
(map #(if (< (rand) replacement-rate)
(utils/random-instruction instructions)
%)
plushy))
(defn diploid-uniform-addition
"Returns plushy with new instructions possibly added before or after each
existing instruction."
@ -105,6 +114,10 @@
(-> (:plushy (selection/select-parent pop argmap))
(uniform-addition (:instructions argmap) (:umad-rate argmap)))
;
:uniform-replacement
(-> (:plushy (selection/select-parent pop argmap))
(uniform-replacement (:instructions argmap) (:replacement-rate argmap)))
;
:uniform-deletion
(-> (:plushy (selection/select-parent pop argmap))
(uniform-deletion (:umad-rate argmap)))
@ -138,4 +151,3 @@
(throw #?(:clj (Exception. (str "No match in new-individual for " op))
:cljs (js/Error
(str "No match in new-individual for " op))))))})