Merge pull request #18 from klingliu/rumad

Add rumad variation
This commit is contained in:
Lee Spector 2021-06-29 15:39:34 -04:00 committed by GitHub
commit d0657c635d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 7 deletions

4
.gitignore vendored
View File

@ -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

2
.idea/misc.xml generated
View File

@ -7,7 +7,7 @@
</list>
</option>
</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" />
</component>
</project>

View File

@ -105,9 +105,11 @@
(defn uniform-deletion
"Randomly deletes instructions from plushy at some rate."
[plushy umad-rate]
(if (zero? umad-rate)
plushy
(remove (fn [_] (< (rand)
(/ 1 (+ 1 (/ 1 umad-rate)))))
plushy))
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)))