Remove rather than filling empty genes.

This commit is contained in:
Lee Spector 2023-12-26 17:27:41 -05:00
parent feb5a52d25
commit d8402962f1
3 changed files with 8 additions and 12 deletions

View File

@ -12,7 +12,7 @@ They hold the genetic material for an `individual`. In the initial population, w
#(utils/random-instruction instructions))]
(if bmx?
(-> plushy
(utils/fill-empty-genes instructions)
(utils/remove-empty-genes)
(utils/enforce-gene-length-limit bmx-gene-length-limit))
plushy)))

View File

@ -198,17 +198,13 @@
(+ (* 0.5 (metrics/multiset-distance p1 p2))
(math/abs (- (count p1) (count p2)))))
(defn fill-empty-genes
(defn remove-empty-genes
"A utility function for bmx-related genetic operators. Returns the provided
plushy with any empty genes (regions before/between/after instances of :gap)
filled with a new random instruction."
[plushy instructions]
(flatten (interpose :gap
(mapv (fn [gene]
(if (empty? gene)
(random-instruction instructions)
gene))
(extract-genes plushy)))))
removed."
[plushy]
(vec (flatten (interpose :gap (filter #(not (empty? %))
(extract-genes plushy))))))
(defn break-up
"A utility function for bmx-related genetic operators. Returns the provided

View File

@ -244,7 +244,7 @@ The function `new-individual` returns a new individual produced by selection and
(-> (bmx plushy1 plushy2 bmx-exchange-rate max-distance argmap)
(uniform-gap-addition gap-change-prob)
(uniform-gap-deletion gap-change-prob)
(utils/fill-empty-genes (:instructions argmap))
(utils/remove-empty-genes)
(utils/enforce-gene-length-limit (:bmx-gene-length-limit argmap))))
;
:umad ;; uniform mutation by addition and deletion, see uniform-deletion for the
@ -277,7 +277,7 @@ The function `new-individual` returns a new individual produced by selection and
(uniform-gap-deletion gap-change-prob)
(uniform-addition (:instructions argmap) umad-rate)
(uniform-deletion umad-rate)
(utils/fill-empty-genes (:instructions argmap))
(utils/remove-empty-genes)
(utils/enforce-gene-length-limit (:bmx-gene-length-limit argmap))))
;
:rumad ;; responsive UMAD, uses a deletion rate computed from the actual