SIM.JS

SIM.JS is an event-based discrete-event simulation library based on standard JavaScript. The library has been written in order to enable simulation within standard browsers by utilizing web technology.

SIM.JS, a free discrete-event simulation package based on JavaScript
Original author(s)Maneesh Varshney
Developer(s)Maneesh Varshney
Stable release
0.26 / January 16, 2012 (2012-01-16)
Written inJavaScript
Operating systemCross-platform
TypeDiscrete event simulation
LicenseLGPL
Websitesimjs.com code.google.com/p/simjs-source/

SIM.JS supports entities, resources (Facility, Buffers and Stores), communication (via Timers, Events and Messages) and statistics (with Data Series, Time Series and Population statistics).

The SIM.JS distribution contains tutorials, in-depth documentation, and a large number of examples.

SIM.JS is released as open source software under the LGPL license. The first version was released in January 2011.

Example

There are several examples bundled with the library download. Trafficlight simulation is a standard simulation problem, which may be simulated as within this example:

function trafficLightSimulation(GREEN_TIME, MEAN_ARRIVAL, SEED, SIMTIME) {
   var sim = new Sim();
   var random = new Random(SEED);
   var trafficLights = [new Sim.Event("North-South Light"),
                        new Sim.Event("East-West Light")]; 
   var stats = new Sim.Population("Waiting at Intersection");
   
   var LightController = {
       currentLight: 0,  // the light that is turned on currently
       start: function () {
           sim.log(trafficLights[this.currentLight].name + " OFF"
                   + ", " + trafficLights[1 - this.currentLight].name + " ON");
           sim.log("------------------------------------------");
           // turn off the current light
           trafficLights[this.currentLight].clear();
           // turn on the other light.
           // Note the true parameter: the event must "sustain"
           trafficLights[1 - this.currentLight].fire(true);
           // update the currentLight variable
           this.currentLight = 1 - this.currentLight;
           // Repeat every GREEN_TIME interval
           this.setTimer(GREEN_TIME).done(this.start);
       }
   };
gollark: Er, yes, although I have no idea who you are.
gollark: He left AGES ago.
gollark: You don't need to go as far as wireshark or something, just shove together a simple program which listens on a port and prints things.
gollark: What stops someone from just listening to the port your thing transmits on and ignoring the bit saying who should receive the packets?
gollark: It's very unpleasant. I used it a bit
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.