Rework handling of defaults to top-level gp function
This commit is contained in:
parent
f0424979b5
commit
81ef86d4ee
@ -48,17 +48,43 @@
|
||||
(prn {:run-completed true})
|
||||
nil)
|
||||
|
||||
(defn fill-defaults
|
||||
"Returns argmap with any unspecified values filled with defaults."
|
||||
[argmap]
|
||||
(let [defaults
|
||||
{:bmx-exchange-rate 0.5
|
||||
:bmx-gene-length-limit 10
|
||||
:bmx-gap-change-probability 0.001
|
||||
:bmx-complementary? false
|
||||
:dont-end false
|
||||
:downsample? true
|
||||
:ds-function :case-maxmin
|
||||
:downsample-rate 0.05
|
||||
:ds-parent-rate 0.01
|
||||
:ds-parent-gens 10
|
||||
:error-function (fn [& args] (println "ERROR FUNCTION NOT PROVIDED"))
|
||||
:ids-type :solved ; :solved or :elite or :soft
|
||||
:max-initial-plushy-size 100
|
||||
:max-generations 1000
|
||||
:parent-selection :lexicase
|
||||
:population-size 1000
|
||||
:single-thread-mode false
|
||||
:solution-error-threshold 0
|
||||
:step-limit 1000
|
||||
:testing-data []
|
||||
:training-data []
|
||||
:umad-rate 0.1
|
||||
:variation {:umad 1}}
|
||||
defaulted (merge defaults argmap)]
|
||||
(merge defaulted ; use the map below to include derived values in argmap
|
||||
{:bmx? (some #{:bmx :bmx-umad} (keys (:variation defaulted)))})))
|
||||
|
||||
(defn gp
|
||||
"Main GP function"
|
||||
[{:keys [population-size max-generations error-function solution-error-threshold
|
||||
ds-parent-rate ds-parent-gens dont-end ids-type downsample?]
|
||||
:or {solution-error-threshold 0.0
|
||||
dont-end false
|
||||
ds-parent-rate 0
|
||||
ds-parent-gens 1
|
||||
ids-type :solved ; :solved or :elite or :soft
|
||||
downsample? false}
|
||||
:as argmap}]
|
||||
[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]
|
||||
;; print starting args
|
||||
(prn {:starting-args (update (update argmap :error-function str)
|
||||
:instructions
|
||||
@ -171,4 +197,4 @@
|
||||
(/ solution-error-threshold
|
||||
(count indexed-training-data)))
|
||||
indexed-training-data)
|
||||
indexed-training-data))))))
|
||||
indexed-training-data)))))))
|
||||
|
Loading…
x
Reference in New Issue
Block a user