Skip to content

Commit

Permalink
Added autoconstructive-entropy.
Browse files Browse the repository at this point in the history
  • Loading branch information
lspector committed Jan 8, 2017
1 parent f9e9178 commit f562f1c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/clojush/args.clj
Expand Up @@ -191,6 +191,9 @@
;; Specifies the probability that a clone will be produced rather than the result of
;; actual autoconstruction, when :autoconstructive is true.

:autoconstructive-entropy 0.0
;; The rate for random gene deletions after autoconstruction.

:autoconstructive-diffmeans-children 10
;; When using :autoconstructive-diversification-test :diffmeans-diversifying?, specifies
;; how many children of each child to generate and test. See genetic-operators.clj.
Expand Down
21 changes: 16 additions & 5 deletions src/clojush/pushgp/genetic_operators.clj
@@ -1,3 +1,6 @@
;; 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 @@ -706,16 +709,22 @@ genome is returned. The construct/clone ration is hardcoded here, but might
be set globally or eliminated in the future."
[parent1 parent2 {:keys [maintain-ancestors atom-generators max-genome-size-in-initial-program
error-function autoconstructive-improve-or-diversify
autoconstructive-fotd autoconstructive-clone-probability]
autoconstructive-fotd autoconstructive-clone-probability
autoconstructive-entropy]
:as argmap}]
(if autoconstructive-fotd
(fotd-autoconstruction parent1 parent2 argmap)
(let [parent1-genome (:genome parent1)
parent2-genome (:genome parent2)
child-genome (if (> (lrand) autoconstructive-clone-probability)
(produce-child-genome-by-autoconstruction
parent1-genome parent2-genome false argmap)
parent1-genome)
pre-entropy-child-genome (if (> (lrand) autoconstructive-clone-probability)
(produce-child-genome-by-autoconstruction
parent1-genome parent2-genome false argmap)
parent1-genome)
child-genome (if (zero? autoconstructive-entropy)
pre-entropy-child-genome
(vec (filter identity
(map #(if (< (lrand) autoconstructive-entropy) nil %)
pre-entropy-child-genome))))
child-errors (if autoconstructive-improve-or-diversify
(do
(swap! evaluations-count inc)
Expand Down Expand Up @@ -744,3 +753,5 @@ be set globally or eliminated in the future."




;; @@

0 comments on commit f562f1c

Please sign in to comment.