Rename :gene to :gap
This commit is contained in:
parent
30a87a2688
commit
a0bd993281
@ -48,8 +48,8 @@ They hold the genetic material for an `individual`. In the initial population, w
|
|||||||
(plushy->push plushy {}))
|
(plushy->push plushy {}))
|
||||||
;; call plushy->push-internal with possibly-preprocessed plushy
|
;; call plushy->push-internal with possibly-preprocessed plushy
|
||||||
([plushy argmap]
|
([plushy argmap]
|
||||||
(plushy->push-internal (if (or (> (or (:bmx (:variation argmap)) 0) 0) ;; must strip :gene
|
(plushy->push-internal (if (or (> (or (:bmx (:variation argmap)) 0) 0) ;; must strip :gap
|
||||||
(> (or (:bmx-umad (:variation argmap)) 0) 0)) ;; must strip :gene
|
(> (or (:bmx-umad (:variation argmap)) 0) 0)) ;; must strip :gap
|
||||||
(filter (complement #{:gene}) plushy)
|
(filter (complement #{:gap}) plushy)
|
||||||
plushy)
|
plushy)
|
||||||
argmap)))
|
argmap)))
|
@ -184,7 +184,7 @@
|
|||||||
n (:bmx-enrichment args)]
|
n (:bmx-enrichment args)]
|
||||||
(if (or (and prob-bmx (> prob-bmx 0))
|
(if (or (and prob-bmx (> prob-bmx 0))
|
||||||
(and prob-bmx-umad (> prob-bmx-umad 0)))
|
(and prob-bmx-umad (> prob-bmx-umad 0)))
|
||||||
(update args :instructions concat (repeat (or n 1) :gene))
|
(update args :instructions concat (repeat (or n 1) :gap))
|
||||||
args)))]
|
args)))]
|
||||||
(gp-loop (-> argmap
|
(gp-loop (-> argmap
|
||||||
(adjust-for-bmx)))))
|
(adjust-for-bmx)))))
|
||||||
|
@ -165,13 +165,13 @@
|
|||||||
|
|
||||||
(defn count-genes
|
(defn count-genes
|
||||||
"A utility for best match crossover (bmx). Returns the number of segments
|
"A utility for best match crossover (bmx). Returns the number of segments
|
||||||
between (and before and after) instances of :gene."
|
between (and before and after) instances of :gap."
|
||||||
[plushy]
|
[plushy]
|
||||||
(inc (count (filter #(= % :gene) plushy))))
|
(inc (count (filter #(= % :gap) plushy))))
|
||||||
|
|
||||||
(defn extract-genes
|
(defn extract-genes
|
||||||
"A utility for best match crossover (bmx). Returns the segments of the plushy
|
"A utility for best match crossover (bmx). Returns the segments of the plushy
|
||||||
before/between/after instances of :gene."
|
before/between/after instances of :gap."
|
||||||
[plushy]
|
[plushy]
|
||||||
(loop [genes []
|
(loop [genes []
|
||||||
current-gene []
|
current-gene []
|
||||||
@ -179,7 +179,7 @@
|
|||||||
(cond (empty? remainder)
|
(cond (empty? remainder)
|
||||||
(conj genes current-gene)
|
(conj genes current-gene)
|
||||||
;
|
;
|
||||||
(= (first remainder) :gene)
|
(= (first remainder) :gap)
|
||||||
(recur (conj genes current-gene)
|
(recur (conj genes current-gene)
|
||||||
[]
|
[]
|
||||||
(rest remainder))
|
(rest remainder))
|
||||||
|
@ -139,7 +139,7 @@ The function `new-individual` returns a new individual produced by selection and
|
|||||||
[plushy-a plushy-b rate]
|
[plushy-a plushy-b rate]
|
||||||
(let [a-genes (utils/extract-genes plushy-a)
|
(let [a-genes (utils/extract-genes plushy-a)
|
||||||
b-genes (utils/extract-genes plushy-b)]
|
b-genes (utils/extract-genes plushy-b)]
|
||||||
(flatten (interpose :gene
|
(flatten (interpose :gap
|
||||||
(mapv (fn [g]
|
(mapv (fn [g]
|
||||||
(if (< (rand) rate)
|
(if (< (rand) rate)
|
||||||
(apply min-key #(metrics/levenshtein-distance g %) b-genes)
|
(apply min-key #(metrics/levenshtein-distance g %) b-genes)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user