-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.lisp
executable file
·58 lines (54 loc) · 1.78 KB
/
test.lisp
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
51
52
53
54
55
56
57
58
(in-package :cl-user)
#-fast
(eval-when
#-:gcl (:compile-toplevel :execute :load-toplevel)
#+:gcl (compile eval load)
(proclaim '(optimize (speed 0) (safety 3) (space 0)(debug 3)(compilation-speed 0)))
)
#+fast
(eval-when
#-:gcl (:compile-toplevel :execute :load-toplevel)
#+:gcl (compile eval load)
(proclaim '(optimize (speed 3) (safety 0) (space 0)(debug 0)(compilation-speed 0)))
)
(defun test-backtracking (title solver &optional (print t)(repetitions 1))
(let ((solution nil)
(before (get-internal-real-time))
after)
(dotimes (x repetitions)
(setq solution (solve-it solver)))
(setq after (get-internal-real-time))
(when print
(show-result solution SOLVER title (- after before))
(format t "~2%")
)
solution
)
)
(defun test-gsat (title solver &optional (print t))
(let ((solution nil)
(before (get-internal-real-time))
after)
(setq solution (solve-it solver))
(setq after (get-internal-real-time))
(when print
(cond (solution
(show-result solution SOLVER title (- after before))
(format t "Iterations:~a~%" (GSAT-SOLVED-ITERATION solver))
(format t "Solutions Tried:~a~%" (solution-tried solver))
)
(t
(format t "~%Failed:~a~%" title)
(format t "~%No solution found, in ~a Iterations. Solutions tried:~a Time ~10,2f seconds ~%"
(GSAT-MAX-tries solver)
(solution-tried solver)
(float (/ (float (- after before)) internal-time-units-per-second)))
)
)
(format t "Worser:~a~%" (GSAT-WORSENED solver))
(format t "Aborted:~a~%" (GSAT-aborted solver))
(format t "~2%")
)
)
(values)
)