Add cleanup to move shutdown-agents into tail position

This commit is contained in:
Lee Spector 2023-10-19 10:58:22 -04:00
parent b6e7b0e86f
commit 92fd220961
2 changed files with 11 additions and 7 deletions

View File

@ -37,6 +37,11 @@
:average-total-error (float (/ (reduce + (map :total-error pop)) (count pop)))}) :average-total-error (float (/ (reduce + (map :total-error pop)) (count pop)))})
(println))) (println)))
(defn cleanup
[]
#?(:clj (shutdown-agents))
nil)
(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
@ -110,13 +115,13 @@
(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)) (if dont-end false true))
false) false)
nil (cleanup)
;; ;;
(and (not downsample?) (>= generation max-generations)) (and (not downsample?) (>= generation max-generations))
nil (cleanup)
;; ;;
(and downsample? (>= evaluations (* max-generations population-size (count indexed-training-data)))) (and downsample? (>= evaluations (* max-generations population-size (count indexed-training-data))))
nil (cleanup)
;; ;;
:else (recur (inc generation) :else (recur (inc generation)
(+ evaluations (* population-size (count training-data)) ;every member evaluated on the current sample (+ evaluations (* population-size (count training-data)) ;every member evaluated on the current sample
@ -136,5 +141,4 @@
(if (zero? (mod generation ds-parent-gens)) (if (zero? (mod generation ds-parent-gens))
(downsample/update-case-distances rep-evaluated-pop indexed-training-data indexed-training-data ids-type (/ solution-error-threshold (count indexed-training-data))) ; update distances every ds-parent-gens generations (downsample/update-case-distances rep-evaluated-pop indexed-training-data indexed-training-data ids-type (/ solution-error-threshold (count indexed-training-data))) ; update distances every ds-parent-gens generations
indexed-training-data) indexed-training-data)
indexed-training-data)))) indexed-training-data))))))
#?(:clj (shutdown-agents))))

View File

@ -315,8 +315,8 @@
;:max-batch-size [1 2 4 8 16 32 64 128 256] ;:max-batch-size [1 2 4 8 16 32 64 128 256]
;:tournament-size 5 ;:tournament-size 5
;:umad-rate 0.09 ;:umad-rate 0.09
:ah-umad-protection 10 ;; ah-umad :ah-umad-protection 100 ;; ah-umad
:ah-umad-rate 0.1 ;; ah-umad :ah-umad-rate 0.01 ;; ah-umad
;:umad-rate [1/2 ;:umad-rate [1/2
; 1/4 1/4 ; 1/4 1/4
; 1/8 1/8 1/8 ; 1/8 1/8 1/8