Add doc string and clean up names

This commit is contained in:
Lee Spector 2023-10-14 17:08:20 -04:00
parent a8d046e52e
commit 5103463cd8
2 changed files with 11 additions and 9 deletions

View File

@ -311,8 +311,9 @@
;:parent-selection :motley-batch-lexicase
;:max-batch-size [1 2 4 8 16 32 64 128 256]
;:tournament-size 5
:umad-rate 0.001 ;; ah-umad
:ah-umad-rate 0.1 ;; ah-umad
;:umad-rate 0.09
:ah-umad-protect-rate 0.001 ;; ah-umad
:ah-umad-vary-rate 0.1 ;; ah-umad
:ah-umad-tournament-size 2 ;; ah-umad
;:umad-rate [1/2
; 1/4 1/4

View File

@ -203,6 +203,8 @@ The function `new-individual` returns a new individual produced by selection and
(partition 2 plushy))))
(defn ah-rates
"Returns the sequence of rates with which each element of plushy should
be mutated when using autoconstructive hypervariability."
[plushy protect-rate hypervariable-rate]
(loop [i 0
protected true
@ -300,18 +302,17 @@ The function `new-individual` returns a new individual produced by selection and
(uniform-addition (:instructions argmap) rate)
(uniform-deletion rate)))
;
:ah-umad
(let [rate (utils/onenum (:umad-rate argmap))
ah-rate (utils/onenum (:ah-umad-rate argmap))
:ah-umad ;; autoconstructive hypervariability UMAD
(let [protect-rate (utils/onenum (:ah-umad-protect-rate argmap))
vary-rate (utils/onenum (:ah-umad-vary-rate argmap))
tourn-size (utils/onenum (:ah-umad-tournament-size argmap))
parent-genome (:plushy (selection/select-parent pop argmap))
offspring (repeatedly
tourn-size
#(-> parent-genome
(ah-uniform-addition (:instructions argmap) rate ah-rate)
(ah-uniform-deletion rate ah-rate)))
hypervariabilities (map #(reduce + (ah-rates % 0 1))
offspring)]
(ah-uniform-addition (:instructions argmap) protect-rate vary-rate)
(ah-uniform-deletion protect-rate vary-rate)))
hypervariabilities (map #(reduce + (ah-rates % 0 1)) offspring)]
(second (last (sort-by first (map vector hypervariabilities offspring)))))
;
:uniform-addition