Created
April 13, 2012 09:08
-
-
Save Killeroid/2375316 to your computer and use it in GitHub Desktop.
Lexicase Parent selection implementation for clojush
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn lexicase-selection | |
"Returns an individual that does the best on a randomly selected set of fitness cases" | |
[pop tournament-size] | |
(loop [survivors pop | |
cases (shuffle (range (count (:errors (first pop)))))] | |
(if (or (empty? cases) | |
(empty? (rest survivors))) | |
(first survivors) | |
(let [min-err-for-case (apply min (map #(nth % (first cases)) | |
(map #(:errors %) survivors)))] | |
(recur (filter #(= (nth (:errors %) (first cases)) min-err-for-case) | |
survivors) | |
(rest cases)))))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment