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 ;:parent-selection :motley-batch-lexicase
;:max-batch-size [1 2 4 8 16 32 64 128 256] ;:max-batch-size [1 2 4 8 16 32 64 128 256]
;:tournament-size 5 ;:tournament-size 5
:umad-rate 0.001 ;; ah-umad ;:umad-rate 0.09
:ah-umad-rate 0.1 ;; ah-umad :ah-umad-protect-rate 0.001 ;; ah-umad
:ah-umad-vary-rate 0.1 ;; ah-umad
:ah-umad-tournament-size 2 ;; ah-umad :ah-umad-tournament-size 2 ;; ah-umad
;:umad-rate [1/2 ;:umad-rate [1/2
; 1/4 1/4 ; 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)))) (partition 2 plushy))))
(defn ah-rates (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] [plushy protect-rate hypervariable-rate]
(loop [i 0 (loop [i 0
protected true protected true
@ -300,18 +302,17 @@ The function `new-individual` returns a new individual produced by selection and
(uniform-addition (:instructions argmap) rate) (uniform-addition (:instructions argmap) rate)
(uniform-deletion rate))) (uniform-deletion rate)))
; ;
:ah-umad :ah-umad ;; autoconstructive hypervariability UMAD
(let [rate (utils/onenum (:umad-rate argmap)) (let [protect-rate (utils/onenum (:ah-umad-protect-rate argmap))
ah-rate (utils/onenum (:ah-umad-rate argmap)) vary-rate (utils/onenum (:ah-umad-vary-rate argmap))
tourn-size (utils/onenum (:ah-umad-tournament-size argmap)) tourn-size (utils/onenum (:ah-umad-tournament-size argmap))
parent-genome (:plushy (selection/select-parent pop argmap)) parent-genome (:plushy (selection/select-parent pop argmap))
offspring (repeatedly offspring (repeatedly
tourn-size tourn-size
#(-> parent-genome #(-> parent-genome
(ah-uniform-addition (:instructions argmap) rate ah-rate) (ah-uniform-addition (:instructions argmap) protect-rate vary-rate)
(ah-uniform-deletion rate ah-rate))) (ah-uniform-deletion protect-rate vary-rate)))
hypervariabilities (map #(reduce + (ah-rates % 0 1)) hypervariabilities (map #(reduce + (ah-rates % 0 1)) offspring)]
offspring)]
(second (last (sort-by first (map vector hypervariabilities offspring))))) (second (last (sort-by first (map vector hypervariabilities offspring)))))
; ;
:uniform-addition :uniform-addition