diff --git a/src/propeller/problems/boolean/mul3.cljc b/src/propeller/problems/boolean/mul3.cljc index 5149c89..17bbeba 100644 --- a/src/propeller/problems/boolean/mul3.cljc +++ b/src/propeller/problems/boolean/mul3.cljc @@ -314,5 +314,6 @@ :umad 0 :bmx 0.1} :single-thread-mode false - :bmx-enrichment 10} + :bmx-rate 0.1 + :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 7d24752..eab7197 100644 --- a/src/propeller/variation.cljc +++ b/src/propeller/variation.cljc @@ -214,13 +214,13 @@ The function `new-individual` returns a new individual produced by selection and (ah-rates plushy ah-min ah-max ah-mean))))) (defn count-genes - "A utility for autoconstructive crossover. Returns the number of segments + "A utility for best match crossover (bmx). Returns the number of segments between (and before and after) instances of :gene." [plushy] (inc (count (filter #(= % :gene) plushy)))) (defn extract-genes - "A utility for autoconstructive crossover. Returns the segments of the plushy + "A utility for best match crossover (bmx). Returns the segments of the plushy before/between/after instances of :gene." [plushy] (loop [genes [] @@ -240,15 +240,15 @@ The function `new-individual` returns a new individual produced by selection and (rest remainder))))) (defn bmx - "Crosses over two plushies using autoconstructive crossover, one Push instruction at a time." - [plushy-a plushy-b] + "Crosses over two plushies using best match crossover (bmx)." + [plushy-a plushy-b rate] (let [a-genes (extract-genes plushy-a) b-genes (extract-genes plushy-b)] (flatten (interpose :gene (mapv (fn [g] - (if (< (rand) 0.5) - g - (apply min-key #(metrics/levenshtein-distance g %) b-genes))) + (if (< (rand) rate) + (apply min-key #(metrics/levenshtein-distance g %) b-genes) + g)) a-genes))))) (defn new-individual @@ -280,7 +280,7 @@ The function `new-individual` returns a new individual produced by selection and :bmx (let [plushy1 (:plushy (selection/select-parent pop argmap)) plushy2 (:plushy (selection/select-parent pop argmap))] - (bmx plushy1 plushy2)) + (bmx plushy1 plushy2 (or (:bmx-rate argmap) 0.5))) ; :umad ;; uniform mutation by addition and deleted, see uniform-deletion for the ;; adjustment that makes this size neutral on average