Resolve merge conflicts
This commit is contained in:
commit
f18dbeeafc
3
deps.edn
3
deps.edn
@ -3,7 +3,8 @@
|
|||||||
{org.clojure/clojure #:mvn{:version "1.10.0"},
|
{org.clojure/clojure #:mvn{:version "1.10.0"},
|
||||||
org.clojure/clojurescript #:mvn{:version "1.9.946"},
|
org.clojure/clojurescript #:mvn{:version "1.9.946"},
|
||||||
org.clojure/test.check #:mvn{:version "1.1.0"},
|
org.clojure/test.check #:mvn{:version "1.1.0"},
|
||||||
net.clojars.schneau/psb2 #:mvn{:version "1.1.1"}},
|
net.clojars.schneau/psb2 #:mvn{:version "1.1.1"}
|
||||||
|
org.clojure/data.csv #:mvn{:version "1.0.1"}},
|
||||||
:mvn/repos {}
|
:mvn/repos {}
|
||||||
:codox {:extra-deps {codox/codox {:mvn/version "0.10.8"}}
|
:codox {:extra-deps {codox/codox {:mvn/version "0.10.8"}}
|
||||||
:exec-fn codox.main/generate-docs
|
:exec-fn codox.main/generate-docs
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
(:require [psb2.core :as psb2]
|
(:require [psb2.core :as psb2]
|
||||||
[propeller.genome :as genome]
|
[propeller.genome :as genome]
|
||||||
[propeller.push.interpreter :as interpreter]
|
[propeller.push.interpreter :as interpreter]
|
||||||
[propeller.problems.data-creation :as dc]
|
|
||||||
[propeller.utils :as utils]
|
[propeller.utils :as utils]
|
||||||
[propeller.push.instructions :refer [def-instruction get-stack-instructions]]
|
[propeller.push.instructions :refer [def-instruction get-stack-instructions]]
|
||||||
[propeller.push.state :as state]
|
[propeller.push.state :as state]
|
||||||
|
@ -10,7 +10,6 @@ Source: https://arxiv.org/pdf/2106.06086.pdf"
|
|||||||
(:require [psb2.core :as psb2]
|
(:require [psb2.core :as psb2]
|
||||||
[propeller.genome :as genome]
|
[propeller.genome :as genome]
|
||||||
[propeller.push.interpreter :as interpreter]
|
[propeller.push.interpreter :as interpreter]
|
||||||
[propeller.problems.data-creation :as dc]
|
|
||||||
[propeller.utils :as utils]
|
[propeller.utils :as utils]
|
||||||
[propeller.push.instructions :refer [get-stack-instructions]]
|
[propeller.push.instructions :refer [get-stack-instructions]]
|
||||||
[propeller.push.state :as state]
|
[propeller.push.state :as state]
|
||||||
|
@ -11,7 +11,6 @@ Source: https://arxiv.org/pdf/2106.06086.pdf"
|
|||||||
(:require [psb2.core :as psb2]
|
(:require [psb2.core :as psb2]
|
||||||
[propeller.genome :as genome]
|
[propeller.genome :as genome]
|
||||||
[propeller.push.interpreter :as interpreter]
|
[propeller.push.interpreter :as interpreter]
|
||||||
[propeller.problems.data-creation :as dc]
|
|
||||||
[propeller.utils :as utils]
|
[propeller.utils :as utils]
|
||||||
[propeller.push.instructions :refer [get-stack-instructions]]
|
[propeller.push.instructions :refer [get-stack-instructions]]
|
||||||
[propeller.push.state :as state]
|
[propeller.push.state :as state]
|
||||||
|
@ -9,7 +9,6 @@ Source: https://arxiv.org/pdf/2106.06086.pdf"
|
|||||||
(:require [psb2.core :as psb2]
|
(:require [psb2.core :as psb2]
|
||||||
[propeller.genome :as genome]
|
[propeller.genome :as genome]
|
||||||
[propeller.push.interpreter :as interpreter]
|
[propeller.push.interpreter :as interpreter]
|
||||||
[propeller.problems.data-creation :as dc]
|
|
||||||
[propeller.utils :as utils]
|
[propeller.utils :as utils]
|
||||||
[propeller.push.instructions :refer [get-stack-instructions]]
|
[propeller.push.instructions :refer [get-stack-instructions]]
|
||||||
[propeller.push.state :as state]
|
[propeller.push.state :as state]
|
||||||
|
@ -315,8 +315,9 @@
|
|||||||
;:max-batch-size [1 2 4 8 16 32 64 128 256]
|
;:max-batch-size [1 2 4 8 16 32 64 128 256]
|
||||||
;:tournament-size 5
|
;:tournament-size 5
|
||||||
;:umad-rate 0.09
|
;:umad-rate 0.09
|
||||||
:ah-umad-protection 100 ;; ah-umad
|
:ah-umad-min 0.01
|
||||||
:ah-umad-rate 0.01 ;; ah-umad
|
:ah-umad-max 0.5
|
||||||
|
:ah-umad-mean 0.05
|
||||||
;:umad-rate [1/2
|
;:umad-rate [1/2
|
||||||
; 1/4 1/4
|
; 1/4 1/4
|
||||||
; 1/8 1/8 1/8
|
; 1/8 1/8 1/8
|
||||||
|
@ -202,50 +202,45 @@ The function `new-individual` returns a new individual produced by selection and
|
|||||||
%)
|
%)
|
||||||
(partition 2 plushy))))
|
(partition 2 plushy))))
|
||||||
|
|
||||||
(defn with-mean
|
(defn ah-normalize
|
||||||
"Returns numeric vector v scaled so that the mean value is m"
|
"Takes a vector of :protect and :vary and returns a numeric vector
|
||||||
[m v]
|
that conforms to the specified min, max, and mean."
|
||||||
(if (empty? v)
|
[v ah-min ah-max ah-mean]
|
||||||
v
|
(let [c (count v)
|
||||||
(let [initial-mean (/ (reduce + v) (count v))]
|
protect-count (count (filter #(= % :protected) v))
|
||||||
(map #(* m (/ % initial-mean)) v))))
|
vary-count (- c protect-count)
|
||||||
|
extremes (mapv #(if (= % :protect) ah-min ah-max) v)
|
||||||
;;; version of ah-rates in which boundaries of hypervariable segments are protected
|
mean-of-extremes (/ (reduce + extremes) (count extremes))]
|
||||||
;;; retained for experimentation
|
(cond
|
||||||
;; (defn ah-rates
|
;; all :vary or all :protect, return all ah-mean
|
||||||
;; "Returns the sequence of rates with which each element of plushy should
|
(or (zero? protect-count) (zero? vary-count))
|
||||||
;; be mutated when using autoconstructive hypervariability."
|
(repeat (count v) ah-mean)
|
||||||
;; [plushy protection rate]
|
;; mean is too high, lower high values from max
|
||||||
;; (loop [i 0
|
(> mean-of-extremes ah-mean)
|
||||||
;; protected true
|
(let [lowered (/ (- (* ah-mean c)
|
||||||
;; rates []
|
(* ah-min protect-count))
|
||||||
;; remainder plushy]
|
vary-count)]
|
||||||
;; (if (empty? remainder)
|
(mapv #(if (= % ah-max) lowered %) extremes))
|
||||||
;; (with-mean rate rates)
|
;; mean is too low, raise low values from min
|
||||||
;; (if (and (not protected)
|
(> mean-of-extremes ah-mean)
|
||||||
;; (= (first remainder) :protect))
|
(let [raised (/ (- (* ah-mean c)
|
||||||
;; (recur i
|
(* ah-max vary-count))
|
||||||
;; true
|
protect-count)]
|
||||||
;; rates
|
(mapv #(if (= % ah-min) raised %) extremes))
|
||||||
;; remainder)
|
;; mean is just right, return extremes
|
||||||
;; (recur (inc i)
|
:else
|
||||||
;; (if protected
|
extremes)))
|
||||||
;; (not= (first remainder) :vary)
|
|
||||||
;; false)
|
|
||||||
;; (conj rates (if protected (/ 1 protection) 1))
|
|
||||||
;; (rest remainder))))))
|
|
||||||
|
|
||||||
(defn ah-rates
|
(defn ah-rates
|
||||||
"Returns the sequence of rates with which each element of plushy should
|
"Returns the sequence of rates with which each element of plushy should
|
||||||
be mutated when using autoconstructive hypervariability. Boundaries of
|
be mutated when using autoconstructive hypervariability."
|
||||||
hypervariable segments are hypervariable."
|
[plushy ah-min ah-max ah-mean]
|
||||||
[plushy protection rate]
|
|
||||||
(loop [i 0
|
(loop [i 0
|
||||||
protected true
|
protected true
|
||||||
rates []
|
rates []
|
||||||
remainder plushy]
|
remainder plushy]
|
||||||
(if (empty? remainder)
|
(if (empty? remainder)
|
||||||
(with-mean rate rates)
|
(ah-normalize rates ah-min ah-max ah-mean)
|
||||||
(if (and (not protected)
|
(if (and (not protected)
|
||||||
(= (first remainder) :protect))
|
(= (first remainder) :protect))
|
||||||
(recur (inc i)
|
(recur (inc i)
|
||||||
@ -256,29 +251,24 @@ The function `new-individual` returns a new individual produced by selection and
|
|||||||
(if protected
|
(if protected
|
||||||
(not= (first remainder) :vary)
|
(not= (first remainder) :vary)
|
||||||
false)
|
false)
|
||||||
(conj rates (if (and protected
|
(conj rates (if protected :protect :vary))
|
||||||
(not= (first remainder) :vary))
|
|
||||||
(/ 1 protection)
|
|
||||||
1))
|
|
||||||
(rest remainder))))))
|
(rest remainder))))))
|
||||||
|
|
||||||
;(ah-rates [0 0 :vary 0 :protect 0 0 :protect :vary] 10 0.1)
|
|
||||||
|
|
||||||
(defn ah-uniform-addition
|
(defn ah-uniform-addition
|
||||||
"Returns plushy with new instructions possibly added before or after each
|
"Returns plushy with new instructions possibly added before or after each
|
||||||
existing instruction. Rates are autoconstructively hypervariable."
|
existing instruction. Rates are autoconstructively hypervariable."
|
||||||
[plushy instructions protection rate]
|
[plushy instructions ah-min ah-max ah-mean]
|
||||||
(apply concat
|
(apply concat
|
||||||
(mapv #(if (< (rand) %2)
|
(mapv #(if (< (rand) %2)
|
||||||
(shuffle [%1 (utils/random-instruction instructions)])
|
(shuffle [%1 (utils/random-instruction instructions)])
|
||||||
[%1])
|
[%1])
|
||||||
plushy
|
plushy
|
||||||
(ah-rates plushy protection rate))))
|
(ah-rates plushy ah-min ah-max ah-mean))))
|
||||||
|
|
||||||
(defn ah-uniform-deletion
|
(defn ah-uniform-deletion
|
||||||
"Randomly deletes instructions from plushy at some rate.
|
"Randomly deletes instructions from plushy at some rate.
|
||||||
Rates are autoconstructively hypervariable."
|
Rates are autoconstructively hypervariable."
|
||||||
[plushy protection rate]
|
[plushy ah-min ah-max ah-mean]
|
||||||
(mapv first
|
(mapv first
|
||||||
(remove (fn [[_ rate]]
|
(remove (fn [[_ rate]]
|
||||||
(< (rand)
|
(< (rand)
|
||||||
@ -287,7 +277,7 @@ The function `new-individual` returns a new individual produced by selection and
|
|||||||
(/ 1 (+ 1 (/ 1 rate))))))
|
(/ 1 (+ 1 (/ 1 rate))))))
|
||||||
(mapv vector
|
(mapv vector
|
||||||
plushy
|
plushy
|
||||||
(ah-rates plushy protection rate)))))
|
(ah-rates plushy ah-min ah-max ah-mean)))))
|
||||||
|
|
||||||
(defn new-individual
|
(defn new-individual
|
||||||
"Returns a new individual produced by selection and variation of
|
"Returns a new individual produced by selection and variation of
|
||||||
@ -344,12 +334,13 @@ The function `new-individual` returns a new individual produced by selection and
|
|||||||
(uniform-deletion rate)))
|
(uniform-deletion rate)))
|
||||||
;
|
;
|
||||||
:ah-umad ;; autoconstructive hypervariability UMAD
|
:ah-umad ;; autoconstructive hypervariability UMAD
|
||||||
(let [protection (utils/onenum (:ah-umad-protection argmap))
|
(let [ah-min (utils/onenum (:ah-umad-min argmap))
|
||||||
rate (utils/onenum (:ah-umad-rate argmap))
|
ah-max (utils/onenum (:ah-umad-max argmap))
|
||||||
|
ah-mean (utils/onenum (:ah-umad-mean argmap))
|
||||||
parent-genome (:plushy (selection/select-parent pop argmap))]
|
parent-genome (:plushy (selection/select-parent pop argmap))]
|
||||||
(-> parent-genome
|
(-> parent-genome
|
||||||
(ah-uniform-addition (:instructions argmap) protection rate)
|
(ah-uniform-addition (:instructions argmap) ah-min ah-max ah-mean)
|
||||||
(ah-uniform-deletion protection rate)))
|
(ah-uniform-deletion ah-min ah-max ah-mean)))
|
||||||
;
|
;
|
||||||
:uniform-addition
|
:uniform-addition
|
||||||
(-> (:plushy (selection/select-parent pop argmap))
|
(-> (:plushy (selection/select-parent pop argmap))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user