Adding UMAD Rate and variation
Adding the ability for the user to modify the UMAD rate that controls the addition and deletion rates and the ability to specify the percentages of new individuals created bu UMAD or crossover
This commit is contained in:
parent
47f3c70b1d
commit
6f930841fc
@ -13,7 +13,9 @@
|
||||
:max-initial-plushy-size 50
|
||||
:step-limit 100
|
||||
:parent-selection :tournament
|
||||
:tournament-size 5}
|
||||
:tournament-size 5
|
||||
:UMADRate 0.2
|
||||
:variation {:UMAD 0.5 :crossover 0.5}}
|
||||
(apply hash-map
|
||||
(map read-string args)))
|
||||
[:error-function]
|
||||
|
@ -18,10 +18,10 @@
|
||||
(defn uniform-addition
|
||||
"Randomly adds new instructions before every instruction (and at the end of
|
||||
the plushy) with some probability."
|
||||
[plushy instructions]
|
||||
[plushy instructions UMADRate]
|
||||
(let [rand-code (repeatedly (inc (count plushy))
|
||||
(fn []
|
||||
(if (< (rand) 0.05)
|
||||
(if (< (rand) UMADRate)
|
||||
(rand-nth instructions)
|
||||
:mutation-padding)))]
|
||||
(remove #(= % :mutation-padding)
|
||||
@ -30,8 +30,8 @@
|
||||
|
||||
(defn uniform-deletion
|
||||
"Randomly deletes instructions from plushy at some rate."
|
||||
[plushy]
|
||||
(remove (fn [x] (< (rand) 0.05))
|
||||
[plushy UMADRate]
|
||||
(remove (fn [x] (< (rand) (/ 1(+ 1 (/ 1 UMADRate)))))
|
||||
plushy))
|
||||
|
||||
(defn new-individual
|
||||
@ -41,8 +41,10 @@
|
||||
{:plushy
|
||||
(let [prob (rand)]
|
||||
(cond
|
||||
(< prob 0.5) (crossover (:plushy (select-parent pop argmap))
|
||||
(:plushy (select-parent pop argmap)))
|
||||
(< prob 0.75) (uniform-addition (:plushy (select-parent pop argmap))
|
||||
(:instructions argmap))
|
||||
:else (uniform-deletion (:plushy (select-parent pop argmap)))))})
|
||||
(< prob (:crossover (:variation argmap))) (crossover (:plushy (select-parent pop argmap))
|
||||
(:plushy (select-parent pop argmap)))
|
||||
(< prob (+ (:crossover (:variation argmap)) (/ (:UMAD (:variation argmap)) 2))) (uniform-addition (:plushy (select-parent pop argmap))
|
||||
(:instructions argmap)
|
||||
(:UMADRate argmap))
|
||||
:else (uniform-deletion (:plushy (select-parent pop argmap))
|
||||
(:UMADRate argmap))))})
|
Loading…
x
Reference in New Issue
Block a user