autosimplification implementation complete

This commit is contained in:
Ryan Boldi 2022-02-19 16:52:11 -05:00
parent f369d23ad5
commit af22f9793b
4 changed files with 37 additions and 15 deletions

1
.gitignore vendored
View File

@ -33,3 +33,4 @@ node_modules/
# https://github.com/thelmuth/program-synthesis-benchmark-datasets # https://github.com/thelmuth/program-synthesis-benchmark-datasets
/data /data
**/.DS_Store **/.DS_Store
.shadow-cljs/classpath.edn

View File

@ -61,7 +61,7 @@
(prn {:total-test-error (prn {:total-test-error
(:total-error (error-function argmap (:testing-data argmap) best-individual))}) (:total-error (error-function argmap (:testing-data argmap) best-individual))})
(if (:simplification? argmap) (if (:simplification? argmap)
(let [simplified-plushy (simplification/auto-simplify-plushy argmap (:plushy best-individual) (:simplification-steps argmap) error-function (:training-data argmap) (:simplification-k argmap) (:simplification-k-prob argmap) (:simplification-verbose? argmap))] (let [simplified-plushy (simplification/auto-simplify-plushy argmap (:plushy best-individual) (:simplification-steps argmap) error-function (:training-data argmap) (:simplification-k argmap) (:simplification-verbose? 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)))}))))
;; ;;
(>= generation max-generations) (>= generation max-generations)

View File

@ -1,6 +1,7 @@
(ns propeller.problems.PSB2.fuel-cost (ns propeller.problems.PSB2.fuel-cost
(:require [psb2.core :as psb2] (:require [psb2.core :as psb2]
[propeller.genome :as genome] [propeller.genome :as genome]
[propeller.simplification :as simplification]
[propeller.push.interpreter :as interpreter] [propeller.push.interpreter :as interpreter]
[propeller.utils :as utils] [propeller.utils :as utils]
[propeller.push.instructions :refer [get-stack-instructions]] [propeller.push.instructions :refer [get-stack-instructions]]
@ -81,3 +82,16 @@
:elitism false} :elitism false}
(apply hash-map (map #(if (string? %) (read-string %) %) args)))) (apply hash-map (map #(if (string? %) (read-string %) %) args))))
(#?(:clj shutdown-agents))) (#?(:clj shutdown-agents)))
(defn fuel-cost-autosimplify
[plushy]
(simplification/auto-simplify-plushy {:instructions instructions
:error-function error-function
:training-data (:train train-and-test-data)
:testing-data (:test train-and-test-data)
:max-generations 300
:population-size 1000
:max-initial-plushy-size 250
:step-limit 2000} plushy 5000 error-function (:train train-and-test-data) 5 true))

35
src/propeller/problems/simple_regression.cljc Executable file → Normal file
View File

@ -66,18 +66,25 @@
[& args] [& args]
(gp/gp (gp/gp
(merge (merge
{:instructions instructions {:instructions instructions
:error-function error-function :error-function error-function
:training-data (:train train-and-test-data) :training-data (:train train-and-test-data)
:testing-data (:test train-and-test-data) :testing-data (:test train-and-test-data)
:max-generations 500 :max-generations 500
:population-size 500 :population-size 500
:max-initial-plushy-size 100 :max-initial-plushy-size 100
:step-limit 200 :step-limit 200
:parent-selection :lexicase :parent-selection :lexicase
:tournament-size 5 :case-queue? false
:umad-rate 0.1 :case-step 1
:variation {:umad 0.5 :crossover 0.5} :downsample-size 10
:elitism false} :tournament-size 5
(apply hash-map (map #(if (string? %) (read-string %) %) args)))) :umad-rate 0.1
:variation {:umad 0.5 :crossover 0.5}
:elitism false
:simplification? true
:simplification-steps 100
:simplification-k 5
:simplification-verbose? true}
(apply hash-map (map #(if (string? %) (read-string %) %) args))))
(#?(:clj shutdown-agents))) (#?(:clj shutdown-agents)))