From d81a9ae3b666b6707593ad1a4a5cd525b2a24645 Mon Sep 17 00:00:00 2001 From: Lee Spector Date: Mon, 20 Nov 2023 20:25:42 -0500 Subject: [PATCH] Rename autoconstructive-crossover bmx, for best match crossover --- src/propeller/genome.cljc | 2 +- src/propeller/gp.cljc | 8 ++++---- src/propeller/problems/boolean/mul3.cljc | 4 ++-- src/propeller/variation.cljc | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/propeller/genome.cljc b/src/propeller/genome.cljc index 14d1b28..7b72c88 100755 --- a/src/propeller/genome.cljc +++ b/src/propeller/genome.cljc @@ -49,7 +49,7 @@ They hold the genetic material for an `individual`. In the initial population, w ;; call plushy->push-internal with possibly-preprocessed plushy ([plushy argmap] (plushy->push-internal (if (or (> (or (:ah-umad (:variation argmap)) 0) 0) ;; must strip :vary and :protect - (> (or (:autoconstructive-crossover (:variation argmap)) 0) 0)) ;; must strip :gene + (> (or (:bmx (:variation argmap)) 0) 0)) ;; must strip :gene (filter (complement #{:vary :protect :gene}) plushy) plushy) argmap))) \ No newline at end of file diff --git a/src/propeller/gp.cljc b/src/propeller/gp.cljc index 7855a67..c593e9d 100644 --- a/src/propeller/gp.cljc +++ b/src/propeller/gp.cljc @@ -143,10 +143,10 @@ (defn gp "Top-level gp function. Calls gp-loop with possibly-adjusted arguments." [argmap] - (let [adjust-for-autoconstructive-crossover + (let [adjust-for-bmx (fn [args] - (let [prob (:autoconstructive-crossover (:variation args)) - n (:autoconstructive-crossover-enrichment args)] + (let [prob (:bmx (:variation args)) + n (:bmx-enrichment args)] (if (and prob (> prob 0)) (update args :instructions concat (repeat (or n 1) :gene)) args))) @@ -159,5 +159,5 @@ (update args :instructions concat (flatten (repeat (or n 1) [:vary :protect]))) args)))] (gp-loop (-> argmap - (adjust-for-autoconstructive-crossover) + (adjust-for-bmx) (adjust-for-ah-umad))))) \ No newline at end of file diff --git a/src/propeller/problems/boolean/mul3.cljc b/src/propeller/problems/boolean/mul3.cljc index 6dd29ec..5149c89 100644 --- a/src/propeller/problems/boolean/mul3.cljc +++ b/src/propeller/problems/boolean/mul3.cljc @@ -312,7 +312,7 @@ :ah-umad-mean 0.01 :variation {:ah-umad 0.9 :umad 0 - :autoconstructive-crossover 0.1} + :bmx 0.1} :single-thread-mode false - :autoconstructive-crossover-enrichment 10} + :bmx-enrichment 10} (apply hash-map (map #(if (string? %) (read-string %) %) args))))) diff --git a/src/propeller/variation.cljc b/src/propeller/variation.cljc index fb8d8a5..7d24752 100644 --- a/src/propeller/variation.cljc +++ b/src/propeller/variation.cljc @@ -239,7 +239,7 @@ The function `new-individual` returns a new individual produced by selection and (conj current-gene (first remainder)) (rest remainder))))) -(defn autoconstructive-crossover +(defn bmx "Crosses over two plushies using autoconstructive crossover, one Push instruction at a time." [plushy-a plushy-b] (let [a-genes (extract-genes plushy-a) @@ -277,10 +277,10 @@ The function `new-individual` returns a new individual produced by selection and (:plushy (selection/select-parent pop argmap)) (:plushy (selection/select-parent pop argmap))) ; - :autoconstructive-crossover + :bmx (let [plushy1 (:plushy (selection/select-parent pop argmap)) plushy2 (:plushy (selection/select-parent pop argmap))] - (autoconstructive-crossover plushy1 plushy2)) + (bmx plushy1 plushy2)) ; :umad ;; uniform mutation by addition and deleted, see uniform-deletion for the ;; adjustment that makes this size neutral on average