update docs site
This commit is contained in:
parent
a00c35385f
commit
fb0888edd5
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -3,18 +3,17 @@
|
|||||||
1. Define a selection method function in `propeller.selection` that selects an individual from the population
|
1. Define a selection method function in `propeller.selection` that selects an individual from the population
|
||||||
2. Add the selection method in `propeller.selection/select-parent` under the `case` call:
|
2. Add the selection method in `propeller.selection/select-parent` under the `case` call:
|
||||||
|
|
||||||
```clojure
|
```clojure
|
||||||
(defn select-parent
|
(defn select-parent
|
||||||
"Selects a parent from the population using the specified method."
|
"Selects a parent from the population using the specified method."
|
||||||
[pop argmap]
|
[pop argmap]
|
||||||
(case (:parent-selection argmap)
|
(case (:parent-selection argmap)
|
||||||
:new-selection-method (new-selection-method )))
|
:new-selection-method (new-selection-method )))
|
||||||
```
|
```
|
||||||
|
|
||||||
3. When runnning a problem, specify the selection method in `:parent-selection`.
|
3. When runnning a problem, specify the selection method in `:parent-selection`.
|
||||||
For example:
|
For example:
|
||||||
```
|
```
|
||||||
lein run -m propeller.problems.simple-regression :parent-selection :new-selection-method"
|
lein run -m propeller.problems.simple-regression :parent-selection :new-selection-method"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
(ns propeller.core
|
(ns ^:no-doc propeller.core
|
||||||
#?(:clj (:gen-class)))
|
#?(:clj (:gen-class)))
|
||||||
|
|
||||||
(defn -main
|
(defn -main
|
||||||
|
@ -13,7 +13,12 @@ They hold the genetic material for an `individual`. In the initial population, w
|
|||||||
#(utils/random-instruction instructions)))
|
#(utils/random-instruction instructions)))
|
||||||
|
|
||||||
(defn plushy->push
|
(defn plushy->push
|
||||||
"Returns the Push program expressed by the given plushy representation."
|
"Returns the Push program expressed by the given plushy representation.
|
||||||
|
|
||||||
|
The function takes in a plushy representation as input and converts it into a Push program by iteratively processing
|
||||||
|
the plushy elements and adding instructions to the push program.
|
||||||
|
It also handles the case where there are open instructions that need to be closed before the end of the program.
|
||||||
|
"
|
||||||
([plushy] (plushy->push plushy {}))
|
([plushy] (plushy->push plushy {}))
|
||||||
([plushy argmap]
|
([plushy argmap]
|
||||||
(let [plushy (if (:diploid argmap) (map first (partition 2 plushy)) plushy)
|
(let [plushy (if (:diploid argmap) (map first (partition 2 plushy)) plushy)
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
[propeller.selection :as selection]))
|
[propeller.selection :as selection]))
|
||||||
|
|
||||||
(defn report
|
(defn report
|
||||||
"Reports information each generation."
|
"Reports information for each generation."
|
||||||
[pop generation argmap]
|
[pop generation argmap]
|
||||||
(let [best (first pop)]
|
(let [best (first pop)]
|
||||||
(clojure.pprint/pprint {:generation generation
|
(clojure.pprint/pprint {:generation generation
|
||||||
@ -31,7 +31,25 @@
|
|||||||
(println)))
|
(println)))
|
||||||
|
|
||||||
(defn gp
|
(defn gp
|
||||||
"Main GP loop."
|
"Main GP loop.
|
||||||
|
|
||||||
|
On each iteration, it creates a population of random plushies using a mapper
|
||||||
|
function and genome/make-random-plushy function,
|
||||||
|
then it sorts the population by the total error using the error-function
|
||||||
|
and sort-by function. It then takes the best individual from the sorted population,
|
||||||
|
and if the parent selection is set to epsilon-lexicase, it adds the epsilons to the argmap.
|
||||||
|
|
||||||
|
The function then checks if the custom-report argument is set,
|
||||||
|
if so it calls that function passing the evaluated population,
|
||||||
|
current generation and argmap. If not, it calls the report function
|
||||||
|
passing the evaluated population, current generation and argmap.
|
||||||
|
|
||||||
|
Then, it checks if the total error of the best individual is less than or equal
|
||||||
|
to the solution-error-threshold or if the current generation is greater than or
|
||||||
|
equal to the max-generations specified. If either is true, the function
|
||||||
|
exits with the best individual or nil. If not, it creates new individuals
|
||||||
|
for the next generation using the variation/new-individual function and the
|
||||||
|
repeatedly function, and then continues to the next iteration of the loop. "
|
||||||
[{:keys [population-size max-generations error-function instructions
|
[{:keys [population-size max-generations error-function instructions
|
||||||
max-initial-plushy-size solution-error-threshold mapper]
|
max-initial-plushy-size solution-error-threshold mapper]
|
||||||
:or {solution-error-threshold 0.0
|
:or {solution-error-threshold 0.0
|
||||||
@ -79,26 +97,3 @@
|
|||||||
(repeatedly population-size
|
(repeatedly population-size
|
||||||
#(variation/new-individual evaluated-pop argmap))))))))
|
#(variation/new-individual evaluated-pop argmap))))))))
|
||||||
|
|
||||||
; This code is defining a function called "gp" (short for genetic programming) that takes in a map of parameters as its argument.
|
|
||||||
; The map contains keys such as "population-size", "max-generations", "error-function", "instructions", "max-initial-plushy-size",
|
|
||||||
; "solution-error-threshold", and "mapper", with default values specified for some of them.
|
|
||||||
;
|
|
||||||
;The function starts by printing some information about the starting arguments using
|
|
||||||
; the prn function and then uses a loop to iterate over generations.
|
|
||||||
; On each iteration, it creates a population of random plushies using a mapper
|
|
||||||
; function and genome/make-random-plushy function,
|
|
||||||
; then it sorts the population by the total error using the error-function
|
|
||||||
; and sort-by function. It then takes the best individual from the sorted population,
|
|
||||||
; and if the parent selection is set to epsilon-lexicase, it adds the epsilons to the argmap.
|
|
||||||
;
|
|
||||||
;The function then checks if the custom-report argument is set,
|
|
||||||
; if so it calls that function passing the evaluated population,
|
|
||||||
; current generation and argmap. If not, it calls the report function
|
|
||||||
; passing the evaluated population, current generation and argmap.
|
|
||||||
;
|
|
||||||
;Then, it checks if the total error of the best individual is less than or equal
|
|
||||||
; to the solution-error-threshold or if the current generation is greater than or
|
|
||||||
; equal to the max-generations specified. If either is true, the function
|
|
||||||
; exits with the best individual or nil. If not, it creates new individuals
|
|
||||||
; for the next generation using the variation/new-individual function and the
|
|
||||||
; repeatedly function, and then continues to the next iteration of the loop.
|
|
@ -1,4 +1,4 @@
|
|||||||
(ns propeller.main
|
(ns ^:no-doc propeller.main
|
||||||
(:require [propeller.core :as propeller]))
|
(:require [propeller.core :as propeller]))
|
||||||
|
|
||||||
(defn main! []
|
(defn main! []
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
; The commented-out stuff is a reminder of how to do some basic things.
|
; The commented-out stuff is a reminder of how to do some basic things.
|
||||||
|
|
||||||
|
|
||||||
(ns propeller.session
|
(ns ^:no-doc propeller.session
|
||||||
"The \"session\" namespace is for trying things out interactively.
|
"The \"session\" namespace is for trying things out interactively.
|
||||||
For example, you can use it to test a new Push instruction by running a program that uses it and seeing the result.
|
For example, you can use it to test a new Push instruction by running a program that uses it and seeing the result.
|
||||||
You might just want to do this interactively in the REPL, but the session file makes it a little easier since it already
|
You might just want to do this interactively in the REPL, but the session file makes it a little easier since it already
|
||||||
|
Loading…
x
Reference in New Issue
Block a user