Skip to content

Commit

Permalink
Added :autoconstructive-si-children to parameterize size & instructio…
Browse files Browse the repository at this point in the history
…n diversification tests; default is 8 for backwards compatibility.
  • Loading branch information
lspector committed Jan 11, 2017
1 parent 2f64eee commit a47e486
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/clojush/args.clj
@@ -1,6 +1,3 @@
;; gorilla-repl.fileformat = 1

;; @@
(ns clojush.args
(:require [clj-random.core :as random])
(:use [clojush globals random util pushstate]
Expand Down Expand Up @@ -198,6 +195,10 @@
;; When using :autoconstructive-diversification-test :diffmeans-diversifying?, specifies
;; how many children of each child to generate and test. See genetic-operators.clj.

:autoconstructive-si-children 8
;; When using a "size and instruction" diversification test, specifies how many
;; children to generate and test. See genetic-operators.clj.

:autoconstructive-fotd false
;; If true, autoconstruction will be performed using the 'flavor of the day' code in
;; genetic_operators.clj, which may change without fanfare. Other autoconstruction-related
Expand Down Expand Up @@ -523,4 +524,3 @@



;; @@
10 changes: 4 additions & 6 deletions src/clojush/pushgp/genetic_operators.clj
@@ -1,6 +1,3 @@
;; gorilla-repl.fileformat = 1

;; @@
(ns clojush.pushgp.genetic-operators
(:use [clojush util random individual globals interpreter translate pushstate]
clojush.instructions.tag
Expand Down Expand Up @@ -573,7 +570,8 @@ programs encoded by genomes g1 and g2."
(defn size-and-instruction-diversifying?
"Returns true iff genome g passes the diversification test."
[g argmap]
(let [kids (repeatedly 8 #(produce-child-genome-by-autoconstruction g g false argmap))
(let [kids (repeatedly (:autoconstructive-si-children argmap)
#(produce-child-genome-by-autoconstruction g g false argmap))
instruction-set (fn [genome]
(hash-set (keys (frequencies (map :instruction genome)))))]
(and (not (some #{g} kids))
Expand All @@ -586,7 +584,8 @@ programs encoded by genomes g1 and g2."
(let [make-child #(produce-child-genome-by-autoconstruction % % false argmap)
instruction-set (fn [genome]
(hash-set (keys (frequencies (map :instruction genome)))))
kids (repeatedly 8 #(make-child g))
kids (repeatedly (:autoconstructive-si-children argmap)
#(make-child g))
grandkids (map make-child kids)]
(and (apply distinct? (concat kids grandkids [g]))
(not (apply = (map count kids)))
Expand Down Expand Up @@ -755,4 +754,3 @@ be set globally or eliminated in the future."



;; @@

0 comments on commit a47e486

Please sign in to comment.