From 7dcf75c43331b3fd80adcfa8643dea0d569fd6e4 Mon Sep 17 00:00:00 2001 From: Lee Spector Date: Tue, 5 Sep 2023 10:44:50 -0400 Subject: [PATCH] Allow collection for :max-batch-size --- src/propeller/problems/boolean/mul3.cljc | 24 +++++++++++++++--------- src/propeller/selection.cljc | 5 +++-- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/propeller/problems/boolean/mul3.cljc b/src/propeller/problems/boolean/mul3.cljc index edeac2f..94a6281 100644 --- a/src/propeller/problems/boolean/mul3.cljc +++ b/src/propeller/problems/boolean/mul3.cljc @@ -303,22 +303,28 @@ :training-data (:train train-and-test-data) :testing-data (:test train-and-test-data) :max-generations 1000 - :population-size 500 + :population-size 100 :max-initial-plushy-size 100 :step-limit 1000 - ;:parent-selection :lexicase + :parent-selection :lexicase ;:parent-selection :tournament - :parent-selection :motley-batch-lexicase - :max-batch-size 8 + ;:parent-selection :motley-batch-lexicase + ;:max-batch-size [1 2 4 8 16 32 64 128 256] ;:tournament-size 5 - :umad-rate [1/64 1/128 1/256] - ;:alternation-rate [1/64 1/128 1/256] - ;:alignment-deviation [0 4 16 64] + :umad-rate [1/2 + 1/4 1/4 + 1/8 1/8 1/8 + 1/16 1/16 1/16 1/16 + 1/32 1/32 1/32 1/32 1/32 + 1/64 1/64 1/64 1/64 1/64 1/64 + 1/128 1/128 1/128 1/128 1/128 1/128 1/128 + 1/256 1/256 1/256 1/256 1/256 1/256 1/256 1/256] + ;:alternation-rate [1 1/2 1/4 1/8 1/16 1/32 1/64 1/128 1/256] + ;:alignment-deviation [0 1 2 4 8 16 32 64 128] :variation {:umad 1 :alternation 0 :reproduction 0 - :tail-aligned-crossover 0 - } + :tail-aligned-crossover 0} ;:diploid true ;:variation {:diploid-vumad 0.8 ; :diploid-uniform-silent-replacement 0.1 diff --git a/src/propeller/selection.cljc b/src/propeller/selection.cljc index 6645e14..2bb7710 100755 --- a/src/propeller/selection.cljc +++ b/src/propeller/selection.cljc @@ -2,7 +2,8 @@ "Propeller includes many kinds of genetic operators to select parents within the population such as tournament selection, lexicase selection, and epsilon lexicase selection." {:doc/format :markdown} - (:require [propeller.tools.math :as math-tools])) + (:require [propeller.tools.math :as math-tools] + [propeller.utils :as utils])) (defn tournament-selection "Selects an individual from the population using tournaments of @@ -38,7 +39,7 @@ (if (or (empty? cases) (empty? (rest survivors))) (rand-nth survivors) - (let [batch-size (inc (rand-int (:max-batch-size argmap))) + (let [batch-size (inc (rand-int (utils/onenum (:max-batch-size argmap)))) batch (take batch-size cases) ind-err-pairs (map (fn [ind] [ind