option to sort by max rather than min
This commit is contained in:
parent
2261b57445
commit
c107363d40
@ -92,6 +92,8 @@
|
||||
:training-data [] ; must be provided
|
||||
:umad-rate 0.1 ; addition rate (from which deletion rate will be derived) for UMAD
|
||||
:variation {:umad 1} ; genetic operators and probabilities for their use, which should sum to 1
|
||||
:tournament-comp-op min-key ; individual error comparison operator for tournament selection
|
||||
:lexicase-comp-op min ; individual error comparison operator for lexicase selection
|
||||
}
|
||||
defaulted (merge defaults argmap)]
|
||||
(merge defaulted ; use the map below to include derived values in argmap
|
||||
|
@ -11,7 +11,7 @@
|
||||
[pop argmap]
|
||||
(let [tournament-size (:tournament-size argmap)
|
||||
tournament-set (take tournament-size (shuffle pop))]
|
||||
(apply min-key :total-error tournament-set)))
|
||||
(apply (:tournament-comp-op argmap) :total-error tournament-set)))
|
||||
|
||||
(defn lexicase-selection
|
||||
"Selects an individual from the population using lexicase selection.
|
||||
@ -26,9 +26,9 @@
|
||||
(if (or (empty? cases)
|
||||
(empty? (rest survivors)))
|
||||
(assoc (rand-nth survivors) :selection-cases initial-cases)
|
||||
(let [min-err-for-case (apply min (map #(nth % (first cases))
|
||||
(let [err-for-case (apply (:lexicase-comp-op argmap) (map #(nth % (first cases))
|
||||
(map :errors survivors)))]
|
||||
(recur (filter #(= (nth (:errors %) (first cases)) min-err-for-case)
|
||||
(recur (filter #(= (nth (:errors %) (first cases)) err-for-case)
|
||||
survivors)
|
||||
(rest cases)))))))
|
||||
|
||||
@ -94,12 +94,12 @@
|
||||
(if (or (empty? cases)
|
||||
(empty? (rest survivors)))
|
||||
(rand-nth survivors)
|
||||
(let [min-err-for-case (apply min (map #(nth % (first cases))
|
||||
(let [err-for-case (apply (:lexicase-comp-op argmap) (map #(nth % (first cases))
|
||||
(map :errors survivors)))
|
||||
epsilon (nth epsilons (first cases))]
|
||||
(recur (filter #(<= (Math/abs (- (nth (:errors %)
|
||||
(first cases))
|
||||
min-err-for-case))
|
||||
err-for-case))
|
||||
epsilon)
|
||||
survivors)
|
||||
(rest cases)))))))
|
||||
|
Loading…
x
Reference in New Issue
Block a user