Add rumad variation
This commit is contained in:
parent
522ca181f9
commit
4c2db8a19a
4
.gitignore
vendored
4
.gitignore
vendored
@ -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
2
.idea/misc.xml
generated
@ -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>
|
@ -1,6 +1,6 @@
|
|||||||
(ns propeller.variation
|
(ns propeller.variation
|
||||||
(:require [propeller.selection :as selection]
|
(:require [propeller.selection :as selection]
|
||||||
[propeller.utils :as utils]))
|
[propeller.utils :as utils]))
|
||||||
|
|
||||||
(defn crossover
|
(defn crossover
|
||||||
"Crosses over two individuals using uniform crossover. Pads shorter one."
|
"Crosses over two individuals using uniform crossover. Pads shorter one."
|
||||||
@ -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]
|
||||||
(remove (fn [_] (< (rand)
|
(if (zero? umad-rate)
|
||||||
(/ 1 (+ 1 (/ 1 umad-rate)))))
|
plushy
|
||||||
plushy))
|
(remove (fn [_] (< (rand)
|
||||||
|
(/ 1 (+ 1 (/ 1 umad-rate)))))
|
||||||
|
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)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user