Remove rather than filling empty genes.
This commit is contained in:
parent
feb5a52d25
commit
d8402962f1
@ -12,7 +12,7 @@ They hold the genetic material for an `individual`. In the initial population, w
|
|||||||
#(utils/random-instruction instructions))]
|
#(utils/random-instruction instructions))]
|
||||||
(if bmx?
|
(if bmx?
|
||||||
(-> plushy
|
(-> plushy
|
||||||
(utils/fill-empty-genes instructions)
|
(utils/remove-empty-genes)
|
||||||
(utils/enforce-gene-length-limit bmx-gene-length-limit))
|
(utils/enforce-gene-length-limit bmx-gene-length-limit))
|
||||||
plushy)))
|
plushy)))
|
||||||
|
|
||||||
|
@ -198,17 +198,13 @@
|
|||||||
(+ (* 0.5 (metrics/multiset-distance p1 p2))
|
(+ (* 0.5 (metrics/multiset-distance p1 p2))
|
||||||
(math/abs (- (count p1) (count 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
|
"A utility function for bmx-related genetic operators. Returns the provided
|
||||||
plushy with any empty genes (regions before/between/after instances of :gap)
|
plushy with any empty genes (regions before/between/after instances of :gap)
|
||||||
filled with a new random instruction."
|
removed."
|
||||||
[plushy instructions]
|
[plushy]
|
||||||
(flatten (interpose :gap
|
(vec (flatten (interpose :gap (filter #(not (empty? %))
|
||||||
(mapv (fn [gene]
|
(extract-genes plushy))))))
|
||||||
(if (empty? gene)
|
|
||||||
(random-instruction instructions)
|
|
||||||
gene))
|
|
||||||
(extract-genes plushy)))))
|
|
||||||
|
|
||||||
(defn break-up
|
(defn break-up
|
||||||
"A utility function for bmx-related genetic operators. Returns the provided
|
"A utility function for bmx-related genetic operators. Returns the provided
|
||||||
|
@ -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)
|
(-> (bmx plushy1 plushy2 bmx-exchange-rate max-distance argmap)
|
||||||
(uniform-gap-addition gap-change-prob)
|
(uniform-gap-addition gap-change-prob)
|
||||||
(uniform-gap-deletion 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))))
|
(utils/enforce-gene-length-limit (:bmx-gene-length-limit argmap))))
|
||||||
;
|
;
|
||||||
:umad ;; uniform mutation by addition and deletion, see uniform-deletion for the
|
: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-gap-deletion gap-change-prob)
|
||||||
(uniform-addition (:instructions argmap) umad-rate)
|
(uniform-addition (:instructions argmap) umad-rate)
|
||||||
(uniform-deletion 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))))
|
(utils/enforce-gene-length-limit (:bmx-gene-length-limit argmap))))
|
||||||
;
|
;
|
||||||
:rumad ;; responsive UMAD, uses a deletion rate computed from the actual
|
:rumad ;; responsive UMAD, uses a deletion rate computed from the actual
|
||||||
|
Loading…
x
Reference in New Issue
Block a user