Use diploid operators when called for; fix bug in diploid-uniform-addition
This commit is contained in:
parent
67fcdb13b5
commit
4df6ea7fdd
@ -47,9 +47,10 @@
|
||||
existing instruction."
|
||||
[plushy instructions umad-rate]
|
||||
(flatten
|
||||
(map #(if (< (rand) umad-rate)
|
||||
(shuffle [% (repeatedly 2 #(utils/random-instruction instructions))])
|
||||
[%])
|
||||
(map (fn [pair]
|
||||
(if (< (rand) umad-rate)
|
||||
(shuffle [pair (repeatedly 2 #(utils/random-instruction instructions))])
|
||||
[pair]))
|
||||
(partition 2 plushy))))
|
||||
|
||||
(defn uniform-deletion
|
||||
@ -71,14 +72,17 @@
|
||||
individuals in the population."
|
||||
[pop argmap]
|
||||
{:plushy
|
||||
(let [prob (rand)]
|
||||
(let [prob (rand)
|
||||
[xover add del] (if (:diploid argmap)
|
||||
[diploid-crossover diploid-uniform-addition diploid-uniform-deletion]
|
||||
[crossover uniform-addition uniform-deletion])]
|
||||
(cond
|
||||
(< prob (:crossover (:variation argmap)))
|
||||
(crossover (:plushy (selection/select-parent pop argmap))
|
||||
(xover (:plushy (selection/select-parent pop argmap))
|
||||
(:plushy (selection/select-parent pop argmap)))
|
||||
(< prob (+ (:crossover (:variation argmap))
|
||||
(:umad (:variation argmap))))
|
||||
(uniform-deletion (uniform-addition (:plushy (selection/select-parent pop argmap))
|
||||
(del (add (:plushy (selection/select-parent pop argmap))
|
||||
(:instructions argmap)
|
||||
(:umad-rate argmap))
|
||||
(:umad-rate argmap))
|
||||
|
Loading…
x
Reference in New Issue
Block a user