Add uniform-replacement; pass argmap to plushy->push in report
This commit is contained in:
parent
180a7fdbe0
commit
0af6aa095e
@ -19,7 +19,7 @@
|
|||||||
(println " Report for Generation" generation)
|
(println " Report for Generation" generation)
|
||||||
(println "-------------------------------------------------------")
|
(println "-------------------------------------------------------")
|
||||||
(print "Best plushy: ") (prn (:plushy best))
|
(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 total error:" (:total-error best))
|
||||||
(println "Best errors:" (:errors best))
|
(println "Best errors:" (:errors best))
|
||||||
(println "Best behaviors:" (:behaviors best))
|
(println "Best behaviors:" (:behaviors best))
|
||||||
|
@ -212,16 +212,18 @@
|
|||||||
(gp/gp {:instructions propeller.problems.valiant/instructions
|
(gp/gp {:instructions propeller.problems.valiant/instructions
|
||||||
:error-function propeller.problems.valiant/error-function
|
:error-function propeller.problems.valiant/error-function
|
||||||
:max-generations 500
|
:max-generations 500
|
||||||
:population-size 50
|
:population-size 1000
|
||||||
:max-initial-plushy-size 50
|
:max-initial-plushy-size 10
|
||||||
:step-limit 2000
|
:step-limit 1000
|
||||||
:parent-selection :lexicase
|
:parent-selection :lexicase
|
||||||
:tournament-size 2
|
:tournament-size 2
|
||||||
:umad-rate 0.01
|
:umad-rate 0.01
|
||||||
|
:replacement-rate 0.01
|
||||||
:diploid-flip-rate 0.01
|
:diploid-flip-rate 0.01
|
||||||
:variation {:diploid-umad 0.5
|
:variation {:diploid-umad 0.25
|
||||||
:diploid-crossover 0.25
|
:diploid-crossover 0.25
|
||||||
:diploid-flip 0.25
|
:diploid-flip 0.25
|
||||||
|
:uniform-replacement 0.25
|
||||||
}
|
}
|
||||||
:elitism false
|
:elitism false
|
||||||
:diploid true})
|
:diploid true})
|
||||||
|
@ -42,6 +42,15 @@
|
|||||||
[%])
|
[%])
|
||||||
plushy)))
|
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
|
(defn diploid-uniform-addition
|
||||||
"Returns plushy with new instructions possibly added before or after each
|
"Returns plushy with new instructions possibly added before or after each
|
||||||
existing instruction."
|
existing instruction."
|
||||||
@ -105,6 +114,10 @@
|
|||||||
(-> (:plushy (selection/select-parent pop argmap))
|
(-> (:plushy (selection/select-parent pop argmap))
|
||||||
(uniform-addition (:instructions argmap) (:umad-rate 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
|
:uniform-deletion
|
||||||
(-> (:plushy (selection/select-parent pop argmap))
|
(-> (:plushy (selection/select-parent pop argmap))
|
||||||
(uniform-deletion (:umad-rate argmap)))
|
(uniform-deletion (:umad-rate argmap)))
|
||||||
@ -138,4 +151,3 @@
|
|||||||
(throw #?(:clj (Exception. (str "No match in new-individual for " op))
|
(throw #?(:clj (Exception. (str "No match in new-individual for " op))
|
||||||
:cljs (js/Error
|
:cljs (js/Error
|
||||||
(str "No match in new-individual for " op))))))})
|
(str "No match in new-individual for " op))))))})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user