GithubHelp home page GithubHelp logo

sfentress / avalanche2d-js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stepheneb/avalanche2d-js

0.0 2.0 0.0 303 KB

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

Home Page: http://stepheneb.github.com/avalanche2d-js/avalanche2d.html

avalanche2d-js's Introduction

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 2011 show this JavaScript adaptation runs about 20 times faster on Chrome than Bureaucrats-fast when displaying folders and graph and about 11 times faster running just the computational model. See Benchmarks section below.

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

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 2 ave rate (model-steps/s) for 5000 steps
Browser graph/canvas off
Chrome 14.0.835.186 8695 11160
Safari v5.1.1 (6534.51.22) 3713 4703
FireFox 7.0.1 3 385 3251
Windows 7 in VirtualBox
Chrome 14.0.835.202 6173 12987
IE v9.0.8112.16421 3 1172 4873
FireFox 7.0.1 3 628 3626
Safari v5.1.1 (7534.51.22) 499 709
NetLogo 5.0RC2
Bureaucrats-fast 448 1172
Tablets and SmartPhones
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 21, 2011

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

3 There is a Canvas-related bug in FireFox which prevents the display of data in the graph while the model is running. This issue is also present in IE9.

avalanche2d-js's People

Contributors

sethtisue avatar stepheneb avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.