diff --git a/.gitignore b/.gitignore index 6368bff..676e68c 100644 --- a/.gitignore +++ b/.gitignore @@ -15,9 +15,11 @@ pom.xml.asc out notes .clj-kondo/ -.idea/ .calva/ .lsp/ +/.idea +/.idea/ +/results # Don't commit the data directory that we'll # use to hold the data from diff --git a/.idea/misc.xml b/.idea/misc.xml index 19c1bc7..bce9de7 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -7,7 +7,7 @@ - + \ No newline at end of file diff --git a/src/propeller/variation.cljc b/src/propeller/variation.cljc index 19578eb..51b0398 100755 --- a/src/propeller/variation.cljc +++ b/src/propeller/variation.cljc @@ -1,6 +1,6 @@ (ns propeller.variation - (:require [propeller.selection :as selection] - [propeller.utils :as utils])) + (:require [propeller.selection :as selection] + [propeller.utils :as utils])) (defn crossover "Crosses over two individuals using uniform crossover. Pads shorter one." @@ -105,9 +105,11 @@ (defn uniform-deletion "Randomly deletes instructions from plushy at some rate." [plushy umad-rate] - (remove (fn [_] (< (rand) - (/ 1 (+ 1 (/ 1 umad-rate))))) - plushy)) + (if (zero? umad-rate) + plushy + (remove (fn [_] (< (rand) + (/ 1 (+ 1 (/ 1 umad-rate))))) + plushy))) (defn diploid-uniform-deletion "Randomly deletes instructions from plushy at some rate." @@ -155,6 +157,16 @@ (uniform-addition (:instructions argmap) (:umad-rate argmap)) (uniform-deletion (:umad-rate argmap))) ; + :rumad + (let [parent-genome (:plushy (selection/select-parent pop argmap)) + after-addition (uniform-addition parent-genome + (:instructions argmap) + (:umad-rate argmap)) + effective-addition-rate (/ (- (count after-addition) + (count parent-genome)) + (count parent-genome))] + (uniform-deletion after-addition effective-addition-rate)) + ; :uniform-addition (-> (:plushy (selection/select-parent pop argmap)) (uniform-addition (:instructions argmap) (:umad-rate argmap)))