Skip to content

Instantly share code, notes, and snippets.

@Killeroid
Created April 13, 2012 09:08
Show Gist options
  • Save Killeroid/2375316 to your computer and use it in GitHub Desktop.
Save Killeroid/2375316 to your computer and use it in GitHub Desktop.
Lexicase Parent selection implementation for clojush
(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