From ad20e435167b5589180fdff6d224c9184384f370 Mon Sep 17 00:00:00 2001 From: Lee Spector Date: Tue, 21 Nov 2023 16:23:26 -0500 Subject: [PATCH] Implement bmx-umad operator; allow collection for bmx-rate --- src/propeller/problems/boolean/mul3.cljc | 5 +++-- src/propeller/variation.cljc | 18 ++++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/propeller/problems/boolean/mul3.cljc b/src/propeller/problems/boolean/mul3.cljc index 17bbeba..2ca3353 100644 --- a/src/propeller/problems/boolean/mul3.cljc +++ b/src/propeller/problems/boolean/mul3.cljc @@ -310,9 +310,10 @@ :ah-umad-min 0.001 :ah-umad-max 0.5 :ah-umad-mean 0.01 - :variation {:ah-umad 0.9 + :variation {:ah-umad 0 :umad 0 - :bmx 0.1} + :bmx 0 + :bmx-umad 1} :single-thread-mode false :bmx-rate 0.1 :bmx-enrichment 10} diff --git a/src/propeller/variation.cljc b/src/propeller/variation.cljc index 3ae50c8..f4a92a8 100644 --- a/src/propeller/variation.cljc +++ b/src/propeller/variation.cljc @@ -251,17 +251,27 @@ The function `new-individual` returns a new individual produced by selection and (:plushy (selection/select-parent pop argmap)) (:plushy (selection/select-parent pop argmap))) ; - :bmx + :bmx ;; best match crossover (let [plushy1 (:plushy (selection/select-parent pop argmap)) - plushy2 (:plushy (selection/select-parent pop argmap))] - (bmx plushy1 plushy2 (or (:bmx-rate argmap) 0.5))) + plushy2 (:plushy (selection/select-parent pop argmap)) + rate (utils/onenum (or (:bmx-rate argmap) 0.5))] + (bmx plushy1 plushy2 rate)) ; - :umad ;; uniform mutation by addition and deleted, see uniform-deletion for the + :umad ;; uniform mutation by addition and deletion, see uniform-deletion for the ;; adjustment that makes this size neutral on average (let [rate (utils/onenum (:umad-rate argmap))] (-> (:plushy (selection/select-parent pop argmap)) (uniform-addition (:instructions argmap) rate) (uniform-deletion rate))) + ; + :bmx-umad ;; applies umad to the results of bmx + (let [umad-rate (utils/onenum (:umad-rate argmap))] + (-> (let [plushy1 (:plushy (selection/select-parent pop argmap)) + plushy2 (:plushy (selection/select-parent pop argmap)) + bmx-rate (utils/onenum (or (:bmx-rate argmap) 0.5))] + (bmx plushy1 plushy2 bmx-rate)) + (uniform-addition (:instructions argmap) umad-rate) + (uniform-deletion umad-rate))) ; :rumad ;; responsive UMAD, uses a deletion rate computed from the actual ;; number of additions made