fixed argmap and levenshtein distance
This commit is contained in:
parent
660fb32d93
commit
a7deb03611
@ -27,14 +27,14 @@
|
||||
(merge
|
||||
{:instructions (eval-problem-var (first args) "instructions")
|
||||
:error-function (eval-problem-var (first args) "error-function")
|
||||
:max-generations 300
|
||||
:population-size 1000
|
||||
:max-initial-plushy-size 250
|
||||
:step-limit 2000
|
||||
:max-generations 500
|
||||
:population-size 500
|
||||
:max-initial-plushy-size 100
|
||||
:step-limit 200
|
||||
:parent-selection :lexicase
|
||||
:tournament-size 5
|
||||
:umad-rate 0.1
|
||||
:variation {:umad 1.0 :crossover 0.0}
|
||||
:variation {:umad 0.5 :crossover 0.5}
|
||||
:elitism false
|
||||
:PSB2-path ""
|
||||
:PSB2-problem (clojure.string/replace (first args) #"PSB2." "")}
|
||||
|
@ -17,16 +17,16 @@
|
||||
"Reports information each generation."
|
||||
[pop generation argmap]
|
||||
(let [best (first pop)]
|
||||
(println {:generation generation
|
||||
:best-plushy (:plushy best)
|
||||
:best-program (genome/plushy->push (:plushy best) argmap)
|
||||
:best-total-error (:total-error best)
|
||||
:best-errors (:errors best)
|
||||
:best-behaviors (:behaviors best)
|
||||
:genotypic-diversity (float (/ (count (distinct (map :plushy pop))) (count pop)))
|
||||
:behavioral-diversity (float (/ (count (distinct (map :behaviors pop))) (count pop)))
|
||||
:average-genome-length (float (/ (reduce + (map count (map :plushy pop))) (count pop)))
|
||||
:average-total-error (float (/ (reduce + (map :total-error pop)) (count pop)))})
|
||||
(clojure.pprint/pprint {:generation generation
|
||||
:best-plushy (:plushy best)
|
||||
:best-program (genome/plushy->push (:plushy best) argmap)
|
||||
:best-total-error (:total-error best)
|
||||
:best-errors (:errors best)
|
||||
:best-behaviors (:behaviors best)
|
||||
:genotypic-diversity (float (/ (count (distinct (map :plushy pop))) (count pop)))
|
||||
:behavioral-diversity (float (/ (count (distinct (map :behaviors pop))) (count pop)))
|
||||
:average-genome-length (float (/ (reduce + (map count (map :plushy pop))) (count pop)))
|
||||
:average-total-error (float (/ (reduce + (map :total-error pop)) (count pop)))})
|
||||
(println)))
|
||||
; (clojure.pprint/pprint
|
||||
|
||||
@ -43,7 +43,7 @@
|
||||
(let [PSB2-data (if (= PSB2-path "")
|
||||
#{}
|
||||
(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
|
||||
population (repeatedly
|
||||
@ -54,7 +54,7 @@
|
||||
(let [evaluated-pop (sort-by :total-error
|
||||
(#?(:clj pmap
|
||||
:cljs map)
|
||||
(partial error-function enhanced-argmap) population))
|
||||
(partial error-function argmap) population))
|
||||
best-individual (first evaluated-pop)]
|
||||
(report evaluated-pop generation argmap)
|
||||
(cond
|
||||
|
@ -68,7 +68,7 @@
|
||||
errors (map (fn [correct-output output]
|
||||
(if (= output :no-stack-item)
|
||||
10000
|
||||
(metrics/levenshtein-distance correct-output output)))
|
||||
(metrics/levenshtein-distance (str correct-output) (str output))))
|
||||
correct-outputs
|
||||
parsed-outputs)]
|
||||
(assoc individual
|
||||
|
@ -75,7 +75,7 @@
|
||||
;; we need to initialize the prev-row with the edit distance
|
||||
;; between the various prefixes of b and the empty string
|
||||
(range (inc (count (str b))))
|
||||
(str a)))))
|
||||
(str a))))
|
||||
|
||||
(defn sequence-similarity
|
||||
"Returns a number between 0 and 1, indicating how similar the sequences are
|
||||
|
Loading…
x
Reference in New Issue
Block a user