Polychronous Wavefront Computing Simulator

Polychronous Wavefront Computing Simulator preview image

1 collaborator

Default-person Fred Highland (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.0.2 • Viewed 201 times • Downloaded 16 times • Run 0 times
Download the 'Polychronous Wavefront Computing Simulator' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


Info tab cannot be displayed because of an encoding error

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

;;
;; Polychronous Wavefront Computing Research Simulator
;;
;; Simulation of a Polychronous Wavefront Computing (PWC - Izhikevich and Hoppensteadt, 2009)
;;   Incorporating:
;;     Leaky Integrate and Fire semantics (Gerstner and Kistler, 2002),
;;     Spike-Timing-Dependent Plasticity (STDP) learning (Song, Miller and Abbott, 2000),
;;     Potentiation decay (membrane threshold decay) (Miller and Jin, 2013),
;;     Axonal conduction delay (Izhikevich, 2006, Highland & Hart, 2016) and
;;     Synaptic Fatigue (activation potential depletion) (Simons-Weidemaier, Weber, Plappert, Pilz & Schmid, 2006, Highland & Hart, 2016)
;;     Transponder position learning (Highland & Hart, 2015)
;;   Using alternative algorithms and code organization to explore GPGPU implementations
;;
;; Version 2
;;    Changed algorithm to support wavefront-transponder event-based approach in addition to time-step
;;      (vs a time and wavefront-based approach)
;;
;; Version 2.1
;;    Added membrane threshold gain and decay
;;    Fixed bug in find-intersection-centroid position estimation
;;    Fixed bug in predefined activation times
;;    Added configurable axon delay
;;    Added activation potential resevoir to control rapid pulse trains
;;    Added optional wavefront color support to configuration files
;;    Removed time-step simulation logic
;;    Added optional membrane-threshold initial and min values to configuration files
;;    Fixed bug with transponder activating itself (transponder at the same location)
;;
;; Version 2.2
;;    Cleaned up code
;;    Updated documemetation
;;    Made compatible with NetLogo V6
;;

extensions [profiler vid]
globals [
;; Global Variables defined in the Interface Tab
;  transponder-configuration-file ; transponder configuration file
;  parameter-configuration-file ; simulation parameter file
;  max-transponders            ; maximum number of transponders in the simulation
;  training-cycle-time         ; the length of a training cycle
;  training-repetitions        ; the number of times to repeat an training cycle (0 or 1 = no repetitions)
;  membrane-threshold-default  ; default value for membrane-threshold-min and initial membrane-threshold
;                                  when not in the transponder-configuration-file
;  membrane-decay-rate         ; rate of membrane degradation (per time unit)
;  synapse-threshold           ; threshold for activating a transponder receptor
;  t-synapse                   ; synapse time constant (synapse decay half-life)
;  t-membrane                  ; membrane time constant (membrane decay half-life)
;  t-membrane-gain             ; membrane-gain time constant for activation
;  membrane-gain-limit         ; limit of adjustment of membrane-threshold for activation
;  refraction-time             ; minimum time between transponder activations (recover time)
;  potentiation-limit          ; limit of adjustment of transponder location toward postive stimulus
;  depression-limit            ; limit of adjustment of transponder location away from negative stimulus
;  propagation-limit           ; maximum distance (in ticks) for propagation of a wavefront
;  attenuation-coefficient     ; wave attenuation factor based on applicatoin of the Beer-Lambert Law
;  debug                       ; turn on internal debug reporting
;  show-label                  ; display label of transponder
;  trace                       ; trace transponder learning location flag
;  waves                       ; display waves
;  record-view                 ; flag to activate recording of the view

;; Other Global Variables
  training-cycle               ; the current training cycle
  activations-previous         ; total activations from previous training cycles (used for plotting)
  event-queue                  ; queue of transponder-wavefront intersection events
  event-queue-not-sorted       ; indicator that event queue needs sorting (for performance)
  wavefronts                   ; list of active wavefronts for display
  max-event-queue-length       ; maximum length of the event queue (for statistics)
]
;; define transponder agents
breed [transponders transponder]
transponders-own [
  name                         ; user provided name for the transponder
  last-update                  ; time of last update
  last-stimulus                ; last stimulus value (debug)
  membrane-threshold-min       ; predefined minimum threshold for transponder activation
  membrane-threshold           ; current membrane threshold for transponder activation
  activation-charge-level      ; current energy level available for activation
  axon-delay                   ; time between intersection and node activation
  activation-times             ; list of activation times for the transponder, [] if none active
  last-activation              ; time of last activation times for the transponder
  activating-stimulus-chain    ; stimulus chain causing last activation (debug)
  predefined-activations       ; list of activation times for the transponder defined in the config file
  stimulus-train               ; list of current stimuli being applied to the transponder
  intersect-dists              ; list of intersection distances (for statistics)
  min-intersect-dist           ; minimum intersection distance (debug)
  max-intersect-dist           ; maximum intersection distance (debug)
  mean-intersect-dist          ; mean intersection distance
  stdev-intersect-dist         ; standard deviation of intersection distance
  activations                  ; number of activations (debug)
  activation-history           ; list of activations (debug)
  activation-levels            ; list of activations (for running average - truncated to last n)
  min-activation               ; minimum activation level (debug)
  max-activation               ; maximum activation level (debug)
  mean-activation              ; mean activation level
  stdev-activation             ; standard deviation of activation level
  x-history                    ; history of transponder x locations (debug)
  y-history                    ; history of transponder y locations (debug)
  x-intersects                 ; list of wave intersection x coordinates
  y-intersects                 ; list of wave intersection y coordinates
  mean-x-intersect             ; average of wave intersection x coordinates
  mean-y-intersect             ; average of wave intersection y coordinates
  stdev-x-intersect            ; standard deviation of wave intersection x coordinates
  stdev-y-intersect            ; standard deviation of wave intersection y coordinates
  wave-color                   ; starting color for display of this transponders wavefronts
]
;; define a wavefront drawing agent
breed [wavedrawers wavedrawer]

;;
;; initialize transponder configuration based on inputs
;;

to setup
  clear-all
  profiler:reset
  profiler:start
  set event-queue []
  set event-queue-not-sorted false
  set wavefronts []
  set training-cycle 0

  ifelse transponder-configuration-file = 0 or transponder-configuration-file = ""
  [ ; initialize random transponders
    init-random-transponders
  ]
  [ ; initialize transponders from transponder configuration file
    init-transponders-from-file
  ]

  create-wavedrawers 1 [hide-turtle] ; used to draw wavefronts

  reset-ticks

  ; view recording requested --> initialize movie
  if record-view
  [
    if vid:recorder-status != "inactive" [vid:reset-recorder]
    vid:start-recorder
  ]
end 

;;
;; initialize random transponders
;;

to init-random-transponders

  ; Create all transponders
  create-transponders max-transponders
  [
    set name ""
    setxy random-xcor random-ycor
    set membrane-threshold-min membrane-threshold-default
    set membrane-threshold membrane-threshold-min
    set activation-times []
    set axon-delay 1
    set activation-charge-level 1
    set predefined-activations []
    set activation-levels []
    set activation-history []
    set stimulus-train []
    set intersect-dists []
    set x-intersects (list xcor)
    set y-intersects (list ycor)
    set x-history (list xcor)
    set y-history (list ycor)
    set shape "circle"
    set color green
    set wave-color white
  ]

  ; activate seed transponders
  foreach n-values ceiling membrane-threshold-default [? -> ?]
  [ seed ->
    ask transponders with [who = seed]
      [
        set predefined-activations (list 1)
        set color red
      ]
  ]
end 

;;
;; initialize transponders from transponder configuration file
;;
;;   transponder configuration file record format:
;;     [“transponder-name” x-location y-location [activation times] init-activation-threshold min-activation-threshold axon-delay wave-color]
;;
;;   Notes:
;;     1. transponder-name, x-location and y-location are required.
;;     2. brakets and quotes specified above are required (they are NetLogo lists and strings).
;;     3. Remaining parameters are optional and may be omitted.
;;     4. Parameters are read in sequence. To specify a parameter value that follows optional parameters,
;;        a default value for the optional parameter must be provided.
;;     5. The default value for activation-times is the empty list [].
;;     6. The default value for initial-activation-threshold is the min-activation-threshold specified in the Interface.
;;        Negative values will result in the use of the default.
;;     7. The default value for min-activation-threshold is specified in the Interface.
;;        Negative values will result in the use of the default.
;;     8. The default value for axon-delay is 1.
;;     9. The default value for wave-color is white. Numbers or color names may be used.
;;

to init-transponders-from-file
  let transponder-config []
  set max-transponders 0
  let ignored 0
  let config-record 0

  carefully [
  file-open transponder-configuration-file
  while [ not file-at-end? ]
  [
    set transponder-config read-from-string file-read-line
    set config-record config-record + 1
    ; transponder defined in world --> load it | ignor it
    ifelse item 1 transponder-config <= max-pxcor and item 1 transponder-config >= min-pxcor and
       item 2 transponder-config <= max-pycor and item 2 transponder-config >= min-pycor
    [
      set max-transponders max-transponders + 1
      create-transponders 1
      [
        set name item 0 transponder-config
        set axon-delay 1
        set activation-charge-level 1
        if labels [set label word name "  "] ; add spaces for fromatting
        setxy item 1 transponder-config item 2 transponder-config
        set predefined-activations []
        set membrane-threshold-min membrane-threshold-default
        set membrane-threshold membrane-threshold-min
        set wave-color white
        if length transponder-config > 3
        [
          set predefined-activations item 3 transponder-config
          if length transponder-config > 4
          [
            if item 4 transponder-config > 0 [set membrane-threshold item 4 transponder-config]
            if length transponder-config > 5
            [
              if item 5 transponder-config > 0 [set membrane-threshold-min item 5 transponder-config]
              if length transponder-config > 6
              [
                set axon-delay item 6 transponder-config
                if length transponder-config > 7
                [
                  set wave-color item 7 transponder-config
                ]
              ]
            ]
          ]
        ]
        set activation-times []
        set activation-levels []
        set activation-history []
        set stimulus-train []
        set intersect-dists []
        set x-intersects (list xcor)
        set y-intersects (list ycor)
        set x-history (list xcor)
        set y-history (list ycor)
        set size 2
        set shape "circle"
        ifelse predefined-activations = [] [set color green] [set color red]
      ]
    ]
    [
      set ignored ignored + 1
    ]
  ]
  ]
  [ print (word "Error in configuration file line " config-record ": " error-message) ]
  file-close
  if ignored > 0 [print (word "Ignored " ignored " transponders outside world boundaries.")]
end 

;;
;; simulate one cycle (tick) of transponder behavior
;;

to go
  clear-drawing

  ; end of training cycle and more specified --> reinit transponder activation times
  if (ticks = 0 or ticks > training-cycle-time) and training-cycle < training-repetitions
  [
    ; initialize predefined transponders activations
    set event-queue []
    set wavefronts []
    set training-cycle training-cycle + 1
    ask transponders [
      set stimulus-train []
      set last-activation last-activation - ticks
      set activation-times []
      ; adjust membrane threshold based on application of the decay rate since last update
      set membrane-threshold membrane-threshold / (membrane-decay-rate ^ (ticks - last-update))
      set last-update 0
      foreach predefined-activations [ activation -> set event-queue lput (list activation self) event-queue ]
    ]
    set event-queue sort-by [[?1 ?2] -> item 0 ?1 < item 0 ?2] event-queue

    reset-ticks
    tick
  ]

  if debug [show list "time" ticks]

  ; activate and deactivate each transponder based on queued events
  while [length event-queue > 0 and item 0 item 0 event-queue <= ticks]
  [
    ; pop event from queue
    let event first event-queue
    set event-queue butfirst event-queue

    ; instantiate event
    ask item 1 event [
      ; remove activation times older than decay threshold
      set activation-times filter [? -> (ticks - ?) <= propagation-limit] activation-times
      ; transponder stimulated --> check activation | activate transponder at predefined time
      ifelse length event > 2
      [
        ; activate transponder if wavefront intersections are suffient
        stimulate-transponder event
      ]
      [
        set activation-times fput item 0 event activation-times
        set activation-history lput 1 activation-history
        set activations activations + 1
        queue-wavefront-event item 0 event
      ]
    ]
  ]

;  sort event queue by time to pick up new events
;     Note: events created in the current tick will be processed in future cycles because they are not placed correctly immediately.
;     This is done to improve performance from sorting large event-queues.
  if event-queue-not-sorted
  [
    set event-queue sort-by [[?1 ?2] -> item 0 ?1 < item 0 ?2] event-queue
    set event-queue-not-sorted false
  ]

  ; visualize activity
  if waves or sound or trace
  [
    ask transponders [
      ; transponder activated --> save wavefront for display
      ;   wavefront schema:    
      if waves and length activation-times > 0 and ceiling item 0 activation-times = ticks
      [ set wavefronts fput (list item 0 activation-times xcor ycor self) wavefronts ]
      ; beep on activation
      if sound and length activation-times > 0 and ceiling item 0 activation-times = ticks [beep]
      ; display tranponder movement trace
      if trace [trace-history x-history y-history blue]
    ]
  ]

  ; display circles for transponder waves with color fading to propagation limit
  if waves
  [
    ; remove wavefronts older than decay threshold
    set wavefronts filter [? -> (ticks - item 0 ?) <= propagation-limit] wavefronts
    ask wavedrawers
    [
      foreach wavefronts
      [ wave ->
        if item 0 wave <= ticks
        [
          ifelse [wave-color] of item 3 wave = white
          [ draw-circle item 1 wave item 2 wave (ticks - item 0 wave) (white - white * (ticks - item 0 wave) / propagation-limit) ]
          [ draw-circle item 1 wave item 2 wave (ticks - item 0 wave) [wave-color] of item 3 wave]
        ]
      ]
    ]
  ]

  ; view recording requested --> capture frame
  if record-view [ vid:record-view]

  tick
end 

;;
;; queue future transponder-wavefront events from the current transponder in the event queue
;;
;;    event-queue entry schema:   
;;
;; Note:  is omitted to indicate predefined activations
;;

to queue-wavefront-event [activation-time]
  ask other transponders [
    let d sqrt ((xcor - [xcor] of myself) ^ 2 + (ycor - [ycor] of myself) ^ 2)
    if d != 0 [ ; can't stimulate yourself!
      set event-queue lput (list (activation-time + d) self myself) event-queue
    ]
  ]
  set event-queue-not-sorted true
end 

;;
;; activate transponder and/or adjust position if sufficient signals are received from other transponders
;;
;; Note: item 0 event (activation time for the event) is considered the current time
;;

to stimulate-transponder [event]
  ; activate transponder if sum of adjacent transponder signals above threshold
  let stimulus integrate-stimulus event ; also sets stimulus-train
  set last-stimulus stimulus ; debug

  ; adjust membrane threshold based application of the decay rate since last update
  set membrane-threshold membrane-threshold / (membrane-decay-rate ^ (item 0 event - last-update))

  ; recharge activation charge based on time since last update
  set activation-charge-level activation-charge-level + (1 - activation-charge-level) * (1 - exp ( -(item 0 event - last-update) / t-activation-charge))

  set last-update item 0 event

  ; compute distance to intersection from stimulus-train
  let intersect-distance mean map [? -> item 1 ?] stimulus-train
  if debug [show (list "stimulus-train" stimulus stimulus-train)]

  ; not activated within refraction time window --> evaluate activation
  if activation-times = [] or (item 0 activation-times + refraction-time < item 0 event + 1)
  [
    ; stimulus above activation threshold --> activate transponder and apply positive reinforcement | apply negative reinforcement
    if length stimulus-train > 1
    [
      ifelse stimulus > construction-threshold
      [
        ; apply positive reinforcement
        ifelse stimulus >= membrane-threshold
        [
          if activation-charge-level >= activation-charge
          [
            ; collect statistics
            collect-stimulus-stats stimulus-train intersect-distance stimulus

            ; set activation for event time + axon delay
            set activation-times fput (item 0 event + axon-delay) activation-times

            ; apply potentiation (adjust transponder to improve response for this stimulus)
            if debug [show (list "adjust-transponder-position for potentiation" stimulus (potentiation-sigma * stdev-intersect-dist))]
            if potentiation-limit > 0
            [
              let dt adjust-transponder-position stimulus-train potentiation-limit t-potentiation (potentiation-sigma * stdev-intersect-dist)
            ]

            ; adjust membrane threshold
            let d-activation item 0 activation-times - last-activation
            set membrane-threshold
              membrane-threshold - membrane-gain-limit * exp (- d-activation / t-membrane-gain) * (membrane-threshold - membrane-threshold-min)

            ; queue transponder activation
            queue-wavefront-event (item 0 event + axon-delay)

            set stimulus-train []
            set last-activation item 0 activation-times

            ; decrement activation-charge-level
            set activation-charge-level activation-charge-level - activation-charge
          ]
        ]
        [
          ; transponder configured for learning --> apply reinforcement
          if membrane-threshold < length stimulus-train ; ??????????????????
          [
            ; apply potentiation for construction (adjust transponder to improve response for this stimulus)
            if construction-limit > 0
            [
              if debug [show (list "adjust-transponder-position for construction" stimulus (construction-sigma * intersect-distance))]
              let dt adjust-transponder-position stimulus-train construction-limit t-potentiation (construction-sigma * stdev-intersect-dist)
            ]
          ]
        ]
      ]
      [
        ; transponder configured for learning --> apply reinforcement
        if stimulus > 0 and membrane-threshold < length stimulus-train
        [
          ; apply depression (adjust transponder to reduce response for this stimulus)
          if debug [show (list "adjust-transponder-position for depression " stimulus)]
          if depression-limit > 0
          [ let dt adjust-transponder-position stimulus-train (- depression-limit) t-depression 10 ]
        ]
      ]
    ]

;    let negative-waves filter [item 1 ? < 0] wave-list
;    if length negative-waves > 0
;    [
;      ; transponder configured for learning --> apply reinforcement
;      if membrane-threshold < max list length stimulus-train 2
;      [
;        ; apply negative reinforcement
;        if debug [show (list "apply-negative-reinforcement" negative-waves)]
;        apply-negative-reinforcement negative-waves depression-rate t-depression
;      ]
;    ]
  ]
end 

;;
;; integrate stimulus using a Leaky-Integrate-and-Fire approach accumulating stimulus data at stimulus-train
;;
;; stimulus-train schema:  
;;
;; note:
;;   1. x and y are the location of the receiving transponder
;;

to-report integrate-stimulus [event]
  ; update stimulus signal strength and displacement for each stimulus and integrate stimulus with loss
  let stimulus-strength 0
  let new-train []
  foreach stimulus-train
  [ stimulus ->
    ; remove/ignore stimuli below threshold or integrate stimuli
    let dt item 0 event - item 4 stimulus
    if exp (- (attenuation-coefficient * dt)) * exp (- dt / t-synapse) >= synapse-threshold
    [
      let new-item (list exp (- dt / t-synapse) (precision dt 13) item 2 stimulus item 3 stimulus item 4 stimulus)
      set new-train lput new-item new-train
      set stimulus-strength stimulus-strength + item 0 new-item
    ]
  ]
  set stimulus-train new-train
  ; add event to stimulus train
  ifelse (xcor - [xcor] of item 2 event) != 0 and (ycor - [ycor] of item 2 event) != 0
  [
    set stimulus-train lput
      (list 1 0 (atan (xcor - [xcor] of item 2 event) (ycor - [ycor] of item 2 event)) item 2 event item 0 event) stimulus-train
  ]
  [
    set stimulus-train lput (list 1 0 0 item 2 event item 0 event) stimulus-train
  ]

  report stimulus-strength + 1
end 

;;
;; collect transponder-level statistics
;;

to collect-stimulus-stats [wave-list intersect-distance stimulus]
  foreach wave-list [wave -> set intersect-dists lput item 1 wave intersect-dists]
  if averaging [set intersect-dists sublist intersect-dists max list 0 (length intersect-dists - potentiation-sigma) length intersect-dists]
  set min-intersect-dist min intersect-dists
  set max-intersect-dist max intersect-dists
  set mean-intersect-dist mean intersect-dists
  set stdev-intersect-dist ifelse-value (length intersect-dists > 1) [standard-deviation intersect-dists] [0] ; [intersect-distance]
  set activation-history lput stimulus activation-history
  set activations activations + 1
  set activation-levels lput stimulus activation-levels
  if averaging [set activation-levels sublist activation-levels max list 0 (length activation-levels - (2 * potentiation-sigma)) length activation-levels]
  set min-activation min activation-levels
  set max-activation max activation-levels
  set mean-activation mean activation-levels
  set stdev-activation ifelse-value (length activation-levels > 1) [standard-deviation activation-levels] [0]
  set activating-stimulus-chain wave-list
end 

;;
;; adjust the location of the transponder toward or away from the wave wave intersections
;;   by an amount inversely proportional to the estimated distance to the intersection
;;
;; Note that this function incorporates the standard exponential STDP adjustments
;;   but approximates them with distance which does not need to be sign adjusted
;;

to-report adjust-transponder-position [wave-list weight t-rate limit]
  let lwave 0
  if length wave-list >= 2
  [
    ; approximate wave intersections from wave distances and travel angles for all wave combinations
    let intersections []
    let bf-wave-list wave-list
    foreach but-last wave-list
    [ wave1 ->
      set bf-wave-list but-first bf-wave-list
      set intersections sentence intersections map [wave2 -> approximate-wave-intersection wave1 wave2] bf-wave-list
    ]
;   if debug and length intersections > 2 [show intersections]

    ; determine centroid of wave intersections
    let intersection find-intersection-centroid intersections t-rate
    let xi item 0 intersection
    let yi item 1 intersection
    set lwave item 2 intersection

    ; adjust position of transponder based on location of wave interesection
    let intersect-distance max list lwave 1E-12
    ; determine new transponder position from average of old and new positions with new position limited to old postion + standard devation
    ; note: this is not really computing the list of intersects but the list of new position incrementing toward the intersect?
    set x-intersects lput (xcor + (xi - xcor) * weight * exp (- lwave / t-rate) * min list 1 (limit / intersect-distance)) x-intersects
    set y-intersects lput (ycor + (yi - ycor) * weight * exp (- lwave / t-rate) * min list 1 (limit / intersect-distance)) y-intersects
    set mean-x-intersect mean x-intersects
    set mean-y-intersect mean y-intersects
    if length x-intersects > 1
    [
      set stdev-x-intersect standard-deviation x-intersects
      set stdev-y-intersect standard-deviation y-intersects
    ]
    ; averaging -> move transponder to average of old and new positions | use raw position
    ifelse Averaging
    [ setxy mean-x-intersect mean-y-intersect ]
    [ setxy last x-intersects last y-intersects ]

    set x-history lput xcor x-history
    set y-history lput ycor y-history
  ]

  report lwave
end 

;;
;; approximate wave intersections from wave distances and travel angles
;;

to-report approximate-wave-intersection [wave1 wave2]
  let theta1 item 2 wave1
  let theta2 item 2 wave2
  let l1 item 1 wave1
  let l2 item 1 wave2
  ; theta1 and theta2 are reversed --> exchange so they are oriented correctly
  if subtract-headings theta1 theta2 > 0
  [
    set theta1 item 2 wave2
    set theta2 item 2 wave1
    set l1 item 1 wave2
    set l2 item 1 wave1
  ]
  let x1 xcor + l1 * cos (90 - theta1)
  let y1 ycor + l1 * sin (90 - theta1)
  let x2 xcor + l2 * cos (90 - theta2)
  let y2 ycor + l2 * sin (90 - theta2)

  let b1 y1 - x1 * (tan (90 - theta1 + 90))
  let b2 y2 - x2 * (tan (90 - theta2 - 90))
  let xi ifelse-value not (member? (theta1 - theta2) [0 180])
    [(b2 - b1) / ((tan (90 - theta1 + 90)) - (tan (90 - theta2 - 90)))]
    [1E-9]
  let yi y1 + ((xi - x1) * (tan (90 - theta1 + 90)))

  report (list xi yi sqrt ((xcor - xi) ^ 2 + (ycor - yi) ^ 2))
end 

;;
;; determine centroid of wave intersections
;;

to-report find-intersection-centroid [intersections t-rate]
  let xi 0
  let yi 0
  let lwave 0
  let total-w 0
  foreach intersections
  [ intersect ->
    let w exp (- item 2 intersect / t-rate)
    set xi xi + item 0 intersect * w
    set yi yi + item 1 intersect * w
    set lwave lwave + item 2 intersect * w
    set total-w total-w + w
  ]
  if total-w > 0
  [
    set xi xi / total-w
    set yi yi / total-w
    set lwave lwave / total-w
  ]

  report (list xi yi lwave)
end 

;;
;; adjust the location of the transponder away from the direction of the wave
;;   by an amount inversely proportional to the distance to the wave
;;

to apply-negative-reinforcement [wave-list weight t-rate]
  foreach wave-list
  [ wave ->
    let dist max list (- item 1 wave) 1E-12
    let theta item 2 wave + 180
    ; determine new transponder position from average of old and new positions with new position limited to old postion + standard devation
    ; note: this is not really computing the list of intersects but the list of new position incrementing toward the intersect?
;   if debug [show (list dist theta (xcor - dist * cos theta * weight * exp (- dist / t-rate)) (ycor - dist * sin theta * weight * exp (- dist / t-rate)))]
;    set x-intersects lput (xcor - dist * cos theta * weight * exp (- dist / t-rate)) x-intersects
;    set y-intersects lput (ycor - dist * sin theta * weight * exp (- dist / t-rate)) y-intersects
;    set mean-x-intersect mean x-intersects
;    set mean-y-intersect mean y-intersects
;    if length x-intersects > 1
;    [
;      set stdev-x-intersect standard-deviation x-intersects
;      set stdev-y-intersect standard-deviation y-intersects
;    ]
    ; averaging -> move transponder to average of old and new positions | use raw position
;    ifelse Averaging
;    [ setxy mean-x-intersect mean-y-intersect ]
;    [ setxy last x-intersects last y-intersects ]
    setxy (xcor - dist * cos theta * weight * exp (- dist / t-rate)) (ycor - dist * sin theta * weight * exp (- dist / t-rate))

    set x-history lput xcor x-history
    set y-history lput ycor y-history
  ]
end 

;;
;; draw a circle at the specified location, radius and color
;;

to draw-circle [x y r c]
  set color c
  let step r * 2 * pi / wave-resolution
  let dangle 360 / wave-resolution
  let angle dangle / 2
  let xnew x - r
  let ynew y
  setxy xnew ynew
  repeat wave-resolution
  [
    let xold xnew
    let yold ynew
    set xnew xnew + step * sin angle
    set ynew ynew + step * cos angle
    ifelse xnew >= min-pxcor and xnew <= max-pxcor and ynew >= min-pycor and ynew <= max-pycor
    and xold >= min-pxcor and xold <= max-pxcor and yold >= min-pycor and yold <= max-pycor
    [ pen-down ]
    [ pen-up ]
    setxy xnew ynew
    set angle angle + dangle
  ]
  pen-up
end 

;;
;; trace the location history path of a transponder
;;

to trace-history [x-list y-list c]
  hide-turtle
  let save-state (list pen-size color xcor ycor)
  set pen-size 2
  set color c
  setxy item 0 x-list item 0 y-list
  pen-down
  foreach (map list x-list y-list) [coord -> setxy item 0 coord item 1 coord]
  pen-up
  setxy item 2 save-state item 3 save-state
  set color item 1 save-state
  set pen-size item 0 save-state
  show-turtle
end 

;;
;; show statistics for nodes - used for manual reporting
;;

to show-node-counts [name-length]
  show (word "activations =0 " count transponders with [length name = name-length and activations = 0]
    " mean(membrane-threshold) " ifelse-value (count transponders with [length name = name-length and activations = 0] > 0)
      [mean [membrane-threshold] of transponders with [length name = name-length and activations = 0]] [0]
    " max(membrane-threshold) " ifelse-value (count transponders with [length name = name-length and activations = 0] > 0)
      [max [membrane-threshold] of transponders with [length name = name-length and activations = 0]] [0]
    " ")
  show (word "activations >0 " count transponders with [length name = name-length and activations > 0]
    " mean(membrane-threshold) " ifelse-value (count transponders with [length name = name-length and activations > 0] > 0)
      [mean [membrane-threshold] of transponders with [length name = name-length and activations > 0]] [0]
    " max(membrane-threshold) " ifelse-value (count transponders with [length name = name-length and activations > 0] > 0)
      [max [membrane-threshold] of transponders with [length name = name-length and activations > 0]] [0]
    " total activations " ifelse-value (count transponders with [length name = name-length and activations > 0] > 0)
      [sum [activations] of transponders with [length name = name-length and activations > 0]] [0]
    " ")
  show (word "membrane-threshold >=2&<3 "
    count transponders with [length name = name-length and membrane-threshold >= 2 and membrane-threshold < 3]
    ifelse-value (count transponders with [length name = name-length and membrane-threshold >= 2 and membrane-threshold < 3] > 0)
    [ (word " mean(membrane-threshold) " mean [membrane-threshold] of transponders with [length name = name-length and membrane-threshold >= 2 and membrane-threshold < 3]
            " max(membrane-threshold) " max [membrane-threshold] of transponders with [length name = name-length and membrane-threshold >= 2 and membrane-threshold < 3]) ]
    [""]
    " ")
  show (word "membrane-threshold >3     " count transponders with [length name = name-length and membrane-threshold > 3]
    ifelse-value (count transponders with [length name = name-length and membrane-threshold > 3] > 0)
    [ (word " mean(membrane-threshold) " mean [membrane-threshold] of transponders with [length name = name-length and membrane-threshold > 3]
            " max(membrane-threshold) " max [membrane-threshold] of transponders with [length name = name-length and membrane-threshold > 3]) ]
    [""]
    " ")
end 

;;
;; show status of nodes - used for manual reporting
;;

to show-node-status [name-length]
  ask transponders with [length name = name-length]
    [show (word name " activations " activations " membrane-threshold " membrane-threshold " activation-charge " activation-charge)]
end 

;; Copyright 2017 Fred Highland.

There is only one version of this model, created over 6 years ago by Fred Highland.

Attached files

File Type Description Last updated
7-Segment Circular 2color color.txt data Configuration of all possible transponders that could be used to recognize 7-segment display digits over 6 years ago, by Fred Highland Download
7-Segment Circular 2color Optimized color.txt data Optimized configuration of a minimal set of transponders that can recognize 7-segment display digits over 6 years ago, by Fred Highland Download
7-Segment Circular 2color.cfg data Parameter configuration file for transponder configuration to recognize 7-segment display digits over 6 years ago, by Fred Highland Download
7-Segment Circular Synfire Single Concept Optimized 3 Layer Test.txt data Example transponder configuration using a number of neuromophic techniques to learn to recognize 7-segment display digits over 6 years ago, by Fred Highland Download
7-Segment Circular Synfire Single Concept Optimized 3 Layer.cfg data Parameter configuration file for a large PWC transponder configuraton using a number of neuromophic techniques to learn to recognize 7-segment display digits over 6 years ago, by Fred Highland Download
if A and B then C simple.cfg data Parameter configuration file for the PWC location learning example over 6 years ago, by Fred Highland Download
if A and B then C simple.txt data Example of transponder location learning with PWC over 6 years ago, by Fred Highland Download
Polychronous Wavefront Computing Simulator.png preview Preview for 'Polychronous Wavefront Computing Simulator' over 6 years ago, by Fred Highland Download
PWC Example 1 Transponder Behavior.txt data Example of basic transponder behavior over 6 years ago, by Fred Highland Download
PWC Example 2 Signal Processing Multiple.txt data Example of signal processing with PWC using a series of signals over 6 years ago, by Fred Highland Download
PWC Example 2 Signal Processing.txt data Example of basic signal processing with PWC over 6 years ago, by Fred Highland Download
PWC Example 3 Reverb a.txt data Example of a reverberating configuration of PWC transponders with synaptic fatigue. over 6 years ago, by Fred Highland Download
PWC Example 3 Reverb b.txt data Another example of a different reverberating configuration of PWC transponders with synaptic fatigue. over 6 years ago, by Fred Highland Download
PWC Example.cfg data Parameter configuration file for PWC Examples over 6 years ago, by Fred Highland Download

This model does not have any ancestors.

This model does not have any descendants.