Add :ssx-not-bmx as a temporary way to experiment with sequential segment crossover
This commit is contained in:
parent
d318d702ed
commit
1e29f88405
@ -178,22 +178,31 @@ 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)]
|
||||||
(flatten
|
(if (:ssx-not-bmx argmap)
|
||||||
(interpose :gap
|
(flatten (interpose :gap
|
||||||
(mapv (fn [a-gene]
|
(mapv (fn [a-gene b-gene]
|
||||||
(if (< (rand) rate)
|
(if (and b-gene
|
||||||
(let [match-info (map (fn [b-gene]
|
(< (rand) rate))
|
||||||
{:distance (bmx-distance a-gene b-gene)
|
b-gene
|
||||||
:gene b-gene})
|
a-gene))
|
||||||
b-genes)
|
a-genes
|
||||||
candidates (filter (fn [info]
|
(concat b-genes (repeat false)))))
|
||||||
(<= (:distance info) max-distance))
|
(flatten
|
||||||
match-info)]
|
(interpose :gap
|
||||||
(if (empty? candidates)
|
(mapv (fn [a-gene]
|
||||||
a-gene
|
(if (< (rand) rate)
|
||||||
(:gene (apply min-key :distance candidates))))
|
(let [match-info (map (fn [b-gene]
|
||||||
a-gene))
|
{:distance (bmx-distance a-gene b-gene)
|
||||||
a-genes)))))
|
:gene b-gene})
|
||||||
|
b-genes)
|
||||||
|
candidates (filter (fn [info]
|
||||||
|
(<= (:distance info) max-distance))
|
||||||
|
match-info)]
|
||||||
|
(if (empty? candidates)
|
||||||
|
a-gene
|
||||||
|
(:gene (apply min-key :distance candidates))))
|
||||||
|
a-gene))
|
||||||
|
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user