From 14f63f880bbcbe1e0e9b9ad775049c3d4dacf11f Mon Sep 17 00:00:00 2001 From: Lee Spector Date: Mon, 7 Dec 2020 13:58:34 -0500 Subject: [PATCH 1/8] Fix comment and error message in handle-input-instruction; begin developing valiant problem --- src/propeller/problems/valiant.cljc | 165 ++++++++++++++++++ .../push/instructions/input_output.cljc | 9 +- 2 files changed, 169 insertions(+), 5 deletions(-) create mode 100644 src/propeller/problems/valiant.cljc diff --git a/src/propeller/problems/valiant.cljc b/src/propeller/problems/valiant.cljc new file mode 100644 index 0000000..640bc64 --- /dev/null +++ b/src/propeller/problems/valiant.cljc @@ -0,0 +1,165 @@ +(ns propeller.problems.valiant) + +(defn train-and-test-data + [num-vars num-inputs num-train num-test] + (let [input-indices (take num-inputs (shuffle (range num-vars))) + rand-vars (fn [] (vec (repeatedly num-vars #(< (rand) 0.5)))) + even-parity? (fn [vars] + (even? (count (filter #(= % true) + (map #(nth vars %) + input-indices))))) + train-inputs (repeatedly num-train rand-vars) + test-inputs (repeatedly num-test rand-vars)] + {:train {:inputs train-inputs + :outputs (map even-parity? train-inputs)} + :test {:inputs test-inputs + :outputs (map even-parity? test-inputs)}})) + +(def instructions + (list :in1 + :integer_add + :integer_subtract + :integer_mult + :integer_quot + :integer_eq + :exec_dup + :exec_if + 'close + 0 + 1)) + +boolean_and boolean_or boolean_not exec_if + +;============== NOTE NOTE NOTE ================= +; This file has note been updated for Clojush 2.0, and will likely not work +;============== NOTE NOTE NOTE ================= +; +;(ns clojush.problems.boolean.valiant +; (:use [clojush.pushgp.pushgp] +; [clojush.pushstate] +; [clojush.random] +; [clojush.interpreter] +; [clojure.math.numeric-tower])) +; +;(def numvars 100) ;1000) +;(def numinputs 50) ;500) +;(def numcases 500) ;5000) +; +;(def input-indices +; (vec (take numinputs (shuffle (range numvars))))) +; +;(def cases +; (vec (repeatedly numcases +; (fn [] (let [vars (vec (repeatedly numvars #(< (lrand) 0.5)))] +; [vars (even? (count (filter #(= % true) +; (map #(nth vars %) +; input-indices))))]))))) +; +;(println "input-indices:" input-indices) +; +;;; ugly way to define all of the input instructions, since I haven't fully +;;; grokked Clojure macros +; +;(def n-hack (atom 0)) +; +;(defn define-input [n] +; (reset! n-hack n) +; (eval `(define-registered ~(symbol (str "input" @n-hack)) +; (fn [state#] +; (push-item (nth (first (:auxiliary state#)) ~(+ @n-hack)) +; :boolean +; state#))))) +; +;(dotimes [n numvars] (define-input n)) +; +;;; this gives the instructions: (registered-for-type "input") +; +;(defn rp [prog state] (run-push prog state true)) +; +;(defn valiant-fitness +; [individual] +; (assoc individual +; :errors +; (doall (for [c (range numcases)] +; (let [[inputs answer] (nth cases c) +; output (->> (make-push-state) +; (push-item inputs :auxiliary) +; (run-push (:program individual)) +; ;(rp (:program individual)) +; (top-item :boolean))] +; ;(println "output" output "answer" answer) +; (if (= output answer) 0 1)))))) +; +;;input-indices +; +;;(reduce + (valiant-fitness '(input1 input4 input0 input7 input9 boolean_and boolean_and boolean_and boolean_and))) +; +;;; oversized-offspring-fail-to-random? -- take fail to random code from here and use right +;;; parameters +;;(in-ns 'clojush.pushgp.genetic-operators) +;;(defn crossover +;; "Returns a copy of parent1 with a random subprogram replaced with a random +;; subprogram of parent2." +;; [parent1 parent2 max-points] +;; (let [new-program (case (lrand-int 2) +;; 0 (insert-code-at-point +;; (:program parent1) +;; (select-node-index (:program parent1)) +;; (code-at-point (:program parent2) +;; (select-node-index (:program parent2)))) +;; 1 (list (random-code 10 @global-atom-generators) 'exec_if (:program parent1) (:program parent2)))] +;; (if (> (count-points new-program) max-points) +;; ;parent1 +;; (make-individual :program (random-code 10 @global-atom-generators) :history (:history parent1) +;; :ancestors (if global-maintain-ancestors +;; (cons (:program parent1) (:ancestors parent1)) +;; (:ancestors parent1))) +;; (make-individual :program new-program :history (:history parent1) +;; :ancestors (if global-maintain-ancestors +;; (cons (:program parent1) (:ancestors parent1)) +;; (:ancestors parent1)))))) +;;(in-ns 'experimental.valiant) +;;; +;;; Probabilistic Pseudo Hillclimbing (persistence) +;;; +; +;;(def argmap +;; {:error-function valiant-fitness +;; :atom-generators (concat (vec (registered-for-type "input")) +;; ;) +;; (apply concat +;; (repeat 25 +;; '(boolean_and boolean_or boolean_not exec_if)))) +;; :use-lexicase-selection true +;; :max-points 40000 +;; :max-genome-size-in-initial-program 10 +;; :population-size 100 +;; :evalpush-limit 10000 +;; :mutation-probability 0.4 +;; :mutation-max-points 50 +;; ;:crossover-probability 0.4 +;; :simplification-probability 0.2 +;; :reproduction-simplifications 1 +;; ;:deletion-mutation-probability 0.2 +;; :boolean-gsxover-probability 0.4 +;; :boolean-gsxover-new-code-max-points 10 +;; :parent-reversion-probability 0.95 +;; ;:decimation-ratio 0.01 +;; ;:use-single-thread true +;; }) +; +;(def argmap +; {:error-function valiant-fitness +; :atom-generators (concat (vec (registered-for-type "input")) +; ;) +; (apply concat +; (repeat 25 +; '(boolean_and boolean_or boolean_not exec_if)))) +; :max-points 4000 +; :max-genome-size-in-initial-program 100 +; :population-size 100 +; :evalpush-limit 2000 +; :genetic-operator-probabilities {[:alternation :uniform-mutation] 1.0} ;Somewhat equivalent to normal Push's ULTRA operator +; :alignment-deviation 20 +; ;:use-single-thread true +; }) \ No newline at end of file diff --git a/src/propeller/push/instructions/input_output.cljc b/src/propeller/push/instructions/input_output.cljc index 55db2ee..18d24c7 100755 --- a/src/propeller/push/instructions/input_output.cljc +++ b/src/propeller/push/instructions/input_output.cljc @@ -12,16 +12,15 @@ ;; ============================================================================= ;; Allows Push to handle input instructions of the form :inN, e.g. :in2, taking -;; elements thus labeled from the :input stack and pushing them onto the :exec -;; stack. We can tell whether a particular inN instruction is valid if N-1 -;; values are on the input stack. +;; elements thus labeled from the :input map and pushing them onto the :exec +;; stack. (defn handle-input-instruction [state instruction] (if-let [input (instruction (:input state))] (state/push-to-stack state :exec input) - (throw #?(:clj (Exception. (str "Undefined input instruction " instruction)) + (throw #?(:clj (Exception. (str "Undefined instruction " instruction)) :cljs (js/Error - (str "Undefined input instruction " instruction)))))) + (str "Undefined instruction " instruction)))))) ;; ============================================================================= ;; OUTPUT Instructions From bb916c2ad36fdf36a42f12f8a98407d086734267 Mon Sep 17 00:00:00 2001 From: Lee Spector Date: Mon, 7 Dec 2020 20:19:59 -0500 Subject: [PATCH 2/8] Fix handling of false boolean input values; continue development of valiant problem --- src/propeller/problems/valiant.cljc | 193 +++--------- .../push/instructions/input_output.cljc | 7 +- src/propeller/session.cljc | 298 ++++++++++-------- 3 files changed, 207 insertions(+), 291 deletions(-) diff --git a/src/propeller/problems/valiant.cljc b/src/propeller/problems/valiant.cljc index 640bc64..d47fd86 100644 --- a/src/propeller/problems/valiant.cljc +++ b/src/propeller/problems/valiant.cljc @@ -1,7 +1,14 @@ -(ns propeller.problems.valiant) +(ns propeller.problems.valiant + (:require [propeller.genome :as genome] + [propeller.push.interpreter :as interpreter] + [propeller.push.state :as state])) -(defn train-and-test-data - [num-vars num-inputs num-train num-test] +(def num-vars 100) ;1000) +(def num-inputs 50) ;500) +(def num-train 500) ;5000) +(def num-test 200) + +(def train-and-test-data (let [input-indices (take num-inputs (shuffle (range num-vars))) rand-vars (fn [] (vec (repeatedly num-vars #(< (rand) 0.5)))) even-parity? (fn [vars] @@ -16,150 +23,38 @@ :outputs (map even-parity? test-inputs)}})) (def instructions - (list :in1 - :integer_add - :integer_subtract - :integer_mult - :integer_quot - :integer_eq - :exec_dup - :exec_if - 'close - 0 - 1)) + (vec (concat (for [i (range num-inputs)] (keyword (str "in" i))) + (take num-inputs + (cycle [:boolean_and + :boolean_or + :boolean_not + :exec_if + 'close]))))) -boolean_and boolean_or boolean_not exec_if - -;============== NOTE NOTE NOTE ================= -; This file has note been updated for Clojush 2.0, and will likely not work -;============== NOTE NOTE NOTE ================= -; -;(ns clojush.problems.boolean.valiant -; (:use [clojush.pushgp.pushgp] -; [clojush.pushstate] -; [clojush.random] -; [clojush.interpreter] -; [clojure.math.numeric-tower])) -; -;(def numvars 100) ;1000) -;(def numinputs 50) ;500) -;(def numcases 500) ;5000) -; -;(def input-indices -; (vec (take numinputs (shuffle (range numvars))))) -; -;(def cases -; (vec (repeatedly numcases -; (fn [] (let [vars (vec (repeatedly numvars #(< (lrand) 0.5)))] -; [vars (even? (count (filter #(= % true) -; (map #(nth vars %) -; input-indices))))]))))) -; -;(println "input-indices:" input-indices) -; -;;; ugly way to define all of the input instructions, since I haven't fully -;;; grokked Clojure macros -; -;(def n-hack (atom 0)) -; -;(defn define-input [n] -; (reset! n-hack n) -; (eval `(define-registered ~(symbol (str "input" @n-hack)) -; (fn [state#] -; (push-item (nth (first (:auxiliary state#)) ~(+ @n-hack)) -; :boolean -; state#))))) -; -;(dotimes [n numvars] (define-input n)) -; -;;; this gives the instructions: (registered-for-type "input") -; -;(defn rp [prog state] (run-push prog state true)) -; -;(defn valiant-fitness -; [individual] -; (assoc individual -; :errors -; (doall (for [c (range numcases)] -; (let [[inputs answer] (nth cases c) -; output (->> (make-push-state) -; (push-item inputs :auxiliary) -; (run-push (:program individual)) -; ;(rp (:program individual)) -; (top-item :boolean))] -; ;(println "output" output "answer" answer) -; (if (= output answer) 0 1)))))) -; -;;input-indices -; -;;(reduce + (valiant-fitness '(input1 input4 input0 input7 input9 boolean_and boolean_and boolean_and boolean_and))) -; -;;; oversized-offspring-fail-to-random? -- take fail to random code from here and use right -;;; parameters -;;(in-ns 'clojush.pushgp.genetic-operators) -;;(defn crossover -;; "Returns a copy of parent1 with a random subprogram replaced with a random -;; subprogram of parent2." -;; [parent1 parent2 max-points] -;; (let [new-program (case (lrand-int 2) -;; 0 (insert-code-at-point -;; (:program parent1) -;; (select-node-index (:program parent1)) -;; (code-at-point (:program parent2) -;; (select-node-index (:program parent2)))) -;; 1 (list (random-code 10 @global-atom-generators) 'exec_if (:program parent1) (:program parent2)))] -;; (if (> (count-points new-program) max-points) -;; ;parent1 -;; (make-individual :program (random-code 10 @global-atom-generators) :history (:history parent1) -;; :ancestors (if global-maintain-ancestors -;; (cons (:program parent1) (:ancestors parent1)) -;; (:ancestors parent1))) -;; (make-individual :program new-program :history (:history parent1) -;; :ancestors (if global-maintain-ancestors -;; (cons (:program parent1) (:ancestors parent1)) -;; (:ancestors parent1)))))) -;;(in-ns 'experimental.valiant) -;;; -;;; Probabilistic Pseudo Hillclimbing (persistence) -;;; -; -;;(def argmap -;; {:error-function valiant-fitness -;; :atom-generators (concat (vec (registered-for-type "input")) -;; ;) -;; (apply concat -;; (repeat 25 -;; '(boolean_and boolean_or boolean_not exec_if)))) -;; :use-lexicase-selection true -;; :max-points 40000 -;; :max-genome-size-in-initial-program 10 -;; :population-size 100 -;; :evalpush-limit 10000 -;; :mutation-probability 0.4 -;; :mutation-max-points 50 -;; ;:crossover-probability 0.4 -;; :simplification-probability 0.2 -;; :reproduction-simplifications 1 -;; ;:deletion-mutation-probability 0.2 -;; :boolean-gsxover-probability 0.4 -;; :boolean-gsxover-new-code-max-points 10 -;; :parent-reversion-probability 0.95 -;; ;:decimation-ratio 0.01 -;; ;:use-single-thread true -;; }) -; -;(def argmap -; {:error-function valiant-fitness -; :atom-generators (concat (vec (registered-for-type "input")) -; ;) -; (apply concat -; (repeat 25 -; '(boolean_and boolean_or boolean_not exec_if)))) -; :max-points 4000 -; :max-genome-size-in-initial-program 100 -; :population-size 100 -; :evalpush-limit 2000 -; :genetic-operator-probabilities {[:alternation :uniform-mutation] 1.0} ;Somewhat equivalent to normal Push's ULTRA operator -; :alignment-deviation 20 -; ;:use-single-thread true -; }) \ No newline at end of file +(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 (:inputs data) + correct-outputs (:outputs data) + outputs (map (fn [input] + (state/peek-stack + (interpreter/interpret-program + program + (assoc state/empty-state + :input (zipmap (for [i (range (count input))] + (keyword (str "in" i))) + input)) + (:step-limit argmap)) + :boolean)) + inputs) + errors (map #(if (= %1 %2) 0 1) + correct-outputs + outputs)] + (assoc individual + :behaviors outputs + :errors errors + :total-error #?(:clj (apply +' errors) + :cljs (apply + errors)))))) diff --git a/src/propeller/push/instructions/input_output.cljc b/src/propeller/push/instructions/input_output.cljc index 18d24c7..2a622e1 100755 --- a/src/propeller/push/instructions/input_output.cljc +++ b/src/propeller/push/instructions/input_output.cljc @@ -16,9 +16,10 @@ ;; stack. (defn handle-input-instruction [state instruction] - (if-let [input (instruction (:input state))] - (state/push-to-stack state :exec input) - (throw #?(:clj (Exception. (str "Undefined instruction " instruction)) + (if (contains? (:input state) instruction) + (let [input (instruction (:input state))] + (state/push-to-stack state :exec input)) + (throw #?(:clj (Exception. (str "Undefined instruction " instruction)) :cljs (js/Error (str "Undefined instruction " instruction)))))) diff --git a/src/propeller/session.cljc b/src/propeller/session.cljc index 7154b7e..73bdf24 100755 --- a/src/propeller/session.cljc +++ b/src/propeller/session.cljc @@ -5,150 +5,170 @@ [propeller.variation :as variation] [propeller.problems.simple-regression :as regression] [propeller.problems.string-classification :as string-classif] + propeller.problems.valiant [propeller.push.core :as push] [propeller.push.interpreter :as interpreter] [propeller.push.state :as state] [propeller.push.utils.helpers :refer [get-stack-instructions]])) -#_(interpreter/interpret-program - '(1 2 :integer_add) state/empty-state 1000) - -#_(interpreter/interpret-program - '(3 3 :integer_eq :exec_if (1 "yes") (2 "no")) - state/empty-state - 1000) - -#_(interpreter/interpret-program - '(:in1 :string_reverse 1 :string_take "?" :string_eq :exec_if - (:in1 " I am asking." :string_concat) - (:in1 " I am saying." :string_concat)) - (assoc state/empty-state :input {:in1 "Can you hear me?"}) - 1000) - -#_(interpreter/interpret-program - '(:in1 :string_reverse 1 :string_take "?" :string_eq :exec_if - (:in1 " I am asking." :string_concat) - (:in1 " I am saying." :string_concat)) - (assoc state/empty-state :input {:in1 "I can hear you."}) - 1000) - -#_(genome/plushy->push - (genome/make-random-plushy (get-stack-instructions #{:float :integer :exec :boolean}) 20)) - -#_(gp/gp {:instructions propeller.problems.software.number-io/instructions - :error-function propeller.problems.software.number-io/error-function - :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 0.5 :crossover 0.5} - :elitism false}) - -#_(gp/gp {:instructions propeller.problems.simple-regression/instructions - :error-function propeller.problems.simple-regression/error-function - :max-generations 500 - :population-size 500 - :max-initial-plushy-size 100 - :step-limit 200 - :parent-selection :tournament - :tournament-size 5 - :umad-rate 0.01 - :variation {:umad 1.0 - :crossover 0.0} - :elitism false}) - -#_(gp/gp {:instructions propeller.problems.simple-regression/instructions - :error-function propeller.problems.simple-regression/error-function - :max-generations 500 - :population-size 500 - :max-initial-plushy-size 100 - :step-limit 200 - :parent-selection :tournament - :tournament-size 5 - :umad-rate 0.1 - :variation {:umad 1.0 - :crossover 0.0} - :elitism false}) +;#_(interpreter/interpret-program +; '(1 2 :integer_add) state/empty-state 1000) +; +;#_(interpreter/interpret-program +; '(3 3 :integer_eq :exec_if (1 "yes") (2 "no")) +; state/empty-state +; 1000) +; +;#_(interpreter/interpret-program +; '(:in1 :string_reverse 1 :string_take "?" :string_eq :exec_if +; (:in1 " I am asking." :string_concat) +; (:in1 " I am saying." :string_concat)) +; (assoc state/empty-state :input {:in1 "Can you hear me?"}) +; 1000) +; +;#_(interpreter/interpret-program +; '(:in1 :string_reverse 1 :string_take "?" :string_eq :exec_if +; (:in1 " I am asking." :string_concat) +; (:in1 " I am saying." :string_concat)) +; (assoc state/empty-state :input {:in1 "I can hear you."}) +; 1000) +; +;#_(genome/plushy->push +; (genome/make-random-plushy (get-stack-instructions #{:float :integer :exec :boolean}) 20)) +; +;#_(gp/gp {:instructions propeller.problems.software.number-io/instructions +; :error-function propeller.problems.software.number-io/error-function +; :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 0.5 :crossover 0.5} +; :elitism false}) +; +;#_(gp/gp {:instructions propeller.problems.simple-regression/instructions +; :error-function propeller.problems.simple-regression/error-function +; :max-generations 500 +; :population-size 500 +; :max-initial-plushy-size 100 +; :step-limit 200 +; :parent-selection :tournament +; :tournament-size 5 +; :umad-rate 0.01 +; :variation {:umad 1.0 +; :crossover 0.0} +; :elitism false}) +; +;#_(gp/gp {:instructions propeller.problems.simple-regression/instructions +; :error-function propeller.problems.simple-regression/error-function +; :max-generations 500 +; :population-size 500 +; :max-initial-plushy-size 100 +; :step-limit 200 +; :parent-selection :tournament +; :tournament-size 5 +; :umad-rate 0.1 +; :variation {:umad 1.0 +; :crossover 0.0} +; :elitism false}) +; +; +;#_(gp/gp {:instructions propeller.problems.simple-regression/instructions +; :error-function propeller.problems.simple-regression/error-function +; :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} +; :elitism false}) +; +;#_(gp/gp {:instructions propeller.problems.simple-regression/instructions +; :error-function propeller.problems.simple-regression/error-function +; :max-generations 500 +; :population-size 500 +; :max-initial-plushy-size 100 +; :step-limit 200 +; :parent-selection :lexicase +; :tournament-size 5 +; :umad-rate 0.1 +; :diploid-flip-rate 0.1 +; :variation {:umad 0.8 +; :diploid-flip 0.2} +; :elitism false +; :diploid true}) +; +; +;#_(gp/gp {:instructions propeller.problems.software.smallest/instructions +; :error-function propeller.problems.software.smallest/error-function +; :max-generations 500 +; :population-size 500 +; :max-initial-plushy-size 100 +; :step-limit 200 +; :parent-selection :lexicase +; :tournament-size 5 +; :umad-rate 0.1 +; :diploid-flip-rate 0.1 +; :variation {;:umad 0.8 +; ;:diploid-flip 0.2 +; :umad 1 +; } +; :elitism false +; :diploid false}) +; +;#_(gp/gp {:instructions propeller.problems.software.smallest/instructions +; :error-function propeller.problems.software.smallest/error-function +; :max-generations 500 +; :population-size 500 +; :max-initial-plushy-size 200 ;100 +; :step-limit 200 +; :parent-selection :lexicase +; :tournament-size 5 +; :umad-rate 0.1 +; :diploid-flip-rate 0.1 +; :variation {:umad 0.8 +; :diploid-flip 0.2 +; ;:umad 1 +; } +; :elitism false +; :diploid true}) +; +; +;(gp/gp {:instructions propeller.problems.string-classification/instructions +; :error-function propeller.problems.string-classification/error-function +; :max-generations 500 +; :population-size 500 +; :max-initial-plushy-size 100 +; :step-limit 200 +; :parent-selection :lexicase +; :tournament-size 5 +; :umad-rate 0.1 +; :diploid-flip-rate 0.1 +; :variation {:umad 0.8 +; :diploid-flip 0.2 +; } +; :elitism false +; :diploid true}) -#_(gp/gp {:instructions propeller.problems.simple-regression/instructions - :error-function propeller.problems.simple-regression/error-function - :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} - :elitism false}) +(gp/gp {:instructions propeller.problems.valiant/instructions + :error-function propeller.problems.valiant/error-function + :max-generations 500 + :population-size 500 + :max-initial-plushy-size 1000 + :step-limit 2000 + :parent-selection :lexicase + :tournament-size 5 + :umad-rate 0.001 + :diploid-flip-rate 0.001 + :variation {:umad 0.5 + :diploid-flip 0.5 + } + :elitism false + :diploid true}) -#_(gp/gp {:instructions propeller.problems.simple-regression/instructions - :error-function propeller.problems.simple-regression/error-function - :max-generations 500 - :population-size 500 - :max-initial-plushy-size 100 - :step-limit 200 - :parent-selection :lexicase - :tournament-size 5 - :umad-rate 0.1 - :diploid-flip-rate 0.1 - :variation {:umad 0.8 - :diploid-flip 0.2} - :elitism false - :diploid true}) - - -#_(gp/gp {:instructions propeller.problems.software.smallest/instructions - :error-function propeller.problems.software.smallest/error-function - :max-generations 500 - :population-size 500 - :max-initial-plushy-size 100 - :step-limit 200 - :parent-selection :lexicase - :tournament-size 5 - :umad-rate 0.1 - :diploid-flip-rate 0.1 - :variation {;:umad 0.8 - ;:diploid-flip 0.2 - :umad 1 - } - :elitism false - :diploid false}) - -#_(gp/gp {:instructions propeller.problems.software.smallest/instructions - :error-function propeller.problems.software.smallest/error-function - :max-generations 500 - :population-size 500 - :max-initial-plushy-size 200 ;100 - :step-limit 200 - :parent-selection :lexicase - :tournament-size 5 - :umad-rate 0.1 - :diploid-flip-rate 0.1 - :variation {:umad 0.8 - :diploid-flip 0.2 - ;:umad 1 - } - :elitism false - :diploid true}) - -#_(gp/gp {:instructions propeller.problems.string-classification/instructions - :error-function propeller.problems.string-classification/error-function - :max-generations 500 - :population-size 500 - :max-initial-plushy-size 100 - :step-limit 200 - :parent-selection :lexicase - :tournament-size 5 - :umad-rate 0.1 - :diploid-flip-rate 0.1 - :variation {:umad 0.8 - :diploid-flip 0.2 - } - :elitism false - :diploid true}) From d49f9e4bf081a3db3c0c073a09017694633a57ed Mon Sep 17 00:00:00 2001 From: Lee Spector Date: Tue, 8 Dec 2020 12:12:23 -0500 Subject: [PATCH 3/8] Remove extraneous argmap argument; experiment with valiant --- .DS_Store | Bin 6148 -> 8196 bytes src/.DS_Store | Bin 6148 -> 6148 bytes src/propeller/.DS_Store | Bin 6148 -> 6148 bytes src/propeller/problems/valiant.cljc | 11 ++++--- src/propeller/session.cljc | 46 +++++++++++++++++++++++++--- src/propeller/variation.cljc | 2 +- 6 files changed, 48 insertions(+), 11 deletions(-) diff --git a/.DS_Store b/.DS_Store index feca8613504bcd7430524202412f605a970dd548..4c8696c854640d8b1087a87465a54826e6211a0c 100644 GIT binary patch literal 8196 zcmeHMJ%|%Q6n>LGcTq8gaB0Lvusby=jCX|+V-zfegNPRAakrar1TzsQ6vEi?`WABsQs7pPS^=%VtOE4xo`ADZ2Nwe6{GK!) z$ym!Pm7J#M;F_`Y`|HWw4<9e9c=bTM(~#Z`oUkwylE~{q6>4BB%<%cUipt#Qo_x9V zi*rlyEpNge?V<3;)+m1pZ1C|@g8+Or19(4;%Q>9+vAw_ZmesFZL(XEJkCF$!*~L)< z4=Pg`Y-0ujk-5L^y?pol8siSpN$s;}1fL0Atl3A-9?mLsKE+MdiSUy1czpiVIFCrr zNlpiQs`*i3tlFn}Ieot)cHAeY({%kHo82d|cp{lPWSE9w95pt|4X^fx*n1*SZ zo9WD8kjv&TEL-`N;j%SY$>MZ1zd9V6#?tBB#p_$Gdpm>s!v{}U0YJo43Xbvb;rMJ) zo+3H<`C@{|GVlEfx0;Ye-ej|=B4^y9#3Jr)x!Z1f?K-Z|>{7VtZIroAx4)7L9NC@5 z<%}NQSl@Uv-u%)v%$j zEUW@?UU`O||F6z}|G%*M=)$!Ei=Y5Wl**+dRyzLGGF@~G7cA^s*lDAFBW_s;4%CIN iv*S40@DD?rTLLQxJK`1*Z2#azfPVfn<@K=03j77KVL@*I delta 143 zcmZp1XfcprU|?W$DortDU=RQ@Ie-{MGpJ5X6gFlAGME{P8HyN^Q;L&wlJfI&KyqNf z1f@Z0fLMS5BEKy(5WE;o< L44dP5<}d>Qx3LtN diff --git a/src/.DS_Store b/src/.DS_Store index bf7db11ae7cdca67181c347f9cc33b772a663d38..059041468db135bd0d2cc7fe59bb35aa6d395f07 100644 GIT binary patch delta 268 zcmZoMXfc@J&&akhU^gQp+hiUlMbVQ<1v#0;B?bo98JU<_SlQS)I5{{bJ29o{b8vEU z#tTSPR~s6bnd>N+S=8z%R9hGTnU-djwY8ia;;M$Wo(Z{?Rn;}Mbu%YlWsb^;)0}{{3HejhT};EIhn;J1_sv|nV4Bv+1NQa zIJhS}F{SBpa&mCS3y4)$8=L7Um|529C{&x98|WyQ7@O7Ba&m~P8rpg$B)qu~2NHo}wrV0|Nsi1A_nqLk>eKLoP#cQh9N~#)Hcl>p?Oc3DYVuLgC%Y#c2OG=BK5{sfi zynw`#j3g*KBtJg~&Q44U%S>T_Yz`)#i e@H_Klei2;}kdYv38Xz>-#?2uj8<;0HumAwE{$D5n delta 94 zcmZoMXfc=|#>CJzu~2NHo}wrd0|Nsi1A_nqLk>eKLoP#cN^x?|#6tDS1|lqze=x~z vHf6rVvN?gdlW8+M2R{c; Date: Tue, 8 Dec 2020 22:53:37 -0500 Subject: [PATCH 4/8] Provide more modular and and extensible approach to genetic operator dispatch --- src/propeller/problems/valiant.cljc | 8 +-- src/propeller/session.cljc | 27 ++++++++-- src/propeller/variation.cljc | 76 +++++++++++++++++++++-------- 3 files changed, 82 insertions(+), 29 deletions(-) diff --git a/src/propeller/problems/valiant.cljc b/src/propeller/problems/valiant.cljc index e43d899..c51e9a4 100644 --- a/src/propeller/problems/valiant.cljc +++ b/src/propeller/problems/valiant.cljc @@ -26,10 +26,10 @@ (vec (concat (for [i (range num-inputs)] (keyword (str "in" i))) (take num-inputs (cycle [:boolean_xor - ;:boolean_or - ;:boolean_not - ;:exec_if - ;'close + :boolean_or + :boolean_not + :exec_if + 'close ]))))) (defn error-function diff --git a/src/propeller/session.cljc b/src/propeller/session.cljc index 9f83bd4..1db83ca 100755 --- a/src/propeller/session.cljc +++ b/src/propeller/session.cljc @@ -190,21 +190,38 @@ ;;; below is when I switched to just xor +;(gp/gp {:instructions propeller.problems.valiant/instructions +; :error-function propeller.problems.valiant/error-function +; :max-generations 500 +; :population-size 500 +; :max-initial-plushy-size 50 +; :step-limit 2000 +; :parent-selection :lexicase +; :tournament-size 2 +; :umad-rate 0.01 +; :diploid-flip-rate 0.01 +; :variation {:umad 0.5 +; :crossover 0.25 +; :diploid-flip 0.25 +; } +; :elitism false +; :diploid true}) + +;; separated diploid from other operators + (gp/gp {:instructions propeller.problems.valiant/instructions :error-function propeller.problems.valiant/error-function :max-generations 500 - :population-size 500 + :population-size 50 :max-initial-plushy-size 50 :step-limit 2000 :parent-selection :lexicase :tournament-size 2 :umad-rate 0.01 :diploid-flip-rate 0.01 - :variation {:umad 0.5 - :crossover 0.25 + :variation {:diploid-umad 0.5 + :diploid-crossover 0.25 :diploid-flip 0.25 } :elitism false :diploid true}) - - diff --git a/src/propeller/variation.cljc b/src/propeller/variation.cljc index 1c01464..b8c148b 100755 --- a/src/propeller/variation.cljc +++ b/src/propeller/variation.cljc @@ -80,26 +80,62 @@ individuals in the population." [pop argmap] {:plushy - (let [prob (rand) - [xover add del] (if (:diploid argmap) - [diploid-crossover diploid-uniform-addition diploid-uniform-deletion] - [crossover uniform-addition uniform-deletion]) - xover-prob (or (:crossover (:variation argmap)) 0) - umad-prob (or (:umad (:variation argmap)) 0) - flip-prob (or (:diploid-flip (:variation argmap)) 0)] - (cond - (< prob xover-prob) - (xover (:plushy (selection/select-parent pop argmap)) - (:plushy (selection/select-parent pop argmap))) + (let [r (rand) + op (loop [accum 0.0 + ops-probs (vec (:variation argmap))] + (if (empty? ops-probs) + :reproduction + (let [[op1 prob1] (first ops-probs)] + (if (>= (+ accum prob1) r) + op1 + (recur (+ accum prob1) + (rest ops-probs))))))] + (case op + :crossover + (crossover + (:plushy (selection/select-parent pop argmap)) + (:plushy (selection/select-parent pop argmap))) ; - (< prob (+ xover-prob umad-prob)) - (del (add (:plushy (selection/select-parent pop argmap)) - (:instructions argmap) - (:umad-rate argmap)) - (:umad-rate argmap)) + :umad + (-> (:plushy (selection/select-parent pop argmap)) + (uniform-addition (:instructions argmap) (:umad-rate argmap)) + (uniform-deletion (:umad-rate argmap))) ; - (< prob (+ xover-prob umad-prob flip-prob)) - (diploid-flip (:plushy (selection/select-parent pop argmap)) - (:diploid-flip-rate argmap)) + :uniform-addition + (-> (:plushy (selection/select-parent pop argmap)) + (uniform-addition (:instructions argmap) (:umad-rate argmap))) ; - :else (:plushy (selection/select-parent pop argmap))))}) + :uniform-deletion + (-> (:plushy (selection/select-parent pop argmap)) + (uniform-deletion (:umad-rate argmap))) + ; + :diploid-crossover + (diploid-crossover + (:plushy (selection/select-parent pop argmap)) + (:plushy (selection/select-parent pop argmap))) + ; + :diploid-umad + (-> (:plushy (selection/select-parent pop argmap)) + (diploid-uniform-addition (:instructions argmap) (:umad-rate argmap)) + (diploid-uniform-deletion (:umad-rate argmap))) + ; + :diploid-uniform-addition + (-> (:plushy (selection/select-parent pop argmap)) + (diploid-uniform-addition (:instructions argmap) (:umad-rate argmap))) + ; + :diploid-uniform-deletion + (-> (:plushy (selection/select-parent pop argmap)) + (diploid-uniform-deletion (:umad-rate argmap))) + ; + :diploid-flip + (-> (:plushy (selection/select-parent pop argmap)) + (diploid-flip (:diploid-flip-rate argmap))) + ; + :reproduction + (:plushy (selection/select-parent pop argmap)) + ; + :else + (throw #?(:clj (Exception. (str "No match in new-individual for " op)) + :cljs (js/Error + (str "No match in new-individual for " op))))))}) + From 0af6aa095e178115f26bf1d916b815a07ee4d932 Mon Sep 17 00:00:00 2001 From: Lee Spector Date: Wed, 9 Dec 2020 10:42:05 -0500 Subject: [PATCH 5/8] Add uniform-replacement; pass argmap to plushy->push in report --- src/propeller/gp.cljc | 2 +- src/propeller/session.cljc | 14 ++++++++------ src/propeller/variation.cljc | 14 +++++++++++++- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/propeller/gp.cljc b/src/propeller/gp.cljc index 1f7e927..ed68be9 100755 --- a/src/propeller/gp.cljc +++ b/src/propeller/gp.cljc @@ -19,7 +19,7 @@ (println " Report for Generation" generation) (println "-------------------------------------------------------") (print "Best plushy: ") (prn (:plushy best)) - (print "Best program: ") (prn (genome/plushy->push (:plushy best))) + (print "Best program: ") (prn (genome/plushy->push (:plushy best) argmap)) (println "Best total error:" (:total-error best)) (println "Best errors:" (:errors best)) (println "Best behaviors:" (:behaviors best)) diff --git a/src/propeller/session.cljc b/src/propeller/session.cljc index 1db83ca..fbca6ec 100755 --- a/src/propeller/session.cljc +++ b/src/propeller/session.cljc @@ -212,16 +212,18 @@ (gp/gp {:instructions propeller.problems.valiant/instructions :error-function propeller.problems.valiant/error-function :max-generations 500 - :population-size 50 - :max-initial-plushy-size 50 - :step-limit 2000 + :population-size 1000 + :max-initial-plushy-size 10 + :step-limit 1000 :parent-selection :lexicase :tournament-size 2 :umad-rate 0.01 + :replacement-rate 0.01 :diploid-flip-rate 0.01 - :variation {:diploid-umad 0.5 - :diploid-crossover 0.25 - :diploid-flip 0.25 + :variation {:diploid-umad 0.25 + :diploid-crossover 0.25 + :diploid-flip 0.25 + :uniform-replacement 0.25 } :elitism false :diploid true}) diff --git a/src/propeller/variation.cljc b/src/propeller/variation.cljc index b8c148b..d35c452 100755 --- a/src/propeller/variation.cljc +++ b/src/propeller/variation.cljc @@ -42,6 +42,15 @@ [%]) plushy))) +(defn uniform-replacement + "Returns plushy with new instructions possibly replacing existing + instructions." + [plushy instructions replacement-rate] + (map #(if (< (rand) replacement-rate) + (utils/random-instruction instructions) + %) + plushy)) + (defn diploid-uniform-addition "Returns plushy with new instructions possibly added before or after each existing instruction." @@ -105,6 +114,10 @@ (-> (:plushy (selection/select-parent pop argmap)) (uniform-addition (:instructions argmap) (:umad-rate argmap))) ; + :uniform-replacement + (-> (:plushy (selection/select-parent pop argmap)) + (uniform-replacement (:instructions argmap) (:replacement-rate argmap))) + ; :uniform-deletion (-> (:plushy (selection/select-parent pop argmap)) (uniform-deletion (:umad-rate argmap))) @@ -138,4 +151,3 @@ (throw #?(:clj (Exception. (str "No match in new-individual for " op)) :cljs (js/Error (str "No match in new-individual for " op))))))}) - From 2f4adfde7acb212ba158d09a77e85d5e766b1878 Mon Sep 17 00:00:00 2001 From: Lee Spector Date: Wed, 9 Dec 2020 10:49:53 -0500 Subject: [PATCH 6/8] Pass argmap to report --- src/propeller/gp.cljc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/propeller/gp.cljc b/src/propeller/gp.cljc index ed68be9..2a46aeb 100755 --- a/src/propeller/gp.cljc +++ b/src/propeller/gp.cljc @@ -13,7 +13,7 @@ (defn report "Reports information each generation." - [pop generation] + [pop generation argmap] (let [best (first pop)] (println "-------------------------------------------------------") (println " Report for Generation" generation) @@ -48,7 +48,7 @@ :cljs map) (partial error-function argmap) population)) best-individual (first evaluated-pop)] - (report evaluated-pop generation) + (report evaluated-pop generation argmap) (cond ;; Success on training cases is verified on testing cases (zero? (:total-error best-individual)) From 6e281b7430596e11de028d3b62b4df328eab8a03 Mon Sep 17 00:00:00 2001 From: Erik Rauer Date: Thu, 21 Jan 2021 15:26:00 -0600 Subject: [PATCH 7/8] Add `.clj-kondo/` to the gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f46b5a3..fe7582f 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,5 @@ pom.xml.asc *.iml .idea/ out -notes \ No newline at end of file +notes +.clj-kondo/ \ No newline at end of file From 864c8fb8ee6f486db11c177df2f82877326f5564 Mon Sep 17 00:00:00 2001 From: Lee Spector Date: Sat, 23 Jan 2021 16:14:09 -0500 Subject: [PATCH 8/8] Print behavioral diversity and avg total error; add tail-aligned crossover and diploid operators; fix valiant problem --- .DS_Store | Bin 8196 -> 8196 bytes src/.DS_Store | Bin 6148 -> 6148 bytes src/propeller/.DS_Store | Bin 6148 -> 6148 bytes src/propeller/gp.cljc | 4 ++ src/propeller/problems/valiant.cljc | 7 +-- src/propeller/session.cljc | 74 ---------------------------- src/propeller/variation.cljc | 54 ++++++++++++++++++++ 7 files changed, 62 insertions(+), 77 deletions(-) diff --git a/.DS_Store b/.DS_Store index 4c8696c854640d8b1087a87465a54826e6211a0c..b9e3ed4cde58e282d3701268d3e1003f97e862b9 100644 GIT binary patch delta 303 zcmZp1XmQw}CQ#q*!N9=4!l1{H&XCDalAG`1l9ZF51Qg?#Ehh1E%7H_UsPZXzC|8h>gZT}%hRQVLV@&y@& z!O8i#1wcIv46+I!k`-unCPNBCDnnvUI+85Ise3@#I3#Ig%k`(7wtEY)97P4fdh9At z9KaN?nOV??iNnyq%v?vo%wn>waHu@v%lSZinHh>1iWriSt-San`+C*Z$s2_w*r3ew P!jeqP3Y%XEOYr~z)5uT9 diff --git a/src/.DS_Store b/src/.DS_Store index 059041468db135bd0d2cc7fe59bb35aa6d395f07..da17f2d6d1484bfb55b14e6e12bdca890d2d7e85 100644 GIT binary patch delta 79 zcmZoMXffEZk%`07!cs@U(8zf5PNqa=W(L>Eh0J0?x%ntG%B<18MF)%Q2oD7h*eY<~h aKC{H+SY{qJI9HXKnSlYMdh=T5a1j91Qy44& diff --git a/src/propeller/.DS_Store b/src/propeller/.DS_Store index a19382269acf6b4531519f866c878f6dca85fd8f..306b0a39dc35785d3aa367defd71ec8b17637caa 100644 GIT binary patch delta 472 zcmZoMXfc=|#>B!ku~2NHo+6{b#(>?7ixZfc7zHNtFfHb=w6N4sFf=lryqzh(J}2EU zI5|JJfB_8bEPxaTLjgk(Lq0eKLoP#cZoZ34QcivnNG{2uYIES>Lyp+hr4XgA zAOmhE3(%Z|$%4$5^(;VJOBsq8GEiK^$l3-}0hdE|$;;a^mJNHsEjEVAV{+;Xm0Z3SBnH2|UlVLf&gC=Or<0672x mHdd=MZf57;=K#jr=0N7}%#-;=961;n7??ovnB)qu~2NHo+2a5#(>?7j4YFRSQc{_8km{uD41DH-p-Ogc^|9FW>F3y mmWd6kH?wo_a{#q$7UcNOJegm_k%IvU7#SE?Hb;o8VFmz*+Y|@@ diff --git a/src/propeller/gp.cljc b/src/propeller/gp.cljc index 2a46aeb..0eb0426 100755 --- a/src/propeller/gp.cljc +++ b/src/propeller/gp.cljc @@ -25,8 +25,12 @@ (println "Best behaviors:" (:behaviors best)) (println "Genotypic diversity:" (float (/ (count (distinct (map :plushy pop))) (count pop)))) + (println "Behavioral diversity:" + (float (/ (count (distinct (map :behaviors pop))) (count pop)))) (println "Average genome length:" (float (/ (reduce + (map count (map :plushy pop))) (count pop)))) + (println "Average total error:" + (float (/ (reduce + (map :total-error pop)) (count pop)))) (println))) (defn gp diff --git a/src/propeller/problems/valiant.cljc b/src/propeller/problems/valiant.cljc index c51e9a4..f51d8b2 100644 --- a/src/propeller/problems/valiant.cljc +++ b/src/propeller/problems/valiant.cljc @@ -3,8 +3,8 @@ [propeller.push.interpreter :as interpreter] [propeller.push.state :as state])) -(def num-vars 100) ;1000) -(def num-inputs 50) ;500) +(def num-vars 100) ;10) ;100) ;1000) +(def num-inputs 50) ;5) ; 50) ;500) (def num-train 500) ;5000) (def num-test 200) @@ -23,10 +23,11 @@ :outputs (map even-parity? test-inputs)}})) (def instructions - (vec (concat (for [i (range num-inputs)] (keyword (str "in" i))) + (vec (concat (for [i (range num-vars)] (keyword (str "in" i))) (take num-inputs (cycle [:boolean_xor :boolean_or + :boolean_and :boolean_not :exec_if 'close diff --git a/src/propeller/session.cljc b/src/propeller/session.cljc index fbca6ec..c9f9e22 100755 --- a/src/propeller/session.cljc +++ b/src/propeller/session.cljc @@ -5,7 +5,6 @@ [propeller.variation :as variation] [propeller.problems.simple-regression :as regression] [propeller.problems.string-classification :as string-classif] - propeller.problems.valiant [propeller.push.core :as push] [propeller.push.interpreter :as interpreter] [propeller.push.state :as state] @@ -154,76 +153,3 @@ ; } ; :elitism false ; :diploid true}) - - -;(gp/gp {:instructions propeller.problems.valiant/instructions -; :error-function propeller.problems.valiant/error-function -; :max-generations 500 -; :population-size 50 -; :max-initial-plushy-size 1000 -; :step-limit 2000 -; :parent-selection :tournament -; :tournament-size 10 -; :umad-rate 0.01 -; :diploid-flip-rate 0.01 -; :variation {:umad 0.9 -; :diploid-flip 0.1 -; } -; :elitism false -; :diploid true}) - -;(gp/gp {:instructions propeller.problems.valiant/instructions -; :error-function propeller.problems.valiant/error-function -; :max-generations 500 -; :population-size 100 -; :max-initial-plushy-size 1000 -; :step-limit 2000 -; :parent-selection :tournament -; :tournament-size 10 -; :umad-rate 0.01 -; :diploid-flip-rate 0.01 -; :variation {:umad 0.9 -; :diploid-flip 0.1 -; } -; :elitism false -; :diploid true}) - -;;; below is when I switched to just xor - -;(gp/gp {:instructions propeller.problems.valiant/instructions -; :error-function propeller.problems.valiant/error-function -; :max-generations 500 -; :population-size 500 -; :max-initial-plushy-size 50 -; :step-limit 2000 -; :parent-selection :lexicase -; :tournament-size 2 -; :umad-rate 0.01 -; :diploid-flip-rate 0.01 -; :variation {:umad 0.5 -; :crossover 0.25 -; :diploid-flip 0.25 -; } -; :elitism false -; :diploid true}) - -;; separated diploid from other operators - -(gp/gp {:instructions propeller.problems.valiant/instructions - :error-function propeller.problems.valiant/error-function - :max-generations 500 - :population-size 1000 - :max-initial-plushy-size 10 - :step-limit 1000 - :parent-selection :lexicase - :tournament-size 2 - :umad-rate 0.01 - :replacement-rate 0.01 - :diploid-flip-rate 0.01 - :variation {:diploid-umad 0.25 - :diploid-crossover 0.25 - :diploid-flip 0.25 - :uniform-replacement 0.25 - } - :elitism false - :diploid true}) diff --git a/src/propeller/variation.cljc b/src/propeller/variation.cljc index d35c452..19578eb 100755 --- a/src/propeller/variation.cljc +++ b/src/propeller/variation.cljc @@ -16,6 +16,20 @@ shorter-padded longer)))) +(defn tail-aligned-crossover + "Crosses over two individuals using uniform crossover. Pads shorter one on the left." + [plushy-a plushy-b] + (let [shorter (min-key count plushy-a plushy-b) + longer (if (= shorter plushy-a) + plushy-b + plushy-a) + length-diff (- (count longer) (count shorter)) + shorter-padded (concat (repeat length-diff :crossover-padding) shorter)] + (remove #(= % :crossover-padding) + (map #(if (< (rand) 0.5) %1 %2) + shorter-padded + longer)))) + (defn diploid-crossover "Crosses over two individuals using uniform crossover. Pads shorter one." [plushy-a plushy-b] @@ -32,6 +46,22 @@ shorter-padded longer))))) +(defn tail-aligned-diploid-crossover + "Crosses over two individuals using uniform crossover. Pads shorter one on the left." + [plushy-a plushy-b] + (let [plushy-a (partition 2 plushy-a) + plushy-b (partition 2 plushy-b) + shorter (min-key count plushy-a plushy-b) + longer (if (= shorter plushy-a) + plushy-b + plushy-a) + length-diff (- (count longer) (count shorter)) + shorter-padded (concat (repeat length-diff :crossover-padding) shorter)] + (flatten (remove #(= % :crossover-padding) + (map #(if (< (rand) 0.5) %1 %2) + shorter-padded + longer))))) + (defn uniform-addition "Returns plushy with new instructions possibly added before or after each existing instruction." @@ -51,6 +81,16 @@ %) plushy)) +(defn diploid-uniform-silent-replacement + "Returns plushy with new instructions possibly replacing existing + instructions, but only among the silent member of each pair." + [plushy instructions replacement-rate] + (interleave (map first (partition 2 plushy)) + (map #(if (< (rand) replacement-rate) + (utils/random-instruction instructions) + %) + (map second (partition 2 plushy))))) + (defn diploid-uniform-addition "Returns plushy with new instructions possibly added before or after each existing instruction." @@ -105,6 +145,11 @@ (:plushy (selection/select-parent pop argmap)) (:plushy (selection/select-parent pop argmap))) ; + :tail-aligned-crossover + (tail-aligned-crossover + (:plushy (selection/select-parent pop argmap)) + (:plushy (selection/select-parent pop argmap))) + ; :umad (-> (:plushy (selection/select-parent pop argmap)) (uniform-addition (:instructions argmap) (:umad-rate argmap)) @@ -118,6 +163,10 @@ (-> (:plushy (selection/select-parent pop argmap)) (uniform-replacement (:instructions argmap) (:replacement-rate argmap))) ; + :diploid-uniform-silent-replacement + (-> (:plushy (selection/select-parent pop argmap)) + (diploid-uniform-silent-replacement (:instructions argmap) (:replacement-rate argmap))) + ; :uniform-deletion (-> (:plushy (selection/select-parent pop argmap)) (uniform-deletion (:umad-rate argmap))) @@ -127,6 +176,11 @@ (:plushy (selection/select-parent pop argmap)) (:plushy (selection/select-parent pop argmap))) ; + :tail-aligned-diploid-crossover + (tail-aligned-diploid-crossover + (:plushy (selection/select-parent pop argmap)) + (:plushy (selection/select-parent pop argmap))) + ; :diploid-umad (-> (:plushy (selection/select-parent pop argmap)) (diploid-uniform-addition (:instructions argmap) (:umad-rate argmap))