From a4703d60a85f4848297c52394eceacb95dc1d9b7 Mon Sep 17 00:00:00 2001 From: Rowan Torbitzky-Lane Date: Tue, 11 Mar 2025 17:18:40 -0500 Subject: [PATCH] more comparisons --- src/propeller/gp.cljc | 11 ++++++----- src/propeller/session.cljc | 6 ++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/propeller/gp.cljc b/src/propeller/gp.cljc index a905ae8..3e1e25d 100644 --- a/src/propeller/gp.cljc +++ b/src/propeller/gp.cljc @@ -92,8 +92,9 @@ :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 + :tournament-comp-op min-key ; individual error comparison operator for tournament selection (switch to max-key for max) + :lexicase-comp-op min ; individual error comparison operator for lexicase selection (switch to max for max) + :population-sort-comp < ; comparision operator to use for sorting the population } defaulted (merge defaults argmap)] (merge defaulted ; use the map below to include derived values in argmap @@ -104,7 +105,7 @@ [non-default-argmap] (let [argmap (fill-defaults non-default-argmap) {:keys [population-size max-generations error-function solution-error-threshold dont-end - downsample? ds-parent-rate ds-parent-gens ids-type]} argmap] + downsample? ds-parent-rate ds-parent-gens ids-type population-sort-comp]} argmap] ;; print starting args (prn {:starting-args (update (update argmap :error-function str) :instructions @@ -136,13 +137,13 @@ '()) ;else just empty list ; parent representatives for down-sampling rep-evaluated-pop (if downsample? - (sort-by :total-error + (sort-by :total-error population-sort-comp (utils/pmapallv (partial error-function argmap indexed-training-data) parent-reps argmap)) '()) - evaluated-pop (sort-by :total-error + evaluated-pop (sort-by :total-error population-sort-comp (utils/pmapallv (partial error-function argmap training-data) population diff --git a/src/propeller/session.cljc b/src/propeller/session.cljc index c9a7e89..03c8954 100755 --- a/src/propeller/session.cljc +++ b/src/propeller/session.cljc @@ -96,7 +96,7 @@ :error-function regression/error-function :training-data (:train regression/train-and-test-data) :testing-data (:test regression/train-and-test-data) - :max-generations 5 + :max-generations 20 :population-size 50 :max-initial-plushy-size 100 :step-limit 200 @@ -105,7 +105,9 @@ :umad-rate 0.01 :variation {:umad 1.0 :crossover 0.0} - :elitism false}) + :elitism false + :downsample? false + }) #_(require '[propeller.problems.string-classification :as sc])