Add autoconstructive-crossover
This commit is contained in:
parent
f9f1a9e22b
commit
ac3690837d
@ -314,7 +314,7 @@
|
||||
;:parent-selection :motley-batch-lexicase
|
||||
;:max-batch-size [1 2 4 8 16 32 64 128 256]
|
||||
;:tournament-size 5
|
||||
;:umad-rate 0.09
|
||||
:umad-rate 0.09
|
||||
;:ah-umad-min 0.01
|
||||
;:ah-umad-max 0.5
|
||||
;:ah-umad-mean 0.05
|
||||
|
@ -279,6 +279,22 @@ The function `new-individual` returns a new individual produced by selection and
|
||||
plushy
|
||||
(ah-rates plushy ah-min ah-max ah-mean)))))
|
||||
|
||||
(defn autoconstructive-crossover
|
||||
"Crosses over two individuals using autoconstructive crossover, one Push instruction at a time.
|
||||
Pads shorter one from the end of the list of instructions."
|
||||
[plushy-a plushy-b]
|
||||
(let [a-genes (partition-by #(= % :gene) plushy-a)
|
||||
b-genes (partition-by #(= % :gene) plushy-b)
|
||||
shorter (min-key count a-genes b-genes)
|
||||
longer (if (= shorter a-genes)
|
||||
b-genes
|
||||
a-genes)
|
||||
length-diff (- (count longer) (count shorter))
|
||||
shorter-padded (concat shorter (repeat length-diff ()))]
|
||||
(flatten (mapv #(if (< (rand) 0.5) %1 %2)
|
||||
shorter-padded
|
||||
longer))))
|
||||
|
||||
(defn new-individual
|
||||
"Returns a new individual produced by selection and variation of
|
||||
individuals in the population."
|
||||
@ -306,6 +322,11 @@ The function `new-individual` returns a new individual produced by selection and
|
||||
(tail-aligned-crossover
|
||||
(:plushy (selection/select-parent pop argmap))
|
||||
(:plushy (selection/select-parent pop argmap)))
|
||||
;
|
||||
:autoconstructive-crossover
|
||||
(autoconstructive-crossover
|
||||
(:plushy (selection/select-parent pop argmap))
|
||||
(:plushy (selection/select-parent pop argmap)))
|
||||
;
|
||||
:umad
|
||||
(let [rate (utils/onenum (:umad-rate argmap))]
|
||||
|
Loading…
x
Reference in New Issue
Block a user