File: solve.lisp

package info (click to toggle)
cl-rsm-genetic-alg 1.2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 88 kB
  • ctags: 35
  • sloc: lisp: 571; makefile: 44; sh: 28
file content (50 lines) | stat: -rw-r--r-- 1,396 bytes parent folder | download | duplicates (2)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
;;;;
;;;; SOLVE THE SAMPLE PROBLEMS.
;;;;


;;;; problems1.lisp

;;; Clear out the old problems.
(rsm.genetic-alg:clear-genetic-problems)

;;; Compile and load a list of genetic problem definitions from file 
;;; problems1.lisp.
(compile-file "problems1.lisp")
(load "problems1")

(format t "~%SOLVE ALL PROBLEMS (in problem set 1):~%~%")
;;; Solve the genetic problems by running a simulation that evolves
;;; the gene pool of each problem 500 times.
(rsm.genetic-alg:display-solutions 
 (rsm.genetic-alg:solve-all-genetic-problems 500))

(format t "~%SOLVE JUST \"MAX_ONES\" (in problem set 1):~%~%")

;;; Or, just solve the problem named "max-ones".
(rsm.genetic-alg:display-solution 
 (rsm.genetic-alg:solve-genetic-problem 500 "max-ones"))


;;;; problems2.lisp

;;; Clear out the old problems.
(rsm.genetic-alg:clear-genetic-problems)

;;; Compile and load a list of genetic problem definitions from file 
;;; problems2.lisp.
(compile-file "problems2.lisp")
(load "problems2")

(format t "~%SOLVE ALL PROBLEMS (in problem set 2):~%~%")

;;; Solve the genetic problem. Run 1500 evolution steps; the 
;;; genes are allowed to vary in size; the 
;;; mutation rate is 10%. 
;;; Display the best 3 solutions found of all the gene pools produced.
(rsm.genetic-alg:display-solutions 
 (rsm.genetic-alg:solve-all-genetic-problems 
  500 
  :gene-length-constant? nil 
  :mutation-rate 10 
  :k 3))