Adding Genetic Operators
In addition to the already-included genetic operators, you can add your own!
Variation Genetic Operators
- Go to
propeller.variation.cljc
- Define a genetic operator function
- In
propeller.variation/new-individual
, add the new genetic operator in thenew-individual
function under thecase
call - When running a problem, specify the genetic operator in
:variation
. For example:
(defn new-individual
"Returns a new individual produced by selection and variation of
individuals in the population."
[pop argmap]
...
(case op
...
:new-genetic-operator
(-> (:plushy (selection/select-parent pop argmap))
(new-genetic-operator ))
...
:else
(throw #?(:clj (Exception. (str "No match in new-individual for " op))
:cljs (js/Error
(str "No match in new-individual for " op))))))})
lein run -m propeller.problems.simple-regression :variation "{:new-genetic-operator 1.0}"
Selection Genetic Operators
- Go to
propeller.selection.cljc
- Define a genetic operator function
- In
propeller.selection.cljc
, add the new genetic operator in theselect-parent
function under thecase
call. - When running a problem, specify the selection method in
:parent-selection
(defn select-parent
"Selects a parent from the population using the specified method."
[pop argmap]
(case (:parent-selection argmap)
...
:new-genetic-operator (:new-genetic-operator )
...
))
For example:
lein run -m propeller.problems.simple-regression :parent-selection :new-genetic-operator