fixed argmap and levenshtein distance

This commit is contained in:
Shuzo Katayama 2021-07-13 11:56:49 -04:00
parent 660fb32d93
commit a7deb03611
4 changed files with 19 additions and 19 deletions

View File

@ -27,14 +27,14 @@
(merge (merge
{:instructions (eval-problem-var (first args) "instructions") {:instructions (eval-problem-var (first args) "instructions")
:error-function (eval-problem-var (first args) "error-function") :error-function (eval-problem-var (first args) "error-function")
:max-generations 300 :max-generations 500
:population-size 1000 :population-size 500
:max-initial-plushy-size 250 :max-initial-plushy-size 100
:step-limit 2000 :step-limit 200
:parent-selection :lexicase :parent-selection :lexicase
:tournament-size 5 :tournament-size 5
:umad-rate 0.1 :umad-rate 0.1
:variation {:umad 1.0 :crossover 0.0} :variation {:umad 0.5 :crossover 0.5}
:elitism false :elitism false
:PSB2-path "" :PSB2-path ""
:PSB2-problem (clojure.string/replace (first args) #"PSB2." "")} :PSB2-problem (clojure.string/replace (first args) #"PSB2." "")}

View File

@ -17,7 +17,7 @@
"Reports information each generation." "Reports information each generation."
[pop generation argmap] [pop generation argmap]
(let [best (first pop)] (let [best (first pop)]
(println {:generation generation (clojure.pprint/pprint {:generation generation
:best-plushy (:plushy best) :best-plushy (:plushy best)
:best-program (genome/plushy->push (:plushy best) argmap) :best-program (genome/plushy->push (:plushy best) argmap)
:best-total-error (:total-error best) :best-total-error (:total-error best)
@ -43,7 +43,7 @@
(let [PSB2-data (if (= PSB2-path "") (let [PSB2-data (if (= PSB2-path "")
#{} #{}
(psb2/fetch-examples PSB2-path PSB2-problem 200 2000)) (psb2/fetch-examples PSB2-path PSB2-problem 200 2000))
enhanced-argmap (assoc argmap :train-and-test-data PSB2-data)] argmap (assoc argmap :train-and-test-data PSB2-data)]
(loop [generation 0 (loop [generation 0
population (repeatedly population (repeatedly
@ -54,7 +54,7 @@
(let [evaluated-pop (sort-by :total-error (let [evaluated-pop (sort-by :total-error
(#?(:clj pmap (#?(:clj pmap
:cljs map) :cljs map)
(partial error-function enhanced-argmap) population)) (partial error-function argmap) population))
best-individual (first evaluated-pop)] best-individual (first evaluated-pop)]
(report evaluated-pop generation argmap) (report evaluated-pop generation argmap)
(cond (cond

View File

@ -68,7 +68,7 @@
errors (map (fn [correct-output output] errors (map (fn [correct-output output]
(if (= output :no-stack-item) (if (= output :no-stack-item)
10000 10000
(metrics/levenshtein-distance correct-output output))) (metrics/levenshtein-distance (str correct-output) (str output))))
correct-outputs correct-outputs
parsed-outputs)] parsed-outputs)]
(assoc individual (assoc individual

View File

@ -75,7 +75,7 @@
;; we need to initialize the prev-row with the edit distance ;; we need to initialize the prev-row with the edit distance
;; between the various prefixes of b and the empty string ;; between the various prefixes of b and the empty string
(range (inc (count (str b)))) (range (inc (count (str b))))
(str a))))) (str a))))
(defn sequence-similarity (defn sequence-similarity
"Returns a number between 0 and 1, indicating how similar the sequences are "Returns a number between 0 and 1, indicating how similar the sequences are