Add :ssx-not-bmx as a temporary way to experiment with sequential segment crossover

This commit is contained in:
Lee Spector 2023-12-14 19:18:43 -08:00
parent d318d702ed
commit 1e29f88405

View File

@ -178,6 +178,15 @@ The function `new-individual` returns a new individual produced by selection and
[plushy-a plushy-b rate max-distance argmap] [plushy-a plushy-b rate max-distance argmap]
(let [a-genes (utils/extract-genes plushy-a) (let [a-genes (utils/extract-genes plushy-a)
b-genes (utils/extract-genes plushy-b)] b-genes (utils/extract-genes plushy-b)]
(if (:ssx-not-bmx argmap)
(flatten (interpose :gap
(mapv (fn [a-gene b-gene]
(if (and b-gene
(< (rand) rate))
b-gene
a-gene))
a-genes
(concat b-genes (repeat false)))))
(flatten (flatten
(interpose :gap (interpose :gap
(mapv (fn [a-gene] (mapv (fn [a-gene]
@ -193,7 +202,7 @@ The function `new-individual` returns a new individual produced by selection and
a-gene a-gene
(:gene (apply min-key :distance candidates)))) (:gene (apply min-key :distance candidates))))
a-gene)) a-gene))
a-genes))))) a-genes))))))
(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