-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathslipnet-functions.lisp
103 lines (80 loc) · 3.89 KB
/
slipnet-functions.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
;---------------------------------------------
; SLIPNET-FUNCTIONS: This file contains functions for the Slipnet.
;---------------------------------------------
(in-package 'user)
(defmethod (slipnode :activate-from-workspace) ()
(incf activation-buffer %workspace-activation%))
;---------------------------------------------
(defmethod (slipnode :add-activation-to-buffer) (activation-to-add)
(incf activation-buffer activation-to-add))
;---------------------------------------------
(defmethod (slipnode :subtract-activation-from-buffer) (activation-to-subtract)
(decf activation-buffer activation-to-subtract))
;---------------------------------------------
(defmethod (slipnode :decay) ()
; A node loses (100 - conceptual-depth) percent of its activation.
(send self :subtract-activation-from-buffer
(round (* (/ (fake-reciprocal (send self :conceptual-depth)) 100)
(send self :activation)))))
;---------------------------------------------
(defun update-slipnet (&aux amount-to-spread full-activation-probability)
; Decay and spread activation (change buffers, not actual activation, until
; all nodes have been updated).
(loop for node in *slipnet* do
(send node :decay)
; If node is active, spread activation to neighbors.
; Note that activation spreading uses the intrinsic link-length,
; not the shrunk link length.
(if* (= (send node :activation) %max-activation%)
then ; Give each neighbor the percentage of the activation
; proportional to the inverse of its distance from the
; original node.
(loop for link in (send node :outgoing-links) do
(setq amount-to-spread
(round (* (/ (send link
:intrinsic-degree-of-association)
100.0)
(send node :activation))))
(send (send link :to-node)
:add-activation-to-buffer amount-to-spread))))
; Next, the actual activation of each node is updated for the next time step.
(loop for node in *slipnet* do
(send node :set-activation
(min %max-activation%
(+ (send node :activation)
(send node :activation-buffer))))
; If node is still clamped, then activate it.
(if* (send node :clamp)
then (send node :set-activation %max-activation%)
else ; See if node should become active. The decision is
; is a probabilistic function of activation.
(if* (>= (send node :activation) %full-activation-threshold%)
then (setq full-activation-probability
(cube (/ (send node :activation) 100)))
(if* (eq (flip-coin full-activation-probability) 'heads)
then (send node :set-activation %max-activation%))))
(send node :set-activation-buffer 0)))
;---------------------------------------------
(defun get-top-down-codelets ()
; Returns a list of top-down codelets, attached to active nodes, to be posted.
(loop for node in *slipnet* do
(if* (and (>= (send node :activation) %full-activation-threshold%)
(send node :codelets))
then (send node :get-codelets))))
;---------------------------------------------
(defmethod (slipnode :get-codelets) ()
(loop for codelet in codelets do
; Decide whether or not to post this codelet, and if so, how many
; copies to post.
(if* (eq (flip-coin (get-post-codelet-probability
(send codelet :structure-category))) 'heads)
then (loop for i from 1 to (get-num-of-codelets-to-post
(send codelet :structure-category)) do
(push (make-codelet (send codelet :codelet-type)
(send codelet :arguments)
(get-urgency-bin
(* (send self :activation)
(/ (send self :conceptual-depth)
100))))
*codelets-to-post*)))))
;---------------------------------------------