added boolean flag to not end runs on success
This commit is contained in:
parent
b5953d3779
commit
b5763dcc5a
@ -34,8 +34,11 @@
|
|||||||
(defn gp
|
(defn gp
|
||||||
"Main GP loop."
|
"Main GP loop."
|
||||||
[{:keys [population-size max-generations error-function instructions
|
[{:keys [population-size max-generations error-function instructions
|
||||||
max-initial-plushy-size solution-error-threshold mapper ds-parent-rate ds-parent-gens]
|
max-initial-plushy-size solution-error-threshold mapper ds-parent-rate ds-parent-gens dont-end]
|
||||||
:or {solution-error-threshold 0.0
|
:or {solution-error-threshold 0.0
|
||||||
|
dont-end false
|
||||||
|
ds-parent-rate 0
|
||||||
|
ds-parent-gens 1
|
||||||
;; The `mapper` will perform a `map`-like operation to apply a function to every individual
|
;; The `mapper` will perform a `map`-like operation to apply a function to every individual
|
||||||
;; in the population. The default is `map` but other options include `mapv`, or `pmap`.
|
;; in the population. The default is `map` but other options include `mapv`, or `pmap`.
|
||||||
mapper #?(:clj pmap :cljs map)}
|
mapper #?(:clj pmap :cljs map)}
|
||||||
@ -80,7 +83,7 @@
|
|||||||
(prn {:semi-success-generation generation}))
|
(prn {:semi-success-generation generation}))
|
||||||
(cond
|
(cond
|
||||||
;; Success on training cases is verified on testing cases
|
;; Success on training cases is verified on testing cases
|
||||||
(or (and best-individual-passes-ds (<= (:total-error (error-function argmap indexed-training-data best-individual)) solution-error-threshold))
|
(if (or (and best-individual-passes-ds (<= (:total-error (error-function argmap indexed-training-data best-individual)) solution-error-threshold))
|
||||||
(and (not= (:parent-selection argmap) :ds-lexicase)
|
(and (not= (:parent-selection argmap) :ds-lexicase)
|
||||||
(<= (:total-error best-individual) solution-error-threshold)))
|
(<= (:total-error best-individual) solution-error-threshold)))
|
||||||
(do (prn {:success-generation generation})
|
(do (prn {:success-generation generation})
|
||||||
@ -88,7 +91,10 @@
|
|||||||
(:total-error (error-function argmap (:testing-data argmap) best-individual))})
|
(:total-error (error-function argmap (:testing-data argmap) best-individual))})
|
||||||
(when (:simplification? argmap)
|
(when (:simplification? argmap)
|
||||||
(let [simplified-plushy (simplification/auto-simplify-plushy (:plushy best-individual) error-function argmap)]
|
(let [simplified-plushy (simplification/auto-simplify-plushy (:plushy best-individual) error-function argmap)]
|
||||||
(prn {:total-test-error-simplified (:total-error (error-function argmap (:testing-data argmap) (hash-map :plushy simplified-plushy)))}))))
|
(prn {:total-test-error-simplified (:total-error (error-function argmap (:testing-data argmap) (hash-map :plushy simplified-plushy)))})))
|
||||||
|
(if dont-end false true))
|
||||||
|
false)
|
||||||
|
nil
|
||||||
;;
|
;;
|
||||||
(>= generation max-generations)
|
(>= generation max-generations)
|
||||||
nil
|
nil
|
||||||
|
@ -73,8 +73,8 @@
|
|||||||
:training-data train-data
|
:training-data train-data
|
||||||
:testing-data test-data
|
:testing-data test-data
|
||||||
:case-t-size (count train-data)
|
:case-t-size (count train-data)
|
||||||
:case-parent-rate 0
|
:ds-parent-rate 0
|
||||||
:case-parent-gens 1
|
:ds-parent-gens 1
|
||||||
:max-generations 300
|
:max-generations 300
|
||||||
:population-size 1000
|
:population-size 1000
|
||||||
:max-initial-plushy-size 250
|
:max-initial-plushy-size 250
|
||||||
|
Loading…
x
Reference in New Issue
Block a user