-
Notifications
You must be signed in to change notification settings - Fork 1
/
atm_email_example.clj
30 lines (26 loc) · 1.01 KB
/
atm_email_example.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
(ns gp.problems.atm.email (:use gp))
(defn fitness [individual]
(+
(if (= (individual false false false) false) 1 0)
(if (= (individual false false true) true) 1 0)
(if (= (individual false true false) true) 1 0)
(if (= (individual false true true) true) 1 0)
(if (= (individual true false false) false) 1 0)
(if (= (individual true false true) false) 1 0)
(if (= (individual true true false) false) 1 0)
(if (= (individual true true true) false) 1 0)))
(defn termination [individual]
(= 8 (fitness individual)))
(def parameters
['statement-printed
'money-withdrawn
'money-deposited])
(evolve {:generations 500 :population-size 200 :max-height 5
:fitness fitness :termination termination
:functions [['and 2] ['or 2] ['not 1]] :terminals [true false]
:parameters parameters
:output (fn [g b _]
(println "Generation: " g)
(println "Fitness: "
(fitness (to-fn parameters b)))
(prn b))})