Add rumad variation

This commit is contained in:
klingliu 2021-06-29 12:15:37 -04:00
parent 522ca181f9
commit 4c2db8a19a
3 changed files with 21 additions and 7 deletions

4
.gitignore vendored
View File

@ -15,9 +15,11 @@ pom.xml.asc
out out
notes notes
.clj-kondo/ .clj-kondo/
.idea/
.calva/ .calva/
.lsp/ .lsp/
/.idea
/.idea/
/results
# Don't commit the data directory that we'll # Don't commit the data directory that we'll
# use to hold the data from # use to hold the data from

2
.idea/misc.xml generated
View File

@ -7,7 +7,7 @@
</list> </list>
</option> </option>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_13" project-jdk-name="13" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_13" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
</project> </project>

View File

@ -105,9 +105,11 @@
(defn uniform-deletion (defn uniform-deletion
"Randomly deletes instructions from plushy at some rate." "Randomly deletes instructions from plushy at some rate."
[plushy umad-rate] [plushy umad-rate]
(if (zero? umad-rate)
plushy
(remove (fn [_] (< (rand) (remove (fn [_] (< (rand)
(/ 1 (+ 1 (/ 1 umad-rate))))) (/ 1 (+ 1 (/ 1 umad-rate)))))
plushy)) plushy)))
(defn diploid-uniform-deletion (defn diploid-uniform-deletion
"Randomly deletes instructions from plushy at some rate." "Randomly deletes instructions from plushy at some rate."
@ -155,6 +157,16 @@
(uniform-addition (:instructions argmap) (:umad-rate argmap)) (uniform-addition (:instructions argmap) (:umad-rate argmap))
(uniform-deletion (: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 :uniform-addition
(-> (:plushy (selection/select-parent pop argmap)) (-> (:plushy (selection/select-parent pop argmap))
(uniform-addition (:instructions argmap) (:umad-rate argmap))) (uniform-addition (:instructions argmap) (:umad-rate argmap)))