Rename autoconstructive-crossover bmx, for best match crossover

This commit is contained in:
Lee Spector 2023-11-20 20:25:42 -05:00
parent 30daac848a
commit d81a9ae3b6
4 changed files with 10 additions and 10 deletions

View File

@ -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 ;; call plushy->push-internal with possibly-preprocessed plushy
([plushy argmap] ([plushy argmap]
(plushy->push-internal (if (or (> (or (:ah-umad (:variation argmap)) 0) 0) ;; must strip :vary and :protect (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) (filter (complement #{:vary :protect :gene}) plushy)
plushy) plushy)
argmap))) argmap)))

View File

@ -143,10 +143,10 @@
(defn gp (defn gp
"Top-level gp function. Calls gp-loop with possibly-adjusted arguments." "Top-level gp function. Calls gp-loop with possibly-adjusted arguments."
[argmap] [argmap]
(let [adjust-for-autoconstructive-crossover (let [adjust-for-bmx
(fn [args] (fn [args]
(let [prob (:autoconstructive-crossover (:variation args)) (let [prob (:bmx (:variation args))
n (:autoconstructive-crossover-enrichment args)] n (:bmx-enrichment args)]
(if (and prob (> prob 0)) (if (and prob (> prob 0))
(update args :instructions concat (repeat (or n 1) :gene)) (update args :instructions concat (repeat (or n 1) :gene))
args))) args)))
@ -159,5 +159,5 @@
(update args :instructions concat (flatten (repeat (or n 1) [:vary :protect]))) (update args :instructions concat (flatten (repeat (or n 1) [:vary :protect])))
args)))] args)))]
(gp-loop (-> argmap (gp-loop (-> argmap
(adjust-for-autoconstructive-crossover) (adjust-for-bmx)
(adjust-for-ah-umad))))) (adjust-for-ah-umad)))))

View File

@ -312,7 +312,7 @@
:ah-umad-mean 0.01 :ah-umad-mean 0.01
:variation {:ah-umad 0.9 :variation {:ah-umad 0.9
:umad 0 :umad 0
:autoconstructive-crossover 0.1} :bmx 0.1}
:single-thread-mode false :single-thread-mode false
:autoconstructive-crossover-enrichment 10} :bmx-enrichment 10}
(apply hash-map (map #(if (string? %) (read-string %) %) args))))) (apply hash-map (map #(if (string? %) (read-string %) %) args)))))

View File

@ -239,7 +239,7 @@ The function `new-individual` returns a new individual produced by selection and
(conj current-gene (first remainder)) (conj current-gene (first remainder))
(rest remainder))))) (rest remainder)))))
(defn autoconstructive-crossover (defn bmx
"Crosses over two plushies using autoconstructive crossover, one Push instruction at a time." "Crosses over two plushies using autoconstructive crossover, one Push instruction at a time."
[plushy-a plushy-b] [plushy-a plushy-b]
(let [a-genes (extract-genes plushy-a) (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))
(:plushy (selection/select-parent pop argmap))) (:plushy (selection/select-parent pop argmap)))
; ;
:autoconstructive-crossover :bmx
(let [plushy1 (:plushy (selection/select-parent pop argmap)) (let [plushy1 (:plushy (selection/select-parent pop argmap))
plushy2 (: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 :umad ;; uniform mutation by addition and deleted, see uniform-deletion for the
;; adjustment that makes this size neutral on average ;; adjustment that makes this size neutral on average