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 {}))
|
||||
;; call plushy->push-internal with possibly-preprocessed plushy
|
||||
([plushy argmap]
|
||||
(plushy->push-internal (if (or (> (or (:bmx (:variation argmap)) 0) 0) ;; must strip :gene
|
||||
(> (or (:bmx-umad (:variation argmap)) 0) 0)) ;; must strip :gene
|
||||
(filter (complement #{:gene}) plushy)
|
||||
(plushy->push-internal (if (or (> (or (:bmx (:variation argmap)) 0) 0) ;; must strip :gap
|
||||
(> (or (:bmx-umad (:variation argmap)) 0) 0)) ;; must strip :gap
|
||||
(filter (complement #{:gap}) plushy)
|
||||
plushy)
|
||||
argmap)))
|
@ -184,7 +184,7 @@
|
||||
n (:bmx-enrichment args)]
|
||||
(if (or (and prob-bmx (> prob-bmx 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)))]
|
||||
(gp-loop (-> argmap
|
||||
(adjust-for-bmx)))))
|
||||
|
@ -165,13 +165,13 @@
|
||||
|
||||
(defn count-genes
|
||||
"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]
|
||||
(inc (count (filter #(= % :gene) plushy))))
|
||||
(inc (count (filter #(= % :gap) plushy))))
|
||||
|
||||
(defn extract-genes
|
||||
"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]
|
||||
(loop [genes []
|
||||
current-gene []
|
||||
@ -179,7 +179,7 @@
|
||||
(cond (empty? remainder)
|
||||
(conj genes current-gene)
|
||||
;
|
||||
(= (first remainder) :gene)
|
||||
(= (first remainder) :gap)
|
||||
(recur (conj genes current-gene)
|
||||
[]
|
||||
(rest remainder))
|
||||
|
@ -139,7 +139,7 @@ The function `new-individual` returns a new individual produced by selection and
|
||||
[plushy-a plushy-b rate]
|
||||
(let [a-genes (utils/extract-genes plushy-a)
|
||||
b-genes (utils/extract-genes plushy-b)]
|
||||
(flatten (interpose :gene
|
||||
(flatten (interpose :gap
|
||||
(mapv (fn [g]
|
||||
(if (< (rand) rate)
|
||||
(apply min-key #(metrics/levenshtein-distance g %) b-genes)
|
||||
|
Loading…
x
Reference in New Issue
Block a user