| AEM XYZ Circuit |
This applet shows X, Y, Z input elements sending pulses to active element B. (If this applet does not appear, you may need to update your JAVA virtual machine. )
In this model, active elements are represented with red (firing) and blue (not firing) circles. Connections between active elements are represnted with white lines. Each active element follows the rule:
If A_(0, i) (s) + A_(1, i) (s) + . . . A_(n, i) (s) > threshold_i then fire element i at time s if element i's refractory period has expired; otherwise, do not fire element i.
Click the Setup button. Next click the On button. A red circle represents that the element just fired. A blue circle represents that the element did not fire. A pink circle represents that the element did not fire and just fired one unit of time ago.
Observe the firing patterns of the active elements.
If you mention this model in an academic publication, please include these citations for the active element machine and for the NetLogo software:
- Michael Fiske (2011). NetLogo Active Element Machine model. http://www.aemea.org/msf/AEM.pdf.
- Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.
Copyright 2009-2011 Michael Fiske. All rights reserved.
;;
;; Active Element Machine
;; Simple Example of XYZ circuit
;;
;; Author: Michael Fiske
;; www.aemea.org/msf/AEM.pdf
;; See Example 1.2
;;
turtles-own
[
t ;; time that the active element is created
name ;; name of the active element
threshold ;; the threshold of the active element
refractory ;; the amount of time to elapse before name can fire again
last_time ;; x-coordinate
self_amplitude ;; NetLogo doesn't allow a turtle to link to itself.
self_width ;; This enables an AEM connection to itself.
self_delay
]
;;
links-own
[
s ;; time that the active element is created
from ;; name of the from active element
target ;; name of the to active element
amplitude ;; pulse amplitude
width ;; pulse width
delay ;; transmission time
]
;;
globals
[
time
num_elements
]
;;
;;;;;;;;;;;;;;;;;;;;;;;;
;;; Setup Procedures ;;;
;;;;;;;;;;;;;;;;;;;;;;;;
to setup
set time 0
clear-all
set-default-shape turtles "circle"
;;
make-XYZ-elements
make-B-connections
;;
display-architecture-values
;; [make_fire 0 time]
;; [make_fire 1 time]
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; NAND circuit procedures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to make-XYZ-elements
let element_size 7
crt 1 ;; Element x
[
set color blue
set label "X"
set size element_size
set xcor 50
set ycor 50
set t 0
set name 0
set threshold 0
set refractory 1
set last_time -1000
set self_amplitude 0
set self_width 0
set self_delay 0
]
crt 1 ;; Element y
[
set color blue
set label "Y"
set size element_size
set xcor 50
set ycor 100
set t 0
set name 1
set threshold 0
set refractory 1
set last_time -1000
set self_amplitude 0
set self_width 0
set self_delay 0
]
;;
crt 1 ;; Element H
[
set color blue
set label "Z"
set size element_size
set xcor 50
set ycor 150
set t 0
set name 2
set threshold 0
set refractory 1
set last_time -1000
set self_amplitude 0
set self_width 0
set self_delay 1
]
;;
crt 1 ;; Element L
[
set color blue
set label "B"
set size element_size
set xcor 100
set ycor 100
set t 0
set name 3
set threshold 10
set refractory 1
set last_time -1000
set self_amplitude 0
set self_width 0
set self_delay 1
]
end
to make-B-connections
;;
ask turtle 0 [ create-link-to turtle 3 ]
ask turtle 1 [ create-link-to turtle 3 ]
ask turtle 2 [ create-link-to turtle 3 ]
;;
;;
;;
;;
ask link 0 3 [set amplitude 3
set width 4
set delay 1
set label amplitude]
;;
ask link 1 3 [set amplitude 4
set width 2
set delay 3
set label amplitude]
;;
ask link 2 3 [set amplitude 4
set width 2
set delay 2
set label amplitude]
;;
end
to display-architecture-values
;;
ask link 0 3 [type "Connection (X, B): amplitude = " type amplitude type "\t width = " type width type "\t delay = " print delay]
ask link 1 3 [type "Connection (Y, B): amplitude = " type amplitude type "\t width = " type width type "\t delay = " print delay]
ask link 2 3 [type "Connection (Z, B): amplitude = " type amplitude type "\t width = " type width type "\t delay = " print delay]
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Runtime Procedures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to go
every 1
[
set num_elements count turtles
ifelse (time = 1) [make_fire 1 time] [turn_off 1 time]
ifelse (time = 2) [make_fire 2 time] [turn_off 2 time]
ifelse (time = 4) [make_fire 0 time] [turn_off 0 time]
tick
set time time + 1
ifelse (fire? 3 time) [turn-on 3] [turn-off 3]
print time
;; print true and true
]
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Active Element Machine routines
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to make_fire [i clock_time]
ask turtle i [set last_time clock_time]
turn-on i
end
to turn_off [i clock_time]
let s ( [last_time] of turtle i)
ifelse (s + 1 = clock_time) [ ask turtle i [set color pink] ]
[ ask turtle i [set color blue] ]
end
;;
;; Does not model AEM properly for firing pulses that overlap i.e. pulse widths are longer than the refractory
;; period. Need to create a list of last_times fired and store the pulse widths at those firing times also.
;;
to-report sum_inputs [i clock_time]
let amp_sum 0
let A_ki 0
let w_ki 0
let k 0
let s 0
let net_time 0
let delay_time 0
let connection_exists false
while [k < num_elements]
[
set s ( [last_time] of turtle k)
set connection_exists false
ifelse (k != i) and (is-link? (link k i))
[
set w_ki ( [width] of link k i)
set delay_time ( [delay] of link k i)
set connection_exists true
]
[ if (k = i) and (is-turtle? (turtle i) )
[
set w_ki ( [self_width] of turtle i)
set delay_time ( [self_delay] of turtle i)
set connection_exists true
]
]
;;
if connection_exists and (is-number? w_ki) and (is-number? delay_time) and (is-number? s)
[
set net_time (clock_time - s - delay_time)
if (net_time >= 0) and (net_time < w_ki)
[
ifelse (k != i)
[set A_ki ([amplitude] of link k i) ]
[set A_ki ([self_amplitude] of turtle i) ]
if (is-number? A_ki) [set amp_sum (amp_sum + A_ki) ]
]
]
set k (k + 1)
]
;;
;; type "A_ki = " type A_ki type "\t w_ki = " print w_ki
report amp_sum
end
to-report fire? [elem_num clock_time]
let refractory_period [refractory] of turtle elem_num
let time_last_fired [last_time] of turtle elem_num
let theta [threshold] of turtle elem_num
;;
ifelse ( (clock_time - time_last_fired) >= refractory_period ) and
( (sum_inputs elem_num clock_time) > theta )
[
ask turtle elem_num [set last_time clock_time]
report true
]
[ report false ]
end
to turn-on [turtle_num]
ask turtle turtle_num [set color red]
end
to turn-refractory-on [turtle_num]
ask turtle turtle_num [set color pink]
end
to turn-off [turtle_num]
ask turtle turtle_num [set color blue]
end