merge
This commit is contained in:
commit
a831990c35
1
PSB2_path.txt
Normal file
1
PSB2_path.txt
Normal file
@ -0,0 +1 @@
|
||||
/Volumes/Samsung_T5/EvolutionaryComputing/PSB2
|
117
errors.txt
Normal file
117
errors.txt
Normal file
@ -0,0 +1,117 @@
|
||||
Average total error: 1.20971232E8
|
||||
Average total error: 7.0990816E7
|
||||
Average total error: 5.8947272E7
|
||||
Average total error: 4.744878E7
|
||||
Average total error: 4.1555428E7
|
||||
Average total error: 3.8916616E7
|
||||
Average total error: 3.8646348E7
|
||||
Average total error: 4.678786E7
|
||||
Average total error: 3.8375184E7
|
||||
Average total error: 3.6898772E7
|
||||
Average total error: 3.8002356E7
|
||||
Average total error: 3.8138176E7
|
||||
Average total error: 3.8647716E7
|
||||
Average total error: 3.6817828E7
|
||||
Average total error: 3.2690788E7
|
||||
Average total error: 3.3710072E7
|
||||
Average total error: 4.3554124E7
|
||||
Average total error: 3.8026116E7
|
||||
Average total error: 4.5374592E7
|
||||
Average total error: 4.7729904E7
|
||||
Average total error: 4.278798E7
|
||||
Average total error: 3.8943096E7
|
||||
Average total error: 3.796032E7
|
||||
Average total error: 4.2565964E7
|
||||
Average total error: 5.199024E7
|
||||
Average total error: 4.9884316E7
|
||||
Average total error: 5.0332596E7
|
||||
Average total error: 4.4738712E7
|
||||
Average total error: 5.1121884E7
|
||||
Average total error: 5.28278E7
|
||||
Average total error: 4.737436E7
|
||||
Average total error: 4.8825116E7
|
||||
Average total error: 4.5050176E7
|
||||
Average total error: 4.7032076E7
|
||||
Average total error: 3.75375E7
|
||||
Average total error: 4.1770188E7
|
||||
Average total error: 4.2192324E7
|
||||
Average total error: 3.8121424E7
|
||||
Average total error: 3.6940792E7
|
||||
Average total error: 4.0735792E7
|
||||
Average total error: 3.7949944E7
|
||||
Average total error: 3.8094084E7
|
||||
Average total error: 3.9462696E7
|
||||
Average total error: 4.2240504E7
|
||||
Average total error: 4.1255188E7
|
||||
Average total error: 4.235198E7
|
||||
Average total error: 3.7214584E7
|
||||
Average total error: 3.861928E7
|
||||
Average total error: 3.77219E7
|
||||
Average total error: 3.7414448E7
|
||||
Average total error: 3.2616348E7
|
||||
Average total error: 2.8501912E7
|
||||
Average total error: 2.9924808E7
|
||||
Average total error: 3.351813E7
|
||||
Average total error: 3.3687728E7
|
||||
Average total error: 3.6236108E7
|
||||
Average total error: 3.6975212E7
|
||||
Average total error: 3.6543472E7
|
||||
Average total error: 3.8481856E7
|
||||
Average total error: 3.4455868E7
|
||||
Average total error: 3.0916116E7
|
||||
Average total error: 2.8618544E7
|
||||
Average total error: 2.7537918E7
|
||||
Average total error: 2.9564782E7
|
||||
Average total error: 2.56306E7
|
||||
Average total error: 2.2281254E7
|
||||
Average total error: 2.599309E7
|
||||
Average total error: 1.966063E7
|
||||
Average total error: 1.7483378E7
|
||||
Average total error: 1.6682909E7
|
||||
Average total error: 1.5032185E7
|
||||
Average total error: 1.7223616E7
|
||||
Average total error: 1.7384072E7
|
||||
Average total error: 1.89933E7
|
||||
Average total error: 2.5394602E7
|
||||
Average total error: 1.708214E7
|
||||
Average total error: 2.1111482E7
|
||||
Average total error: 1.82417E7
|
||||
Average total error: 2.4765124E7
|
||||
Average total error: 2.0515838E7
|
||||
Average total error: 2.5062742E7
|
||||
Average total error: 2.6861224E7
|
||||
Average total error: 3.4709076E7
|
||||
Average total error: 3.0924278E7
|
||||
Average total error: 3.5103116E7
|
||||
Average total error: 3.0408544E7
|
||||
Average total error: 3.8609756E7
|
||||
Average total error: 3.8840836E7
|
||||
Average total error: 3.641088E7
|
||||
Average total error: 3.7741632E7
|
||||
Average total error: 3.4173112E7
|
||||
Average total error: 3.921708E7
|
||||
Average total error: 3.5226188E7
|
||||
Average total error: 3.9501532E7
|
||||
Average total error: 3.7897072E7
|
||||
Average total error: 3.4845884E7
|
||||
Average total error: 3.3286008E7
|
||||
Average total error: 3.5198156E7
|
||||
Average total error: 2.665777E7
|
||||
Average total error: 2.0974234E7
|
||||
Average total error: 2.3158012E7
|
||||
Average total error: 2.6645172E7
|
||||
Average total error: 2.6971466E7
|
||||
Average total error: 2.2053082E7
|
||||
Average total error: 2.0063062E7
|
||||
Average total error: 2.9107796E7
|
||||
Average total error: 2.5797774E7
|
||||
Average total error: 2.9464382E7
|
||||
Average total error: 1.6345746E7
|
||||
Average total error: 2.2872656E7
|
||||
Average total error: 2.6626478E7
|
||||
Average total error: 2.4253808E7
|
||||
Average total error: 3.2652544E7
|
||||
Average total error: 3.1584964E7
|
||||
Average total error: 3.2416886E7
|
||||
Average total error: 3.328668E7
|
||||
Average total error: 3.4721056E7
|
@ -6,8 +6,8 @@
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/resources" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/dev-resources" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/dev-resources" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
@ -23,6 +23,7 @@
|
||||
<orderEntry type="library" name="Leiningen: com.google.javascript/closure-compiler-unshaded:v20170910" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: com.google.jsinterop/jsinterop-annotations:1.0.0" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: com.google.protobuf/protobuf-java:3.0.2" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: net.clojars.schneau/psb2:1.0.0" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: nrepl:0.6.0" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: org.clojure/clojure:1.10.0" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: org.clojure/clojurescript:1.9.946" level="project" />
|
||||
|
1522
results.txt
Normal file
1522
results.txt
Normal file
File diff suppressed because it is too large
Load Diff
@ -12,11 +12,20 @@
|
||||
(defn -main
|
||||
"Runs propel-gp, giving it a map of arguments."
|
||||
[& args]
|
||||
;; Exception for when no args were passed
|
||||
(when (empty? args)
|
||||
(println "You must specify a problem to run.")
|
||||
(println "Try, for example:")
|
||||
(println " lein run software.smallest")
|
||||
(System/exit 1))
|
||||
|
||||
;; Setting the path for PSB2
|
||||
(when (= (first args) "PSB2-set-path")
|
||||
(spit "PSB2_path.txt" (second args))
|
||||
(println (str "Set path to PSB2 as " (second args)))
|
||||
(System/exit 1))
|
||||
|
||||
;; Creates problems
|
||||
(require (symbol (str "propeller.problems." (first args))))
|
||||
(gp/gp
|
||||
(update-in
|
||||
|
@ -54,8 +54,7 @@
|
||||
(zero? (:total-error best-individual))
|
||||
(do (println {:success-generation generation})
|
||||
(println {:total-test-error (:total-error (error-function argmap best-individual :test))})
|
||||
(#?(:clj shutdown-agents))
|
||||
)
|
||||
(#?(:clj shutdown-agents)))
|
||||
;;
|
||||
(>= generation max-generations)
|
||||
nil
|
||||
|
60
src/propeller/problems/PSB2/fuel_cost.cljc
Normal file
60
src/propeller/problems/PSB2/fuel_cost.cljc
Normal file
@ -0,0 +1,60 @@
|
||||
(ns propeller.problems.PSB2.fuel-cost
|
||||
(:require [psb2.core :as psb2]
|
||||
[propeller.genome :as genome]
|
||||
[propeller.push.interpreter :as interpreter]
|
||||
[propeller.utils :as utils]
|
||||
[propeller.push.utils.helpers :refer [get-stack-instructions]]
|
||||
[propeller.push.state :as state]
|
||||
[clojure.pprint :as pprint]
|
||||
[propeller.tools.math :as math]))
|
||||
|
||||
;; Get path from text file
|
||||
(def PSB2-path (slurp "PSB2_path.txt"))
|
||||
|
||||
; Random integer between -100 and 100 (from smallest)
|
||||
(defn random-int [] (- (rand-int 201) 100))
|
||||
|
||||
(def train-and-test-data (psb2/fetch-examples PSB2-path "fuel-cost" 200 2000))
|
||||
|
||||
(def instructions
|
||||
(utils/not-lazy
|
||||
(concat
|
||||
;;; stack-specific instructions
|
||||
(get-stack-instructions #{:exec :integer :vector_integer :boolean :print})
|
||||
;;; input instructions
|
||||
(list :in1)
|
||||
;;; close
|
||||
(list 'close)
|
||||
;;; ERCs (constants)
|
||||
(list random-int 0 1 2 3))))
|
||||
|
||||
; Error function takes from integer stack, calculates error based on absolute value of
|
||||
; difference between output and correct output.
|
||||
(defn error-function
|
||||
([argmap individual]
|
||||
(error-function argmap individual :train))
|
||||
([argmap individual subset]
|
||||
(let [program (genome/plushy->push (:plushy individual) argmap)
|
||||
data (get train-and-test-data subset)
|
||||
inputs (map (fn [i] (get i :input1)) data)
|
||||
correct-outputs (map (fn [i] (get i :output1)) data)
|
||||
outputs (map (fn [input]
|
||||
(state/peek-stack
|
||||
(interpreter/interpret-program
|
||||
program
|
||||
(assoc state/empty-state :input {:in1 input})
|
||||
(:step-limit argmap))
|
||||
:integer))
|
||||
inputs)
|
||||
errors (map (fn [correct-output output]
|
||||
(if (= output :no-stack-item)
|
||||
1000000
|
||||
(min 1000.0 (math/abs (- correct-output output)))))
|
||||
correct-outputs
|
||||
outputs)]
|
||||
(assoc individual
|
||||
:behaviors outputs
|
||||
:errors errors
|
||||
:total-error #?(:clj (apply +' errors)
|
||||
:cljs (apply + errors))))))
|
||||
|
64
src/propeller/problems/PSB2/substitution_cipher.cljc
Normal file
64
src/propeller/problems/PSB2/substitution_cipher.cljc
Normal file
@ -0,0 +1,64 @@
|
||||
(ns propeller.problems.PSB2.substitution-cipher
|
||||
(:require [psb2.core :as psb2]
|
||||
[propeller.genome :as genome]
|
||||
[propeller.push.interpreter :as interpreter]
|
||||
[propeller.utils :as utils]
|
||||
[propeller.push.utils.helpers :refer [get-stack-instructions]]
|
||||
[propeller.push.state :as state]
|
||||
[propeller.tools.math :as math]
|
||||
[propeller.tools.metrics :as metrics]))
|
||||
|
||||
;; Get path from text file
|
||||
(def PSB2-path (slurp "PSB2_path.txt"))
|
||||
|
||||
(def train-and-test-data (psb2/fetch-examples PSB2-path "substitution-cipher" 200 2000))
|
||||
|
||||
(def instructions
|
||||
(utils/not-lazy
|
||||
(concat
|
||||
;;; stack-specific instructions
|
||||
(get-stack-instructions #{:exec :integer :boolean :char :string :print})
|
||||
;;; input instructions
|
||||
(list :in1)
|
||||
;;; close
|
||||
(list 'close)
|
||||
;;; ERCs (constants)
|
||||
(list 0 ""))))
|
||||
|
||||
; Error function takes from integer stack, calculates error based on absolute value of
|
||||
; difference between output and correct output.
|
||||
(defn error-function
|
||||
([argmap individual]
|
||||
(error-function argmap individual :train))
|
||||
([argmap individual subset]
|
||||
(let [program (genome/plushy->push (:plushy individual) argmap)
|
||||
data (get train-and-test-data subset)
|
||||
inputs (map (fn [i] (get i :input1)) data)
|
||||
correct-outputs (map (fn [i] (get i :output1)) data)
|
||||
outputs (map (fn [input]
|
||||
(state/peek-stack
|
||||
(interpreter/interpret-program
|
||||
program
|
||||
(assoc state/empty-state :input {:in1 (get input 0)
|
||||
:in2 (get input 1)
|
||||
:in3 (get input 2)})
|
||||
(:step-limit argmap))
|
||||
:string))
|
||||
inputs)
|
||||
parsed-outputs (map (fn [output]
|
||||
(try (read-string output)
|
||||
#?(:clj (catch Exception e 1000.0)
|
||||
:cljs (catch js/Error. e 1000.0))))
|
||||
outputs)
|
||||
errors (map (fn [correct-output output]
|
||||
(if (= output :no-stack-item)
|
||||
10000
|
||||
(metrics/levenshtein-distance correct-output output)))
|
||||
correct-outputs
|
||||
parsed-outputs)]
|
||||
(assoc individual
|
||||
:behaviors parsed-outputs
|
||||
:errors errors
|
||||
:total-error #?(:clj (apply +' errors)
|
||||
:cljs (apply + errors))))))
|
||||
|
@ -18,7 +18,7 @@
|
||||
[x]
|
||||
(+ (* x x x) x 3))
|
||||
|
||||
;; Set of original propel instructions
|
||||
; Set of original propel instructions
|
||||
(def instructions
|
||||
(list :in1
|
||||
:integer_add
|
||||
|
@ -8,7 +8,7 @@
|
||||
:float '()
|
||||
:input {}
|
||||
:integer '()
|
||||
:output '()
|
||||
:output '("")
|
||||
:string '()
|
||||
:vector_boolean '()
|
||||
:vector_float '()
|
||||
|
Loading…
x
Reference in New Issue
Block a user