Skip to content

A partial JavaScript port of Bob Tinker's NetLogo model Bureaucrats.v6 exploring Self-Organised Criticality

Notifications You must be signed in to change notification settings

stepheneb/avalanche2d-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A partial JavaScript adaptation of Bob Tinker’s NetLogo model Bureaucrats.v6 exploring Self-Organised Criticality

The mathematics of avalanche size and frequency follows a power law that can be simulated to
a first approximation by any system that exhibits self-organized criticality (SOC). In “How
Nature Works”" Per Bak reports a simplified model of a sandpile that he, Chao Tang, and Curt
Wiesenfeld developed that shows SOC, the so-called BTW model. Bak also mentions that
Grassberger describes a representation of this model that is fanciful but equivalent to the
BTW model. Imagine an N-by-N grid of office desks and a bureaucrat sitting at each. A folder
is randomly assigned to one desk. The bureaucrat does nothing until four or more folders are
on his desk at which time he sends one to each of his four nearest neighbors. Any bureaucrat
sitting at the edge of this array throws a folder out the window if there is no desk to send
it to. Sometimes, adding one folder can cause multiple redistributions of folders as one
bureaucrat’s actions causes neighbors to exceed three folders, which then ripples through
the office. In principle, just adding one new folder might involve redistribution at every
desk, sometimes multiple times.

The screen after approximately 5000 avalanches.

screenshot of avalanche2d-js

I’m working on new ways of being able to create and run models in html5 browser-technologies that we used to build with Java and wanted to see how hard it would be to convert one of Bob’s NetLogo models. The avalanche/bureaucrat model was a good first choice because it only uses the patches feature of NetLogo and not turtles.

While it would take a good deal more work to make a whole authoring environment that would be effective and productive for non-professional programmers I think this is a very successful proof-of-concept. At this point I think it would be relatively easy to convert a model that had turtles also.

Seth Tisue, the lead NetLogo developer contributed Bureaucrats-fast a simplified re-write of Bureaucrats.v6 that runs about 20 times as fast as the original. Bureaucrats-fast is more appropriate to use when comparing performance of a NetLogo model with this JavaScript adaptation.

Testing on Oct 20 and 28 2011 show this JavaScript adaptation runs about 15 times faster on Chrome than Bureaucrats-fast when displaying folders and graph and about 8 times faster running just the computational model. See Benchmarks section below.

Self-Organised Criticality References

  1. Review of: How Nature Works: The Science of Self-Organised Criticality, Per Bak, New York, NY: Copernicus Press 1996
  2. Self organized criticality in earth systems By Stefan Hergarten, page 94
  3. On the avalanche size distribution in the BTW model
  4. Wikipedia: Self-Organised Criticality

Programming References

  1. Efficient Script Yielding
  2. setImmediate
  3. W3C: Timing control for script-based animations
  4. W3C: Real-Time Web Communications Working Group
  5. Real-Time Web Communication Use-cases and Requirements
  6. W3C: Audio Working Group"
  7. Beyond HTML5 Audio Capture in Web Browsers
  8. W3C: Web Audio API
  9. Web Audio Examples

Benchmarks

Time for modeling and rendering to both the model canvas and the real-time graph rendering using a Canvas overlay over the D3.js SVG graph. 1

Mac OS X 10.6.8 1 2 ave rate (model-steps/s) for 5000 steps
Browser graph/canvas off
Chrome 14.0.835.186 9578 12594
Safari v5.1.1 (6534.51.22) 3576 4840
FireFox 7.0.1 2291 3191
Windows 7 in VirtualBox 1 2
Chrome 14.0.835.202 5165 10661
IE v9.0.8112.16421 3941 5682
FireFox 7.0.1 2484 3934
Safari v5.1.1 (7534.51.22) 630 1089
NetLogo 5.0RC2 3 2
Bureaucrats-fast 644 1568
Tablets and SmartPhones 3
iPad2, iOS 4.3.1 130 263
iPhone 4S, iOS 5.0 203
Samsung Galaxy tablet, Android 3.1 243 660

1 Data collected October 25, 2011

2 MacBook Pro, 2.66 GHz Intel Core i7, Mac OS X 10.6.8

3 Data collected October 21, 2011

About

A partial JavaScript port of Bob Tinker's NetLogo model Bureaucrats.v6 exploring Self-Organised Criticality

Resources

Stars

Watchers

Forks

Packages

No packages published