Difference between revisions of "WebKit Users Guide"
| Line 63: | Line 63: | ||
<br clear='both'> | <br clear='both'> | ||
In subsequent sections we describe the platform's features with illustrations using one or more of the sample projects in the model library. The full model library can be found in the [[WebKit Examples]] document. Note that we will be looking at the Javascript model implementation only at this time, as some of the features described here are only available with this implementation. | |||
In | |||
Among the topics covered are: | Among the topics covered are: | ||
| Line 75: | Line 74: | ||
* Downloading CSVs | * Downloading CSVs | ||
== Model Initialization and Using Presets with Conway's Game of Life and Agents (1) == | |||
[[File:lifeinit.gif|thumb|Initializing Conway's Game of Life]] | [[File:lifeinit.gif|thumb|Initializing Conway's Game of Life]] | ||
[[File:agentsinit.gif|thumb|Initializing Agents (1)]] | [[File:agentsinit.gif|thumb|Initializing Agents (1)]] | ||
| Line 86: | Line 85: | ||
* Save your configuration in the Presets. | * Save your configuration in the Presets. | ||
=== Creating new initial configurations in CGOL === | |||
This CGOL simulation uses a Cell Matrix with black/white respectively representing dead/alive. To alter the initial configuration, '''press''' or '''click''' the left mouse button on any black or white cell to toggle that cell to the opposite color. If you press the mouse button, you can '''drag''' the mouse to change dragged-over cells to the new color. | This CGOL simulation uses a Cell Matrix with black/white respectively representing dead/alive. To alter the initial configuration, '''press''' or '''click''' the left mouse button on any black or white cell to toggle that cell to the opposite color. If you press the mouse button, you can '''drag''' the mouse to change dragged-over cells to the new color. | ||
| Line 92: | Line 91: | ||
When done, '''click''' the '''Reset''' button once; clicking '''Run''' will execute the simulation with the new configuration, and single clicks on '''Reset''' will restore your initial configuration. '''Double-clicking''' '''Reset''' restores factory settings. | When done, '''click''' the '''Reset''' button once; clicking '''Run''' will execute the simulation with the new configuration, and single clicks on '''Reset''' will restore your initial configuration. '''Double-clicking''' '''Reset''' restores factory settings. | ||
=== Creating new initial configurations in Agents (1) === | |||
You add agents to Agents (1)'s landscape in a similar manner. '''Shift-click''' on a cell to add an agent, and continue to '''shift-click''' to rotate through cell colors. At the end of the rotation the agent will be deleted. You can also delete an agent immediately with '''alt-shift-click'''. | You add agents to Agents (1)'s landscape in a similar manner. '''Shift-click''' on a cell to add an agent, and continue to '''shift-click''' to rotate through cell colors. At the end of the rotation the agent will be deleted. You can also delete an agent immediately with '''alt-shift-click'''. | ||
| Line 100: | Line 99: | ||
<br clear="both"> | <br clear="both"> | ||
== Preset Basics == | |||
[[File:preset.png|thumb|Preset Control in Drawer Panel]] | [[File:preset.png|thumb|Preset Control in Drawer Panel]] | ||
The Preset feature provides a quick way to save and restore a configuration, modeled on the "radio buttons" found in cars. The Preset control consists of 13 such preset buttons. Each preset label is either red or green, respectively, depending on whether or not the preset is currently assigned to a configuration. Selecting a "green" label will restore the configuration saved in that preset. Selecting a red label has no effect on the configuration. | The Preset feature provides a quick way to save and restore a configuration, modeled on the "radio buttons" found in cars. The Preset control consists of 13 such preset buttons. Each preset label is either red or green, respectively, depending on whether or not the preset is currently assigned to a configuration. Selecting a "green" label will restore the configuration saved in that preset. Selecting a red label has no effect on the configuration. | ||
| Line 121: | Line 120: | ||
---- | ---- | ||
=== One more thing about Presets === | |||
Some projects include ready-made presets. These will be installed the first time you access the project. You may make changes to and save ready made presets. You can restore the factory set of ready-mades by deleting all presets and reloading the project. | Some projects include ready-made presets. These will be installed the first time you access the project. You may make changes to and save ready made presets. You can restore the factory set of ready-mades by deleting all presets and reloading the project. | ||
<br clear="both"> | <br clear="both"> | ||
== Using RAMs with the Extended Game of Life 3 (EGOL3) == | |||
[[File:egol3.png|thumb|Extended Game of Life Showing RAM Panel]] | [[File:egol3.png|thumb|Extended Game of Life Showing RAM Panel]] | ||
[[File:egol3RAM.gif|thumb|Preset Selection Showing RAM Choices]] | [[File:egol3RAM.gif|thumb|Preset Selection Showing RAM Choices]] | ||
Revision as of 20:12, 2 July 2025
Numerus WebKit (NWK) is a technology for building powerful simulations that run in a Web browser. It consists of applications and APIs that support the design of models along the lines of NetLogo (NL) and Stella, but using conventional languages such as Java, JavaScript (JS) and Python.[1] These applications are deployed either from a remote server, such as Amazon Web Services (AWS) Elastic Beanstalk (AWSEB), (or, in Java mode, any other server that supports WebSockets, or in JS mode, from any conventional Web or Cloud server); alternatively, they can be run locally without using any network connectivity using a localhost server. JS development only requires text editing, and Java development can take advantage of the Eclipse J2EE (Jakarta) platform using the Apache Tomcat server.
This Guide will introduce the NWK user interface (UI) and the many useful functions that enhance and support the user's experience. A separate document, the WebKit Authors Guide, is under development.
Concepts
- Model
- A system that is initialized parametrically to an start state and is sequentially clocked to produce a new state and output vector on each clock strobe. NWK supports System Dynamic (SD), Spatial (Sp) and Individual-based (IB) models. Models in NWK are currently implemented either in Javascript or Java.
- Simulation
- A model in execution. Simulations are managed from the UI.
- Spatial (Sp) and Individual-based (IB) models
- Spacial models are represented by a 2-dimensional grid of cells. At each point in time a cell assumes a state determined by the values of a set of variables. Some property of the state is visualized by the cell's color. Individual-, or agent-based models add to this a set of objects, each occupying a cell. Each object is similarly in a state visualized by color, shape and size of either a circle or square. Cells are fixed in place in a grid, with either a Cartesian or hexagonal topology, while agents move about the landscape. The edges of the landscape can either serve as fixed boundaries, or "wrap-around" horizontally and vertically to create a torus. In many simulations with fixed boundaries, agents "bounce off" the edge like a billiard ball. Agents can also bounce off each other like an ideal gas, or not interact. These choices are made by the project's author, and in some cases may be overridden.
- System Dynamics (SD)
- The behavior of SD models over time can often be characterized using differential or difference equations. An SD model might be the entirety of project, or might characterize the local behavior of a cell or agent in Sp and IB models.
- Project
- A single unit deploying 1 or more simulations, usually employing a single Web page. Projects are specified using a project file, containing JSON code detailing the UI and at least providing parameters for the model. Small SD models may be specified in the project file.
- "Factory Settings"
- Projects are delivered with parameters and settings determined by the author. Users may change parameters and override some setting, however factory settings can always be recovered.
- "The Drawer"
- The NWK screen has a sliding partition on the right-hand side, controlled by the user, that reveals documentation and other features detailed below when slid leftward.
- Presets
- NWK provides a storage facility to record and recall various choices for settings and parameters. The presets are like "radio buttons" selecting various alternative sets of configurations.
- RAMs
- RAMs (Runtime alterable modules) allow the author to provide the means for selecting sets of alternative algorithms used by the model. Authors may also use the RAM facility to enable a user to completely specify some model (these are called UberRAMs, or URAMs).
- "numml"
- numml (Numerus Modeling Language) is a small, simple, domain-specific language (dsl) that serves 2 functions: 1) to specify the algorithm or model in RAMs and URAMs; and 2) to assert configuration changes to factory settings.
- Analysis Platforms
- These are special tabs used in some projects to enable such facilities as sensitivity analysis, curve fitting, MCMC, etc.
- CSV
- This refers to the option of saving data from a graph to a comma separated list.
Platform Overview
This image shows the browser window running the sample individual-based project "Rock Paper Scissors". The features are all described later in this guide.
- Model Inputs
- These sliders set parameters for the simulation. Changes are forwarded even while the simulation is running and may have immediate effect.
- Timers
- These windows show the current model time. The left window counts up from 0. If the simulation is designed to run for a fixed time period, the right timer window will be initialized to that time and will count down.
- Operating Buttons
- The Connect/Disconnect buttons activate/deactivate the connection between the UI and the model logic. Disconnecting and Connecting is one way to restart the application; reloading the page is another.
- The Reset, Step and Start/Stop buttons operate the simulation. Step executes a single time step, Start/Stop bring about continuous operation, and Reset restores the initial state and resets the timers. Double-clicking Reset also reinitializes the application.
- Speed Control
- This determines the real-time interval between steps.
- Displays
- A spatial or agent-based simulation will include a "SimWorld" display that uses graphic cues to show the current state of the model. Among these cues are location and color, for both cells and agents, and, additionally, size and shape for agents.
- Other displays such as Spys (showing a single current value) graphs, tables, etc. are specified in the Project file (see below).
- Side Panel
- The browser page has a side panel contained in a "drawer". Use
to toggle it open and closed, or pull on the lavender bar to adjust its location. The drawer contains model documentation, the preset display, a configuration window, and a log window for status reports. If the project uses RAMs the side panel will be wider and will contain access to RAM controls.
- System Dynamics
- The third image shows the sample SD Lotka-Volterra project. An SD project will display the current choices for dt and integration method (Euler or RK4). These can be overridden from factory settings using the configuration window.
In subsequent sections we describe the platform's features with illustrations using one or more of the sample projects in the model library. The full model library can be found in the WebKit Examples document. Note that we will be looking at the Javascript model implementation only at this time, as some of the features described here are only available with this implementation.
Among the topics covered are:
- User initialization of spatial and agent-based models
- Presets
- numml language
- RAMS and URAMS
- Configuration overrides
- Analysis platforms
- Downloading CSVs
Model Initialization and Using Presets with Conway's Game of Life and Agents (1)
Conway's Game of Life (CGOL) uses a 128 x 128 board with solid edge and an initial configuration consisting of the "R-pentomino". (Try it!) CGOL's model operates on a cellular automaton with 2 possible states, dead and alive.
Agents is a very simple simulation of agents of different sizes and shapes. The space in which they are moving has elastic walls off of which the agents bounce. They also behave like an ideal gas with respect to their physical interaction. (This behavior was a choice made by the project's author.) Agents (1) has the same model, only initially empty.
With NWK you can:
- Click and drag to create new initial configurations;
- Save your configuration in the Presets.
Creating new initial configurations in CGOL
This CGOL simulation uses a Cell Matrix with black/white respectively representing dead/alive. To alter the initial configuration, press or click the left mouse button on any black or white cell to toggle that cell to the opposite color. If you press the mouse button, you can drag the mouse to change dragged-over cells to the new color.
When done, click the Reset button once; clicking Run will execute the simulation with the new configuration, and single clicks on Reset will restore your initial configuration. Double-clicking Reset restores factory settings.
Creating new initial configurations in Agents (1)
You add agents to Agents (1)'s landscape in a similar manner. Shift-click on a cell to add an agent, and continue to shift-click to rotate through cell colors. At the end of the rotation the agent will be deleted. You can also delete an agent immediately with alt-shift-click.
When done, double-click Reset, and then Run. To restore factory settings you must reload the page.
Preset Basics
The Preset feature provides a quick way to save and restore a configuration, modeled on the "radio buttons" found in cars. The Preset control consists of 13 such preset buttons. Each preset label is either red or green, respectively, depending on whether or not the preset is currently assigned to a configuration. Selecting a "green" label will restore the configuration saved in that preset. Selecting a red label has no effect on the configuration.
Note that preset 0 is permanently bound to factory settings and cannot be changed.
Tags. Each preset can be optionally given a tag; i.e., a label used to identify the settings for that preset. Simply enter the tag in the Tag text field before saving the preset.
Preset and tag selection are also controlled from the main control panel, making it unnecessary to have the drawer open while shifting between different presets. The Preset control is located to the right of the Speed slider, and rotates through the available presets as it is clicked up or down. Tagged presets display their tag when selected.
Configurations are saved and cleared using the Save/Clear/Cl All buttons to the right of the Preset controls. Whichever preset is selected will be affected by Save/Clear; Cl All will delete all presets (except for preset 0).
Presets are stored in the Web browser and will be there when you return to the project. A local JSON file storing the complete current bank of presets is created using the Preset ↔ Local File controls found to the left of the Configuration window. Use stored presets as a backup, for transferring between browsers, and when you exceed the 12 user preset limit.
Something to try
Create a set of CGOL and Agent (1) initial configurations using the mouse as described and store them in presets. Test the presets by restoring the configurations. Practice using Save and Clear until you are comfortable with building configurations and storing/restoring them using the presets.
One more thing about Presets
Some projects include ready-made presets. These will be installed the first time you access the project. You may make changes to and save ready made presets. You can restore the factory set of ready-mades by deleting all presets and reloading the project.
Using RAMs with the Extended Game of Life 3 (EGOL3)
RAMs introduce the means for changing some aspect of the project model. Each RAM presents a set of alternatives, including a Display or Default alternative that is part of the factory settings. An Alternative may require some additional input through sliders, text fields or text areas. Space is provided so that RAMs are thoroughly documented.
EGOL3 is an extension to Conway's Game of Life to 3 live states (birth, newborn and adult). The simulation has been constructed to support 4 alternate approaches to the creating the initial state, which are presented to you as a RAM with 4 alternatives. The RAM is revealed when the drawer is fully open and Initial State is selected from the RAM Selection Panel (see right).
The RAM Selection Panel appears whenever a project contains one or more RAMs. Selecting a RAM replaces the content of the Documentation Window with overview documentation for the selected RAM. A new column appears topped by the RAM Alternative Selection Panel. Each alternative introduces documentation specific to that alternative and, if needed, a set of input controls (in some cases an input control such as a text area is included for reference only and cannot be edited).
RAMs are powerful tools when combined with presets since the selected RAM and any input values are stored as part of the preset configuration. The factory settings for EGOL3 include 7 different initialization configurations realized mixing different main parameters, RAM alternatives and RAM parameters. You can see this in action by opening the RAM panels as shown and clicking through the 7 presets, as shown at right.
- ↑ This API is under development.


