diff --git a/project.clj b/project.clj index c451a6d48..12a0cb44e 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject clojush "2.0.27" +(defproject clojush "2.0.28" :description "The Push programming language and the PushGP genetic programming system implemented in Clojure. See http://hampshire.edu/lspector/push.html" diff --git a/src/clojush/instructions/genome.clj b/src/clojush/instructions/genome.clj index 227ce8f6c..43945cf55 100644 --- a/src/clojush/instructions/genome.clj +++ b/src/clojush/instructions/genome.clj @@ -21,7 +21,8 @@ (if (and (not (empty? (:integer state))) (not (empty? (:genome state))) (not (empty? (stack-ref :genome 0 state))) - (< (count (first (:genome state))) @global-max-points)) ;; should really be max genome length + (< (count (first (:genome state))) + (/ @global-max-points 2))) (let [genome (stack-ref :genome 0 state) index (mod (stack-ref :integer 0 state) (count genome))] (->> (pop-item :integer state) diff --git a/src/clojush/problems/boolean/digital_multiplier.clj b/src/clojush/problems/boolean/digital_multiplier.clj index bd6f3950a..78ffbc4c0 100644 --- a/src/clojush/problems/boolean/digital_multiplier.clj +++ b/src/clojush/problems/boolean/digital_multiplier.clj @@ -129,8 +129,8 @@ :atom-generators (dm-atom-generators num-bits-n) :population-size 1000 :max-generations 500 - :max-points 400 - :max-points-in-initial-program 200 + :max-points 800 + :max-genome-size-in-initial-program 200 :evalpush-limit 400 :epigenetic-markers [] :genetic-operator-probabilities {[:alternation :uniform-mutation] 1} diff --git a/src/clojush/problems/boolean/mux_11.clj b/src/clojush/problems/boolean/mux_11.clj index 7ba343819..d60ac8a81 100644 --- a/src/clojush/problems/boolean/mux_11.clj +++ b/src/clojush/problems/boolean/mux_11.clj @@ -79,8 +79,8 @@ ;boolean_dup boolean_swap boolean_pop boolean_rot ) :population-size 100 - :max-points 100 - :max-points-in-initial-program 100 + :max-points 200 + :max-genome-size-in-initial-program 100 :genetic-operator-probabilities {:uniform-close-mutation 0.1 :alternation 0.45 :uniform-mutation 0.45} diff --git a/src/clojush/problems/boolean/mux_6.clj b/src/clojush/problems/boolean/mux_6.clj index 9a8914064..b3f98cb2a 100644 --- a/src/clojush/problems/boolean/mux_6.clj +++ b/src/clojush/problems/boolean/mux_6.clj @@ -73,8 +73,8 @@ d0 d1 d2 d3 ;boolean_dup boolean_swap boolean_pop boolean_rot ) - :max-points 200 - :max-points-in-initial-program 200 + :max-points 400 + :max-genome-size-in-initial-program 200 :genetic-operator-probabilities {:uniform-close-mutation 0.1 :alternation 0.45 :uniform-mutation 0.45} diff --git a/src/clojush/problems/boolean/mux_indexed.clj b/src/clojush/problems/boolean/mux_indexed.clj index 24dfe9d99..66c431349 100644 --- a/src/clojush/problems/boolean/mux_indexed.clj +++ b/src/clojush/problems/boolean/mux_indexed.clj @@ -87,8 +87,8 @@ ;integer_add integer_sub integer_mult integer_div integer_mod ;integer_dup integer_swap integer_pop integer_rot )) - :max-points 200 - :max-points-in-initial-program 200 + :max-points 400 + :max-genome-size-in-initial-program 200 :genetic-operator-probabilities {:uniform-close-mutation 0.1 :alternation 0.45 :uniform-mutation 0.45} diff --git a/src/clojush/problems/boolean/valiant.clj b/src/clojush/problems/boolean/valiant.clj index 953b97b63..c334bd994 100644 --- a/src/clojush/problems/boolean/valiant.clj +++ b/src/clojush/problems/boolean/valiant.clj @@ -97,8 +97,8 @@ ; (repeat 25 ; '(boolean_and boolean_or boolean_not exec_if)))) ; :use-lexicase-selection true -; :max-points 10000 -; :max-points-in-initial-program 10 +; :max-points 20000 +; :max-genome-size-in-initial-program 10 ; :population-size 100 ; :evalpush-limit 10000 ; :mutation-probability 0.4 @@ -121,8 +121,8 @@ (apply concat (repeat 25 '(boolean_and boolean_or boolean_not exec_if)))) - :max-points 1000 - :max-points-in-initial-program 100 + :max-points 2000 + :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 diff --git a/src/clojush/problems/control/dsoar.clj b/src/clojush/problems/control/dsoar.clj index be363f459..205afa0ad 100644 --- a/src/clojush/problems/control/dsoar.clj +++ b/src/clojush/problems/control/dsoar.clj @@ -293,7 +293,7 @@ ;:simplification-probability 0.3 ;:reproduction-probability 0.1 ;:reproduction-simplifications 10 - :max-points 200 - :max-points-in-initial-program 200 + :max-points 400 + :max-genome-size-in-initial-program 200 :evalpush-limit 1000 }) diff --git a/src/clojush/problems/control/lawnmower.clj b/src/clojush/problems/control/lawnmower.clj index 682fdce62..ef26b9571 100644 --- a/src/clojush/problems/control/lawnmower.clj +++ b/src/clojush/problems/control/lawnmower.clj @@ -237,7 +237,7 @@ ;:simplification-probability 0.3 ;:reproduction-probability 0.1 ;:reproduction-simplifications 10 - :max-points 200 - :max-points-in-initial-program 200 + :max-points 400 + :max-genome-size-in-initial-program 200 :evalpush-limit 1000 }) diff --git a/src/clojush/problems/demos/autoconstructive_digital_multiplier.clj b/src/clojush/problems/demos/autoconstructive_digital_multiplier.clj index 57b699253..155fdf7f6 100644 --- a/src/clojush/problems/demos/autoconstructive_digital_multiplier.clj +++ b/src/clojush/problems/demos/autoconstructive_digital_multiplier.clj @@ -210,13 +210,14 @@ ;(defn dm-meta-error-fn ; "Takes an individual and an argmap and returns a meta-error value." -; [ind {:keys [atom-generators max-points-in-initial-program] :as argmap}] -; (let [random-genome (random-plush-genome max-points-in-initial-program atom-generators argmap) +; [ind {:keys [atom-generators max-genome-size-in-initial-program] :as argmap}] +; (let [random-genome (random-plush-genome max-genome-size-in-initial-program atom-generators argmap) ; semantics-fn (fn [g1 g2] ; (full-dm-error-function ; (translate-plush-genome-to-push-program ; {:genome -; (produce-child-genome-by-autoconstruction g1 g2)}))) +; (produce-child-genome-by-autoconstruction g1 g2)} +; argmap))) ; e1 (semantics-fn (:genome ind) random-genome)] ; (if (= (:errors ind) e1) ; 1 @@ -243,8 +244,8 @@ :atom-generators (dm-atom-generators num-bits-n) :population-size 500 :max-generations 10000 - :max-points 2000 - :max-points-in-initial-program 100 + :max-points 4000 + :max-genome-size-in-initial-program 100 :evalpush-limit 10000 :epigenetic-markers [:close :silent] :genetic-operator-probabilities {:autoconstruction 1.0} diff --git a/src/clojush/problems/integer_regression/change.clj b/src/clojush/problems/integer_regression/change.clj index 471d1f85c..668378788 100644 --- a/src/clojush/problems/integer_regression/change.clj +++ b/src/clojush/problems/integer_regression/change.clj @@ -76,8 +76,8 @@ (def argmap {:error-function (change-error-function 150) :atom-generators change-atom-generators - :max-points 500 - :max-points-in-initial-program 500 + :max-points 1000 + :max-genome-size-in-initial-program 500 :evalpush-limit 800 :population-size 2000 :max-generations 1000 diff --git a/src/clojush/problems/integer_regression/factorial.clj b/src/clojush/problems/integer_regression/factorial.clj index 3bdb18e73..cc199d0ab 100644 --- a/src/clojush/problems/integer_regression/factorial.clj +++ b/src/clojush/problems/integer_regression/factorial.clj @@ -72,8 +72,8 @@ ) :population-size 1000 :max-generations 500 - :max-points 500 - :max-points-in-initial-program 100 + :max-points 1000 + :max-genome-size-in-initial-program 100 :evalpush-limit 1000 :genetic-operator-probabilities {[:alternation :uniform-mutation] 0.5 [:alternation :uniform-mutation :uniform-close-mutation] 0.5} diff --git a/src/clojush/problems/integer_regression/mackey_glass_int.clj b/src/clojush/problems/integer_regression/mackey_glass_int.clj index 8815ab19c..a20988615 100644 --- a/src/clojush/problems/integer_regression/mackey_glass_int.clj +++ b/src/clojush/problems/integer_regression/mackey_glass_int.clj @@ -96,8 +96,8 @@ {:error-function (partial error-function 200);; Use 200 random samples :atom-generators atom-generators :report-simplifications 0 - :max-points 500 - :max-points-in-initial-program 500 + :max-points 1000 + :max-genome-size-in-initial-program 500 :evalpush-limit 500 :population-size 1000 :epigenetic-markers [] diff --git a/src/clojush/problems/integer_regression/tagged_tg8.clj b/src/clojush/problems/integer_regression/tagged_tg8.clj index f4f8a6379..1e994fa60 100644 --- a/src/clojush/problems/integer_regression/tagged_tg8.clj +++ b/src/clojush/problems/integer_regression/tagged_tg8.clj @@ -51,7 +51,7 @@ :genetic-operator-probabilities {:alternation 0.5 :uniform-mutation 0.4 :uniform-close-mutation 0.1} - :max-points 100 - :max-points-in-initial-program 100 + :max-points 200 + :max-genome-size-in-initial-program 100 :population-size 5000 }) diff --git a/src/clojush/problems/integer_regression/tg8.clj b/src/clojush/problems/integer_regression/tg8.clj index 67407c6f0..f0a72a2a6 100644 --- a/src/clojush/problems/integer_regression/tg8.clj +++ b/src/clojush/problems/integer_regression/tg8.clj @@ -51,7 +51,7 @@ ;:crossover-probability 0.3 ;:simplification-probability 0.3 ;:reproduction-simplifications 10 - :max-points 100 - :max-points-in-initial-program 100 + :max-points 200 + :max-genome-size-in-initial-program 100 :population-size 5000 }) diff --git a/src/clojush/problems/regression/bioavailability.clj b/src/clojush/problems/regression/bioavailability.clj index 429b78654..457de5cd2 100644 --- a/src/clojush/problems/regression/bioavailability.clj +++ b/src/clojush/problems/regression/bioavailability.clj @@ -138,8 +138,8 @@ (def argmap {:error-function (partial bioavailability-error-function :train) :atom-generators bioavailability-atom-generators - :max-points 500 - :max-points-in-initial-program 500 + :max-points 1000 + :max-genome-size-in-initial-program 500 :evalpush-limit 500 :population-size 500 :max-generations 100 diff --git a/src/clojush/problems/regression/korns_regression_p12.clj b/src/clojush/problems/regression/korns_regression_p12.clj index cbfba817d..92b350b5a 100644 --- a/src/clojush/problems/regression/korns_regression_p12.clj +++ b/src/clojush/problems/regression/korns_regression_p12.clj @@ -276,8 +276,8 @@ 'float_cos ;'float_tan ) - :max-points 30 - :max-points-in-initial-program 30 + :max-points 60 + :max-genome-size-in-initial-program 30 :evalpush-limit 50 :population-size 500 :epigenetic-markers [] diff --git a/src/clojush/problems/regression/pagie_hogeweg_with_erc.clj b/src/clojush/problems/regression/pagie_hogeweg_with_erc.clj index 15b67166a..6f50d3cde 100644 --- a/src/clojush/problems/regression/pagie_hogeweg_with_erc.clj +++ b/src/clojush/problems/regression/pagie_hogeweg_with_erc.clj @@ -87,8 +87,8 @@ {:error-function (partial error-function (count data));; Use all samples :atom-generators atom-generators :report-simplifications 0 - :max-points 500 - :max-points-in-initial-program 500 + :max-points 1000 + :max-genome-size-in-initial-program 500 :evalpush-limit 500 :population-size 1000 :max-generations 1000 diff --git a/src/clojush/problems/software/calc.clj b/src/clojush/problems/software/calc.clj index 0379eb372..9de346137 100644 --- a/src/clojush/problems/software/calc.clj +++ b/src/clojush/problems/software/calc.clj @@ -489,8 +489,8 @@ :max-generations 100000 :evalpush-limit 3000 :tag-limit 10000 - :max-points 3000 - :max-points-in-initial-program 500 ;;100 + :max-points 6000 + :max-genome-size-in-initial-program 500 ;;100 :mutation-probability 0.0 :crossover-probability 0.0 :simplification-probability 0 diff --git a/src/clojush/problems/software/checksum.clj b/src/clojush/problems/software/checksum.clj index efa290b81..c77dd5f61 100644 --- a/src/clojush/problems/software/checksum.clj +++ b/src/clojush/problems/software/checksum.clj @@ -151,8 +151,8 @@ (def argmap {:error-function (checksum-error-function checksum-data-domains) :atom-generators checksum-atom-generators - :max-points 800 - :max-points-in-initial-program 400 + :max-points 1600 + :max-genome-size-in-initial-program 400 :evalpush-limit 1500 :population-size 1000 :max-generations 300 diff --git a/src/clojush/problems/software/collatz_numbers.clj b/src/clojush/problems/software/collatz_numbers.clj index 3a94a4315..7a76ac232 100644 --- a/src/clojush/problems/software/collatz_numbers.clj +++ b/src/clojush/problems/software/collatz_numbers.clj @@ -138,8 +138,8 @@ (def argmap {:error-function (collatz-numbers-error-function collatz-numbers-data-domains) :atom-generators collatz-numbers-atom-generators - :max-points 600 - :max-points-in-initial-program 300 + :max-points 1200 + :max-genome-size-in-initial-program 300 :evalpush-limit 15000 :population-size 1000 :max-generations 300 diff --git a/src/clojush/problems/software/compare_string_lengths.clj b/src/clojush/problems/software/compare_string_lengths.clj index a3fccebdd..b9c6b94d3 100644 --- a/src/clojush/problems/software/compare_string_lengths.clj +++ b/src/clojush/problems/software/compare_string_lengths.clj @@ -138,8 +138,8 @@ (def argmap {:error-function (csl-error-function csl-data-domains) :atom-generators csl-atom-generators - :max-points 400 - :max-points-in-initial-program 200 + :max-points 800 + :max-genome-size-in-initial-program 200 :evalpush-limit 600 :population-size 1000 :max-generations 300 diff --git a/src/clojush/problems/software/count_odds.clj b/src/clojush/problems/software/count_odds.clj index a71b82c30..e51536f7e 100644 --- a/src/clojush/problems/software/count_odds.clj +++ b/src/clojush/problems/software/count_odds.clj @@ -144,8 +144,8 @@ (def argmap {:error-function (count-odds-error-function count-odds-data-domains) :atom-generators count-odds-atom-generators - :max-points 500 - :max-points-in-initial-program 250 + :max-points 1000 + :max-genome-size-in-initial-program 250 :evalpush-limit 1500 :population-size 1000 :max-generations 300 diff --git a/src/clojush/problems/software/digits.clj b/src/clojush/problems/software/digits.clj index 955d92b34..d218a051b 100644 --- a/src/clojush/problems/software/digits.clj +++ b/src/clojush/problems/software/digits.clj @@ -132,8 +132,8 @@ (def argmap {:error-function (digits-error-function digits-data-domains) :atom-generators digits-atom-generators - :max-points 300 - :max-points-in-initial-program 150 + :max-points 600 + :max-genome-size-in-initial-program 150 :evalpush-limit 600 :population-size 1000 :max-generations 300 diff --git a/src/clojush/problems/software/double_letters.clj b/src/clojush/problems/software/double_letters.clj index f79ce0e53..b16cc796f 100644 --- a/src/clojush/problems/software/double_letters.clj +++ b/src/clojush/problems/software/double_letters.clj @@ -148,8 +148,8 @@ (def argmap {:error-function (double-letters-error-function double-letters-data-domains) :atom-generators double-letters-atom-generators - :max-points 800 - :max-points-in-initial-program 400 + :max-points 1600 + :max-genome-size-in-initial-program 400 :evalpush-limit 1600 :population-size 1000 :max-generations 300 diff --git a/src/clojush/problems/software/even_squares.clj b/src/clojush/problems/software/even_squares.clj index 996c18882..485a5f865 100644 --- a/src/clojush/problems/software/even_squares.clj +++ b/src/clojush/problems/software/even_squares.clj @@ -150,8 +150,8 @@ (def argmap {:error-function (even-squares-error-function even-squares-data-domains) :atom-generators even-squares-atom-generators - :max-points 400 - :max-points-in-initial-program 200 + :max-points 800 + :max-genome-size-in-initial-program 200 :evalpush-limit 2000 :population-size 1000 :max-generations 300 diff --git a/src/clojush/problems/software/for_loop_index.clj b/src/clojush/problems/software/for_loop_index.clj index fbb905229..de7c72dce 100644 --- a/src/clojush/problems/software/for_loop_index.clj +++ b/src/clojush/problems/software/for_loop_index.clj @@ -141,8 +141,8 @@ (def argmap {:error-function (loop-error-function loop-data-domains) :atom-generators loop-atom-generators - :max-points 300 - :max-points-in-initial-program 150 + :max-points 600 + :max-genome-size-in-initial-program 150 :evalpush-limit 600 :population-size 1000 :max-generations 300 diff --git a/src/clojush/problems/software/grade.clj b/src/clojush/problems/software/grade.clj index d38a1d10a..62a9c4048 100644 --- a/src/clojush/problems/software/grade.clj +++ b/src/clojush/problems/software/grade.clj @@ -198,8 +198,8 @@ (def argmap {:error-function (grade-error-function grade-data-domains) :atom-generators grade-atom-generators - :max-points 400 - :max-points-in-initial-program 200 + :max-points 800 + :max-genome-size-in-initial-program 200 :evalpush-limit 800 :population-size 1000 :max-generations 300 diff --git a/src/clojush/problems/software/last_index_of_zero.clj b/src/clojush/problems/software/last_index_of_zero.clj index 24a7990c5..676db0b8c 100644 --- a/src/clojush/problems/software/last_index_of_zero.clj +++ b/src/clojush/problems/software/last_index_of_zero.clj @@ -148,8 +148,8 @@ (def argmap {:error-function (last-index-of-zero-error-function last-index-of-zero-data-domains) :atom-generators last-index-of-zero-atom-generators - :max-points 300 - :max-points-in-initial-program 150 + :max-points 600 + :max-genome-size-in-initial-program 150 :evalpush-limit 600 :population-size 1000 :max-generations 300 diff --git a/src/clojush/problems/software/median.clj b/src/clojush/problems/software/median.clj index 80bc1c699..dd993d773 100644 --- a/src/clojush/problems/software/median.clj +++ b/src/clojush/problems/software/median.clj @@ -127,8 +127,8 @@ (def argmap {:error-function (median-error-function median-data-domains) :atom-generators median-atom-generators - :max-points 200 - :max-points-in-initial-program 100 + :max-points 400 + :max-genome-size-in-initial-program 100 :evalpush-limit 200 :population-size 1000 :max-generations 200 diff --git a/src/clojush/problems/software/mirror_image.clj b/src/clojush/problems/software/mirror_image.clj index dfe9a1d4a..549819e0e 100644 --- a/src/clojush/problems/software/mirror_image.clj +++ b/src/clojush/problems/software/mirror_image.clj @@ -164,8 +164,8 @@ (def argmap {:error-function (mirror-image-error-function mirror-image-data-domains) :atom-generators mirror-image-atom-generators - :max-points 300 - :max-points-in-initial-program 150 + :max-points 600 + :max-genome-size-in-initial-program 150 :evalpush-limit 600 :population-size 1000 :max-generations 300 diff --git a/src/clojush/problems/software/negative_to_zero.clj b/src/clojush/problems/software/negative_to_zero.clj index 20c1b2973..1990483ef 100644 --- a/src/clojush/problems/software/negative_to_zero.clj +++ b/src/clojush/problems/software/negative_to_zero.clj @@ -148,8 +148,8 @@ (def argmap {:error-function (negative-to-zero-error-function negative-to-zero-data-domains) :atom-generators negative-to-zero-atom-generators - :max-points 500 - :max-points-in-initial-program 250 + :max-points 1000 + :max-genome-size-in-initial-program 250 :evalpush-limit 1500 :population-size 1000 :max-generations 300 diff --git a/src/clojush/problems/software/number_io.clj b/src/clojush/problems/software/number_io.clj index 5b8f87e94..764ccd376 100644 --- a/src/clojush/problems/software/number_io.clj +++ b/src/clojush/problems/software/number_io.clj @@ -130,8 +130,8 @@ (def argmap {:error-function (num-io-error-function num-io-data-domains) :atom-generators num-io-atom-generators - :max-points 200 - :max-points-in-initial-program 100 + :max-points 400 + :max-genome-size-in-initial-program 100 :evalpush-limit 200 :population-size 1000 :max-generations 200 diff --git a/src/clojush/problems/software/pig_latin.clj b/src/clojush/problems/software/pig_latin.clj index ddbcef46f..69e4d67a2 100644 --- a/src/clojush/problems/software/pig_latin.clj +++ b/src/clojush/problems/software/pig_latin.clj @@ -159,8 +159,8 @@ (def argmap {:error-function (pig-latin-error-function pig-latin-data-domains) :atom-generators pig-latin-atom-generators - :max-points 1000 - :max-points-in-initial-program 500 + :max-points 2000 + :max-genome-size-in-initial-program 500 :evalpush-limit 2000 :population-size 1000 :max-generations 300 diff --git a/src/clojush/problems/software/replace_space_with_newline.clj b/src/clojush/problems/software/replace_space_with_newline.clj index 9efc0f42f..a8a4f7034 100644 --- a/src/clojush/problems/software/replace_space_with_newline.clj +++ b/src/clojush/problems/software/replace_space_with_newline.clj @@ -160,8 +160,8 @@ (def argmap {:error-function (replace-space-error-function replace-space-data-domains) :atom-generators replace-space-atom-generators - :max-points 800 - :max-points-in-initial-program 400 + :max-points 1600 + :max-genome-size-in-initial-program 400 :evalpush-limit 1600 :population-size 1000 :max-generations 300 diff --git a/src/clojush/problems/software/scrabble_score.clj b/src/clojush/problems/software/scrabble_score.clj index cb21c20c7..7e6406f6d 100644 --- a/src/clojush/problems/software/scrabble_score.clj +++ b/src/clojush/problems/software/scrabble_score.clj @@ -180,8 +180,8 @@ (def argmap {:error-function (scrabble-score-error-function scrabble-score-data-domains) :atom-generators scrabble-score-atom-generators - :max-points 1000 - :max-points-in-initial-program 500 + :max-points 2000 + :max-genome-size-in-initial-program 500 :evalpush-limit 2000 :population-size 1000 :max-generations 300 diff --git a/src/clojush/problems/software/small_or_large.clj b/src/clojush/problems/software/small_or_large.clj index 77a8b4c46..14805d47b 100644 --- a/src/clojush/problems/software/small_or_large.clj +++ b/src/clojush/problems/software/small_or_large.clj @@ -127,8 +127,8 @@ (def argmap {:error-function (small-or-large-error-function small-or-large-data-domains) :atom-generators small-or-large-atom-generators - :max-points 200 - :max-points-in-initial-program 100 + :max-points 400 + :max-genome-size-in-initial-program 100 :evalpush-limit 300 :population-size 1000 :max-generations 300 diff --git a/src/clojush/problems/software/smallest.clj b/src/clojush/problems/software/smallest.clj index 84d104442..7da33e177 100644 --- a/src/clojush/problems/software/smallest.clj +++ b/src/clojush/problems/software/smallest.clj @@ -130,8 +130,8 @@ (def argmap {:error-function (smallest-error-function smallest-data-domains) :atom-generators smallest-atom-generators - :max-points 200 - :max-points-in-initial-program 100 + :max-points 400 + :max-genome-size-in-initial-program 100 :evalpush-limit 200 :population-size 1000 :max-generations 200 diff --git a/src/clojush/problems/software/string_differences.clj b/src/clojush/problems/software/string_differences.clj index e79a7eca0..47b6010b7 100644 --- a/src/clojush/problems/software/string_differences.clj +++ b/src/clojush/problems/software/string_differences.clj @@ -204,8 +204,8 @@ (def argmap {:error-function (string-differences-error-function string-differences-data-domains) :atom-generators string-differences-atom-generators - :max-points 1000 - :max-points-in-initial-program 500 + :max-points 2000 + :max-genome-size-in-initial-program 500 :evalpush-limit 2000 :population-size 1000 :max-generations 300 diff --git a/src/clojush/problems/software/string_lengths_backwards.clj b/src/clojush/problems/software/string_lengths_backwards.clj index dd28e39f1..c5f7620a6 100644 --- a/src/clojush/problems/software/string_lengths_backwards.clj +++ b/src/clojush/problems/software/string_lengths_backwards.clj @@ -143,8 +143,8 @@ (def argmap {:error-function (string-lengths-error-function string-lengths-data-domains) :atom-generators string-lengths-atom-generators - :max-points 300 - :max-points-in-initial-program 150 + :max-points 600 + :max-genome-size-in-initial-program 150 :evalpush-limit 600 :population-size 1000 :max-generations 300 diff --git a/src/clojush/problems/software/sum_of_squares.clj b/src/clojush/problems/software/sum_of_squares.clj index 2544455c2..676e9b165 100644 --- a/src/clojush/problems/software/sum_of_squares.clj +++ b/src/clojush/problems/software/sum_of_squares.clj @@ -127,8 +127,8 @@ (def argmap {:error-function (sum-of-squares-error-function sum-of-squares-data-domains) :atom-generators sum-of-squares-atom-generators - :max-points 400 - :max-points-in-initial-program 200 + :max-points 800 + :max-genome-size-in-initial-program 200 :evalpush-limit 4000 :population-size 1000 :max-generations 300 diff --git a/src/clojush/problems/software/super_anagrams.clj b/src/clojush/problems/software/super_anagrams.clj index 78f706cd6..ec2cdd7e1 100644 --- a/src/clojush/problems/software/super_anagrams.clj +++ b/src/clojush/problems/software/super_anagrams.clj @@ -187,8 +187,8 @@ (def argmap {:error-function (super-anagrams-error-function super-anagrams-data-domains) :atom-generators super-anagrams-atom-generators - :max-points 800 - :max-points-in-initial-program 400 + :max-points 1600 + :max-genome-size-in-initial-program 400 :evalpush-limit 1600 :population-size 1000 :max-generations 300 diff --git a/src/clojush/problems/software/syllables.clj b/src/clojush/problems/software/syllables.clj index e12f77101..67416e50e 100644 --- a/src/clojush/problems/software/syllables.clj +++ b/src/clojush/problems/software/syllables.clj @@ -156,8 +156,8 @@ (def argmap {:error-function (syllables-error-function syllables-data-domains) :atom-generators syllables-atom-generators - :max-points 800 - :max-points-in-initial-program 400 + :max-points 1600 + :max-genome-size-in-initial-program 400 :evalpush-limit 1600 :population-size 1000 :max-generations 300 diff --git a/src/clojush/problems/software/vector_average.clj b/src/clojush/problems/software/vector_average.clj index 9d9a95abe..6a66d871b 100644 --- a/src/clojush/problems/software/vector_average.clj +++ b/src/clojush/problems/software/vector_average.clj @@ -138,8 +138,8 @@ (def argmap {:error-function (vector-average-error-function vector-average-data-domains) :atom-generators vector-average-atom-generators - :max-points 400 - :max-points-in-initial-program 200 + :max-points 800 + :max-genome-size-in-initial-program 200 :evalpush-limit 800 :population-size 1000 :max-generations 300 diff --git a/src/clojush/problems/software/vectors_summed.clj b/src/clojush/problems/software/vectors_summed.clj index 01ad45a1c..14eca767a 100644 --- a/src/clojush/problems/software/vectors_summed.clj +++ b/src/clojush/problems/software/vectors_summed.clj @@ -150,8 +150,8 @@ (def argmap {:error-function (vectors-summed-error-function vectors-summed-data-domains) :atom-generators vectors-summed-atom-generators - :max-points 500 - :max-points-in-initial-program 250 + :max-points 1000 + :max-genome-size-in-initial-program 250 :evalpush-limit 1500 :population-size 1000 :max-generations 300 diff --git a/src/clojush/problems/software/wallis_pi.clj b/src/clojush/problems/software/wallis_pi.clj index fae92bb95..ca689d96c 100644 --- a/src/clojush/problems/software/wallis_pi.clj +++ b/src/clojush/problems/software/wallis_pi.clj @@ -149,8 +149,8 @@ (def argmap {:error-function (wallis-pi-error-function wallis-pi-data-domains) :atom-generators wallis-pi-atom-generators - :max-points 600 - :max-points-in-initial-program 300 + :max-points 1200 + :max-genome-size-in-initial-program 300 :evalpush-limit 8000 :population-size 1000 :max-generations 300 diff --git a/src/clojush/problems/software/wc.clj b/src/clojush/problems/software/wc.clj index 244e9a3a0..a46500d8e 100644 --- a/src/clojush/problems/software/wc.clj +++ b/src/clojush/problems/software/wc.clj @@ -334,8 +334,8 @@ (def argmap {:error-function (wc-error-function wc-data-domains) :atom-generators wc-atom-generators - :max-points 1000 - :max-points-in-initial-program 400 + :max-points 2000 + :max-genome-size-in-initial-program 400 :evalpush-limit 2000 :population-size 1000 :max-generations 300 diff --git a/src/clojush/problems/software/word_stats.clj b/src/clojush/problems/software/word_stats.clj index 7d07f3909..929978597 100644 --- a/src/clojush/problems/software/word_stats.clj +++ b/src/clojush/problems/software/word_stats.clj @@ -266,8 +266,8 @@ (def argmap {:error-function (word-stats-error-function word-stats-data-domains) :atom-generators word-stats-atom-generators - :max-points 800 - :max-points-in-initial-program 400 + :max-points 1600 + :max-genome-size-in-initial-program 400 :evalpush-limit 6000 :population-size 1000 :max-generations 300 diff --git a/src/clojush/problems/software/x_word_lines.clj b/src/clojush/problems/software/x_word_lines.clj index 91ef048ca..9be8d518c 100644 --- a/src/clojush/problems/software/x_word_lines.clj +++ b/src/clojush/problems/software/x_word_lines.clj @@ -204,8 +204,8 @@ (def argmap {:error-function (x-word-lines-error-function x-word-lines-data-domains) :atom-generators x-word-lines-atom-generators - :max-points 800 - :max-points-in-initial-program 400 + :max-points 1600 + :max-genome-size-in-initial-program 400 :evalpush-limit 1600 :population-size 1000 :max-generations 300 diff --git a/src/clojush/problems/synthetic/majority.clj b/src/clojush/problems/synthetic/majority.clj index bcd9b02eb..d5a23d007 100644 --- a/src/clojush/problems/synthetic/majority.clj +++ b/src/clojush/problems/synthetic/majority.clj @@ -42,8 +42,8 @@ depth and number of nodes." (reset! global-problem-size size) (println "problem-size =" size) (def argmap - {:max-points (* 10 size) - :max-points-in-initial-program (* 10 size) + {:max-points (* 10 2 size) + :max-genome-size-in-initial-program (* 10 size) :error-function majority-fitness :atom-generators atom-generators :epigenetic-markers [] diff --git a/src/clojush/problems/synthetic/order.clj b/src/clojush/problems/synthetic/order.clj index 3f5d6b38a..84f1ad62b 100644 --- a/src/clojush/problems/synthetic/order.clj +++ b/src/clojush/problems/synthetic/order.clj @@ -43,8 +43,8 @@ depth and number of nodes." (reset! global-problem-size size) (println "problem-size =" size) (def argmap - {:max-points (* 10 size) - :max-points-in-initial-program (* 10 size) + {:max-points (* 10 2 size) + :max-genome-size-in-initial-program (* 10 size) :error-function order-fitness :atom-generators atom-generators :epigenetic-markers [] diff --git a/src/clojush/pushgp/breed.clj b/src/clojush/pushgp/breed.clj index 587056eef..d7ead2141 100644 --- a/src/clojush/pushgp/breed.clj +++ b/src/clojush/pushgp/breed.clj @@ -28,13 +28,13 @@ In future, may implement :delete, which deletes some of the instructions in a parent." [parent child {:keys [replace-child-that-exceeds-size-limit-with atom-generators - max-points-in-initial-program max-points] + max-genome-size-in-initial-program max-points] :as argmap}] (case replace-child-that-exceeds-size-limit-with :parent parent :empty (make-individual :genome '() :genetic-operators :empty) - :truncate (assoc child :genome (take max-points (:genome child))) - :random (make-individual :genome (random-plush-genome max-points-in-initial-program atom-generators argmap) + :truncate (assoc child :genome (take (/ max-points 2) (:genome child))) + :random (make-individual :genome (random-plush-genome max-genome-size-in-initial-program atom-generators argmap) :genetic-operators :random) )) @@ -42,12 +42,12 @@ "Evaluates child and parent, returning the child if it is at least as good as the parent on every test case." [child parent rand-gen {:keys [error-function parent-reversion-probability] :as argmap}] - (let [evaluated-child (evaluate-individual (assoc child :program (translate-plush-genome-to-push-program child)) + (let [evaluated-child (evaluate-individual (assoc child :program (translate-plush-genome-to-push-program child argmap)) error-function rand-gen argmap)] (if (>= (lrand) parent-reversion-probability) evaluated-child (let [child-errors (:errors evaluated-child) - evaluated-parent (evaluate-individual (assoc parent :program (translate-plush-genome-to-push-program parent)) + evaluated-parent (evaluate-individual (assoc parent :program (translate-plush-genome-to-push-program parent argmap)) error-function rand-gen argmap) parent-errors (:errors evaluated-parent)] (if (reduce #(and %1 %2) @@ -93,7 +93,8 @@ child (perform-genetic-operator-list operator-vector (assoc first-parent :parent-uuids (vector (:uuid first-parent))) population location rand-gen argmap)] - (if (> (count (:genome child)) max-points) ; Check if too big + (if (> (count (:genome child)) + (/ max-points 2)) ; Check if too big (revert-too-big-child first-parent child argmap) (assoc child :genetic-operators operator diff --git a/src/clojush/pushgp/genetic_operators.clj b/src/clojush/pushgp/genetic_operators.clj index 0769c4004..42171437d 100644 --- a/src/clojush/pushgp/genetic_operators.clj +++ b/src/clojush/pushgp/genetic_operators.clj @@ -167,7 +167,7 @@ given by uniform-deletion-rate." use-s1 (lrand-nth [true false]) result-genome []] (if (or (>= i (count (if use-s1 s1 s2))) ;; finished current program - (> (count result-genome) (* 2 max-points))) ;; runaway growth + (> (count result-genome) max-points)) ;; runaway growth (seq result-genome);; Return, converting back into a sequence (if (< (lrand) alternation-rate) (recur (max 0 (+' i (Math/round (*' alignment-deviation (gaussian-noise-factor))))) @@ -308,7 +308,7 @@ given by uniform-deletion-rate." (defn autoconstruction "Returns a genome for child produced by autoconstruction by executing parent1 with parent1, and parent2 on top of the genome stack. EXPERIMENTAL AND SUBJECT TO CHANGE." - [parent1 parent2 {:keys [maintain-ancestors atom-generators max-points-in-initial-program error-function] + [parent1 parent2 {:keys [maintain-ancestors atom-generators max-genome-size-in-initial-program error-function] :as argmap}] (let [parent1-genome (:genome parent1) parent2-genome (:genome parent2) @@ -316,7 +316,7 @@ and parent2 on top of the genome stack. EXPERIMENTAL AND SUBJECT TO CHANGE." competent (reproductively-competent? child-genome) new-genome (if competent child-genome - (random-plush-genome max-points-in-initial-program atom-generators argmap))] + (random-plush-genome max-genome-size-in-initial-program atom-generators argmap))] (assoc (make-individual :genome new-genome :history (:history parent1) :ancestors (if maintain-ancestors diff --git a/src/clojush/pushgp/pushgp.clj b/src/clojush/pushgp/pushgp.clj index 9ccbd97cb..30718fb0b 100644 --- a/src/clojush/pushgp/pushgp.clj +++ b/src/clojush/pushgp/pushgp.clj @@ -31,8 +31,8 @@ :population-size 1000 ;; Number of individuals in the population :max-generations 1001 ;; The maximum number of generations to run GP :max-point-evaluations 10e100 ;; The limit for the number of point (instruction) evaluations to execute during the run - :max-points 50 ;; Maximum size of push programs, as counted by points in the program - :max-points-in-initial-program 50 ;; Maximum size of initial programs in generation 0 + :max-points 100 ;; Maximum size of push programs and push code, as counted by points in the program. 1/2 this limit is used as the limit for sizes of Plush genomes. + :max-genome-size-in-initial-program 50 ;; Maximum size of initial Plush genomes in generation 0. Keep in mind that genome lengths will otherwise be limited by 1/2 of :max-points :evalpush-limit 150 ;; The number of Push instructions that can be evaluated before stopping evaluation :evalpush-time-limit 0 ;; The time in nanoseconds that a program can evaluate before stopping, 0 means no time limit :reuse-errors true ;; When true, children produced through direct reproduction will not be re-evaluated but will have the error vector of their parent @@ -74,7 +74,7 @@ :close-increment-rate 0.2 ;; The probability of making an increment change to :close during uniform close mutation, as opposed to a decrement change :uniform-deletion-rate 0.01 ;; The probability that any instruction will be deleted during uniform deletion :uniform-silence-mutation-rate 0.1 ;; The probability of each :silent being switched during uniform silent mutation - :replace-child-that-exceeds-size-limit-with :random ;; When a child is produced that exceeds the size limit of max-points, this is used to determine what program to return. Options include :parent, :empty, :random, :truncate + :replace-child-that-exceeds-size-limit-with :random ;; When a child is produced that exceeds the size limit of (max-points / 2), this is used to determine what program to return. Options include :parent, :empty, :random, :truncate :parent-reversion-probability 1.0 ;; The probability of a child being reverted to its parent by a genetic operator that has been made revertable, if the child is not as good as the parent on at least one test case ;; ;;---------------------------------------- @@ -150,8 +150,8 @@ (throw (Exception. (str "globals.clj definition " gname " has no matching argument in push-argmap. Only such definitions should use the prefix 'global-'.")))))) (defn make-agents-and-rng - [{:keys [use-single-thread population-size - max-points-in-initial-program atom-generators random-seed + [{:keys [use-single-thread population-size random-seed + max-genome-size-in-initial-program atom-generators save-initial-population] :as argmap}] (let [agent-error-handler (fn [agnt except] @@ -169,8 +169,9 @@ seeds)))] {:pop-agents (let [pa (doall (for [_ (range population-size)] (make-individual - :genome (random-plush-genome max-points-in-initial-program - atom-generators argmap) + :genome (random-plush-genome max-genome-size-in-initial-program + atom-generators + argmap) :genetic-operators :random))) f (str "data/" (System/currentTimeMillis) ".ser")] (when save-initial-population diff --git a/src/clojush/random.clj b/src/clojush/random.clj index 7020e63d5..2196d8fe3 100644 --- a/src/clojush/random.clj +++ b/src/clojush/random.clj @@ -69,18 +69,18 @@ (defn random-plush-genome-with-size "Returns a random Plush genome containing the given number of points." - [points atom-generators argmap] - (repeatedly points + [genome-size atom-generators argmap] + (repeatedly genome-size #(random-plush-instruction-map atom-generators argmap))) (defn random-plush-genome - "Returns a random Plush genome with size limited by max-points." - ([max-points atom-generators] - (random-plush-genome max-points atom-generators {})) - ([max-points atom-generators argmap] - (random-plush-genome-with-size (inc (lrand-int max-points)) + "Returns a random Plush genome with size limited by max-genome-size." + ([max-genome-size atom-generators] + (random-plush-genome max-genome-size atom-generators {})) + ([max-genome-size atom-generators argmap] + (random-plush-genome-with-size (inc (lrand-int max-genome-size)) atom-generators argmap))) @@ -90,7 +90,10 @@ (defn random-push-code "Returns a random Push expression with size limited by max-points." ([max-points atom-generators] - (random-push-code max-points atom-generators {})) + (random-push-code max-points atom-generators {:max-points @global-max-points})) ([max-points atom-generators argmap] (translate-plush-genome-to-push-program - {:genome (random-plush-genome max-points atom-generators argmap)}))) + {:genome (random-plush-genome (max (int (/ max-points 2)) 1) + atom-generators + argmap)} + argmap))) diff --git a/src/clojush/translate.clj b/src/clojush/translate.clj index fca35b20a..6bea5a18d 100644 --- a/src/clojush/translate.clj +++ b/src/clojush/translate.clj @@ -59,61 +59,72 @@ If the end of the program is reached but parens are still needed (as indicated by the paren-stack), parens are added until the paren-stack is empty. Instruction maps that have :silence set to true will be ignored entirely." - [{:keys [genome program]}] + [{:keys [genome program]} + {:keys [max-points] :as argmap}] (if program program - (loop [prog [] ; The Push program incrementally being built - gn genome ; The linear Plush genome, where items will be popped off the front. Each item is a map containing at least the key :instruction, and unless the program is flat, also :close - num-parens-here 0 ; The number of parens that still need to be added at this location. - paren-stack '()] ; Whenever an instruction requires parens grouping, it will push either :close or :close-open on this stack. This will indicate what to insert in the program the next time a paren is indicated by the :close key in the instruction map. - (cond - ; Check if need to add close parens here - (< 0 num-parens-here) (recur (cond - (= (first paren-stack) :close) (conj prog :close) - (= (first paren-stack) :close-open) (conj (conj prog :close) :open) - :else prog) ; If paren-stack is empty, we won't put any parens in even though the :close epigenetic marker indicated to do so - gn - (dec num-parens-here) - (rest paren-stack)) - ; Check if at end of program but still need to add parens - (and (empty? gn) - (not (empty? paren-stack))) (recur prog - gn - (count paren-stack) - paren-stack) - ; Check if done - (empty? gn) (open-close-sequence-to-list (apply list prog)) - ; Check for silenced instruction - (get (first gn) :silent false) (recur prog - (rest gn) - num-parens-here - paren-stack) - ; If here, ready for next instruction - :else (let [number-paren-groups (lookup-instruction-paren-groups (:instruction (first gn))) - new-paren-stack (if (>= 0 number-paren-groups) - paren-stack - (concat (repeat (dec number-paren-groups) :close-open) - '(:close) - paren-stack))] - (if (= 'noop_delete_prev_paren_pair (:instruction (first gn))) - (recur (delete-prev-paren-pair prog) - (rest gn) - (get (first gn) :close 0) - new-paren-stack) - (recur (if (= 'noop_open_paren (:instruction (first gn))) - (conj prog :open) - (if (>= 0 number-paren-groups) - (conj prog (:instruction (first gn))) - (conj (conj prog (:instruction (first gn))) :open))) - (rest gn) - (get (first gn) :close 0) ; The number of close parens to put after this instruction; if :close isn't in instruction map, default to zero - new-paren-stack))))))) + (let [translated-program + (loop [prog [] ; The Push program incrementally being built + gn genome ; The linear Plush genome, where items will be popped off the front. Each item is a map containing at least the key :instruction, and unless the program is flat, also :close + num-parens-here 0 ; The number of parens that still need to be added at this location. + paren-stack '()] ; Whenever an instruction requires parens grouping, it will push either :close or :close-open on this stack. This will indicate what to insert in the program the next time a paren is indicated by the :close key in the instruction map. + (cond + ; Check if need to add close parens here + (< 0 num-parens-here) (recur (cond + (= (first paren-stack) :close) (conj prog :close) + (= (first paren-stack) :close-open) (conj (conj prog :close) :open) + :else prog) ; If paren-stack is empty, we won't put any parens in even though the :close epigenetic marker indicated to do so + gn + (dec num-parens-here) + (rest paren-stack)) + ; Check if at end of program but still need to add parens + (and (empty? gn) + (not (empty? paren-stack))) (recur prog + gn + (count paren-stack) + paren-stack) + ; Check if done + (empty? gn) (open-close-sequence-to-list (apply list prog)) + ; Check for silenced instruction + (get (first gn) :silent false) (recur prog + (rest gn) + num-parens-here + paren-stack) + ; If here, ready for next instruction + :else (let [number-paren-groups (lookup-instruction-paren-groups (:instruction (first gn))) + new-paren-stack (if (>= 0 number-paren-groups) + paren-stack + (concat (repeat (dec number-paren-groups) :close-open) + '(:close) + paren-stack))] + (if (= 'noop_delete_prev_paren_pair (:instruction (first gn))) + (recur (delete-prev-paren-pair prog) + (rest gn) + (get (first gn) :close 0) + new-paren-stack) + (recur (if (= 'noop_open_paren (:instruction (first gn))) + (conj prog :open) + (if (>= 0 number-paren-groups) + (conj prog (:instruction (first gn))) + (conj (conj prog (:instruction (first gn))) :open))) + (rest gn) + (get (first gn) :close 0) ; The number of close parens to put after this instruction; if :close isn't in instruction map, default to zero + new-paren-stack)))))] + (if (<= (count-points translated-program) max-points) + translated-program + (do + (println "WARNING: A translated program was bigger than max-points. Recuring translation after removing the last instruction in genome.") + (println " genome length:" (count genome)) + (println " points in program:" (count-points translated-program)) + (println " :max-points:" max-points) + (recur {:genome (butlast genome)} + argmap)))))) (defn population-translate-plush-to-push "Converts the population of Plush genomes into Push programs." - [pop-agents {:keys [use-single-thread]}] + [pop-agents {:keys [use-single-thread] :as argmap}] (dorun (map #((if use-single-thread swap! send) % - (fn [i] (assoc i :program (translate-plush-genome-to-push-program i)))) + (fn [i] (assoc i :program (translate-plush-genome-to-push-program i argmap)))) pop-agents)) (when-not use-single-thread (apply await pop-agents))) ;; SYNCHRONIZE