Add motley batch lexicase selection

This commit is contained in:
Lee Spector 2023-09-02 16:38:15 -04:00
parent a95e1ea872
commit 06e9f9445d
2 changed files with 31 additions and 4 deletions

View File

@ -306,8 +306,10 @@
:population-size 1000
:max-initial-plushy-size 100
:step-limit 1000
:parent-selection :lexicase
;:parent-selection :lexicase
;:parent-selection :tournament
:parent-selection :motley-batch-lexicase
:max-batch-size 16
:tournament-size 5
:umad-rate 0.05
:alternation-rate 0.05
@ -323,5 +325,6 @@
; :diploid-flip 0.1}
;:replacement-rate 0.01
;:diploid-flip-rate 0.01
:elitism false}
:elitism false
:single-thread-mode false}
(apply hash-map (map #(if (string? %) (read-string %) %) args)))))

View File

@ -29,6 +29,29 @@
survivors)
(rest cases))))))
(defn motley-batch-lexicase-selection
"Selects an individual from the population using motley batch lexicase selection.
Cases are combined in random collections of max size (:max-batch-size argmap),
and then the population is passed to lexicase-selection."
[pop argmap]
(let [cases (range (count (:errors (first pop))))
batches (loop [remaining (shuffle cases)
result ()]
(if (empty? remaining)
result
(let [n (inc (rand-int (:max-batch-size argmap)))]
(recur (drop n remaining)
(conj result (take n remaining))))))]
(lexicase-selection (mapv (fn [ind]
(assoc ind
:errors
(mapv (fn [batch]
(reduce + (map #(nth (:errors ind) %)
batch)))
batches)))
pop)
argmap)))
(defn epsilon-list
"List of epsilons for each training case based on median absolute deviation of errors."
[pop]
@ -69,4 +92,5 @@
(case (:parent-selection argmap)
:tournament (tournament-selection pop argmap)
:lexicase (lexicase-selection pop argmap)
:epsilon-lexicase (epsilon-lexicase-selection pop argmap)))
:epsilon-lexicase (epsilon-lexicase-selection pop argmap)
:motley-batch-lexicase (motley-batch-lexicase-selection pop argmap)))