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
|
:training-data [] ; must be provided
|
||||||
:umad-rate 0.1 ; addition rate (from which deletion rate will be derived) for UMAD
|
: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
|
: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)]
|
defaulted (merge defaults argmap)]
|
||||||
(merge defaulted ; use the map below to include derived values in argmap
|
(merge defaulted ; use the map below to include derived values in argmap
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
[pop argmap]
|
[pop argmap]
|
||||||
(let [tournament-size (:tournament-size argmap)
|
(let [tournament-size (:tournament-size argmap)
|
||||||
tournament-set (take tournament-size (shuffle pop))]
|
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
|
(defn lexicase-selection
|
||||||
"Selects an individual from the population using lexicase selection.
|
"Selects an individual from the population using lexicase selection.
|
||||||
@ -26,9 +26,9 @@
|
|||||||
(if (or (empty? cases)
|
(if (or (empty? cases)
|
||||||
(empty? (rest survivors)))
|
(empty? (rest survivors)))
|
||||||
(assoc (rand-nth survivors) :selection-cases initial-cases)
|
(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)))]
|
(map :errors survivors)))]
|
||||||
(recur (filter #(= (nth (:errors %) (first cases)) min-err-for-case)
|
(recur (filter #(= (nth (:errors %) (first cases)) err-for-case)
|
||||||
survivors)
|
survivors)
|
||||||
(rest cases)))))))
|
(rest cases)))))))
|
||||||
|
|
||||||
@ -94,12 +94,12 @@
|
|||||||
(if (or (empty? cases)
|
(if (or (empty? cases)
|
||||||
(empty? (rest survivors)))
|
(empty? (rest survivors)))
|
||||||
(rand-nth 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)))
|
(map :errors survivors)))
|
||||||
epsilon (nth epsilons (first cases))]
|
epsilon (nth epsilons (first cases))]
|
||||||
(recur (filter #(<= (Math/abs (- (nth (:errors %)
|
(recur (filter #(<= (Math/abs (- (nth (:errors %)
|
||||||
(first cases))
|
(first cases))
|
||||||
min-err-for-case))
|
err-for-case))
|
||||||
epsilon)
|
epsilon)
|
||||||
survivors)
|
survivors)
|
||||||
(rest cases)))))))
|
(rest cases)))))))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user