For bmx, add instances of :gap in initial plushy genomes according to :bmx-gap-probability
This commit is contained in:
parent
27857faf85
commit
28ab925601
@ -6,11 +6,17 @@ They hold the genetic material for an `individual`. In the initial population, w
|
|||||||
[propeller.utils :as utils]))
|
[propeller.utils :as utils]))
|
||||||
|
|
||||||
(defn make-random-plushy
|
(defn make-random-plushy
|
||||||
"Creates and returns a new plushy made of random instructions and of a maximum size of max-initial-plushy-size."
|
"Creates and returns a new plushy made of random instructions."
|
||||||
[instructions max-initial-plushy-size]
|
[{:keys [instructions max-initial-plushy-size bmx? bmx-gap-probability]}]
|
||||||
|
(if bmx?
|
||||||
(repeatedly
|
(repeatedly
|
||||||
(rand-int max-initial-plushy-size)
|
(rand-int max-initial-plushy-size)
|
||||||
#(utils/random-instruction instructions)))
|
#(if (< (rand) bmx-gap-probability)
|
||||||
|
:gap
|
||||||
|
(utils/random-instruction instructions)))
|
||||||
|
(repeatedly
|
||||||
|
(rand-int max-initial-plushy-size)
|
||||||
|
#(utils/random-instruction instructions))))
|
||||||
|
|
||||||
(defn plushy->push-internal
|
(defn plushy->push-internal
|
||||||
[plushy argmap]
|
[plushy argmap]
|
||||||
|
@ -50,8 +50,8 @@
|
|||||||
|
|
||||||
(defn gp
|
(defn gp
|
||||||
"Main GP function"
|
"Main GP function"
|
||||||
[{:keys [population-size max-generations error-function instructions max-initial-plushy-size
|
[{:keys [population-size max-generations error-function solution-error-threshold
|
||||||
solution-error-threshold ds-parent-rate ds-parent-gens dont-end ids-type downsample?]
|
ds-parent-rate ds-parent-gens dont-end ids-type downsample?]
|
||||||
:or {solution-error-threshold 0.0
|
:or {solution-error-threshold 0.0
|
||||||
dont-end false
|
dont-end false
|
||||||
ds-parent-rate 0
|
ds-parent-rate 0
|
||||||
@ -69,7 +69,7 @@
|
|||||||
(loop [generation 0
|
(loop [generation 0
|
||||||
evaluations 0
|
evaluations 0
|
||||||
population (utils/pmapallv
|
population (utils/pmapallv
|
||||||
(fn [_] {:plushy (genome/make-random-plushy instructions max-initial-plushy-size)})
|
(fn [_] {:plushy (genome/make-random-plushy argmap)})
|
||||||
(range population-size)
|
(range population-size)
|
||||||
argmap)
|
argmap)
|
||||||
indexed-training-data (if downsample?
|
indexed-training-data (if downsample?
|
||||||
|
@ -55,7 +55,9 @@
|
|||||||
;; and returning the Push program expressed by the genome:
|
;; and returning the Push program expressed by the genome:
|
||||||
|
|
||||||
#_(genome/plushy->push
|
#_(genome/plushy->push
|
||||||
(genome/make-random-plushy (instructions/get-stack-instructions #{:float :integer :exec :boolean}) 20))
|
(genome/make-random-plushy
|
||||||
|
{:instructions (instructions/get-stack-instructions #{:float :integer :exec :boolean})
|
||||||
|
:bmx-gap-probability 20}))
|
||||||
|
|
||||||
;; One way of running a genetic programming problem defined in the project
|
;; One way of running a genetic programming problem defined in the project
|
||||||
;; is to require the problem's namespace and then call `gp/gp` using the
|
;; is to require the problem's namespace and then call `gp/gp` using the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user