/[cells]/cells/test-synapse.lisp
ViewVC logotype

Contents of /cells/test-synapse.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Fri Nov 30 16:51:18 2007 UTC (6 years, 4 months ago) by ktilton
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +1 -0 lines
*** empty log message ***
1 ;; -*- mode: Lisp; Syntax: Common-Lisp; Package: cells; -*-
2 ;;;
3 ;;; Copyright (c) 1995,2003 by Kenneth William Tilton.
4 ;;;
5 ;;; Permission is hereby granted, free of charge, to any person obtaining a copy
6 ;;; of this software and associated documentation files (the "Software"), to deal
7 ;;; in the Software without restriction, including without limitation the rights
8 ;;; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 ;;; copies of the Software, and to permit persons to whom the Software is furnished
10 ;;; to do so, subject to the following conditions:
11 ;;;
12 ;;; The above copyright notice and this permission notice shall be included in
13 ;;; all copies or substantial portions of the Software.
14 ;;;
15 ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 ;;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 ;;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 ;;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 ;;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 ;;; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 ;;; IN THE SOFTWARE.
22
23 (in-package :cells)
24
25
26 (defmodel m-syn ()
27 ((m-syn-a :initform nil :initarg :m-syn-a :accessor m-syn-a)
28 (m-syn-b :initform nil :initarg :m-syn-b :accessor m-syn-b)
29 (m-syn-factor :initform nil :initarg :m-syn-factor :accessor m-syn-factor)
30 (m-sens :initform nil :initarg :m-sens :accessor m-sens)
31 (m-plus :initform nil :initarg :m-plus :accessor m-plus)
32 ))
33
34 (def-c-output m-syn-b ()
35 (print `(output m-syn-b ,self ,new-value ,old-value)))
36
37
38
39 (def-cell-test m-syn
40 (progn (cell-reset)
41 (let* ((delta-ct 0)
42 (sens-ct 0)
43 (plus-ct 0)
44 (m (make-be 'm-syn
45 :m-syn-a (c-in 0)
46 :m-syn-b (c? (incf delta-ct)
47 (trc nil "syn-b rule firing!!!!!!!!!!!!!!" delta-ct)
48 (eko (nil "syn-b rule returning")
49 (f-delta :syna-1 (:sensitivity 2)
50 (^m-syn-a))))
51 :m-syn-factor (c-in 1)
52 :m-sens (c? (incf sens-ct)
53 (trc nil "m-sens rule firing ~d !!!!!!!!!!!!!!" sens-ct)
54 (* (^m-syn-factor)
55 (f-sensitivity :sensa (3) (^m-syn-a))))
56 :m-plus (c? (incf plus-ct)
57 (trc nil "m-plus rule firing!!!!!!!!!!!!!!" plus-ct)
58 (f-plusp :syna-2 (- 2 (^m-syn-a)))))))
59 (ct-assert (= 1 delta-ct))
60 (ct-assert (= 1 sens-ct))
61 (ct-assert (= 1 plus-ct))
62 (ct-assert (= 0 (m-sens m)))
63 (trc "make-be complete. about to incf m-syn-a")
64 (incf (m-syn-a m))
65 (ct-assert (= 1 delta-ct))
66 (ct-assert (= 1 sens-ct))
67 (ct-assert (= 1 plus-ct))
68 (ct-assert (= 0 (m-sens m)))
69 (trc "about to incf m-syn-a 2")
70 (incf (m-syn-a m) 2)
71 (trc nil "syn-b now" (m-syn-b m))
72 (ct-assert (= 2 delta-ct))
73 (ct-assert (= 2 sens-ct))
74 (ct-assert (= 2 plus-ct))
75
76 (ct-assert (= 3 (m-sens m)))
77 (trc "about to incf m-syn-a")
78 (incf (m-syn-a m))
79 (ct-assert (= 2 delta-ct))
80 (ct-assert (= 2 sens-ct))
81 (trc "about to incf m-syn-factor")
82 (incf (m-syn-factor m))
83 (ct-assert (= 3 sens-ct))
84 (ct-assert (= (m-sens m) (* (m-syn-factor m) (m-syn-a m))))
85 (trc "about to incf m-syn-a xxx")
86 (incf (m-syn-a m))
87 (ct-assert (= 2 delta-ct))
88 (ct-assert (= 3 sens-ct))
89 (trc "about to incf m-syn-a yyyy")
90 (incf (m-syn-a m))
91 (ct-assert (= 3 delta-ct))
92 (ct-assert (= 4 sens-ct))
93 (ct-assert (= 2 plus-ct))
94 (describe m)
95 (print '(start)))))
96
97 (Def-c-output m-syn-a ()
98 (trc "!!! M-SYN-A now =" new-value))
99
100 #+(or)
101 (m-syn)
102

  ViewVC Help
Powered by ViewVC 1.1.5