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]))
|
||||
|
||||
(defn make-random-plushy
|
||||
"Creates and returns a new plushy made of random instructions and of a maximum size of max-initial-plushy-size."
|
||||
[instructions max-initial-plushy-size]
|
||||
(repeatedly
|
||||
(rand-int max-initial-plushy-size)
|
||||
#(utils/random-instruction instructions)))
|
||||
"Creates and returns a new plushy made of random instructions."
|
||||
[{:keys [instructions max-initial-plushy-size bmx? bmx-gap-probability]}]
|
||||
(if bmx?
|
||||
(repeatedly
|
||||
(rand-int max-initial-plushy-size)
|
||||
#(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
|
||||
[plushy argmap]
|
||||
|
@ -50,8 +50,8 @@
|
||||
|
||||
(defn gp
|
||||
"Main GP function"
|
||||
[{:keys [population-size max-generations error-function instructions max-initial-plushy-size
|
||||
solution-error-threshold ds-parent-rate ds-parent-gens dont-end ids-type downsample?]
|
||||
[{:keys [population-size max-generations error-function solution-error-threshold
|
||||
ds-parent-rate ds-parent-gens dont-end ids-type downsample?]
|
||||
:or {solution-error-threshold 0.0
|
||||
dont-end false
|
||||
ds-parent-rate 0
|
||||
@ -69,7 +69,7 @@
|
||||
(loop [generation 0
|
||||
evaluations 0
|
||||
population (utils/pmapallv
|
||||
(fn [_] {:plushy (genome/make-random-plushy instructions max-initial-plushy-size)})
|
||||
(fn [_] {:plushy (genome/make-random-plushy argmap)})
|
||||
(range population-size)
|
||||
argmap)
|
||||
indexed-training-data (if downsample?
|
||||
|
@ -55,7 +55,9 @@
|
||||
;; and returning the Push program expressed by the genome:
|
||||
|
||||
#_(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
|
||||
;; is to require the problem's namespace and then call `gp/gp` using the
|
||||
|
Loading…
x
Reference in New Issue
Block a user