From 3ca6d4175f4c743713aa8fdc95c4f078f1140944 Mon Sep 17 00:00:00 2001 From: Lee Spector Date: Thu, 31 Aug 2023 17:17:33 -0400 Subject: [PATCH] Initialize diploid genomes to pairs of same; implement diploid vumad; mess around with mul3 --- src/propeller/gp.cljc | 5 ++++- src/propeller/problems/boolean/mul3.cljc | 28 +++++++++++++++++------- src/propeller/variation.cljc | 6 +++++ 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/propeller/gp.cljc b/src/propeller/gp.cljc index f7d3ff9..adfe378 100644 --- a/src/propeller/gp.cljc +++ b/src/propeller/gp.cljc @@ -44,7 +44,10 @@ ;; (loop [generation 0 population (utils/pmapallv - (fn [_] {:plushy (genome/make-random-plushy instructions max-initial-plushy-size)}) + (fn [_] {:plushy (let [plushy (genome/make-random-plushy instructions max-initial-plushy-size)] + (if (:diploid argmap) + (interleave plushy plushy) + plushy))}) (range population-size) argmap)] ;creates population of random plushys (let [evaluated-pop (sort-by :total-error diff --git a/src/propeller/problems/boolean/mul3.cljc b/src/propeller/problems/boolean/mul3.cljc index 677ba73..6537d16 100644 --- a/src/propeller/problems/boolean/mul3.cljc +++ b/src/propeller/problems/boolean/mul3.cljc @@ -164,6 +164,9 @@ :set-c2 ;; defined here :set-c1 ;; defined here :set-c0 ;; defined here +;; PROVIDE ACCESS ALSO TO c0-c5? + ;; AND/OR BOOLEAN TAGGING? + ;; Recommended by Kalkreuth et al: BUFa, NOTa, AND, OR, XOR, NAND, NOR, XNOR :boolean_bufa ;; defined here :boolean_nota ;; defined here @@ -173,15 +176,21 @@ :boolean_nand ;; defined here :boolean_nor ;; defined here :boolean_xnor ;; defined here + + ;:boolean_pop ;:boolean_dup ;:boolean_swap ;:boolean_rot - ;:boolean_pop + ;:exec_pop ;:exec_dup + ;:exec_swap + ;:exec_rot ;'close - true - false)) + + ;true + ;false + )) @@ -231,7 +240,7 @@ :error-function error-function :training-data (:train train-and-test-data) :testing-data (:test train-and-test-data) - :max-generations 100 + :max-generations 1000 :population-size 1000 :max-initial-plushy-size 100 :step-limit 1000 @@ -239,12 +248,15 @@ ;:parent-selection :tournament :tournament-size 5 :umad-rate 0.01 - :variation {:vumad 1} + :variation {:umad 1 + :reproduction 0 + :tail-aligned-crossover 0 + } ;:diploid true - ;:variation {:diploid-umad 0.8 + ;:variation {:diploid-vumad 0.8 ; :diploid-uniform-silent-replacement 0.1 ; :diploid-flip 0.1} - ;:replacement-rate 0.1 - ;:diploid-flip-rate 0.1 + ;:replacement-rate 0.01 + ;:diploid-flip-rate 0.01 :elitism false} (apply hash-map (map #(if (string? %) (read-string %) %) args))))) diff --git a/src/propeller/variation.cljc b/src/propeller/variation.cljc index 5b1c08f..36d8321 100755 --- a/src/propeller/variation.cljc +++ b/src/propeller/variation.cljc @@ -266,6 +266,12 @@ The function `new-individual` returns a new individual produced by selection and (diploid-uniform-addition (:instructions argmap) (:umad-rate argmap)) (diploid-uniform-deletion (:umad-rate argmap))) ; + :diploid-vumad ;; variable umad: :umad-rate is interpreted as max, actual uniform 0-max + (let [rate (rand (:umad-rate argmap))] + (-> (:plushy (selection/select-parent pop argmap)) + (diploid-uniform-addition (:instructions argmap) rate) + (diploid-uniform-deletion rate))) + ; :diploid-uniform-addition (-> (:plushy (selection/select-parent pop argmap)) (diploid-uniform-addition (:instructions argmap) (:umad-rate argmap)))