<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.numerusinc.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Rsalter</id>
	<title>Numerus - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.numerusinc.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Rsalter"/>
	<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php/Special:Contributions/Rsalter"/>
	<updated>2026-04-07T10:58:15Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.36.2</generator>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2583</id>
		<title>NuML Language Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2583"/>
		<updated>2026-04-03T20:13:02Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: /* Semantic Rules for #= */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What is NuML?==&lt;br /&gt;
&lt;br /&gt;
NuML is a small, domain-specific language (dsl) for coding SD models and configuring the UI of a NuWebKit (NWK) site. It is used in DynSS models and in the Configuration Window. This document serves as reference for NWK authors and users wishing to use NuML in their  designs.&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
NuML serves two purposes: (1) to specify a system dynamics (SD) model program; and (2) to override the factory settings configuration for inputs, displays, and model operation. The choice of operator in an NuML statement, from the two described in the next section, respectively determines its purpose. To specify an SD program, NuML has special operators for defining a differential or difference equation with initial values. There are also primitive operators (primops) to supply random values and compute useful mathematical functions. To override factory settings there are operators to configure properties of input and display components, and to fix integration parameters. Finally, there are operators to configure properties of the analytical platforms. Currently there is only 1 of these (sensitivity analysis), and NuML will be extended as more such platforms become available.&lt;br /&gt;
&lt;br /&gt;
==NuML Operators==&lt;br /&gt;
NuML uses Javascript syntax extended with 2 infix operators (&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt;) that are not recognized as meaningful to Javascript. NWK uses a Javascript parser extended to accept these operators to analyze NuML code and respectively generate code or change the value of specific configuration parameters. Each NuML statement has the form:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS'';&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS'';&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
with slightly different rules for what is allowed on each side of the operator. In discussing NuML syntax we use the following terminology:&lt;br /&gt;
&lt;br /&gt;
==Language Categories==&lt;br /&gt;
;Constant&lt;br /&gt;
:Either a string constant enclosed in single or double quotes (&amp;lt;code&amp;gt;'Infection Stats'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;SIR Model&amp;quot;&amp;quot;&amp;lt;/code&amp;gt;) or a number in decimal (&amp;lt;code&amp;gt;3.1415&amp;lt;/code&amp;gt;) or scientific notation (&amp;lt;code&amp;gt;3.14159e5&amp;lt;/code&amp;gt;).&lt;br /&gt;
;Identifier&lt;br /&gt;
:Equivalent of a Javascript variable such as &amp;lt;code&amp;gt;Sigma&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;beta&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
;Unary Expression&lt;br /&gt;
:An unary operator modifying a term, such as &amp;lt;code&amp;gt;-10&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-Sigma&amp;lt;/code&amp;gt;.&lt;br /&gt;
;Call Expression&lt;br /&gt;
:A function name followed by a comma-separated sequence of arguments enclosed in parentheses. The function name must be an identifier; the arguments can be any list of terms.&lt;br /&gt;
;Term&lt;br /&gt;
:Either a constant, identifier, unary expression, or a call expression using one of the following function names, which differ for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;. These functions are called '''primops''' and are discussed below.&lt;br /&gt;
:&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;code&amp;gt;choose&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;multinomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;binomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;poisson&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;flip&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;irandom&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;random&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi34&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;degToRad&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;radToDeg&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tanh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;legend&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;phase&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;title&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statDat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statParam&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integration&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;statRuns&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statLo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statHi&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;min&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;max&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;step&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;xlabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ylabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;interval&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
;Keywords&lt;br /&gt;
:Special terms used by #= to identify UI components:&lt;br /&gt;
::&amp;lt;code&amp;gt;Slider&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Switch&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TimeGraph&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PhaseGraph&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StatGraph&amp;lt;/code&amp;gt;&lt;br /&gt;
:These may be followed by numbers; e.g., &amp;lt;code&amp;gt;Slider1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Slider2&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
&lt;br /&gt;
;Computational Expression&lt;br /&gt;
:A single term or a sequence of terms connected using arithmetic operators &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt;, or any other legal Javascript operators.&lt;br /&gt;
;Array&lt;br /&gt;
:A comma-separated sequence of terms enclosed in square brackets; e.g., &amp;lt;code&amp;gt;[Sigma, foo(1,2,3), 15.123e3]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
LHS can be:&lt;br /&gt;
:An identifier&lt;br /&gt;
:A call expression of the form:&lt;br /&gt;
::&amp;lt;code&amp;gt;deriv(&amp;lt;/code&amp;gt;ident&amp;lt;code&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;next(&amp;lt;/code&amp;gt;ident&amp;lt;code&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;initial(&amp;lt;/code&amp;gt;ident&amp;lt;/code&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;update(&amp;lt;/code&amp;gt;ident1, ident2, ...&amp;lt;code&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:these are discussed below.&lt;br /&gt;
&lt;br /&gt;
RHS can be &lt;br /&gt;
: A computational expression when LHS is either &amp;lt;code&amp;gt;deriv&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;next&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initial&amp;lt;/code&amp;gt; or an identifier.&lt;br /&gt;
: An identifier when LHS is &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Examples&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(S) @=  -beta * S * I / N&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(I) @= beta * S * I / N - sigma * I&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(R) @= sigma * I&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
initial(S) @= N - I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(I) @= I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(R) @= 0&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
update(S,I,R) @= TimeGraph&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
N @= Slider1&amp;lt;br&amp;gt;&lt;br /&gt;
beta @= Slider2&amp;lt;br&amp;gt;&lt;br /&gt;
I0 @= Slider3&amp;lt;br&amp;gt;&lt;br /&gt;
sigma @= Slider4&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
next(L) @= R * L * (1 - L)&amp;lt;br&amp;gt;&lt;br /&gt;
initial(L) @= 0.5&amp;lt;br&amp;gt;&lt;br /&gt;
update(L) @= TimeGraph&amp;lt;br&amp;gt;&lt;br /&gt;
R @= Slider1&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;deriv(&amp;lt;/code&amp;gt;ident&amp;lt;code&amp;gt;)&amp;lt;/code&amp;gt; asserts a that the RHS equation is the time derivative of ident(t)&lt;br /&gt;
* &amp;lt;code&amp;gt;next(&amp;lt;/code&amp;gt;ident&amp;lt;code&amp;gt;)&amp;lt;/code&amp;gt; asserts a that the RHS equation is the next element in the time sequence ident&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, ident&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ...&lt;br /&gt;
: e.g., &amp;lt;code&amp;gt; next(X) @= X + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;initial(&amp;lt;/code&amp;gt;ident&amp;lt;code&amp;gt;)&amp;lt;/code&amp;gt; asserts that the RHS is the initial value of ident&lt;br /&gt;
* &amp;lt;code&amp;gt;update(&amp;lt;/code&amp;gt;arg1, arg2, ...&amp;lt;code&amp;gt;)&amp;lt;/code&amp;gt; asserts that arg1, arg2, ... should be downloaded to the output component with ID of the RHS. The arguments should match the legend assigned to the output component&lt;br /&gt;
&lt;br /&gt;
An identifier appearing on the LHS is defined by the expression on the ''RHS''.&lt;br /&gt;
&lt;br /&gt;
== Syntax Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
LHS can be&lt;br /&gt;
: An identifier&lt;br /&gt;
: An array of identifiers&lt;br /&gt;
&lt;br /&gt;
RHS can be&lt;br /&gt;
: A constant, primop, or array of primops&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
TimeGraph #= [legend(S,I,R), title(&amp;quot;SIR Model&amp;quot;)]&amp;lt;br&amp;gt;&lt;br /&gt;
StatGraph #= title(&amp;quot;Infection Stats&amp;quot;)&amp;lt;br&amp;gt;&lt;br /&gt;
StatGraph #= [statDat(I),statParam(beta),statRuns(12),statLo(3.4),statHi(4.5)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider1 #= [legend(N),max(1000000),step(1000)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider2 #= [legend(beta),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider3 #= [legend(I0),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider4 #= [legend(sigma),max(10),step(0.1)];&amp;lt;br&amp;gt;&lt;br /&gt;
[Slider5, Slider6] #= legend(&amp;quot;&amp;quot;);&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
* Identifiers on the LHS reference component IDs or parameters such as &amp;lt;code&amp;gt;dt&amp;lt;/code&amp;gt;&lt;br /&gt;
* Constants on the RHS are only used with parameters and assign values to them.&lt;br /&gt;
* Primops on the RHS are only used with component IDs and define attributes such as legend, max value, etc.&lt;br /&gt;
* Arrays on either side &amp;quot;multiply out&amp;quot; to a sequence of statements and are there for convenience.&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
====Random Number Generation====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(size)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Randomly picks a number from 0 to ''size-1'' with uniform probability.&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to 1, then this function randomly picks a number from 0 to ''n-1'' with the indicated probabilities. If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to less than 1, then the function returns ''n'' with probability 1 - ''&amp;amp;Sigma; p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;flip(p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns 1 with probability ''p''; 0 otherwise&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;binomial(n, p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns the sum of ''n'' independent ''flip(p)'' calls.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;multinomial(N, p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Performs ''N'' independent ''choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)'' calls and returns a vector of ''n'' (or ''n+1'') values ''(v&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, v&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ...)'' where ''v&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' is the number of times ''i'' was selected.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;poisson(lambda)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value 0, 1, ... distributed using the Poisson distribution with density ''lambda''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;normal(m, s)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value distributed using a Gaussian distribution with mean ''m'' and standard deviation ''s''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between 0 and ''y''.&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(x, y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between ''x'' and ''y''.&lt;br /&gt;
&lt;br /&gt;
====Trigonometric Functions====&lt;br /&gt;
;&amp;lt;code&amp;gt;cos, sin, tan, acos, asin, atan, atan2, cosh, sinh, tanh, acosh, asinh, atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
:Note: &amp;lt;code&amp;gt;(atan2 y x)&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;(atan y/x)&amp;lt;/code&amp;gt; extended to handle the case where ''x == 0''.&lt;br /&gt;
&lt;br /&gt;
====Constants====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;PI, PI2, Pi2, Pi34&amp;lt;/code&amp;gt;&lt;br /&gt;
:Respectively, &amp;amp;pi;, 2&amp;amp;pi;, &amp;amp;pi;/2, 3&amp;amp;pi;/4&lt;br /&gt;
&lt;br /&gt;
;degToRad&lt;br /&gt;
:&amp;amp;pi;/180&lt;br /&gt;
&lt;br /&gt;
;radToDeg&lt;br /&gt;
:180/&amp;amp;pi;&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Assigned to runtime graphs and displays:&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''title'''&lt;br /&gt;
:'''xlabel'''&lt;br /&gt;
:'''ylabel'''&lt;br /&gt;
:'''interval''' (between plots)&lt;br /&gt;
&lt;br /&gt;
Assigned to input sliders&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''min'''&lt;br /&gt;
:'''max'''&lt;br /&gt;
:'''step'''&lt;br /&gt;
&lt;br /&gt;
Integration Control&lt;br /&gt;
:'''dt'''&lt;br /&gt;
::Integration step size&lt;br /&gt;
:'''method''' ('''RK4''' or '''Euler''')&lt;br /&gt;
&lt;br /&gt;
Sensitivity Analysis Platform&lt;br /&gt;
:'''statParam'''&lt;br /&gt;
::Parameter varied by sensitivity test&lt;br /&gt;
:'''statDat'''&lt;br /&gt;
::Value to be graphed&lt;br /&gt;
:'''statRuns'''&lt;br /&gt;
::Number of runs&lt;br /&gt;
:'''StatLo, StatHi'''&lt;br /&gt;
::Testing boundaries&lt;br /&gt;
&lt;br /&gt;
Integration notes:&lt;br /&gt;
:'''method #= RK4'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using the Runge-Kutte 4 algorithm. If dt is not specified, it defaults to 0.5. RK4 requires that dt be some fraction of 1.0.&lt;br /&gt;
&lt;br /&gt;
:'''method #= Euler'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using Euler's method. Any value can be used for dt.&lt;br /&gt;
&lt;br /&gt;
:'''method''' and '''dt''' are both ignored for any quantity defined by '''next'''.&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2582</id>
		<title>NuML Language Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2582"/>
		<updated>2026-04-03T20:12:35Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: /* Semantic Rules for #= */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What is NuML?==&lt;br /&gt;
&lt;br /&gt;
NuML is a small, domain-specific language (dsl) for coding SD models and configuring the UI of a NuWebKit (NWK) site. It is used in DynSS models and in the Configuration Window. This document serves as reference for NWK authors and users wishing to use NuML in their  designs.&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
NuML serves two purposes: (1) to specify a system dynamics (SD) model program; and (2) to override the factory settings configuration for inputs, displays, and model operation. The choice of operator in an NuML statement, from the two described in the next section, respectively determines its purpose. To specify an SD program, NuML has special operators for defining a differential or difference equation with initial values. There are also primitive operators (primops) to supply random values and compute useful mathematical functions. To override factory settings there are operators to configure properties of input and display components, and to fix integration parameters. Finally, there are operators to configure properties of the analytical platforms. Currently there is only 1 of these (sensitivity analysis), and NuML will be extended as more such platforms become available.&lt;br /&gt;
&lt;br /&gt;
==NuML Operators==&lt;br /&gt;
NuML uses Javascript syntax extended with 2 infix operators (&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt;) that are not recognized as meaningful to Javascript. NWK uses a Javascript parser extended to accept these operators to analyze NuML code and respectively generate code or change the value of specific configuration parameters. Each NuML statement has the form:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS'';&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS'';&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
with slightly different rules for what is allowed on each side of the operator. In discussing NuML syntax we use the following terminology:&lt;br /&gt;
&lt;br /&gt;
==Language Categories==&lt;br /&gt;
;Constant&lt;br /&gt;
:Either a string constant enclosed in single or double quotes (&amp;lt;code&amp;gt;'Infection Stats'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;SIR Model&amp;quot;&amp;quot;&amp;lt;/code&amp;gt;) or a number in decimal (&amp;lt;code&amp;gt;3.1415&amp;lt;/code&amp;gt;) or scientific notation (&amp;lt;code&amp;gt;3.14159e5&amp;lt;/code&amp;gt;).&lt;br /&gt;
;Identifier&lt;br /&gt;
:Equivalent of a Javascript variable such as &amp;lt;code&amp;gt;Sigma&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;beta&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
;Unary Expression&lt;br /&gt;
:An unary operator modifying a term, such as &amp;lt;code&amp;gt;-10&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-Sigma&amp;lt;/code&amp;gt;.&lt;br /&gt;
;Call Expression&lt;br /&gt;
:A function name followed by a comma-separated sequence of arguments enclosed in parentheses. The function name must be an identifier; the arguments can be any list of terms.&lt;br /&gt;
;Term&lt;br /&gt;
:Either a constant, identifier, unary expression, or a call expression using one of the following function names, which differ for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;. These functions are called '''primops''' and are discussed below.&lt;br /&gt;
:&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;code&amp;gt;choose&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;multinomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;binomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;poisson&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;flip&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;irandom&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;random&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi34&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;degToRad&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;radToDeg&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tanh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;legend&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;phase&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;title&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statDat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statParam&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integration&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;statRuns&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statLo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statHi&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;min&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;max&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;step&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;xlabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ylabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;interval&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
;Keywords&lt;br /&gt;
:Special terms used by #= to identify UI components:&lt;br /&gt;
::&amp;lt;code&amp;gt;Slider&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Switch&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TimeGraph&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PhaseGraph&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StatGraph&amp;lt;/code&amp;gt;&lt;br /&gt;
:These may be followed by numbers; e.g., &amp;lt;code&amp;gt;Slider1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Slider2&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
&lt;br /&gt;
;Computational Expression&lt;br /&gt;
:A single term or a sequence of terms connected using arithmetic operators &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt;, or any other legal Javascript operators.&lt;br /&gt;
;Array&lt;br /&gt;
:A comma-separated sequence of terms enclosed in square brackets; e.g., &amp;lt;code&amp;gt;[Sigma, foo(1,2,3), 15.123e3]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
LHS can be:&lt;br /&gt;
:An identifier&lt;br /&gt;
:A call expression of the form:&lt;br /&gt;
::&amp;lt;code&amp;gt;deriv(&amp;lt;/code&amp;gt;ident&amp;lt;code&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;next(&amp;lt;/code&amp;gt;ident&amp;lt;code&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;initial(&amp;lt;/code&amp;gt;ident&amp;lt;/code&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;update(&amp;lt;/code&amp;gt;ident1, ident2, ...&amp;lt;code&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:these are discussed below.&lt;br /&gt;
&lt;br /&gt;
RHS can be &lt;br /&gt;
: A computational expression when LHS is either &amp;lt;code&amp;gt;deriv&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;next&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initial&amp;lt;/code&amp;gt; or an identifier.&lt;br /&gt;
: An identifier when LHS is &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Examples&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(S) @=  -beta * S * I / N&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(I) @= beta * S * I / N - sigma * I&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(R) @= sigma * I&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
initial(S) @= N - I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(I) @= I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(R) @= 0&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
update(S,I,R) @= TimeGraph&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
N @= Slider1&amp;lt;br&amp;gt;&lt;br /&gt;
beta @= Slider2&amp;lt;br&amp;gt;&lt;br /&gt;
I0 @= Slider3&amp;lt;br&amp;gt;&lt;br /&gt;
sigma @= Slider4&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
next(L) @= R * L * (1 - L)&amp;lt;br&amp;gt;&lt;br /&gt;
initial(L) @= 0.5&amp;lt;br&amp;gt;&lt;br /&gt;
update(L) @= TimeGraph&amp;lt;br&amp;gt;&lt;br /&gt;
R @= Slider1&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;deriv(&amp;lt;/code&amp;gt;ident&amp;lt;code&amp;gt;)&amp;lt;/code&amp;gt; asserts a that the RHS equation is the time derivative of ident(t)&lt;br /&gt;
* &amp;lt;code&amp;gt;next(&amp;lt;/code&amp;gt;ident&amp;lt;code&amp;gt;)&amp;lt;/code&amp;gt; asserts a that the RHS equation is the next element in the time sequence ident&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, ident&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ...&lt;br /&gt;
: e.g., &amp;lt;code&amp;gt; next(X) @= X + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;initial(&amp;lt;/code&amp;gt;ident&amp;lt;code&amp;gt;)&amp;lt;/code&amp;gt; asserts that the RHS is the initial value of ident&lt;br /&gt;
* &amp;lt;code&amp;gt;update(&amp;lt;/code&amp;gt;arg1, arg2, ...&amp;lt;code&amp;gt;)&amp;lt;/code&amp;gt; asserts that arg1, arg2, ... should be downloaded to the output component with ID of the RHS. The arguments should match the legend assigned to the output component&lt;br /&gt;
&lt;br /&gt;
An identifier appearing on the LHS is defined by the expression on the ''RHS''.&lt;br /&gt;
&lt;br /&gt;
== Syntax Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
LHS can be&lt;br /&gt;
: An identifier&lt;br /&gt;
: An array of identifiers&lt;br /&gt;
&lt;br /&gt;
RHS can be&lt;br /&gt;
: A constant, primop, or array of primops&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
TimeGraph #= [legend(S,I,R), title(&amp;quot;SIR Model&amp;quot;)]&amp;lt;br&amp;gt;&lt;br /&gt;
StatGraph #= title(&amp;quot;Infection Stats&amp;quot;)&amp;lt;br&amp;gt;&lt;br /&gt;
StatGraph #= [statDat(I),statParam(beta),statRuns(12),statLo(3.4),statHi(4.5)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider1 #= [legend(N),max(1000000),step(1000)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider2 #= [legend(beta),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider3 #= [legend(I0),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider4 #= [legend(sigma),max(10),step(0.1)];&amp;lt;br&amp;gt;&lt;br /&gt;
[Slider5, Slider6] #= legend(&amp;quot;&amp;quot;);&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
* Identifiers on the LHS reference component IDs or parameters such as &amp;lt;code&amp;gt;dt&amp;lt;/code&amp;gt;&lt;br /&gt;
* Constants on the RHS are only used with parameters and assign values to them.&lt;br /&gt;
* Primops on the RHS are only used with component IDs and define attributes such as legend, max value, etc.&lt;br /&gt;
* Arrays on either side &amp;quot;multiply out&amp;quot; to as sequence of statements and are there for convenience.&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
====Random Number Generation====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(size)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Randomly picks a number from 0 to ''size-1'' with uniform probability.&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to 1, then this function randomly picks a number from 0 to ''n-1'' with the indicated probabilities. If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to less than 1, then the function returns ''n'' with probability 1 - ''&amp;amp;Sigma; p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;flip(p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns 1 with probability ''p''; 0 otherwise&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;binomial(n, p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns the sum of ''n'' independent ''flip(p)'' calls.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;multinomial(N, p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Performs ''N'' independent ''choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)'' calls and returns a vector of ''n'' (or ''n+1'') values ''(v&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, v&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ...)'' where ''v&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' is the number of times ''i'' was selected.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;poisson(lambda)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value 0, 1, ... distributed using the Poisson distribution with density ''lambda''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;normal(m, s)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value distributed using a Gaussian distribution with mean ''m'' and standard deviation ''s''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between 0 and ''y''.&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(x, y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between ''x'' and ''y''.&lt;br /&gt;
&lt;br /&gt;
====Trigonometric Functions====&lt;br /&gt;
;&amp;lt;code&amp;gt;cos, sin, tan, acos, asin, atan, atan2, cosh, sinh, tanh, acosh, asinh, atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
:Note: &amp;lt;code&amp;gt;(atan2 y x)&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;(atan y/x)&amp;lt;/code&amp;gt; extended to handle the case where ''x == 0''.&lt;br /&gt;
&lt;br /&gt;
====Constants====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;PI, PI2, Pi2, Pi34&amp;lt;/code&amp;gt;&lt;br /&gt;
:Respectively, &amp;amp;pi;, 2&amp;amp;pi;, &amp;amp;pi;/2, 3&amp;amp;pi;/4&lt;br /&gt;
&lt;br /&gt;
;degToRad&lt;br /&gt;
:&amp;amp;pi;/180&lt;br /&gt;
&lt;br /&gt;
;radToDeg&lt;br /&gt;
:180/&amp;amp;pi;&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Assigned to runtime graphs and displays:&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''title'''&lt;br /&gt;
:'''xlabel'''&lt;br /&gt;
:'''ylabel'''&lt;br /&gt;
:'''interval''' (between plots)&lt;br /&gt;
&lt;br /&gt;
Assigned to input sliders&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''min'''&lt;br /&gt;
:'''max'''&lt;br /&gt;
:'''step'''&lt;br /&gt;
&lt;br /&gt;
Integration Control&lt;br /&gt;
:'''dt'''&lt;br /&gt;
::Integration step size&lt;br /&gt;
:'''method''' ('''RK4''' or '''Euler''')&lt;br /&gt;
&lt;br /&gt;
Sensitivity Analysis Platform&lt;br /&gt;
:'''statParam'''&lt;br /&gt;
::Parameter varied by sensitivity test&lt;br /&gt;
:'''statDat'''&lt;br /&gt;
::Value to be graphed&lt;br /&gt;
:'''statRuns'''&lt;br /&gt;
::Number of runs&lt;br /&gt;
:'''StatLo, StatHi'''&lt;br /&gt;
::Testing boundaries&lt;br /&gt;
&lt;br /&gt;
Integration notes:&lt;br /&gt;
:'''method #= RK4'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using the Runge-Kutte 4 algorithm. If dt is not specified, it defaults to 0.5. RK4 requires that dt be some fraction of 1.0.&lt;br /&gt;
&lt;br /&gt;
:'''method #= Euler'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using Euler's method. Any value can be used for dt.&lt;br /&gt;
&lt;br /&gt;
:'''method''' and '''dt''' are both ignored for any quantity defined by '''next'''.&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2581</id>
		<title>NuML Language Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2581"/>
		<updated>2026-04-03T20:11:44Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: /* Semantic Rules for @= */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What is NuML?==&lt;br /&gt;
&lt;br /&gt;
NuML is a small, domain-specific language (dsl) for coding SD models and configuring the UI of a NuWebKit (NWK) site. It is used in DynSS models and in the Configuration Window. This document serves as reference for NWK authors and users wishing to use NuML in their  designs.&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
NuML serves two purposes: (1) to specify a system dynamics (SD) model program; and (2) to override the factory settings configuration for inputs, displays, and model operation. The choice of operator in an NuML statement, from the two described in the next section, respectively determines its purpose. To specify an SD program, NuML has special operators for defining a differential or difference equation with initial values. There are also primitive operators (primops) to supply random values and compute useful mathematical functions. To override factory settings there are operators to configure properties of input and display components, and to fix integration parameters. Finally, there are operators to configure properties of the analytical platforms. Currently there is only 1 of these (sensitivity analysis), and NuML will be extended as more such platforms become available.&lt;br /&gt;
&lt;br /&gt;
==NuML Operators==&lt;br /&gt;
NuML uses Javascript syntax extended with 2 infix operators (&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt;) that are not recognized as meaningful to Javascript. NWK uses a Javascript parser extended to accept these operators to analyze NuML code and respectively generate code or change the value of specific configuration parameters. Each NuML statement has the form:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS'';&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS'';&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
with slightly different rules for what is allowed on each side of the operator. In discussing NuML syntax we use the following terminology:&lt;br /&gt;
&lt;br /&gt;
==Language Categories==&lt;br /&gt;
;Constant&lt;br /&gt;
:Either a string constant enclosed in single or double quotes (&amp;lt;code&amp;gt;'Infection Stats'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;SIR Model&amp;quot;&amp;quot;&amp;lt;/code&amp;gt;) or a number in decimal (&amp;lt;code&amp;gt;3.1415&amp;lt;/code&amp;gt;) or scientific notation (&amp;lt;code&amp;gt;3.14159e5&amp;lt;/code&amp;gt;).&lt;br /&gt;
;Identifier&lt;br /&gt;
:Equivalent of a Javascript variable such as &amp;lt;code&amp;gt;Sigma&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;beta&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
;Unary Expression&lt;br /&gt;
:An unary operator modifying a term, such as &amp;lt;code&amp;gt;-10&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-Sigma&amp;lt;/code&amp;gt;.&lt;br /&gt;
;Call Expression&lt;br /&gt;
:A function name followed by a comma-separated sequence of arguments enclosed in parentheses. The function name must be an identifier; the arguments can be any list of terms.&lt;br /&gt;
;Term&lt;br /&gt;
:Either a constant, identifier, unary expression, or a call expression using one of the following function names, which differ for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;. These functions are called '''primops''' and are discussed below.&lt;br /&gt;
:&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;code&amp;gt;choose&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;multinomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;binomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;poisson&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;flip&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;irandom&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;random&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi34&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;degToRad&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;radToDeg&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tanh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;legend&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;phase&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;title&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statDat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statParam&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integration&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;statRuns&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statLo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statHi&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;min&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;max&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;step&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;xlabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ylabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;interval&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
;Keywords&lt;br /&gt;
:Special terms used by #= to identify UI components:&lt;br /&gt;
::&amp;lt;code&amp;gt;Slider&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Switch&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TimeGraph&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PhaseGraph&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StatGraph&amp;lt;/code&amp;gt;&lt;br /&gt;
:These may be followed by numbers; e.g., &amp;lt;code&amp;gt;Slider1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Slider2&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
&lt;br /&gt;
;Computational Expression&lt;br /&gt;
:A single term or a sequence of terms connected using arithmetic operators &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt;, or any other legal Javascript operators.&lt;br /&gt;
;Array&lt;br /&gt;
:A comma-separated sequence of terms enclosed in square brackets; e.g., &amp;lt;code&amp;gt;[Sigma, foo(1,2,3), 15.123e3]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
LHS can be:&lt;br /&gt;
:An identifier&lt;br /&gt;
:A call expression of the form:&lt;br /&gt;
::&amp;lt;code&amp;gt;deriv(&amp;lt;/code&amp;gt;ident&amp;lt;code&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;next(&amp;lt;/code&amp;gt;ident&amp;lt;code&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;initial(&amp;lt;/code&amp;gt;ident&amp;lt;/code&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;update(&amp;lt;/code&amp;gt;ident1, ident2, ...&amp;lt;code&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:these are discussed below.&lt;br /&gt;
&lt;br /&gt;
RHS can be &lt;br /&gt;
: A computational expression when LHS is either &amp;lt;code&amp;gt;deriv&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;next&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initial&amp;lt;/code&amp;gt; or an identifier.&lt;br /&gt;
: An identifier when LHS is &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Examples&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(S) @=  -beta * S * I / N&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(I) @= beta * S * I / N - sigma * I&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(R) @= sigma * I&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
initial(S) @= N - I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(I) @= I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(R) @= 0&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
update(S,I,R) @= TimeGraph&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
N @= Slider1&amp;lt;br&amp;gt;&lt;br /&gt;
beta @= Slider2&amp;lt;br&amp;gt;&lt;br /&gt;
I0 @= Slider3&amp;lt;br&amp;gt;&lt;br /&gt;
sigma @= Slider4&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
next(L) @= R * L * (1 - L)&amp;lt;br&amp;gt;&lt;br /&gt;
initial(L) @= 0.5&amp;lt;br&amp;gt;&lt;br /&gt;
update(L) @= TimeGraph&amp;lt;br&amp;gt;&lt;br /&gt;
R @= Slider1&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;deriv(&amp;lt;/code&amp;gt;ident&amp;lt;code&amp;gt;)&amp;lt;/code&amp;gt; asserts a that the RHS equation is the time derivative of ident(t)&lt;br /&gt;
* &amp;lt;code&amp;gt;next(&amp;lt;/code&amp;gt;ident&amp;lt;code&amp;gt;)&amp;lt;/code&amp;gt; asserts a that the RHS equation is the next element in the time sequence ident&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, ident&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ...&lt;br /&gt;
: e.g., &amp;lt;code&amp;gt; next(X) @= X + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;initial(&amp;lt;/code&amp;gt;ident&amp;lt;code&amp;gt;)&amp;lt;/code&amp;gt; asserts that the RHS is the initial value of ident&lt;br /&gt;
* &amp;lt;code&amp;gt;update(&amp;lt;/code&amp;gt;arg1, arg2, ...&amp;lt;code&amp;gt;)&amp;lt;/code&amp;gt; asserts that arg1, arg2, ... should be downloaded to the output component with ID of the RHS. The arguments should match the legend assigned to the output component&lt;br /&gt;
&lt;br /&gt;
An identifier appearing on the LHS is defined by the expression on the ''RHS''.&lt;br /&gt;
&lt;br /&gt;
== Syntax Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
LHS can be&lt;br /&gt;
: An identifier&lt;br /&gt;
: An array of identifiers&lt;br /&gt;
&lt;br /&gt;
RHS can be&lt;br /&gt;
: A constant, primop, or array of primops&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
TimeGraph #= [legend(S,I,R), title(&amp;quot;SIR Model&amp;quot;)]&amp;lt;br&amp;gt;&lt;br /&gt;
StatGraph #= title(&amp;quot;Infection Stats&amp;quot;)&amp;lt;br&amp;gt;&lt;br /&gt;
StatGraph #= [statDat(I),statParam(beta),statRuns(12),statLo(3.4),statHi(4.5)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider1 #= [legend(N),max(1000000),step(1000)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider2 #= [legend(beta),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider3 #= [legend(I0),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider4 #= [legend(sigma),max(10),step(0.1)];&amp;lt;br&amp;gt;&lt;br /&gt;
[Slider5, Slider6] #= legend(&amp;quot;&amp;quot;);&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
* Identifiers on the ''LHS'' reference component IDs or parameters such as &amp;lt;code&amp;gt;dt&amp;lt;/code&amp;gt;&lt;br /&gt;
* Constants on the ''RHS'' are only used with parameters and assign values to them.&lt;br /&gt;
* Primops on the ''RHS'' are only used with component IDs and define attributes such as legend, max value, etc.&lt;br /&gt;
* Arrays on either side &amp;quot;multiply out&amp;quot; to as sequence of statements and are there for convenience.&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
====Random Number Generation====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(size)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Randomly picks a number from 0 to ''size-1'' with uniform probability.&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to 1, then this function randomly picks a number from 0 to ''n-1'' with the indicated probabilities. If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to less than 1, then the function returns ''n'' with probability 1 - ''&amp;amp;Sigma; p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;flip(p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns 1 with probability ''p''; 0 otherwise&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;binomial(n, p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns the sum of ''n'' independent ''flip(p)'' calls.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;multinomial(N, p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Performs ''N'' independent ''choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)'' calls and returns a vector of ''n'' (or ''n+1'') values ''(v&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, v&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ...)'' where ''v&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' is the number of times ''i'' was selected.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;poisson(lambda)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value 0, 1, ... distributed using the Poisson distribution with density ''lambda''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;normal(m, s)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value distributed using a Gaussian distribution with mean ''m'' and standard deviation ''s''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between 0 and ''y''.&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(x, y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between ''x'' and ''y''.&lt;br /&gt;
&lt;br /&gt;
====Trigonometric Functions====&lt;br /&gt;
;&amp;lt;code&amp;gt;cos, sin, tan, acos, asin, atan, atan2, cosh, sinh, tanh, acosh, asinh, atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
:Note: &amp;lt;code&amp;gt;(atan2 y x)&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;(atan y/x)&amp;lt;/code&amp;gt; extended to handle the case where ''x == 0''.&lt;br /&gt;
&lt;br /&gt;
====Constants====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;PI, PI2, Pi2, Pi34&amp;lt;/code&amp;gt;&lt;br /&gt;
:Respectively, &amp;amp;pi;, 2&amp;amp;pi;, &amp;amp;pi;/2, 3&amp;amp;pi;/4&lt;br /&gt;
&lt;br /&gt;
;degToRad&lt;br /&gt;
:&amp;amp;pi;/180&lt;br /&gt;
&lt;br /&gt;
;radToDeg&lt;br /&gt;
:180/&amp;amp;pi;&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Assigned to runtime graphs and displays:&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''title'''&lt;br /&gt;
:'''xlabel'''&lt;br /&gt;
:'''ylabel'''&lt;br /&gt;
:'''interval''' (between plots)&lt;br /&gt;
&lt;br /&gt;
Assigned to input sliders&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''min'''&lt;br /&gt;
:'''max'''&lt;br /&gt;
:'''step'''&lt;br /&gt;
&lt;br /&gt;
Integration Control&lt;br /&gt;
:'''dt'''&lt;br /&gt;
::Integration step size&lt;br /&gt;
:'''method''' ('''RK4''' or '''Euler''')&lt;br /&gt;
&lt;br /&gt;
Sensitivity Analysis Platform&lt;br /&gt;
:'''statParam'''&lt;br /&gt;
::Parameter varied by sensitivity test&lt;br /&gt;
:'''statDat'''&lt;br /&gt;
::Value to be graphed&lt;br /&gt;
:'''statRuns'''&lt;br /&gt;
::Number of runs&lt;br /&gt;
:'''StatLo, StatHi'''&lt;br /&gt;
::Testing boundaries&lt;br /&gt;
&lt;br /&gt;
Integration notes:&lt;br /&gt;
:'''method #= RK4'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using the Runge-Kutte 4 algorithm. If dt is not specified, it defaults to 0.5. RK4 requires that dt be some fraction of 1.0.&lt;br /&gt;
&lt;br /&gt;
:'''method #= Euler'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using Euler's method. Any value can be used for dt.&lt;br /&gt;
&lt;br /&gt;
:'''method''' and '''dt''' are both ignored for any quantity defined by '''next'''.&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2580</id>
		<title>NuML Language Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2580"/>
		<updated>2026-04-03T20:09:26Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: /* Syntax Rules for @= */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What is NuML?==&lt;br /&gt;
&lt;br /&gt;
NuML is a small, domain-specific language (dsl) for coding SD models and configuring the UI of a NuWebKit (NWK) site. It is used in DynSS models and in the Configuration Window. This document serves as reference for NWK authors and users wishing to use NuML in their  designs.&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
NuML serves two purposes: (1) to specify a system dynamics (SD) model program; and (2) to override the factory settings configuration for inputs, displays, and model operation. The choice of operator in an NuML statement, from the two described in the next section, respectively determines its purpose. To specify an SD program, NuML has special operators for defining a differential or difference equation with initial values. There are also primitive operators (primops) to supply random values and compute useful mathematical functions. To override factory settings there are operators to configure properties of input and display components, and to fix integration parameters. Finally, there are operators to configure properties of the analytical platforms. Currently there is only 1 of these (sensitivity analysis), and NuML will be extended as more such platforms become available.&lt;br /&gt;
&lt;br /&gt;
==NuML Operators==&lt;br /&gt;
NuML uses Javascript syntax extended with 2 infix operators (&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt;) that are not recognized as meaningful to Javascript. NWK uses a Javascript parser extended to accept these operators to analyze NuML code and respectively generate code or change the value of specific configuration parameters. Each NuML statement has the form:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS'';&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS'';&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
with slightly different rules for what is allowed on each side of the operator. In discussing NuML syntax we use the following terminology:&lt;br /&gt;
&lt;br /&gt;
==Language Categories==&lt;br /&gt;
;Constant&lt;br /&gt;
:Either a string constant enclosed in single or double quotes (&amp;lt;code&amp;gt;'Infection Stats'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;SIR Model&amp;quot;&amp;quot;&amp;lt;/code&amp;gt;) or a number in decimal (&amp;lt;code&amp;gt;3.1415&amp;lt;/code&amp;gt;) or scientific notation (&amp;lt;code&amp;gt;3.14159e5&amp;lt;/code&amp;gt;).&lt;br /&gt;
;Identifier&lt;br /&gt;
:Equivalent of a Javascript variable such as &amp;lt;code&amp;gt;Sigma&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;beta&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
;Unary Expression&lt;br /&gt;
:An unary operator modifying a term, such as &amp;lt;code&amp;gt;-10&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-Sigma&amp;lt;/code&amp;gt;.&lt;br /&gt;
;Call Expression&lt;br /&gt;
:A function name followed by a comma-separated sequence of arguments enclosed in parentheses. The function name must be an identifier; the arguments can be any list of terms.&lt;br /&gt;
;Term&lt;br /&gt;
:Either a constant, identifier, unary expression, or a call expression using one of the following function names, which differ for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;. These functions are called '''primops''' and are discussed below.&lt;br /&gt;
:&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;code&amp;gt;choose&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;multinomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;binomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;poisson&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;flip&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;irandom&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;random&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi34&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;degToRad&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;radToDeg&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tanh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;legend&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;phase&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;title&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statDat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statParam&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integration&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;statRuns&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statLo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statHi&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;min&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;max&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;step&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;xlabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ylabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;interval&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
;Keywords&lt;br /&gt;
:Special terms used by #= to identify UI components:&lt;br /&gt;
::&amp;lt;code&amp;gt;Slider&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Switch&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TimeGraph&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PhaseGraph&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StatGraph&amp;lt;/code&amp;gt;&lt;br /&gt;
:These may be followed by numbers; e.g., &amp;lt;code&amp;gt;Slider1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Slider2&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
&lt;br /&gt;
;Computational Expression&lt;br /&gt;
:A single term or a sequence of terms connected using arithmetic operators &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt;, or any other legal Javascript operators.&lt;br /&gt;
;Array&lt;br /&gt;
:A comma-separated sequence of terms enclosed in square brackets; e.g., &amp;lt;code&amp;gt;[Sigma, foo(1,2,3), 15.123e3]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
LHS can be:&lt;br /&gt;
:An identifier&lt;br /&gt;
:A call expression of the form:&lt;br /&gt;
::&amp;lt;code&amp;gt;deriv(&amp;lt;/code&amp;gt;ident&amp;lt;code&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;next(&amp;lt;/code&amp;gt;ident&amp;lt;code&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;initial(&amp;lt;/code&amp;gt;ident&amp;lt;/code&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;update(&amp;lt;/code&amp;gt;ident1, ident2, ...&amp;lt;code&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:these are discussed below.&lt;br /&gt;
&lt;br /&gt;
RHS can be &lt;br /&gt;
: A computational expression when LHS is either &amp;lt;code&amp;gt;deriv&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;next&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initial&amp;lt;/code&amp;gt; or an identifier.&lt;br /&gt;
: An identifier when LHS is &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Examples&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(S) @=  -beta * S * I / N&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(I) @= beta * S * I / N - sigma * I&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(R) @= sigma * I&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
initial(S) @= N - I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(I) @= I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(R) @= 0&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
update(S,I,R) @= TimeGraph&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
N @= Slider1&amp;lt;br&amp;gt;&lt;br /&gt;
beta @= Slider2&amp;lt;br&amp;gt;&lt;br /&gt;
I0 @= Slider3&amp;lt;br&amp;gt;&lt;br /&gt;
sigma @= Slider4&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
next(L) @= R * L * (1 - L)&amp;lt;br&amp;gt;&lt;br /&gt;
initial(L) @= 0.5&amp;lt;br&amp;gt;&lt;br /&gt;
update(L) @= TimeGraph&amp;lt;br&amp;gt;&lt;br /&gt;
R @= Slider1&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;deriv(arg)&amp;lt;/code&amp;gt; asserts a that the RHS equation is the time derivative of arg(t)&lt;br /&gt;
* &amp;lt;code&amp;gt;next(arg)&amp;lt;/code&amp;gt; asserts a that the RHS equation is the next element in the time sequence arg&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, arg&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ...&lt;br /&gt;
: e.g., &amp;lt;code&amp;gt; next(X) @= X + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;initial(arg)&amp;lt;/code&amp;gt; asserts that the RHS is the initial value of arg&lt;br /&gt;
* &amp;lt;code&amp;gt;update(arg1, arg2, ...)&amp;lt;/code&amp;gt; asserts that arg1, arg2, ... should be downloaded to the output component with ID of the RHS. The arguments should match the legend assigned to the output component&lt;br /&gt;
&lt;br /&gt;
An identifier appearing on the LHS is defined by the expression on the ''RHS''.&lt;br /&gt;
&lt;br /&gt;
== Syntax Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
LHS can be&lt;br /&gt;
: An identifier&lt;br /&gt;
: An array of identifiers&lt;br /&gt;
&lt;br /&gt;
RHS can be&lt;br /&gt;
: A constant, primop, or array of primops&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
TimeGraph #= [legend(S,I,R), title(&amp;quot;SIR Model&amp;quot;)]&amp;lt;br&amp;gt;&lt;br /&gt;
StatGraph #= title(&amp;quot;Infection Stats&amp;quot;)&amp;lt;br&amp;gt;&lt;br /&gt;
StatGraph #= [statDat(I),statParam(beta),statRuns(12),statLo(3.4),statHi(4.5)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider1 #= [legend(N),max(1000000),step(1000)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider2 #= [legend(beta),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider3 #= [legend(I0),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider4 #= [legend(sigma),max(10),step(0.1)];&amp;lt;br&amp;gt;&lt;br /&gt;
[Slider5, Slider6] #= legend(&amp;quot;&amp;quot;);&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
* Identifiers on the ''LHS'' reference component IDs or parameters such as &amp;lt;code&amp;gt;dt&amp;lt;/code&amp;gt;&lt;br /&gt;
* Constants on the ''RHS'' are only used with parameters and assign values to them.&lt;br /&gt;
* Primops on the ''RHS'' are only used with component IDs and define attributes such as legend, max value, etc.&lt;br /&gt;
* Arrays on either side &amp;quot;multiply out&amp;quot; to as sequence of statements and are there for convenience.&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
====Random Number Generation====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(size)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Randomly picks a number from 0 to ''size-1'' with uniform probability.&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to 1, then this function randomly picks a number from 0 to ''n-1'' with the indicated probabilities. If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to less than 1, then the function returns ''n'' with probability 1 - ''&amp;amp;Sigma; p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;flip(p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns 1 with probability ''p''; 0 otherwise&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;binomial(n, p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns the sum of ''n'' independent ''flip(p)'' calls.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;multinomial(N, p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Performs ''N'' independent ''choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)'' calls and returns a vector of ''n'' (or ''n+1'') values ''(v&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, v&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ...)'' where ''v&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' is the number of times ''i'' was selected.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;poisson(lambda)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value 0, 1, ... distributed using the Poisson distribution with density ''lambda''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;normal(m, s)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value distributed using a Gaussian distribution with mean ''m'' and standard deviation ''s''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between 0 and ''y''.&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(x, y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between ''x'' and ''y''.&lt;br /&gt;
&lt;br /&gt;
====Trigonometric Functions====&lt;br /&gt;
;&amp;lt;code&amp;gt;cos, sin, tan, acos, asin, atan, atan2, cosh, sinh, tanh, acosh, asinh, atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
:Note: &amp;lt;code&amp;gt;(atan2 y x)&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;(atan y/x)&amp;lt;/code&amp;gt; extended to handle the case where ''x == 0''.&lt;br /&gt;
&lt;br /&gt;
====Constants====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;PI, PI2, Pi2, Pi34&amp;lt;/code&amp;gt;&lt;br /&gt;
:Respectively, &amp;amp;pi;, 2&amp;amp;pi;, &amp;amp;pi;/2, 3&amp;amp;pi;/4&lt;br /&gt;
&lt;br /&gt;
;degToRad&lt;br /&gt;
:&amp;amp;pi;/180&lt;br /&gt;
&lt;br /&gt;
;radToDeg&lt;br /&gt;
:180/&amp;amp;pi;&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Assigned to runtime graphs and displays:&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''title'''&lt;br /&gt;
:'''xlabel'''&lt;br /&gt;
:'''ylabel'''&lt;br /&gt;
:'''interval''' (between plots)&lt;br /&gt;
&lt;br /&gt;
Assigned to input sliders&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''min'''&lt;br /&gt;
:'''max'''&lt;br /&gt;
:'''step'''&lt;br /&gt;
&lt;br /&gt;
Integration Control&lt;br /&gt;
:'''dt'''&lt;br /&gt;
::Integration step size&lt;br /&gt;
:'''method''' ('''RK4''' or '''Euler''')&lt;br /&gt;
&lt;br /&gt;
Sensitivity Analysis Platform&lt;br /&gt;
:'''statParam'''&lt;br /&gt;
::Parameter varied by sensitivity test&lt;br /&gt;
:'''statDat'''&lt;br /&gt;
::Value to be graphed&lt;br /&gt;
:'''statRuns'''&lt;br /&gt;
::Number of runs&lt;br /&gt;
:'''StatLo, StatHi'''&lt;br /&gt;
::Testing boundaries&lt;br /&gt;
&lt;br /&gt;
Integration notes:&lt;br /&gt;
:'''method #= RK4'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using the Runge-Kutte 4 algorithm. If dt is not specified, it defaults to 0.5. RK4 requires that dt be some fraction of 1.0.&lt;br /&gt;
&lt;br /&gt;
:'''method #= Euler'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using Euler's method. Any value can be used for dt.&lt;br /&gt;
&lt;br /&gt;
:'''method''' and '''dt''' are both ignored for any quantity defined by '''next'''.&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2579</id>
		<title>NuML Language Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2579"/>
		<updated>2026-04-03T19:44:39Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: /* Semantic Rules for @= */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What is NuML?==&lt;br /&gt;
&lt;br /&gt;
NuML is a small, domain-specific language (dsl) for coding SD models and configuring the UI of a NuWebKit (NWK) site. It is used in DynSS models and in the Configuration Window. This document serves as reference for NWK authors and users wishing to use NuML in their  designs.&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
NuML serves two purposes: (1) to specify a system dynamics (SD) model program; and (2) to override the factory settings configuration for inputs, displays, and model operation. The choice of operator in an NuML statement, from the two described in the next section, respectively determines its purpose. To specify an SD program, NuML has special operators for defining a differential or difference equation with initial values. There are also primitive operators (primops) to supply random values and compute useful mathematical functions. To override factory settings there are operators to configure properties of input and display components, and to fix integration parameters. Finally, there are operators to configure properties of the analytical platforms. Currently there is only 1 of these (sensitivity analysis), and NuML will be extended as more such platforms become available.&lt;br /&gt;
&lt;br /&gt;
==NuML Operators==&lt;br /&gt;
NuML uses Javascript syntax extended with 2 infix operators (&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt;) that are not recognized as meaningful to Javascript. NWK uses a Javascript parser extended to accept these operators to analyze NuML code and respectively generate code or change the value of specific configuration parameters. Each NuML statement has the form:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS'';&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS'';&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
with slightly different rules for what is allowed on each side of the operator. In discussing NuML syntax we use the following terminology:&lt;br /&gt;
&lt;br /&gt;
==Language Categories==&lt;br /&gt;
;Constant&lt;br /&gt;
:Either a string constant enclosed in single or double quotes (&amp;lt;code&amp;gt;'Infection Stats'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;SIR Model&amp;quot;&amp;quot;&amp;lt;/code&amp;gt;) or a number in decimal (&amp;lt;code&amp;gt;3.1415&amp;lt;/code&amp;gt;) or scientific notation (&amp;lt;code&amp;gt;3.14159e5&amp;lt;/code&amp;gt;).&lt;br /&gt;
;Identifier&lt;br /&gt;
:Equivalent of a Javascript variable such as &amp;lt;code&amp;gt;Sigma&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;beta&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
;Unary Expression&lt;br /&gt;
:An unary operator modifying a term, such as &amp;lt;code&amp;gt;-10&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-Sigma&amp;lt;/code&amp;gt;.&lt;br /&gt;
;Call Expression&lt;br /&gt;
:A function name followed by a comma-separated sequence of arguments enclosed in parentheses. The function name must be an identifier; the arguments can be any list of terms.&lt;br /&gt;
;Term&lt;br /&gt;
:Either a constant, identifier, unary expression, or a call expression using one of the following function names, which differ for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;. These functions are called '''primops''' and are discussed below.&lt;br /&gt;
:&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;code&amp;gt;choose&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;multinomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;binomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;poisson&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;flip&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;irandom&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;random&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi34&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;degToRad&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;radToDeg&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tanh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;legend&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;phase&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;title&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statDat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statParam&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integration&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;statRuns&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statLo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statHi&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;min&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;max&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;step&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;xlabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ylabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;interval&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
;Keywords&lt;br /&gt;
:Special terms used by #= to identify UI components:&lt;br /&gt;
::&amp;lt;code&amp;gt;Slider&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Switch&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TimeGraph&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PhaseGraph&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StatGraph&amp;lt;/code&amp;gt;&lt;br /&gt;
:These may be followed by numbers; e.g., &amp;lt;code&amp;gt;Slider1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Slider2&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
&lt;br /&gt;
;Computational Expression&lt;br /&gt;
:A single term or a sequence of terms connected using arithmetic operators &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt;, or any other legal Javascript operators.&lt;br /&gt;
;Array&lt;br /&gt;
:A comma-separated sequence of terms enclosed in square brackets; e.g., &amp;lt;code&amp;gt;[Sigma, foo(1,2,3), 15.123e3]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be:&lt;br /&gt;
:An identifier&lt;br /&gt;
:A call expression of the form:&lt;br /&gt;
::&amp;lt;code&amp;gt;deriv(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;next(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;initial(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;update(''ident&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ''ident&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;'', ...)&amp;lt;/code&amp;gt;&lt;br /&gt;
:these are discussed below.&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be &lt;br /&gt;
: A computational expression when ''LHS'' is either &amp;lt;code&amp;gt;deriv&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;next&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initial&amp;lt;/code&amp;gt; or an identifier.&lt;br /&gt;
: An identifier when ''LHS'' is &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Examples&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(S) @=  -beta * S * I / N&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(I) @= beta * S * I / N - sigma * I&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(R) @= sigma * I&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
initial(S) @= N - I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(I) @= I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(R) @= 0&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
update(S,I,R) @= TimeGraph&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
N @= Slider1&amp;lt;br&amp;gt;&lt;br /&gt;
beta @= Slider2&amp;lt;br&amp;gt;&lt;br /&gt;
I0 @= Slider3&amp;lt;br&amp;gt;&lt;br /&gt;
sigma @= Slider4&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
next(L) @= R * L * (1 - L)&amp;lt;br&amp;gt;&lt;br /&gt;
initial(L) @= 0.5&amp;lt;br&amp;gt;&lt;br /&gt;
update(L) @= TimeGraph&amp;lt;br&amp;gt;&lt;br /&gt;
R @= Slider1&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;deriv(arg)&amp;lt;/code&amp;gt; asserts a that the RHS equation is the time derivative of arg(t)&lt;br /&gt;
* &amp;lt;code&amp;gt;next(arg)&amp;lt;/code&amp;gt; asserts a that the RHS equation is the next element in the time sequence arg&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, arg&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ...&lt;br /&gt;
: e.g., &amp;lt;code&amp;gt; next(X) @= X + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;initial(arg)&amp;lt;/code&amp;gt; asserts that the RHS is the initial value of arg&lt;br /&gt;
* &amp;lt;code&amp;gt;update(arg1, arg2, ...)&amp;lt;/code&amp;gt; asserts that arg1, arg2, ... should be downloaded to the output component with ID of the RHS. The arguments should match the legend assigned to the output component&lt;br /&gt;
&lt;br /&gt;
An identifier appearing on the LHS is defined by the expression on the ''RHS''.&lt;br /&gt;
&lt;br /&gt;
== Syntax Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
LHS can be&lt;br /&gt;
: An identifier&lt;br /&gt;
: An array of identifiers&lt;br /&gt;
&lt;br /&gt;
RHS can be&lt;br /&gt;
: A constant, primop, or array of primops&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
TimeGraph #= [legend(S,I,R), title(&amp;quot;SIR Model&amp;quot;)]&amp;lt;br&amp;gt;&lt;br /&gt;
StatGraph #= title(&amp;quot;Infection Stats&amp;quot;)&amp;lt;br&amp;gt;&lt;br /&gt;
StatGraph #= [statDat(I),statParam(beta),statRuns(12),statLo(3.4),statHi(4.5)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider1 #= [legend(N),max(1000000),step(1000)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider2 #= [legend(beta),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider3 #= [legend(I0),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider4 #= [legend(sigma),max(10),step(0.1)];&amp;lt;br&amp;gt;&lt;br /&gt;
[Slider5, Slider6] #= legend(&amp;quot;&amp;quot;);&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
* Identifiers on the ''LHS'' reference component IDs or parameters such as &amp;lt;code&amp;gt;dt&amp;lt;/code&amp;gt;&lt;br /&gt;
* Constants on the ''RHS'' are only used with parameters and assign values to them.&lt;br /&gt;
* Primops on the ''RHS'' are only used with component IDs and define attributes such as legend, max value, etc.&lt;br /&gt;
* Arrays on either side &amp;quot;multiply out&amp;quot; to as sequence of statements and are there for convenience.&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
====Random Number Generation====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(size)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Randomly picks a number from 0 to ''size-1'' with uniform probability.&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to 1, then this function randomly picks a number from 0 to ''n-1'' with the indicated probabilities. If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to less than 1, then the function returns ''n'' with probability 1 - ''&amp;amp;Sigma; p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;flip(p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns 1 with probability ''p''; 0 otherwise&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;binomial(n, p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns the sum of ''n'' independent ''flip(p)'' calls.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;multinomial(N, p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Performs ''N'' independent ''choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)'' calls and returns a vector of ''n'' (or ''n+1'') values ''(v&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, v&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ...)'' where ''v&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' is the number of times ''i'' was selected.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;poisson(lambda)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value 0, 1, ... distributed using the Poisson distribution with density ''lambda''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;normal(m, s)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value distributed using a Gaussian distribution with mean ''m'' and standard deviation ''s''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between 0 and ''y''.&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(x, y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between ''x'' and ''y''.&lt;br /&gt;
&lt;br /&gt;
====Trigonometric Functions====&lt;br /&gt;
;&amp;lt;code&amp;gt;cos, sin, tan, acos, asin, atan, atan2, cosh, sinh, tanh, acosh, asinh, atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
:Note: &amp;lt;code&amp;gt;(atan2 y x)&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;(atan y/x)&amp;lt;/code&amp;gt; extended to handle the case where ''x == 0''.&lt;br /&gt;
&lt;br /&gt;
====Constants====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;PI, PI2, Pi2, Pi34&amp;lt;/code&amp;gt;&lt;br /&gt;
:Respectively, &amp;amp;pi;, 2&amp;amp;pi;, &amp;amp;pi;/2, 3&amp;amp;pi;/4&lt;br /&gt;
&lt;br /&gt;
;degToRad&lt;br /&gt;
:&amp;amp;pi;/180&lt;br /&gt;
&lt;br /&gt;
;radToDeg&lt;br /&gt;
:180/&amp;amp;pi;&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Assigned to runtime graphs and displays:&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''title'''&lt;br /&gt;
:'''xlabel'''&lt;br /&gt;
:'''ylabel'''&lt;br /&gt;
:'''interval''' (between plots)&lt;br /&gt;
&lt;br /&gt;
Assigned to input sliders&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''min'''&lt;br /&gt;
:'''max'''&lt;br /&gt;
:'''step'''&lt;br /&gt;
&lt;br /&gt;
Integration Control&lt;br /&gt;
:'''dt'''&lt;br /&gt;
::Integration step size&lt;br /&gt;
:'''method''' ('''RK4''' or '''Euler''')&lt;br /&gt;
&lt;br /&gt;
Sensitivity Analysis Platform&lt;br /&gt;
:'''statParam'''&lt;br /&gt;
::Parameter varied by sensitivity test&lt;br /&gt;
:'''statDat'''&lt;br /&gt;
::Value to be graphed&lt;br /&gt;
:'''statRuns'''&lt;br /&gt;
::Number of runs&lt;br /&gt;
:'''StatLo, StatHi'''&lt;br /&gt;
::Testing boundaries&lt;br /&gt;
&lt;br /&gt;
Integration notes:&lt;br /&gt;
:'''method #= RK4'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using the Runge-Kutte 4 algorithm. If dt is not specified, it defaults to 0.5. RK4 requires that dt be some fraction of 1.0.&lt;br /&gt;
&lt;br /&gt;
:'''method #= Euler'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using Euler's method. Any value can be used for dt.&lt;br /&gt;
&lt;br /&gt;
:'''method''' and '''dt''' are both ignored for any quantity defined by '''next'''.&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2578</id>
		<title>NuML Language Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2578"/>
		<updated>2026-04-03T19:40:54Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: /* Syntax Rules for #= */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What is NuML?==&lt;br /&gt;
&lt;br /&gt;
NuML is a small, domain-specific language (dsl) for coding SD models and configuring the UI of a NuWebKit (NWK) site. It is used in DynSS models and in the Configuration Window. This document serves as reference for NWK authors and users wishing to use NuML in their  designs.&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
NuML serves two purposes: (1) to specify a system dynamics (SD) model program; and (2) to override the factory settings configuration for inputs, displays, and model operation. The choice of operator in an NuML statement, from the two described in the next section, respectively determines its purpose. To specify an SD program, NuML has special operators for defining a differential or difference equation with initial values. There are also primitive operators (primops) to supply random values and compute useful mathematical functions. To override factory settings there are operators to configure properties of input and display components, and to fix integration parameters. Finally, there are operators to configure properties of the analytical platforms. Currently there is only 1 of these (sensitivity analysis), and NuML will be extended as more such platforms become available.&lt;br /&gt;
&lt;br /&gt;
==NuML Operators==&lt;br /&gt;
NuML uses Javascript syntax extended with 2 infix operators (&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt;) that are not recognized as meaningful to Javascript. NWK uses a Javascript parser extended to accept these operators to analyze NuML code and respectively generate code or change the value of specific configuration parameters. Each NuML statement has the form:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS'';&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS'';&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
with slightly different rules for what is allowed on each side of the operator. In discussing NuML syntax we use the following terminology:&lt;br /&gt;
&lt;br /&gt;
==Language Categories==&lt;br /&gt;
;Constant&lt;br /&gt;
:Either a string constant enclosed in single or double quotes (&amp;lt;code&amp;gt;'Infection Stats'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;SIR Model&amp;quot;&amp;quot;&amp;lt;/code&amp;gt;) or a number in decimal (&amp;lt;code&amp;gt;3.1415&amp;lt;/code&amp;gt;) or scientific notation (&amp;lt;code&amp;gt;3.14159e5&amp;lt;/code&amp;gt;).&lt;br /&gt;
;Identifier&lt;br /&gt;
:Equivalent of a Javascript variable such as &amp;lt;code&amp;gt;Sigma&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;beta&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
;Unary Expression&lt;br /&gt;
:An unary operator modifying a term, such as &amp;lt;code&amp;gt;-10&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-Sigma&amp;lt;/code&amp;gt;.&lt;br /&gt;
;Call Expression&lt;br /&gt;
:A function name followed by a comma-separated sequence of arguments enclosed in parentheses. The function name must be an identifier; the arguments can be any list of terms.&lt;br /&gt;
;Term&lt;br /&gt;
:Either a constant, identifier, unary expression, or a call expression using one of the following function names, which differ for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;. These functions are called '''primops''' and are discussed below.&lt;br /&gt;
:&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;code&amp;gt;choose&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;multinomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;binomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;poisson&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;flip&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;irandom&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;random&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi34&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;degToRad&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;radToDeg&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tanh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;legend&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;phase&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;title&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statDat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statParam&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integration&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;statRuns&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statLo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statHi&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;min&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;max&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;step&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;xlabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ylabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;interval&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
;Keywords&lt;br /&gt;
:Special terms used by #= to identify UI components:&lt;br /&gt;
::&amp;lt;code&amp;gt;Slider&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Switch&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TimeGraph&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PhaseGraph&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StatGraph&amp;lt;/code&amp;gt;&lt;br /&gt;
:These may be followed by numbers; e.g., &amp;lt;code&amp;gt;Slider1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Slider2&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
&lt;br /&gt;
;Computational Expression&lt;br /&gt;
:A single term or a sequence of terms connected using arithmetic operators &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt;, or any other legal Javascript operators.&lt;br /&gt;
;Array&lt;br /&gt;
:A comma-separated sequence of terms enclosed in square brackets; e.g., &amp;lt;code&amp;gt;[Sigma, foo(1,2,3), 15.123e3]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be:&lt;br /&gt;
:An identifier&lt;br /&gt;
:A call expression of the form:&lt;br /&gt;
::&amp;lt;code&amp;gt;deriv(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;next(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;initial(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;update(''ident&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ''ident&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;'', ...)&amp;lt;/code&amp;gt;&lt;br /&gt;
:these are discussed below.&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be &lt;br /&gt;
: A computational expression when ''LHS'' is either &amp;lt;code&amp;gt;deriv&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;next&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initial&amp;lt;/code&amp;gt; or an identifier.&lt;br /&gt;
: An identifier when ''LHS'' is &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Examples&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(S) @=  -beta * S * I / N&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(I) @= beta * S * I / N - sigma * I&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(R) @= sigma * I&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
initial(S) @= N - I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(I) @= I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(R) @= 0&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
update(S,I,R) @= TimeGraph&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
N @= Slider1&amp;lt;br&amp;gt;&lt;br /&gt;
beta @= Slider2&amp;lt;br&amp;gt;&lt;br /&gt;
I0 @= Slider3&amp;lt;br&amp;gt;&lt;br /&gt;
sigma @= Slider4&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
next(L) @= R * L * (1 - L)&amp;lt;br&amp;gt;&lt;br /&gt;
initial(L) @= 0.5&amp;lt;br&amp;gt;&lt;br /&gt;
update(L) @= TimeGraph&amp;lt;br&amp;gt;&lt;br /&gt;
R @= Slider1&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;deriv(arg)&amp;lt;/code&amp;gt; asserts a that the RHS equation is the time derivative of arg(t)&lt;br /&gt;
* &amp;lt;code&amp;gt;next(arg)&amp;lt;/code&amp;gt; asserts a that the RHS equation is the next element in the time sequence arg&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, arg&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ...&lt;br /&gt;
: e.g., &amp;lt;code&amp;gt; next(X) @= X + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;initial(arg)&amp;lt;/code&amp;gt; asserts that the RHS is the initial value of arg&lt;br /&gt;
* &amp;lt;code&amp;gt;update(arg&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, arg&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;, ...)&amp;lt;/code&amp;gt; asserts that arg&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, arg&amp;lt;sub&amp;gt;2&amp;lt;sub&amp;gt;, ... should be downloaded to the output component with ID of the RHS. The arguments should match the legend assigned to the output component&lt;br /&gt;
&lt;br /&gt;
An identifier appearing on the LHS is defined by the expression on the ''RHS''.&lt;br /&gt;
&lt;br /&gt;
== Syntax Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
LHS can be&lt;br /&gt;
: An identifier&lt;br /&gt;
: An array of identifiers&lt;br /&gt;
&lt;br /&gt;
RHS can be&lt;br /&gt;
: A constant, primop, or array of primops&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
TimeGraph #= [legend(S,I,R), title(&amp;quot;SIR Model&amp;quot;)]&amp;lt;br&amp;gt;&lt;br /&gt;
StatGraph #= title(&amp;quot;Infection Stats&amp;quot;)&amp;lt;br&amp;gt;&lt;br /&gt;
StatGraph #= [statDat(I),statParam(beta),statRuns(12),statLo(3.4),statHi(4.5)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider1 #= [legend(N),max(1000000),step(1000)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider2 #= [legend(beta),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider3 #= [legend(I0),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider4 #= [legend(sigma),max(10),step(0.1)];&amp;lt;br&amp;gt;&lt;br /&gt;
[Slider5, Slider6] #= legend(&amp;quot;&amp;quot;);&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
* Identifiers on the ''LHS'' reference component IDs or parameters such as &amp;lt;code&amp;gt;dt&amp;lt;/code&amp;gt;&lt;br /&gt;
* Constants on the ''RHS'' are only used with parameters and assign values to them.&lt;br /&gt;
* Primops on the ''RHS'' are only used with component IDs and define attributes such as legend, max value, etc.&lt;br /&gt;
* Arrays on either side &amp;quot;multiply out&amp;quot; to as sequence of statements and are there for convenience.&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
====Random Number Generation====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(size)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Randomly picks a number from 0 to ''size-1'' with uniform probability.&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to 1, then this function randomly picks a number from 0 to ''n-1'' with the indicated probabilities. If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to less than 1, then the function returns ''n'' with probability 1 - ''&amp;amp;Sigma; p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;flip(p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns 1 with probability ''p''; 0 otherwise&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;binomial(n, p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns the sum of ''n'' independent ''flip(p)'' calls.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;multinomial(N, p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Performs ''N'' independent ''choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)'' calls and returns a vector of ''n'' (or ''n+1'') values ''(v&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, v&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ...)'' where ''v&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' is the number of times ''i'' was selected.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;poisson(lambda)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value 0, 1, ... distributed using the Poisson distribution with density ''lambda''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;normal(m, s)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value distributed using a Gaussian distribution with mean ''m'' and standard deviation ''s''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between 0 and ''y''.&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(x, y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between ''x'' and ''y''.&lt;br /&gt;
&lt;br /&gt;
====Trigonometric Functions====&lt;br /&gt;
;&amp;lt;code&amp;gt;cos, sin, tan, acos, asin, atan, atan2, cosh, sinh, tanh, acosh, asinh, atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
:Note: &amp;lt;code&amp;gt;(atan2 y x)&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;(atan y/x)&amp;lt;/code&amp;gt; extended to handle the case where ''x == 0''.&lt;br /&gt;
&lt;br /&gt;
====Constants====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;PI, PI2, Pi2, Pi34&amp;lt;/code&amp;gt;&lt;br /&gt;
:Respectively, &amp;amp;pi;, 2&amp;amp;pi;, &amp;amp;pi;/2, 3&amp;amp;pi;/4&lt;br /&gt;
&lt;br /&gt;
;degToRad&lt;br /&gt;
:&amp;amp;pi;/180&lt;br /&gt;
&lt;br /&gt;
;radToDeg&lt;br /&gt;
:180/&amp;amp;pi;&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Assigned to runtime graphs and displays:&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''title'''&lt;br /&gt;
:'''xlabel'''&lt;br /&gt;
:'''ylabel'''&lt;br /&gt;
:'''interval''' (between plots)&lt;br /&gt;
&lt;br /&gt;
Assigned to input sliders&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''min'''&lt;br /&gt;
:'''max'''&lt;br /&gt;
:'''step'''&lt;br /&gt;
&lt;br /&gt;
Integration Control&lt;br /&gt;
:'''dt'''&lt;br /&gt;
::Integration step size&lt;br /&gt;
:'''method''' ('''RK4''' or '''Euler''')&lt;br /&gt;
&lt;br /&gt;
Sensitivity Analysis Platform&lt;br /&gt;
:'''statParam'''&lt;br /&gt;
::Parameter varied by sensitivity test&lt;br /&gt;
:'''statDat'''&lt;br /&gt;
::Value to be graphed&lt;br /&gt;
:'''statRuns'''&lt;br /&gt;
::Number of runs&lt;br /&gt;
:'''StatLo, StatHi'''&lt;br /&gt;
::Testing boundaries&lt;br /&gt;
&lt;br /&gt;
Integration notes:&lt;br /&gt;
:'''method #= RK4'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using the Runge-Kutte 4 algorithm. If dt is not specified, it defaults to 0.5. RK4 requires that dt be some fraction of 1.0.&lt;br /&gt;
&lt;br /&gt;
:'''method #= Euler'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using Euler's method. Any value can be used for dt.&lt;br /&gt;
&lt;br /&gt;
:'''method''' and '''dt''' are both ignored for any quantity defined by '''next'''.&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2577</id>
		<title>NuML Language Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2577"/>
		<updated>2026-04-03T19:39:09Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: /* Semantic Rules for @= */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What is NuML?==&lt;br /&gt;
&lt;br /&gt;
NuML is a small, domain-specific language (dsl) for coding SD models and configuring the UI of a NuWebKit (NWK) site. It is used in DynSS models and in the Configuration Window. This document serves as reference for NWK authors and users wishing to use NuML in their  designs.&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
NuML serves two purposes: (1) to specify a system dynamics (SD) model program; and (2) to override the factory settings configuration for inputs, displays, and model operation. The choice of operator in an NuML statement, from the two described in the next section, respectively determines its purpose. To specify an SD program, NuML has special operators for defining a differential or difference equation with initial values. There are also primitive operators (primops) to supply random values and compute useful mathematical functions. To override factory settings there are operators to configure properties of input and display components, and to fix integration parameters. Finally, there are operators to configure properties of the analytical platforms. Currently there is only 1 of these (sensitivity analysis), and NuML will be extended as more such platforms become available.&lt;br /&gt;
&lt;br /&gt;
==NuML Operators==&lt;br /&gt;
NuML uses Javascript syntax extended with 2 infix operators (&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt;) that are not recognized as meaningful to Javascript. NWK uses a Javascript parser extended to accept these operators to analyze NuML code and respectively generate code or change the value of specific configuration parameters. Each NuML statement has the form:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS'';&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS'';&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
with slightly different rules for what is allowed on each side of the operator. In discussing NuML syntax we use the following terminology:&lt;br /&gt;
&lt;br /&gt;
==Language Categories==&lt;br /&gt;
;Constant&lt;br /&gt;
:Either a string constant enclosed in single or double quotes (&amp;lt;code&amp;gt;'Infection Stats'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;SIR Model&amp;quot;&amp;quot;&amp;lt;/code&amp;gt;) or a number in decimal (&amp;lt;code&amp;gt;3.1415&amp;lt;/code&amp;gt;) or scientific notation (&amp;lt;code&amp;gt;3.14159e5&amp;lt;/code&amp;gt;).&lt;br /&gt;
;Identifier&lt;br /&gt;
:Equivalent of a Javascript variable such as &amp;lt;code&amp;gt;Sigma&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;beta&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
;Unary Expression&lt;br /&gt;
:An unary operator modifying a term, such as &amp;lt;code&amp;gt;-10&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-Sigma&amp;lt;/code&amp;gt;.&lt;br /&gt;
;Call Expression&lt;br /&gt;
:A function name followed by a comma-separated sequence of arguments enclosed in parentheses. The function name must be an identifier; the arguments can be any list of terms.&lt;br /&gt;
;Term&lt;br /&gt;
:Either a constant, identifier, unary expression, or a call expression using one of the following function names, which differ for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;. These functions are called '''primops''' and are discussed below.&lt;br /&gt;
:&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;code&amp;gt;choose&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;multinomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;binomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;poisson&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;flip&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;irandom&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;random&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi34&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;degToRad&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;radToDeg&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tanh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;legend&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;phase&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;title&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statDat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statParam&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integration&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;statRuns&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statLo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statHi&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;min&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;max&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;step&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;xlabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ylabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;interval&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
;Keywords&lt;br /&gt;
:Special terms used by #= to identify UI components:&lt;br /&gt;
::&amp;lt;code&amp;gt;Slider&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Switch&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TimeGraph&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PhaseGraph&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StatGraph&amp;lt;/code&amp;gt;&lt;br /&gt;
:These may be followed by numbers; e.g., &amp;lt;code&amp;gt;Slider1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Slider2&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
&lt;br /&gt;
;Computational Expression&lt;br /&gt;
:A single term or a sequence of terms connected using arithmetic operators &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt;, or any other legal Javascript operators.&lt;br /&gt;
;Array&lt;br /&gt;
:A comma-separated sequence of terms enclosed in square brackets; e.g., &amp;lt;code&amp;gt;[Sigma, foo(1,2,3), 15.123e3]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be:&lt;br /&gt;
:An identifier&lt;br /&gt;
:A call expression of the form:&lt;br /&gt;
::&amp;lt;code&amp;gt;deriv(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;next(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;initial(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;update(''ident&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ''ident&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;'', ...)&amp;lt;/code&amp;gt;&lt;br /&gt;
:these are discussed below.&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be &lt;br /&gt;
: A computational expression when ''LHS'' is either &amp;lt;code&amp;gt;deriv&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;next&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initial&amp;lt;/code&amp;gt; or an identifier.&lt;br /&gt;
: An identifier when ''LHS'' is &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Examples&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(S) @=  -beta * S * I / N&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(I) @= beta * S * I / N - sigma * I&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(R) @= sigma * I&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
initial(S) @= N - I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(I) @= I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(R) @= 0&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
update(S,I,R) @= TimeGraph&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
N @= Slider1&amp;lt;br&amp;gt;&lt;br /&gt;
beta @= Slider2&amp;lt;br&amp;gt;&lt;br /&gt;
I0 @= Slider3&amp;lt;br&amp;gt;&lt;br /&gt;
sigma @= Slider4&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
next(L) @= R * L * (1 - L)&amp;lt;br&amp;gt;&lt;br /&gt;
initial(L) @= 0.5&amp;lt;br&amp;gt;&lt;br /&gt;
update(L) @= TimeGraph&amp;lt;br&amp;gt;&lt;br /&gt;
R @= Slider1&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;deriv(arg)&amp;lt;/code&amp;gt; asserts a that the RHS equation is the time derivative of arg(t)&lt;br /&gt;
* &amp;lt;code&amp;gt;next(arg)&amp;lt;/code&amp;gt; asserts a that the RHS equation is the next element in the time sequence arg&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, arg&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ...&lt;br /&gt;
: e.g., &amp;lt;code&amp;gt; next(X) @= X + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;initial(arg)&amp;lt;/code&amp;gt; asserts that the RHS is the initial value of arg&lt;br /&gt;
* &amp;lt;code&amp;gt;update(arg&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, arg&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;, ...)&amp;lt;/code&amp;gt; asserts that arg&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, arg&amp;lt;sub&amp;gt;2&amp;lt;sub&amp;gt;, ... should be downloaded to the output component with ID of the RHS. The arguments should match the legend assigned to the output component&lt;br /&gt;
&lt;br /&gt;
An identifier appearing on the LHS is defined by the expression on the ''RHS''.&lt;br /&gt;
&lt;br /&gt;
== Syntax Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be&lt;br /&gt;
: An identifier&lt;br /&gt;
: An array of identifiers&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be&lt;br /&gt;
: A constant, primop, or array of primops&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
mainGraph #= [legend(S,I,R), title(&amp;quot;SIR Model&amp;quot;)]&amp;lt;br&amp;gt;&lt;br /&gt;
statsGraph #= title(&amp;quot;Infection Stats&amp;quot;)&amp;lt;br&amp;gt;&lt;br /&gt;
statsGraph #= [statDat(I),statParam(Beta),statRuns(12),statLo(3.4),statHi(4.5)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider1 #= [legend(N),max(1000000),step(1000)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider2 #= [legend(Beta),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider3 #= [legend(I0),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider4 #= [legend(Sigma),max(10),step(0.1)];&amp;lt;br&amp;gt;&lt;br /&gt;
[Slider5, Slider6] #= legend(&amp;quot;&amp;quot;);&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
* Identifiers on the ''LHS'' reference component IDs or parameters such as &amp;lt;code&amp;gt;dt&amp;lt;/code&amp;gt;&lt;br /&gt;
* Constants on the ''RHS'' are only used with parameters and assign values to them.&lt;br /&gt;
* Primops on the ''RHS'' are only used with component IDs and define attributes such as legend, max value, etc.&lt;br /&gt;
* Arrays on either side &amp;quot;multiply out&amp;quot; to as sequence of statements and are there for convenience.&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
====Random Number Generation====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(size)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Randomly picks a number from 0 to ''size-1'' with uniform probability.&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to 1, then this function randomly picks a number from 0 to ''n-1'' with the indicated probabilities. If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to less than 1, then the function returns ''n'' with probability 1 - ''&amp;amp;Sigma; p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;flip(p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns 1 with probability ''p''; 0 otherwise&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;binomial(n, p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns the sum of ''n'' independent ''flip(p)'' calls.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;multinomial(N, p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Performs ''N'' independent ''choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)'' calls and returns a vector of ''n'' (or ''n+1'') values ''(v&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, v&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ...)'' where ''v&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' is the number of times ''i'' was selected.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;poisson(lambda)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value 0, 1, ... distributed using the Poisson distribution with density ''lambda''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;normal(m, s)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value distributed using a Gaussian distribution with mean ''m'' and standard deviation ''s''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between 0 and ''y''.&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(x, y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between ''x'' and ''y''.&lt;br /&gt;
&lt;br /&gt;
====Trigonometric Functions====&lt;br /&gt;
;&amp;lt;code&amp;gt;cos, sin, tan, acos, asin, atan, atan2, cosh, sinh, tanh, acosh, asinh, atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
:Note: &amp;lt;code&amp;gt;(atan2 y x)&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;(atan y/x)&amp;lt;/code&amp;gt; extended to handle the case where ''x == 0''.&lt;br /&gt;
&lt;br /&gt;
====Constants====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;PI, PI2, Pi2, Pi34&amp;lt;/code&amp;gt;&lt;br /&gt;
:Respectively, &amp;amp;pi;, 2&amp;amp;pi;, &amp;amp;pi;/2, 3&amp;amp;pi;/4&lt;br /&gt;
&lt;br /&gt;
;degToRad&lt;br /&gt;
:&amp;amp;pi;/180&lt;br /&gt;
&lt;br /&gt;
;radToDeg&lt;br /&gt;
:180/&amp;amp;pi;&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Assigned to runtime graphs and displays:&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''title'''&lt;br /&gt;
:'''xlabel'''&lt;br /&gt;
:'''ylabel'''&lt;br /&gt;
:'''interval''' (between plots)&lt;br /&gt;
&lt;br /&gt;
Assigned to input sliders&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''min'''&lt;br /&gt;
:'''max'''&lt;br /&gt;
:'''step'''&lt;br /&gt;
&lt;br /&gt;
Integration Control&lt;br /&gt;
:'''dt'''&lt;br /&gt;
::Integration step size&lt;br /&gt;
:'''method''' ('''RK4''' or '''Euler''')&lt;br /&gt;
&lt;br /&gt;
Sensitivity Analysis Platform&lt;br /&gt;
:'''statParam'''&lt;br /&gt;
::Parameter varied by sensitivity test&lt;br /&gt;
:'''statDat'''&lt;br /&gt;
::Value to be graphed&lt;br /&gt;
:'''statRuns'''&lt;br /&gt;
::Number of runs&lt;br /&gt;
:'''StatLo, StatHi'''&lt;br /&gt;
::Testing boundaries&lt;br /&gt;
&lt;br /&gt;
Integration notes:&lt;br /&gt;
:'''method #= RK4'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using the Runge-Kutte 4 algorithm. If dt is not specified, it defaults to 0.5. RK4 requires that dt be some fraction of 1.0.&lt;br /&gt;
&lt;br /&gt;
:'''method #= Euler'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using Euler's method. Any value can be used for dt.&lt;br /&gt;
&lt;br /&gt;
:'''method''' and '''dt''' are both ignored for any quantity defined by '''next'''.&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2576</id>
		<title>NuML Language Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2576"/>
		<updated>2026-04-01T17:53:21Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: /* Primops for @# */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What is NuML?==&lt;br /&gt;
&lt;br /&gt;
NuML is a small, domain-specific language (dsl) for coding SD models and configuring the UI of a NuWebKit (NWK) site. It is used in DynSS models and in the Configuration Window. This document serves as reference for NWK authors and users wishing to use NuML in their  designs.&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
NuML serves two purposes: (1) to specify a system dynamics (SD) model program; and (2) to override the factory settings configuration for inputs, displays, and model operation. The choice of operator in an NuML statement, from the two described in the next section, respectively determines its purpose. To specify an SD program, NuML has special operators for defining a differential or difference equation with initial values. There are also primitive operators (primops) to supply random values and compute useful mathematical functions. To override factory settings there are operators to configure properties of input and display components, and to fix integration parameters. Finally, there are operators to configure properties of the analytical platforms. Currently there is only 1 of these (sensitivity analysis), and NuML will be extended as more such platforms become available.&lt;br /&gt;
&lt;br /&gt;
==NuML Operators==&lt;br /&gt;
NuML uses Javascript syntax extended with 2 infix operators (&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt;) that are not recognized as meaningful to Javascript. NWK uses a Javascript parser extended to accept these operators to analyze NuML code and respectively generate code or change the value of specific configuration parameters. Each NuML statement has the form:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS'';&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS'';&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
with slightly different rules for what is allowed on each side of the operator. In discussing NuML syntax we use the following terminology:&lt;br /&gt;
&lt;br /&gt;
==Language Categories==&lt;br /&gt;
;Constant&lt;br /&gt;
:Either a string constant enclosed in single or double quotes (&amp;lt;code&amp;gt;'Infection Stats'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;SIR Model&amp;quot;&amp;quot;&amp;lt;/code&amp;gt;) or a number in decimal (&amp;lt;code&amp;gt;3.1415&amp;lt;/code&amp;gt;) or scientific notation (&amp;lt;code&amp;gt;3.14159e5&amp;lt;/code&amp;gt;).&lt;br /&gt;
;Identifier&lt;br /&gt;
:Equivalent of a Javascript variable such as &amp;lt;code&amp;gt;Sigma&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;beta&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
;Unary Expression&lt;br /&gt;
:An unary operator modifying a term, such as &amp;lt;code&amp;gt;-10&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-Sigma&amp;lt;/code&amp;gt;.&lt;br /&gt;
;Call Expression&lt;br /&gt;
:A function name followed by a comma-separated sequence of arguments enclosed in parentheses. The function name must be an identifier; the arguments can be any list of terms.&lt;br /&gt;
;Term&lt;br /&gt;
:Either a constant, identifier, unary expression, or a call expression using one of the following function names, which differ for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;. These functions are called '''primops''' and are discussed below.&lt;br /&gt;
:&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;code&amp;gt;choose&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;multinomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;binomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;poisson&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;flip&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;irandom&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;random&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi34&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;degToRad&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;radToDeg&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tanh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;legend&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;phase&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;title&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statDat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statParam&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integration&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;statRuns&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statLo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statHi&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;min&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;max&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;step&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;xlabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ylabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;interval&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
;Keywords&lt;br /&gt;
:Special terms used by #= to identify UI components:&lt;br /&gt;
::&amp;lt;code&amp;gt;Slider&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Switch&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TimeGraph&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PhaseGraph&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StatGraph&amp;lt;/code&amp;gt;&lt;br /&gt;
:These may be followed by numbers; e.g., &amp;lt;code&amp;gt;Slider1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Slider2&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
&lt;br /&gt;
;Computational Expression&lt;br /&gt;
:A single term or a sequence of terms connected using arithmetic operators &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt;, or any other legal Javascript operators.&lt;br /&gt;
;Array&lt;br /&gt;
:A comma-separated sequence of terms enclosed in square brackets; e.g., &amp;lt;code&amp;gt;[Sigma, foo(1,2,3), 15.123e3]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be:&lt;br /&gt;
:An identifier&lt;br /&gt;
:A call expression of the form:&lt;br /&gt;
::&amp;lt;code&amp;gt;deriv(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;next(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;initial(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;update(''ident&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ''ident&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;'', ...)&amp;lt;/code&amp;gt;&lt;br /&gt;
:these are discussed below.&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be &lt;br /&gt;
: A computational expression when ''LHS'' is either &amp;lt;code&amp;gt;deriv&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;next&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initial&amp;lt;/code&amp;gt; or an identifier.&lt;br /&gt;
: An identifier when ''LHS'' is &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Examples&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(S) @=  -beta * S * I / N&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(I) @= beta * S * I / N - sigma * I&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(R) @= sigma * I&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
initial(S) @= N - I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(I) @= I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(R) @= 0&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
update(S,I,R) @= TimeGraph&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
N @= Slider1&amp;lt;br&amp;gt;&lt;br /&gt;
beta @= Slider2&amp;lt;br&amp;gt;&lt;br /&gt;
I0 @= Slider3&amp;lt;br&amp;gt;&lt;br /&gt;
sigma @= Slider4&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
next(L) @= R * L * (1 - L)&amp;lt;br&amp;gt;&lt;br /&gt;
initial(L) @= 0.5&amp;lt;br&amp;gt;&lt;br /&gt;
update(L) @= TimeGraph&amp;lt;br&amp;gt;&lt;br /&gt;
R @= Slider1&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;deriv(''Arg'')&amp;lt;/code&amp;gt; asserts a that the ''RHS'' equation is the time derivative of ''Arg''(t)&lt;br /&gt;
* &amp;lt;code&amp;gt;next(''Arg'')&amp;lt;/code&amp;gt; asserts a that the ''RHS'' equation is the next element in the time sequence ''Arg&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;'', ''Arg&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ...&lt;br /&gt;
: e.g., &amp;lt;code&amp;gt; next(X) @= X + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;initial(''Arg'')&amp;lt;/code&amp;gt; asserts that the ''RHS'' is the initial value of ''Arg''&lt;br /&gt;
* &amp;lt;code&amp;gt;update(''Val&amp;lt;sub&amp;gt;1'', ''Val&amp;lt;sub&amp;gt;2'', ...)&amp;lt;/code&amp;gt; asserts that ''Val&amp;lt;sub&amp;gt;1'', ''Val&amp;lt;sub&amp;gt;2'', ... should be downloaded to the output component with ID of the ''RHS''. The arguments should match the legend assigned to the output component&lt;br /&gt;
&lt;br /&gt;
An identifier appearing on the ''LHS'' is defined by the expression on the ''RHS''.&lt;br /&gt;
&lt;br /&gt;
== Syntax Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be&lt;br /&gt;
: An identifier&lt;br /&gt;
: An array of identifiers&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be&lt;br /&gt;
: A constant, primop, or array of primops&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
mainGraph #= [legend(S,I,R), title(&amp;quot;SIR Model&amp;quot;)]&amp;lt;br&amp;gt;&lt;br /&gt;
statsGraph #= title(&amp;quot;Infection Stats&amp;quot;)&amp;lt;br&amp;gt;&lt;br /&gt;
statsGraph #= [statDat(I),statParam(Beta),statRuns(12),statLo(3.4),statHi(4.5)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider1 #= [legend(N),max(1000000),step(1000)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider2 #= [legend(Beta),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider3 #= [legend(I0),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider4 #= [legend(Sigma),max(10),step(0.1)];&amp;lt;br&amp;gt;&lt;br /&gt;
[Slider5, Slider6] #= legend(&amp;quot;&amp;quot;);&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
* Identifiers on the ''LHS'' reference component IDs or parameters such as &amp;lt;code&amp;gt;dt&amp;lt;/code&amp;gt;&lt;br /&gt;
* Constants on the ''RHS'' are only used with parameters and assign values to them.&lt;br /&gt;
* Primops on the ''RHS'' are only used with component IDs and define attributes such as legend, max value, etc.&lt;br /&gt;
* Arrays on either side &amp;quot;multiply out&amp;quot; to as sequence of statements and are there for convenience.&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
====Random Number Generation====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(size)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Randomly picks a number from 0 to ''size-1'' with uniform probability.&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to 1, then this function randomly picks a number from 0 to ''n-1'' with the indicated probabilities. If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to less than 1, then the function returns ''n'' with probability 1 - ''&amp;amp;Sigma; p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;flip(p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns 1 with probability ''p''; 0 otherwise&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;binomial(n, p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns the sum of ''n'' independent ''flip(p)'' calls.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;multinomial(N, p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Performs ''N'' independent ''choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)'' calls and returns a vector of ''n'' (or ''n+1'') values ''(v&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, v&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ...)'' where ''v&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' is the number of times ''i'' was selected.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;poisson(lambda)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value 0, 1, ... distributed using the Poisson distribution with density ''lambda''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;normal(m, s)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value distributed using a Gaussian distribution with mean ''m'' and standard deviation ''s''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between 0 and ''y''.&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(x, y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between ''x'' and ''y''.&lt;br /&gt;
&lt;br /&gt;
====Trigonometric Functions====&lt;br /&gt;
;&amp;lt;code&amp;gt;cos, sin, tan, acos, asin, atan, atan2, cosh, sinh, tanh, acosh, asinh, atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
:Note: &amp;lt;code&amp;gt;(atan2 y x)&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;(atan y/x)&amp;lt;/code&amp;gt; extended to handle the case where ''x == 0''.&lt;br /&gt;
&lt;br /&gt;
====Constants====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;PI, PI2, Pi2, Pi34&amp;lt;/code&amp;gt;&lt;br /&gt;
:Respectively, &amp;amp;pi;, 2&amp;amp;pi;, &amp;amp;pi;/2, 3&amp;amp;pi;/4&lt;br /&gt;
&lt;br /&gt;
;degToRad&lt;br /&gt;
:&amp;amp;pi;/180&lt;br /&gt;
&lt;br /&gt;
;radToDeg&lt;br /&gt;
:180/&amp;amp;pi;&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Assigned to runtime graphs and displays:&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''title'''&lt;br /&gt;
:'''xlabel'''&lt;br /&gt;
:'''ylabel'''&lt;br /&gt;
:'''interval''' (between plots)&lt;br /&gt;
&lt;br /&gt;
Assigned to input sliders&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''min'''&lt;br /&gt;
:'''max'''&lt;br /&gt;
:'''step'''&lt;br /&gt;
&lt;br /&gt;
Integration Control&lt;br /&gt;
:'''dt'''&lt;br /&gt;
::Integration step size&lt;br /&gt;
:'''method''' ('''RK4''' or '''Euler''')&lt;br /&gt;
&lt;br /&gt;
Sensitivity Analysis Platform&lt;br /&gt;
:'''statParam'''&lt;br /&gt;
::Parameter varied by sensitivity test&lt;br /&gt;
:'''statDat'''&lt;br /&gt;
::Value to be graphed&lt;br /&gt;
:'''statRuns'''&lt;br /&gt;
::Number of runs&lt;br /&gt;
:'''StatLo, StatHi'''&lt;br /&gt;
::Testing boundaries&lt;br /&gt;
&lt;br /&gt;
Integration notes:&lt;br /&gt;
:'''method #= RK4'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using the Runge-Kutte 4 algorithm. If dt is not specified, it defaults to 0.5. RK4 requires that dt be some fraction of 1.0.&lt;br /&gt;
&lt;br /&gt;
:'''method #= Euler'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using Euler's method. Any value can be used for dt.&lt;br /&gt;
&lt;br /&gt;
:'''method''' and '''dt''' are both ignored for any quantity defined by '''next'''.&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2575</id>
		<title>NuML Language Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2575"/>
		<updated>2026-04-01T17:52:58Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: /* Primops for @# */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What is NuML?==&lt;br /&gt;
&lt;br /&gt;
NuML is a small, domain-specific language (dsl) for coding SD models and configuring the UI of a NuWebKit (NWK) site. It is used in DynSS models and in the Configuration Window. This document serves as reference for NWK authors and users wishing to use NuML in their  designs.&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
NuML serves two purposes: (1) to specify a system dynamics (SD) model program; and (2) to override the factory settings configuration for inputs, displays, and model operation. The choice of operator in an NuML statement, from the two described in the next section, respectively determines its purpose. To specify an SD program, NuML has special operators for defining a differential or difference equation with initial values. There are also primitive operators (primops) to supply random values and compute useful mathematical functions. To override factory settings there are operators to configure properties of input and display components, and to fix integration parameters. Finally, there are operators to configure properties of the analytical platforms. Currently there is only 1 of these (sensitivity analysis), and NuML will be extended as more such platforms become available.&lt;br /&gt;
&lt;br /&gt;
==NuML Operators==&lt;br /&gt;
NuML uses Javascript syntax extended with 2 infix operators (&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt;) that are not recognized as meaningful to Javascript. NWK uses a Javascript parser extended to accept these operators to analyze NuML code and respectively generate code or change the value of specific configuration parameters. Each NuML statement has the form:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS'';&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS'';&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
with slightly different rules for what is allowed on each side of the operator. In discussing NuML syntax we use the following terminology:&lt;br /&gt;
&lt;br /&gt;
==Language Categories==&lt;br /&gt;
;Constant&lt;br /&gt;
:Either a string constant enclosed in single or double quotes (&amp;lt;code&amp;gt;'Infection Stats'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;SIR Model&amp;quot;&amp;quot;&amp;lt;/code&amp;gt;) or a number in decimal (&amp;lt;code&amp;gt;3.1415&amp;lt;/code&amp;gt;) or scientific notation (&amp;lt;code&amp;gt;3.14159e5&amp;lt;/code&amp;gt;).&lt;br /&gt;
;Identifier&lt;br /&gt;
:Equivalent of a Javascript variable such as &amp;lt;code&amp;gt;Sigma&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;beta&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
;Unary Expression&lt;br /&gt;
:An unary operator modifying a term, such as &amp;lt;code&amp;gt;-10&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-Sigma&amp;lt;/code&amp;gt;.&lt;br /&gt;
;Call Expression&lt;br /&gt;
:A function name followed by a comma-separated sequence of arguments enclosed in parentheses. The function name must be an identifier; the arguments can be any list of terms.&lt;br /&gt;
;Term&lt;br /&gt;
:Either a constant, identifier, unary expression, or a call expression using one of the following function names, which differ for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;. These functions are called '''primops''' and are discussed below.&lt;br /&gt;
:&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;code&amp;gt;choose&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;multinomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;binomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;poisson&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;flip&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;irandom&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;random&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi34&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;degToRad&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;radToDeg&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tanh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;legend&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;phase&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;title&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statDat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statParam&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integration&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;statRuns&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statLo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statHi&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;min&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;max&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;step&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;xlabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ylabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;interval&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
;Keywords&lt;br /&gt;
:Special terms used by #= to identify UI components:&lt;br /&gt;
::&amp;lt;code&amp;gt;Slider&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Switch&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TimeGraph&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PhaseGraph&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StatGraph&amp;lt;/code&amp;gt;&lt;br /&gt;
:These may be followed by numbers; e.g., &amp;lt;code&amp;gt;Slider1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Slider2&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
&lt;br /&gt;
;Computational Expression&lt;br /&gt;
:A single term or a sequence of terms connected using arithmetic operators &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt;, or any other legal Javascript operators.&lt;br /&gt;
;Array&lt;br /&gt;
:A comma-separated sequence of terms enclosed in square brackets; e.g., &amp;lt;code&amp;gt;[Sigma, foo(1,2,3), 15.123e3]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be:&lt;br /&gt;
:An identifier&lt;br /&gt;
:A call expression of the form:&lt;br /&gt;
::&amp;lt;code&amp;gt;deriv(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;next(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;initial(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;update(''ident&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ''ident&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;'', ...)&amp;lt;/code&amp;gt;&lt;br /&gt;
:these are discussed below.&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be &lt;br /&gt;
: A computational expression when ''LHS'' is either &amp;lt;code&amp;gt;deriv&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;next&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initial&amp;lt;/code&amp;gt; or an identifier.&lt;br /&gt;
: An identifier when ''LHS'' is &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Examples&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(S) @=  -beta * S * I / N&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(I) @= beta * S * I / N - sigma * I&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(R) @= sigma * I&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
initial(S) @= N - I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(I) @= I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(R) @= 0&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
update(S,I,R) @= TimeGraph&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
N @= Slider1&amp;lt;br&amp;gt;&lt;br /&gt;
beta @= Slider2&amp;lt;br&amp;gt;&lt;br /&gt;
I0 @= Slider3&amp;lt;br&amp;gt;&lt;br /&gt;
sigma @= Slider4&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
next(L) @= R * L * (1 - L)&amp;lt;br&amp;gt;&lt;br /&gt;
initial(L) @= 0.5&amp;lt;br&amp;gt;&lt;br /&gt;
update(L) @= TimeGraph&amp;lt;br&amp;gt;&lt;br /&gt;
R @= Slider1&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;deriv(''Arg'')&amp;lt;/code&amp;gt; asserts a that the ''RHS'' equation is the time derivative of ''Arg''(t)&lt;br /&gt;
* &amp;lt;code&amp;gt;next(''Arg'')&amp;lt;/code&amp;gt; asserts a that the ''RHS'' equation is the next element in the time sequence ''Arg&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;'', ''Arg&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ...&lt;br /&gt;
: e.g., &amp;lt;code&amp;gt; next(X) @= X + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;initial(''Arg'')&amp;lt;/code&amp;gt; asserts that the ''RHS'' is the initial value of ''Arg''&lt;br /&gt;
* &amp;lt;code&amp;gt;update(''Val&amp;lt;sub&amp;gt;1'', ''Val&amp;lt;sub&amp;gt;2'', ...)&amp;lt;/code&amp;gt; asserts that ''Val&amp;lt;sub&amp;gt;1'', ''Val&amp;lt;sub&amp;gt;2'', ... should be downloaded to the output component with ID of the ''RHS''. The arguments should match the legend assigned to the output component&lt;br /&gt;
&lt;br /&gt;
An identifier appearing on the ''LHS'' is defined by the expression on the ''RHS''.&lt;br /&gt;
&lt;br /&gt;
== Syntax Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be&lt;br /&gt;
: An identifier&lt;br /&gt;
: An array of identifiers&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be&lt;br /&gt;
: A constant, primop, or array of primops&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
mainGraph #= [legend(S,I,R), title(&amp;quot;SIR Model&amp;quot;)]&amp;lt;br&amp;gt;&lt;br /&gt;
statsGraph #= title(&amp;quot;Infection Stats&amp;quot;)&amp;lt;br&amp;gt;&lt;br /&gt;
statsGraph #= [statDat(I),statParam(Beta),statRuns(12),statLo(3.4),statHi(4.5)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider1 #= [legend(N),max(1000000),step(1000)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider2 #= [legend(Beta),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider3 #= [legend(I0),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider4 #= [legend(Sigma),max(10),step(0.1)];&amp;lt;br&amp;gt;&lt;br /&gt;
[Slider5, Slider6] #= legend(&amp;quot;&amp;quot;);&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
* Identifiers on the ''LHS'' reference component IDs or parameters such as &amp;lt;code&amp;gt;dt&amp;lt;/code&amp;gt;&lt;br /&gt;
* Constants on the ''RHS'' are only used with parameters and assign values to them.&lt;br /&gt;
* Primops on the ''RHS'' are only used with component IDs and define attributes such as legend, max value, etc.&lt;br /&gt;
* Arrays on either side &amp;quot;multiply out&amp;quot; to as sequence of statements and are there for convenience.&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
====Random Number Generation====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(size)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Randomly picks a number from 0 to ''size-1'' with uniform probability.&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to 1, then this function randomly picks a number from 0 to ''n-1'' with the indicated probabilities. If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to less than 1, then the function returns ''n'' with probability 1 - ''&amp;amp;Sigma; p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;flip(p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns 1 with probability ''p''; 0 otherwise&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;binomial(n, p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns the sum of ''n'' independent ''flip(p)'' calls.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;multinomial(N, p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Performs ''N'' independent ''choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)'' calls and returns a vector of ''n'' (or ''n+1'') values ''(v&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, v&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ...)'' where ''v&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' is the number of times ''i'' was selected.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;poisson(lambda)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value 0, 1, ... distributed using the Poisson distribution with density ''lambda''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;normal(m, s)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value distributed using a Gaussian distribution with mean ''m'' and standard deviation ''s''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between 0 and ''y''.&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(x, y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between ''x'' and ''y''.&lt;br /&gt;
&lt;br /&gt;
====Trigonometric Functions====&lt;br /&gt;
;&amp;lt;code&amp;gt;cos, sin, tan, acos, asin, atan, atan2, cosh, sinh, tanh, acosh, asinh, atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
:Note: &amp;lt;code&amp;gt;(atan2 y x)&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;(atan y/x)&amp;lt;/code&amp;gt; extended to handle the case where ''x == 0''.&lt;br /&gt;
&lt;br /&gt;
====Constants====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;PI, PI2, Pi2, Pi34&amp;lt;/code&amp;gt;&lt;br /&gt;
:Respectively, &amp;amp;pi;, 2&amp;amp;pi;, &amp;amp;pi;/2, 3&amp;amp;pi;/4&lt;br /&gt;
&lt;br /&gt;
;degToRad&lt;br /&gt;
:&amp;amp;pi;/180&lt;br /&gt;
&lt;br /&gt;
;radToDeg&lt;br /&gt;
:180/&amp;amp;pi;&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Assigned to runtime graphs and displays:&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''title'''&lt;br /&gt;
:'''xlabel'''&lt;br /&gt;
:'''ylabel'''&lt;br /&gt;
:'''interval''' (between plots)&lt;br /&gt;
&lt;br /&gt;
Assigned to input sliders&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''min'''&lt;br /&gt;
:'''max'''&lt;br /&gt;
:'''step'''&lt;br /&gt;
&lt;br /&gt;
Integration Control&lt;br /&gt;
:'''dt'''&lt;br /&gt;
::Integration step size&lt;br /&gt;
::'''method''' ('''RK4''' or '''Euler''')&lt;br /&gt;
&lt;br /&gt;
Sensitivity Analysis Platform&lt;br /&gt;
:'''statParam'''&lt;br /&gt;
::Parameter varied by sensitivity test&lt;br /&gt;
:'''statDat'''&lt;br /&gt;
::Value to be graphed&lt;br /&gt;
:'''statRuns'''&lt;br /&gt;
::Number of runs&lt;br /&gt;
:'''StatLo, StatHi'''&lt;br /&gt;
::Testing boundaries&lt;br /&gt;
&lt;br /&gt;
Integration notes:&lt;br /&gt;
:'''method #= RK4'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using the Runge-Kutte 4 algorithm. If dt is not specified, it defaults to 0.5. RK4 requires that dt be some fraction of 1.0.&lt;br /&gt;
&lt;br /&gt;
:'''method #= Euler'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using Euler's method. Any value can be used for dt.&lt;br /&gt;
&lt;br /&gt;
:'''method''' and '''dt''' are both ignored for any quantity defined by '''next'''.&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2574</id>
		<title>NuML Language Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2574"/>
		<updated>2026-04-01T17:52:17Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What is NuML?==&lt;br /&gt;
&lt;br /&gt;
NuML is a small, domain-specific language (dsl) for coding SD models and configuring the UI of a NuWebKit (NWK) site. It is used in DynSS models and in the Configuration Window. This document serves as reference for NWK authors and users wishing to use NuML in their  designs.&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
NuML serves two purposes: (1) to specify a system dynamics (SD) model program; and (2) to override the factory settings configuration for inputs, displays, and model operation. The choice of operator in an NuML statement, from the two described in the next section, respectively determines its purpose. To specify an SD program, NuML has special operators for defining a differential or difference equation with initial values. There are also primitive operators (primops) to supply random values and compute useful mathematical functions. To override factory settings there are operators to configure properties of input and display components, and to fix integration parameters. Finally, there are operators to configure properties of the analytical platforms. Currently there is only 1 of these (sensitivity analysis), and NuML will be extended as more such platforms become available.&lt;br /&gt;
&lt;br /&gt;
==NuML Operators==&lt;br /&gt;
NuML uses Javascript syntax extended with 2 infix operators (&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt;) that are not recognized as meaningful to Javascript. NWK uses a Javascript parser extended to accept these operators to analyze NuML code and respectively generate code or change the value of specific configuration parameters. Each NuML statement has the form:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS'';&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS'';&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
with slightly different rules for what is allowed on each side of the operator. In discussing NuML syntax we use the following terminology:&lt;br /&gt;
&lt;br /&gt;
==Language Categories==&lt;br /&gt;
;Constant&lt;br /&gt;
:Either a string constant enclosed in single or double quotes (&amp;lt;code&amp;gt;'Infection Stats'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;SIR Model&amp;quot;&amp;quot;&amp;lt;/code&amp;gt;) or a number in decimal (&amp;lt;code&amp;gt;3.1415&amp;lt;/code&amp;gt;) or scientific notation (&amp;lt;code&amp;gt;3.14159e5&amp;lt;/code&amp;gt;).&lt;br /&gt;
;Identifier&lt;br /&gt;
:Equivalent of a Javascript variable such as &amp;lt;code&amp;gt;Sigma&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;beta&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
;Unary Expression&lt;br /&gt;
:An unary operator modifying a term, such as &amp;lt;code&amp;gt;-10&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-Sigma&amp;lt;/code&amp;gt;.&lt;br /&gt;
;Call Expression&lt;br /&gt;
:A function name followed by a comma-separated sequence of arguments enclosed in parentheses. The function name must be an identifier; the arguments can be any list of terms.&lt;br /&gt;
;Term&lt;br /&gt;
:Either a constant, identifier, unary expression, or a call expression using one of the following function names, which differ for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;. These functions are called '''primops''' and are discussed below.&lt;br /&gt;
:&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;code&amp;gt;choose&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;multinomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;binomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;poisson&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;flip&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;irandom&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;random&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi34&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;degToRad&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;radToDeg&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tanh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;legend&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;phase&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;title&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statDat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statParam&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integration&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;statRuns&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statLo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statHi&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;min&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;max&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;step&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;xlabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ylabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;interval&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
;Keywords&lt;br /&gt;
:Special terms used by #= to identify UI components:&lt;br /&gt;
::&amp;lt;code&amp;gt;Slider&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Switch&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TimeGraph&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PhaseGraph&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StatGraph&amp;lt;/code&amp;gt;&lt;br /&gt;
:These may be followed by numbers; e.g., &amp;lt;code&amp;gt;Slider1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Slider2&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
&lt;br /&gt;
;Computational Expression&lt;br /&gt;
:A single term or a sequence of terms connected using arithmetic operators &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt;, or any other legal Javascript operators.&lt;br /&gt;
;Array&lt;br /&gt;
:A comma-separated sequence of terms enclosed in square brackets; e.g., &amp;lt;code&amp;gt;[Sigma, foo(1,2,3), 15.123e3]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be:&lt;br /&gt;
:An identifier&lt;br /&gt;
:A call expression of the form:&lt;br /&gt;
::&amp;lt;code&amp;gt;deriv(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;next(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;initial(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;update(''ident&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ''ident&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;'', ...)&amp;lt;/code&amp;gt;&lt;br /&gt;
:these are discussed below.&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be &lt;br /&gt;
: A computational expression when ''LHS'' is either &amp;lt;code&amp;gt;deriv&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;next&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initial&amp;lt;/code&amp;gt; or an identifier.&lt;br /&gt;
: An identifier when ''LHS'' is &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Examples&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(S) @=  -beta * S * I / N&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(I) @= beta * S * I / N - sigma * I&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(R) @= sigma * I&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
initial(S) @= N - I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(I) @= I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(R) @= 0&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
update(S,I,R) @= TimeGraph&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
N @= Slider1&amp;lt;br&amp;gt;&lt;br /&gt;
beta @= Slider2&amp;lt;br&amp;gt;&lt;br /&gt;
I0 @= Slider3&amp;lt;br&amp;gt;&lt;br /&gt;
sigma @= Slider4&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
next(L) @= R * L * (1 - L)&amp;lt;br&amp;gt;&lt;br /&gt;
initial(L) @= 0.5&amp;lt;br&amp;gt;&lt;br /&gt;
update(L) @= TimeGraph&amp;lt;br&amp;gt;&lt;br /&gt;
R @= Slider1&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;deriv(''Arg'')&amp;lt;/code&amp;gt; asserts a that the ''RHS'' equation is the time derivative of ''Arg''(t)&lt;br /&gt;
* &amp;lt;code&amp;gt;next(''Arg'')&amp;lt;/code&amp;gt; asserts a that the ''RHS'' equation is the next element in the time sequence ''Arg&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;'', ''Arg&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ...&lt;br /&gt;
: e.g., &amp;lt;code&amp;gt; next(X) @= X + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;initial(''Arg'')&amp;lt;/code&amp;gt; asserts that the ''RHS'' is the initial value of ''Arg''&lt;br /&gt;
* &amp;lt;code&amp;gt;update(''Val&amp;lt;sub&amp;gt;1'', ''Val&amp;lt;sub&amp;gt;2'', ...)&amp;lt;/code&amp;gt; asserts that ''Val&amp;lt;sub&amp;gt;1'', ''Val&amp;lt;sub&amp;gt;2'', ... should be downloaded to the output component with ID of the ''RHS''. The arguments should match the legend assigned to the output component&lt;br /&gt;
&lt;br /&gt;
An identifier appearing on the ''LHS'' is defined by the expression on the ''RHS''.&lt;br /&gt;
&lt;br /&gt;
== Syntax Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be&lt;br /&gt;
: An identifier&lt;br /&gt;
: An array of identifiers&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be&lt;br /&gt;
: A constant, primop, or array of primops&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
mainGraph #= [legend(S,I,R), title(&amp;quot;SIR Model&amp;quot;)]&amp;lt;br&amp;gt;&lt;br /&gt;
statsGraph #= title(&amp;quot;Infection Stats&amp;quot;)&amp;lt;br&amp;gt;&lt;br /&gt;
statsGraph #= [statDat(I),statParam(Beta),statRuns(12),statLo(3.4),statHi(4.5)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider1 #= [legend(N),max(1000000),step(1000)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider2 #= [legend(Beta),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider3 #= [legend(I0),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider4 #= [legend(Sigma),max(10),step(0.1)];&amp;lt;br&amp;gt;&lt;br /&gt;
[Slider5, Slider6] #= legend(&amp;quot;&amp;quot;);&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
* Identifiers on the ''LHS'' reference component IDs or parameters such as &amp;lt;code&amp;gt;dt&amp;lt;/code&amp;gt;&lt;br /&gt;
* Constants on the ''RHS'' are only used with parameters and assign values to them.&lt;br /&gt;
* Primops on the ''RHS'' are only used with component IDs and define attributes such as legend, max value, etc.&lt;br /&gt;
* Arrays on either side &amp;quot;multiply out&amp;quot; to as sequence of statements and are there for convenience.&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
====Random Number Generation====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(size)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Randomly picks a number from 0 to ''size-1'' with uniform probability.&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to 1, then this function randomly picks a number from 0 to ''n-1'' with the indicated probabilities. If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to less than 1, then the function returns ''n'' with probability 1 - ''&amp;amp;Sigma; p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;flip(p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns 1 with probability ''p''; 0 otherwise&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;binomial(n, p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns the sum of ''n'' independent ''flip(p)'' calls.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;multinomial(N, p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Performs ''N'' independent ''choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)'' calls and returns a vector of ''n'' (or ''n+1'') values ''(v&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, v&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ...)'' where ''v&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' is the number of times ''i'' was selected.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;poisson(lambda)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value 0, 1, ... distributed using the Poisson distribution with density ''lambda''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;normal(m, s)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value distributed using a Gaussian distribution with mean ''m'' and standard deviation ''s''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between 0 and ''y''.&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(x, y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between ''x'' and ''y''.&lt;br /&gt;
&lt;br /&gt;
====Trigonometric Functions====&lt;br /&gt;
;&amp;lt;code&amp;gt;cos, sin, tan, acos, asin, atan, atan2, cosh, sinh, tanh, acosh, asinh, atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
:Note: &amp;lt;code&amp;gt;(atan2 y x)&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;(atan y/x)&amp;lt;/code&amp;gt; extended to handle the case where ''x == 0''.&lt;br /&gt;
&lt;br /&gt;
====Constants====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;PI, PI2, Pi2, Pi34&amp;lt;/code&amp;gt;&lt;br /&gt;
:Respectively, &amp;amp;pi;, 2&amp;amp;pi;, &amp;amp;pi;/2, 3&amp;amp;pi;/4&lt;br /&gt;
&lt;br /&gt;
;degToRad&lt;br /&gt;
:&amp;amp;pi;/180&lt;br /&gt;
&lt;br /&gt;
;radToDeg&lt;br /&gt;
:180/&amp;amp;pi;&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Assigned to runtime graphs and displays:&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''title'''&lt;br /&gt;
:'''xlabel'''&lt;br /&gt;
:'''ylabel'''&lt;br /&gt;
:'''interval''' (between plots)&lt;br /&gt;
&lt;br /&gt;
Assigned to input sliders&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''min'''&lt;br /&gt;
:'''max'''&lt;br /&gt;
:'''step'''&lt;br /&gt;
&lt;br /&gt;
Integration Control&lt;br /&gt;
:'''dt'''&lt;br /&gt;
::Integration step size&lt;br /&gt;
:'''method''' ('''RK4''' or '''Euler''')&lt;br /&gt;
&lt;br /&gt;
Sensitivity Analysis Platform&lt;br /&gt;
:'''statParam'''&lt;br /&gt;
::Parameter varied by sensitivity test&lt;br /&gt;
:'''statDat'''&lt;br /&gt;
::Value to be graphed&lt;br /&gt;
:'''statRuns'''&lt;br /&gt;
::Number of runs&lt;br /&gt;
:'''StatLo, StatHi'''&lt;br /&gt;
::Testing boundaries&lt;br /&gt;
&lt;br /&gt;
Integration notes:&lt;br /&gt;
:'''method #= RK4'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using the Runge-Kutte 4 algorithm. If dt is not specified, it defaults to 0.5. RK4 requires that dt be some fraction of 1.0.&lt;br /&gt;
&lt;br /&gt;
:'''method #= Euler'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using Euler's method. Any value can be used for dt.&lt;br /&gt;
&lt;br /&gt;
:'''method''' and '''dt''' are both ignored for any quantity defined by '''next'''.&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2573</id>
		<title>NuML Language Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2573"/>
		<updated>2026-04-01T17:51:01Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What is NuML?==&lt;br /&gt;
&lt;br /&gt;
NuML is a small, domain-specific language (dsl) for coding SD models and configuring the UI of a NuWebKit (NWK) site. It is used in DynSS models and in the Configuration Window. This document serves as reference for NWK authors and users wishing to use NuML in their  designs.&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
NuML serves two purposes: (1) to specify a system dynamics (SD) model program; and (2) to override the factory settings configuration for inputs, displays, and model operation. The choice of operator in an NuML statement, from the two described in the next section, respectively determines its purpose. To specify an SD program, NuML has special operators for defining a differential or difference equation with initial values. There are also primitive operators (primops) to supply random values and compute useful mathematical functions. To override factory settings there are operators to configure properties of input and display components, and to fix integration parameters. Finally, there are operators to configure properties of the analytical platforms. Currently there is only 1 of these (sensitivity analysis), and NuML will be extended as more such platforms become available.&lt;br /&gt;
&lt;br /&gt;
==NuML Operators==&lt;br /&gt;
NuML uses Javascript syntax extended with 2 infix operators (&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt;) that are not recognized as meaningful to Javascript. NWK uses a Javascript parser extended to accept these operators to analyze NuML code and respectively generate code or change the value of specific configuration parameters. Each NuML statement has the form:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS'';&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS'';&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
with slightly different rules for what is allowed on each side of the operator. In discussing NuML syntax we use the following terminology:&lt;br /&gt;
&lt;br /&gt;
==Language Categories==&lt;br /&gt;
;Constant&lt;br /&gt;
:Either a string constant enclosed in single or double quotes (&amp;lt;code&amp;gt;'Infection Stats'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;SIR Model&amp;quot;&amp;quot;&amp;lt;/code&amp;gt;) or a number in decimal (&amp;lt;code&amp;gt;3.1415&amp;lt;/code&amp;gt;) or scientific notation (&amp;lt;code&amp;gt;3.14159e5&amp;lt;/code&amp;gt;).&lt;br /&gt;
;Identifier&lt;br /&gt;
:Equivalent of a Javascript variable such as &amp;lt;code&amp;gt;Sigma&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;beta&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
;Unary Expression&lt;br /&gt;
:An unary operator modifying a term, such as &amp;lt;code&amp;gt;-10&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-Sigma&amp;lt;/code&amp;gt;.&lt;br /&gt;
;Call Expression&lt;br /&gt;
:A function name followed by a comma-separated sequence of arguments enclosed in parentheses. The function name must be an identifier; the arguments can be any list of terms.&lt;br /&gt;
;Term&lt;br /&gt;
:Either a constant, identifier, unary expression, or a call expression using one of the following function names, which differ for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;. These functions are called '''primops''' and are discussed below.&lt;br /&gt;
:&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;code&amp;gt;choose&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;multinomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;binomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;poisson&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;flip&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;irandom&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;random&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi34&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;degToRad&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;radToDeg&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tanh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;legend&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;phase&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;title&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statDat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statParam&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integration&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;statRuns&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statLo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statHi&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;min&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;max&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;step&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;xlabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ylabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;interval&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
;Keywords&lt;br /&gt;
:Special terms used by #= to identify UI components:&lt;br /&gt;
::&amp;lt;code&amp;gt;Slider&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Switch&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TimeGraph&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PhaseGraph&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StatGraph&amp;lt;/code&amp;gt;&lt;br /&gt;
:These may be followed by numbers; e.g., &amp;lt;code&amp;gt;Slider1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Slider2&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
&lt;br /&gt;
;Computational Expression&lt;br /&gt;
:A single term or a sequence of terms connected using arithmetic operators &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt;, or any other legal Javascript operators.&lt;br /&gt;
;Array&lt;br /&gt;
:A comma-separated sequence of terms enclosed in square brackets; e.g., &amp;lt;code&amp;gt;[Sigma, foo(1,2,3), 15.123e3]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be:&lt;br /&gt;
:An identifier&lt;br /&gt;
:A call expression of the form:&lt;br /&gt;
::&amp;lt;code&amp;gt;deriv(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;next(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;initial(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;update(''ident&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ''ident&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;'', ...)&amp;lt;/code&amp;gt;&lt;br /&gt;
:these are discussed below.&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be &lt;br /&gt;
: A computational expression when ''LHS'' is either &amp;lt;code&amp;gt;deriv&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;next&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initial&amp;lt;/code&amp;gt; or an identifier.&lt;br /&gt;
: An identifier when ''LHS'' is &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Examples&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(S) @=  -beta * S * I / N&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(I) @= beta * S * I / N - sigma * I&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(R) @= sigma * I&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
initial(S) @= N - I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(I) @= I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(R) @= 0&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
update(S,I,R) @= mainGraph&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
N @= Slider1&amp;lt;br&amp;gt;&lt;br /&gt;
beta @= Slider2&amp;lt;br&amp;gt;&lt;br /&gt;
I0 @= Slider3&amp;lt;br&amp;gt;&lt;br /&gt;
sigma @= Slider4&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
next(L) @= R * L * (1 - L)&amp;lt;br&amp;gt;&lt;br /&gt;
initial(L) @= 0.5&amp;lt;br&amp;gt;&lt;br /&gt;
update(L) @= TimeGraph&amp;lt;br&amp;gt;&lt;br /&gt;
R @= Slider1&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;deriv(''Arg'')&amp;lt;/code&amp;gt; asserts a that the ''RHS'' equation is the time derivative of ''Arg''(t)&lt;br /&gt;
* &amp;lt;code&amp;gt;next(''Arg'')&amp;lt;/code&amp;gt; asserts a that the ''RHS'' equation is the next element in the time sequence ''Arg&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;'', ''Arg&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ...&lt;br /&gt;
: e.g., &amp;lt;code&amp;gt; next(X) @= X + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;initial(''Arg'')&amp;lt;/code&amp;gt; asserts that the ''RHS'' is the initial value of ''Arg''&lt;br /&gt;
* &amp;lt;code&amp;gt;update(''Val&amp;lt;sub&amp;gt;1'', ''Val&amp;lt;sub&amp;gt;2'', ...)&amp;lt;/code&amp;gt; asserts that ''Val&amp;lt;sub&amp;gt;1'', ''Val&amp;lt;sub&amp;gt;2'', ... should be downloaded to the output component with ID of the ''RHS''. The arguments should match the legend assigned to the output component&lt;br /&gt;
&lt;br /&gt;
An identifier appearing on the ''LHS'' is defined by the expression on the ''RHS''.&lt;br /&gt;
&lt;br /&gt;
== Syntax Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be&lt;br /&gt;
: An identifier&lt;br /&gt;
: An array of identifiers&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be&lt;br /&gt;
: A constant, primop, or array of primops&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
mainGraph #= [legend(S,I,R), title(&amp;quot;SIR Model&amp;quot;)]&amp;lt;br&amp;gt;&lt;br /&gt;
statsGraph #= title(&amp;quot;Infection Stats&amp;quot;)&amp;lt;br&amp;gt;&lt;br /&gt;
statsGraph #= [statDat(I),statParam(Beta),statRuns(12),statLo(3.4),statHi(4.5)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider1 #= [legend(N),max(1000000),step(1000)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider2 #= [legend(Beta),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider3 #= [legend(I0),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Slider4 #= [legend(Sigma),max(10),step(0.1)];&amp;lt;br&amp;gt;&lt;br /&gt;
[Slider5, Slider6] #= legend(&amp;quot;&amp;quot;);&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
* Identifiers on the ''LHS'' reference component IDs or parameters such as &amp;lt;code&amp;gt;dt&amp;lt;/code&amp;gt;&lt;br /&gt;
* Constants on the ''RHS'' are only used with parameters and assign values to them.&lt;br /&gt;
* Primops on the ''RHS'' are only used with component IDs and define attributes such as legend, max value, etc.&lt;br /&gt;
* Arrays on either side &amp;quot;multiply out&amp;quot; to as sequence of statements and are there for convenience.&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
====Random Number Generation====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(size)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Randomly picks a number from 0 to ''size-1'' with uniform probability.&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to 1, then this function randomly picks a number from 0 to ''n-1'' with the indicated probabilities. If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to less than 1, then the function returns ''n'' with probability 1 - ''&amp;amp;Sigma; p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;flip(p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns 1 with probability ''p''; 0 otherwise&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;binomial(n, p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns the sum of ''n'' independent ''flip(p)'' calls.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;multinomial(N, p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Performs ''N'' independent ''choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)'' calls and returns a vector of ''n'' (or ''n+1'') values ''(v&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, v&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ...)'' where ''v&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' is the number of times ''i'' was selected.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;poisson(lambda)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value 0, 1, ... distributed using the Poisson distribution with density ''lambda''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;normal(m, s)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value distributed using a Gaussian distribution with mean ''m'' and standard deviation ''s''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between 0 and ''y''.&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(x, y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between ''x'' and ''y''.&lt;br /&gt;
&lt;br /&gt;
====Trigonometric Functions====&lt;br /&gt;
;&amp;lt;code&amp;gt;cos, sin, tan, acos, asin, atan, atan2, cosh, sinh, tanh, acosh, asinh, atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
:Note: &amp;lt;code&amp;gt;(atan2 y x)&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;(atan y/x)&amp;lt;/code&amp;gt; extended to handle the case where ''x == 0''.&lt;br /&gt;
&lt;br /&gt;
====Constants====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;PI, PI2, Pi2, Pi34&amp;lt;/code&amp;gt;&lt;br /&gt;
:Respectively, &amp;amp;pi;, 2&amp;amp;pi;, &amp;amp;pi;/2, 3&amp;amp;pi;/4&lt;br /&gt;
&lt;br /&gt;
;degToRad&lt;br /&gt;
:&amp;amp;pi;/180&lt;br /&gt;
&lt;br /&gt;
;radToDeg&lt;br /&gt;
:180/&amp;amp;pi;&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Assigned to runtime graphs and displays:&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''title'''&lt;br /&gt;
:'''xlabel'''&lt;br /&gt;
:'''ylabel'''&lt;br /&gt;
:'''interval''' (between plots)&lt;br /&gt;
&lt;br /&gt;
Assigned to input sliders&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''min'''&lt;br /&gt;
:'''max'''&lt;br /&gt;
:'''step'''&lt;br /&gt;
&lt;br /&gt;
Integration Control&lt;br /&gt;
:'''dt'''&lt;br /&gt;
::Integration step size&lt;br /&gt;
:'''method''' ('''RK4''' or '''Euler''')&lt;br /&gt;
&lt;br /&gt;
Sensitivity Analysis Platform&lt;br /&gt;
:'''statParam'''&lt;br /&gt;
::Parameter varied by sensitivity test&lt;br /&gt;
:'''statDat'''&lt;br /&gt;
::Value to be graphed&lt;br /&gt;
:'''statRuns'''&lt;br /&gt;
::Number of runs&lt;br /&gt;
:'''StatLo, StatHi'''&lt;br /&gt;
::Testing boundaries&lt;br /&gt;
&lt;br /&gt;
Integration notes:&lt;br /&gt;
:'''method #= RK4'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using the Runge-Kutte 4 algorithm. If dt is not specified, it defaults to 0.5. RK4 requires that dt be some fraction of 1.0.&lt;br /&gt;
&lt;br /&gt;
:'''method #= Euler'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using Euler's method. Any value can be used for dt.&lt;br /&gt;
&lt;br /&gt;
:'''method''' and '''dt''' are both ignored for any quantity defined by '''next'''.&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2572</id>
		<title>NuML Language Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2572"/>
		<updated>2026-04-01T17:44:03Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: /* Syntax Rules for @= */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What is NuML?==&lt;br /&gt;
&lt;br /&gt;
NuML is a small, domain-specific language (dsl) for coding SD models and configuring the UI of a NuWebKit (NWK) site. It is used in DynSS models and in the Configuration Window. This document serves as reference for NWK authors and users wishing to use NuML in their  designs.&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
NuML serves two purposes: (1) to specify a system dynamics (SD) model program; and (2) to override the factory settings configuration for inputs, displays, and model operation. The choice of operator in an NuML statement, from the two described in the next section, respectively determines its purpose. To specify an SD program, NuML has special operators for defining a differential or difference equation with initial values. There are also primitive operators (primops) to supply random values and compute useful mathematical functions. To override factory settings there are operators to configure properties of input and display components, and to fix integration parameters. Finally, there are operators to configure properties of the analytical platforms. Currently there is only 1 of these (sensitivity analysis), and NuML will be extended as more such platforms become available.&lt;br /&gt;
&lt;br /&gt;
==NuML Operators==&lt;br /&gt;
NuML uses Javascript syntax extended with 2 infix operators (&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt;) that are not recognized as meaningful to Javascript. NWK uses a Javascript parser extended to accept these operators to analyze NuML code and respectively generate code or change the value of specific configuration parameters. Each NuML statement has the form:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS'';&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS'';&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
with slightly different rules for what is allowed on each side of the operator. In discussing NuML syntax we use the following terminology:&lt;br /&gt;
&lt;br /&gt;
==Language Categories==&lt;br /&gt;
;Constant&lt;br /&gt;
:Either a string constant enclosed in single or double quotes (&amp;lt;code&amp;gt;'Infection Stats'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;SIR Model&amp;quot;&amp;quot;&amp;lt;/code&amp;gt;) or a number in decimal (&amp;lt;code&amp;gt;3.1415&amp;lt;/code&amp;gt;) or scientific notation (&amp;lt;code&amp;gt;3.14159e5&amp;lt;/code&amp;gt;).&lt;br /&gt;
;Identifier&lt;br /&gt;
:Equivalent of a Javascript variable such as &amp;lt;code&amp;gt;Sigma&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;beta&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
;Unary Expression&lt;br /&gt;
:An unary operator modifying a term, such as &amp;lt;code&amp;gt;-10&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-Sigma&amp;lt;/code&amp;gt;.&lt;br /&gt;
;Call Expression&lt;br /&gt;
:A function name followed by a comma-separated sequence of arguments enclosed in parentheses. The function name must be an identifier; the arguments can be any list of terms.&lt;br /&gt;
;Term&lt;br /&gt;
:Either a constant, identifier, unary expression, or a call expression using one of the following function names, which differ for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;. These functions are called '''primops''' and are discussed below.&lt;br /&gt;
:&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;code&amp;gt;choose&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;multinomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;binomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;poisson&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;flip&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;irandom&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;random&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi34&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;degToRad&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;radToDeg&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tanh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;legend&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;phase&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;title&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statDat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statParam&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integration&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;statRuns&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statLo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statHi&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;min&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;max&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;step&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;xlabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ylabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;interval&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Computational Expression&lt;br /&gt;
:A single term or a sequence of terms connected using arithmetic operators &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt;, or any other legal Javascript operators.&lt;br /&gt;
;Array&lt;br /&gt;
:A comma-separated sequence of terms enclosed in square brackets; e.g., &amp;lt;code&amp;gt;[Sigma, foo(1,2,3), 15.123e3]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be:&lt;br /&gt;
:An identifier&lt;br /&gt;
:A call expression of the form:&lt;br /&gt;
::&amp;lt;code&amp;gt;deriv(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;next(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;initial(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;update(''ident&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ''ident&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;'', ...)&amp;lt;/code&amp;gt;&lt;br /&gt;
:these are discussed below.&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be &lt;br /&gt;
: A computational expression when ''LHS'' is either &amp;lt;code&amp;gt;deriv&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;next&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initial&amp;lt;/code&amp;gt; or an identifier.&lt;br /&gt;
: An identifier when ''LHS'' is &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Examples&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(S) @=  -beta * S * I / N&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(I) @= beta * S * I / N - sigma * I&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(R) @= sigma * I&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
initial(S) @= N - I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(I) @= I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(R) @= 0&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
update(S,I,R) @= mainGraph&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
N @= Param1&amp;lt;br&amp;gt;&lt;br /&gt;
beta @= Param2&amp;lt;br&amp;gt;&lt;br /&gt;
I0 @= Param3&amp;lt;br&amp;gt;&lt;br /&gt;
sigma @= Param4&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
next(L) @= R * L * (1 - L)&amp;lt;br&amp;gt;&lt;br /&gt;
initial(L) @= 0.5&amp;lt;br&amp;gt;&lt;br /&gt;
update(L) @= TimeGraph&amp;lt;br&amp;gt;&lt;br /&gt;
R @= Slider1&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;deriv(''Arg'')&amp;lt;/code&amp;gt; asserts a that the ''RHS'' equation is the time derivative of ''Arg''(t)&lt;br /&gt;
* &amp;lt;code&amp;gt;next(''Arg'')&amp;lt;/code&amp;gt; asserts a that the ''RHS'' equation is the next element in the time sequence ''Arg&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;'', ''Arg&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ...&lt;br /&gt;
: e.g., &amp;lt;code&amp;gt; next(X) @= X + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;initial(''Arg'')&amp;lt;/code&amp;gt; asserts that the ''RHS'' is the initial value of ''Arg''&lt;br /&gt;
* &amp;lt;code&amp;gt;update(''Val&amp;lt;sub&amp;gt;1'', ''Val&amp;lt;sub&amp;gt;2'', ...)&amp;lt;/code&amp;gt; asserts that ''Val&amp;lt;sub&amp;gt;1'', ''Val&amp;lt;sub&amp;gt;2'', ... should be downloaded to the output component with ID of the ''RHS''. The arguments should match the legend assigned to the output component&lt;br /&gt;
&lt;br /&gt;
An identifier appearing on the ''LHS'' is defined by the expression on the ''RHS''.&lt;br /&gt;
&lt;br /&gt;
== Syntax Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be&lt;br /&gt;
: An identifier&lt;br /&gt;
: An array of identifiers&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be&lt;br /&gt;
: A constant, primop, or array of primops&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
mainGraph #= [legend(S,I,R), title(&amp;quot;SIR Model&amp;quot;)]&amp;lt;br&amp;gt;&lt;br /&gt;
statsGraph #= title(&amp;quot;Infection Stats&amp;quot;)&amp;lt;br&amp;gt;&lt;br /&gt;
statsGraph #= [statDat(I),statParam(Beta),statRuns(12),statLo(3.4),statHi(4.5)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param1 #= [legend(N),max(1000000),step(1000)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param2 #= [legend(Beta),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param3 #= [legend(I0),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param4 #= [legend(Sigma),max(10),step(0.1)];&amp;lt;br&amp;gt;&lt;br /&gt;
[Param5, Param6] #= legend(&amp;quot;&amp;quot;);&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
* Identifiers on the ''LHS'' reference component IDs or parameters such as &amp;lt;code&amp;gt;dt&amp;lt;/code&amp;gt;&lt;br /&gt;
* Constants on the ''RHS'' are only used with parameters and assign values to them.&lt;br /&gt;
* Primops on the ''RHS'' are only used with component IDs and define attributes such as legend, max value, etc.&lt;br /&gt;
* Arrays on either side &amp;quot;multiply out&amp;quot; to as sequence of statements and are there for convenience.&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
====Random Number Generation====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(size)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Randomly picks a number from 0 to ''size-1'' with uniform probability.&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to 1, then this function randomly picks a number from 0 to ''n-1'' with the indicated probabilities. If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to less than 1, then the function returns ''n'' with probability 1 - ''&amp;amp;Sigma; p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;flip(p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns 1 with probability ''p''; 0 otherwise&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;binomial(n, p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns the sum of ''n'' independent ''flip(p)'' calls.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;multinomial(N, p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Performs ''N'' independent ''choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)'' calls and returns a vector of ''n'' (or ''n+1'') values ''(v&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, v&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ...)'' where ''v&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' is the number of times ''i'' was selected.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;poisson(lambda)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value 0, 1, ... distributed using the Poisson distribution with density ''lambda''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;normal(m, s)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value distributed using a Gaussian distribution with mean ''m'' and standard deviation ''s''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between 0 and ''y''.&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(x, y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between ''x'' and ''y''.&lt;br /&gt;
&lt;br /&gt;
====Trigonometric Functions====&lt;br /&gt;
;&amp;lt;code&amp;gt;cos, sin, tan, acos, asin, atan, atan2, cosh, sinh, tanh, acosh, asinh, atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
:Note: &amp;lt;code&amp;gt;(atan2 y x)&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;(atan y/x)&amp;lt;/code&amp;gt; extended to handle the case where ''x == 0''.&lt;br /&gt;
&lt;br /&gt;
====Constants====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;PI, PI2, Pi2, Pi34&amp;lt;/code&amp;gt;&lt;br /&gt;
:Respectively, &amp;amp;pi;, 2&amp;amp;pi;, &amp;amp;pi;/2, 3&amp;amp;pi;/4&lt;br /&gt;
&lt;br /&gt;
;degToRad&lt;br /&gt;
:&amp;amp;pi;/180&lt;br /&gt;
&lt;br /&gt;
;radToDeg&lt;br /&gt;
:180/&amp;amp;pi;&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Assigned to runtime graphs and displays:&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''title'''&lt;br /&gt;
:'''xlabel'''&lt;br /&gt;
:'''ylabel'''&lt;br /&gt;
:'''interval''' (between plots)&lt;br /&gt;
&lt;br /&gt;
Assigned to input sliders&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''min'''&lt;br /&gt;
:'''max'''&lt;br /&gt;
:'''step'''&lt;br /&gt;
&lt;br /&gt;
Integration Control&lt;br /&gt;
:'''dt'''&lt;br /&gt;
::Integration step size&lt;br /&gt;
:'''method''' ('''RK4''' or '''Euler''')&lt;br /&gt;
&lt;br /&gt;
Sensitivity Analysis Platform&lt;br /&gt;
:'''statParam'''&lt;br /&gt;
::Parameter varied by sensitivity test&lt;br /&gt;
:'''statDat'''&lt;br /&gt;
::Value to be graphed&lt;br /&gt;
:'''statRuns'''&lt;br /&gt;
::Number of runs&lt;br /&gt;
:'''StatLo, StatHi'''&lt;br /&gt;
::Testing boundaries&lt;br /&gt;
&lt;br /&gt;
Integration notes:&lt;br /&gt;
:'''method #= RK4'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using the Runge-Kutte 4 algorithm. If dt is not specified, it defaults to 0.5. RK4 requires that dt be some fraction of 1.0.&lt;br /&gt;
&lt;br /&gt;
:'''method #= Euler'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using Euler's method. Any value can be used for dt.&lt;br /&gt;
&lt;br /&gt;
:'''method''' and '''dt''' are both ignored for any quantity defined by '''next'''.&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2571</id>
		<title>NuML Language Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2571"/>
		<updated>2026-04-01T17:43:31Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: /* Primops for @# */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What is NuML?==&lt;br /&gt;
&lt;br /&gt;
NuML is a small, domain-specific language (dsl) for coding SD models and configuring the UI of a NuWebKit (NWK) site. It is used in DynSS models and in the Configuration Window. This document serves as reference for NWK authors and users wishing to use NuML in their  designs.&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
NuML serves two purposes: (1) to specify a system dynamics (SD) model program; and (2) to override the factory settings configuration for inputs, displays, and model operation. The choice of operator in an NuML statement, from the two described in the next section, respectively determines its purpose. To specify an SD program, NuML has special operators for defining a differential or difference equation with initial values. There are also primitive operators (primops) to supply random values and compute useful mathematical functions. To override factory settings there are operators to configure properties of input and display components, and to fix integration parameters. Finally, there are operators to configure properties of the analytical platforms. Currently there is only 1 of these (sensitivity analysis), and NuML will be extended as more such platforms become available.&lt;br /&gt;
&lt;br /&gt;
==NuML Operators==&lt;br /&gt;
NuML uses Javascript syntax extended with 2 infix operators (&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt;) that are not recognized as meaningful to Javascript. NWK uses a Javascript parser extended to accept these operators to analyze NuML code and respectively generate code or change the value of specific configuration parameters. Each NuML statement has the form:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS'';&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS'';&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
with slightly different rules for what is allowed on each side of the operator. In discussing NuML syntax we use the following terminology:&lt;br /&gt;
&lt;br /&gt;
==Language Categories==&lt;br /&gt;
;Constant&lt;br /&gt;
:Either a string constant enclosed in single or double quotes (&amp;lt;code&amp;gt;'Infection Stats'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;SIR Model&amp;quot;&amp;quot;&amp;lt;/code&amp;gt;) or a number in decimal (&amp;lt;code&amp;gt;3.1415&amp;lt;/code&amp;gt;) or scientific notation (&amp;lt;code&amp;gt;3.14159e5&amp;lt;/code&amp;gt;).&lt;br /&gt;
;Identifier&lt;br /&gt;
:Equivalent of a Javascript variable such as &amp;lt;code&amp;gt;Sigma&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;beta&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
;Unary Expression&lt;br /&gt;
:An unary operator modifying a term, such as &amp;lt;code&amp;gt;-10&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-Sigma&amp;lt;/code&amp;gt;.&lt;br /&gt;
;Call Expression&lt;br /&gt;
:A function name followed by a comma-separated sequence of arguments enclosed in parentheses. The function name must be an identifier; the arguments can be any list of terms.&lt;br /&gt;
;Term&lt;br /&gt;
:Either a constant, identifier, unary expression, or a call expression using one of the following function names, which differ for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;. These functions are called '''primops''' and are discussed below.&lt;br /&gt;
:&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;code&amp;gt;choose&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;multinomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;binomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;poisson&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;flip&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;irandom&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;random&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi34&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;degToRad&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;radToDeg&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tanh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;legend&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;phase&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;title&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statDat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statParam&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integration&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;statRuns&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statLo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statHi&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;min&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;max&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;step&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;xlabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ylabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;interval&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Computational Expression&lt;br /&gt;
:A single term or a sequence of terms connected using arithmetic operators &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt;, or any other legal Javascript operators.&lt;br /&gt;
;Array&lt;br /&gt;
:A comma-separated sequence of terms enclosed in square brackets; e.g., &amp;lt;code&amp;gt;[Sigma, foo(1,2,3), 15.123e3]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be:&lt;br /&gt;
:An identifier&lt;br /&gt;
:A call expression of the form:&lt;br /&gt;
::&amp;lt;code&amp;gt;deriv(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;next(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;initial(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;update(''ident&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ''ident&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;'', ...)&amp;lt;/code&amp;gt;&lt;br /&gt;
:these are discussed below.&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be &lt;br /&gt;
: A computational expression when ''LHS'' is either &amp;lt;code&amp;gt;deriv&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;next&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initial&amp;lt;/code&amp;gt; or an identifier.&lt;br /&gt;
: An identifier when ''LHS'' is &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Examples&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(S) @=  -beta * S * I / N&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(I) @= beta * S * I / N - sigma * I&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(R) @= sigma * I&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
initial(S) @= N - I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(I) @= I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(R) @= 0&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
update(S,I,R) @= mainGraph&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
N @= Param1&amp;lt;br&amp;gt;&lt;br /&gt;
beta @= Param2&amp;lt;br&amp;gt;&lt;br /&gt;
I0 @= Param3&amp;lt;br&amp;gt;&lt;br /&gt;
sigma @= Param4&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
next(L) @= R * L * (1 - L)&amp;lt;br&amp;gt;&lt;br /&gt;
initial(L) @= 0.5&amp;lt;br&amp;gt;&lt;br /&gt;
update(L) @= TimeGraph&amp;lt;br&amp;gt;&lt;br /&gt;
R @= Slider1&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;deriv(''Arg'')&amp;lt;/code&amp;gt; asserts a that the ''RHS'' equation is the time derivative of ''Arg''(t)&lt;br /&gt;
* &amp;lt;code&amp;gt;next(''Arg'')&amp;lt;/code&amp;gt; asserts a that the ''RHS'' equation is the next element in the time sequence ''Arg&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;'', ''Arg&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ...&lt;br /&gt;
: e.g., &amp;lt;code&amp;gt; next(X) @= X + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;initial(''Arg'')&amp;lt;/code&amp;gt; asserts that the ''RHS'' is the initial value of ''Arg''&lt;br /&gt;
* &amp;lt;code&amp;gt;update(''Val&amp;lt;sub&amp;gt;1'', ''Val&amp;lt;sub&amp;gt;2'', ...)&amp;lt;/code&amp;gt; asserts that ''Val&amp;lt;sub&amp;gt;1'', ''Val&amp;lt;sub&amp;gt;2'', ... should be downloaded to the output component with ID of the ''RHS''. The arguments should match the legend assigned to the output component&lt;br /&gt;
&lt;br /&gt;
An identifier appearing on the ''LHS'' is defined by the expression on the ''RHS''.&lt;br /&gt;
&lt;br /&gt;
== Syntax Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be&lt;br /&gt;
: An identifier&lt;br /&gt;
: An array of identifiers&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be&lt;br /&gt;
: A constant, primop, or array of primops&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
mainGraph #= [legend(S,I,R), title(&amp;quot;SIR Model&amp;quot;)]&amp;lt;br&amp;gt;&lt;br /&gt;
statsGraph #= title(&amp;quot;Infection Stats&amp;quot;)&amp;lt;br&amp;gt;&lt;br /&gt;
statsGraph #= [statDat(I),statParam(Beta),statRuns(12),statLo(3.4),statHi(4.5)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param1 #= [legend(N),max(1000000),step(1000)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param2 #= [legend(Beta),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param3 #= [legend(I0),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param4 #= [legend(Sigma),max(10),step(0.1)];&amp;lt;br&amp;gt;&lt;br /&gt;
[Param5, Param6] #= legend(&amp;quot;&amp;quot;);&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
* Identifiers on the ''LHS'' reference component IDs or parameters such as &amp;lt;code&amp;gt;dt&amp;lt;/code&amp;gt;&lt;br /&gt;
* Constants on the ''RHS'' are only used with parameters and assign values to them.&lt;br /&gt;
* Primops on the ''RHS'' are only used with component IDs and define attributes such as legend, max value, etc.&lt;br /&gt;
* Arrays on either side &amp;quot;multiply out&amp;quot; to as sequence of statements and are there for convenience.&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
====Random Number Generation====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(size)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Randomly picks a number from 0 to ''size-1'' with uniform probability.&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to 1, then this function randomly picks a number from 0 to ''n-1'' with the indicated probabilities. If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to less than 1, then the function returns ''n'' with probability 1 - ''&amp;amp;Sigma; p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;flip(p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns 1 with probability ''p''; 0 otherwise&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;binomial(n, p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns the sum of ''n'' independent ''flip(p)'' calls.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;multinomial(N, p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Performs ''N'' independent ''choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)'' calls and returns a vector of ''n'' (or ''n+1'') values ''(v&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, v&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ...)'' where ''v&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' is the number of times ''i'' was selected.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;poisson(lambda)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value 0, 1, ... distributed using the Poisson distribution with density ''lambda''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;normal(m, s)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value distributed using a Gaussian distribution with mean ''m'' and standard deviation ''s''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between 0 and ''y''.&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(x, y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between ''x'' and ''y''.&lt;br /&gt;
&lt;br /&gt;
====Trigonometric Functions====&lt;br /&gt;
;&amp;lt;code&amp;gt;cos, sin, tan, acos, asin, atan, atan2, cosh, sinh, tanh, acosh, asinh, atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
:Note: &amp;lt;code&amp;gt;(atan2 y x)&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;(atan y/x)&amp;lt;/code&amp;gt; extended to handle the case where ''x == 0''.&lt;br /&gt;
&lt;br /&gt;
====Constants====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;PI, PI2, Pi2, Pi34&amp;lt;/code&amp;gt;&lt;br /&gt;
:Respectively, &amp;amp;pi;, 2&amp;amp;pi;, &amp;amp;pi;/2, 3&amp;amp;pi;/4&lt;br /&gt;
&lt;br /&gt;
;degToRad&lt;br /&gt;
:&amp;amp;pi;/180&lt;br /&gt;
&lt;br /&gt;
;radToDeg&lt;br /&gt;
:180/&amp;amp;pi;&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Assigned to runtime graphs and displays:&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''title'''&lt;br /&gt;
:'''xlabel'''&lt;br /&gt;
:'''ylabel'''&lt;br /&gt;
:'''interval''' (between plots)&lt;br /&gt;
&lt;br /&gt;
Assigned to input sliders&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''min'''&lt;br /&gt;
:'''max'''&lt;br /&gt;
:'''step'''&lt;br /&gt;
&lt;br /&gt;
Integration Control&lt;br /&gt;
:'''dt'''&lt;br /&gt;
::Integration step size&lt;br /&gt;
:'''method''' ('''RK4''' or '''Euler''')&lt;br /&gt;
&lt;br /&gt;
Sensitivity Analysis Platform&lt;br /&gt;
:'''statParam'''&lt;br /&gt;
::Parameter varied by sensitivity test&lt;br /&gt;
:'''statDat'''&lt;br /&gt;
::Value to be graphed&lt;br /&gt;
:'''statRuns'''&lt;br /&gt;
::Number of runs&lt;br /&gt;
:'''StatLo, StatHi'''&lt;br /&gt;
::Testing boundaries&lt;br /&gt;
&lt;br /&gt;
Integration notes:&lt;br /&gt;
:'''method #= RK4'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using the Runge-Kutte 4 algorithm. If dt is not specified, it defaults to 0.5. RK4 requires that dt be some fraction of 1.0.&lt;br /&gt;
&lt;br /&gt;
:'''method #= Euler'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using Euler's method. Any value can be used for dt.&lt;br /&gt;
&lt;br /&gt;
:'''method''' and '''dt''' are both ignored for any quantity defined by '''next'''.&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2570</id>
		<title>NuML Language Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2570"/>
		<updated>2026-04-01T17:42:13Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What is NuML?==&lt;br /&gt;
&lt;br /&gt;
NuML is a small, domain-specific language (dsl) for coding SD models and configuring the UI of a NuWebKit (NWK) site. It is used in DynSS models and in the Configuration Window. This document serves as reference for NWK authors and users wishing to use NuML in their  designs.&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
NuML serves two purposes: (1) to specify a system dynamics (SD) model program; and (2) to override the factory settings configuration for inputs, displays, and model operation. The choice of operator in an NuML statement, from the two described in the next section, respectively determines its purpose. To specify an SD program, NuML has special operators for defining a differential or difference equation with initial values. There are also primitive operators (primops) to supply random values and compute useful mathematical functions. To override factory settings there are operators to configure properties of input and display components, and to fix integration parameters. Finally, there are operators to configure properties of the analytical platforms. Currently there is only 1 of these (sensitivity analysis), and NuML will be extended as more such platforms become available.&lt;br /&gt;
&lt;br /&gt;
==NuML Operators==&lt;br /&gt;
NuML uses Javascript syntax extended with 2 infix operators (&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt;) that are not recognized as meaningful to Javascript. NWK uses a Javascript parser extended to accept these operators to analyze NuML code and respectively generate code or change the value of specific configuration parameters. Each NuML statement has the form:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS'';&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS'';&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
with slightly different rules for what is allowed on each side of the operator. In discussing NuML syntax we use the following terminology:&lt;br /&gt;
&lt;br /&gt;
==Language Categories==&lt;br /&gt;
;Constant&lt;br /&gt;
:Either a string constant enclosed in single or double quotes (&amp;lt;code&amp;gt;'Infection Stats'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;SIR Model&amp;quot;&amp;quot;&amp;lt;/code&amp;gt;) or a number in decimal (&amp;lt;code&amp;gt;3.1415&amp;lt;/code&amp;gt;) or scientific notation (&amp;lt;code&amp;gt;3.14159e5&amp;lt;/code&amp;gt;).&lt;br /&gt;
;Identifier&lt;br /&gt;
:Equivalent of a Javascript variable such as &amp;lt;code&amp;gt;Sigma&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;beta&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
;Unary Expression&lt;br /&gt;
:An unary operator modifying a term, such as &amp;lt;code&amp;gt;-10&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-Sigma&amp;lt;/code&amp;gt;.&lt;br /&gt;
;Call Expression&lt;br /&gt;
:A function name followed by a comma-separated sequence of arguments enclosed in parentheses. The function name must be an identifier; the arguments can be any list of terms.&lt;br /&gt;
;Term&lt;br /&gt;
:Either a constant, identifier, unary expression, or a call expression using one of the following function names, which differ for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;. These functions are called '''primops''' and are discussed below.&lt;br /&gt;
:&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;code&amp;gt;choose&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;multinomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;binomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;poisson&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;flip&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;irandom&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;random&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi34&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;degToRad&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;radToDeg&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tanh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;legend&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;phase&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;title&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statDat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statParam&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integration&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;statRuns&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statLo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statHi&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;min&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;max&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;step&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;xlabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ylabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;interval&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Computational Expression&lt;br /&gt;
:A single term or a sequence of terms connected using arithmetic operators &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt;, or any other legal Javascript operators.&lt;br /&gt;
;Array&lt;br /&gt;
:A comma-separated sequence of terms enclosed in square brackets; e.g., &amp;lt;code&amp;gt;[Sigma, foo(1,2,3), 15.123e3]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be:&lt;br /&gt;
:An identifier&lt;br /&gt;
:A call expression of the form:&lt;br /&gt;
::&amp;lt;code&amp;gt;deriv(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;next(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;initial(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;update(''ident&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ''ident&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;'', ...)&amp;lt;/code&amp;gt;&lt;br /&gt;
:these are discussed below.&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be &lt;br /&gt;
: A computational expression when ''LHS'' is either &amp;lt;code&amp;gt;deriv&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;next&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initial&amp;lt;/code&amp;gt; or an identifier.&lt;br /&gt;
: An identifier when ''LHS'' is &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Examples&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(S) @=  -beta * S * I / N&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(I) @= beta * S * I / N - sigma * I&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(R) @= sigma * I&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
initial(S) @= N - I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(I) @= I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(R) @= 0&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
update(S,I,R) @= mainGraph&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
N @= Param1&amp;lt;br&amp;gt;&lt;br /&gt;
beta @= Param2&amp;lt;br&amp;gt;&lt;br /&gt;
I0 @= Param3&amp;lt;br&amp;gt;&lt;br /&gt;
sigma @= Param4&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
next(L) @= R * L * (1 - L)&amp;lt;br&amp;gt;&lt;br /&gt;
initial(L) @= 0.5&amp;lt;br&amp;gt;&lt;br /&gt;
update(L) @= TimeGraph&amp;lt;br&amp;gt;&lt;br /&gt;
R @= Slider1&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;deriv(''Arg'')&amp;lt;/code&amp;gt; asserts a that the ''RHS'' equation is the time derivative of ''Arg''(t)&lt;br /&gt;
* &amp;lt;code&amp;gt;next(''Arg'')&amp;lt;/code&amp;gt; asserts a that the ''RHS'' equation is the next element in the time sequence ''Arg&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;'', ''Arg&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ...&lt;br /&gt;
: e.g., &amp;lt;code&amp;gt; next(X) @= X + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;initial(''Arg'')&amp;lt;/code&amp;gt; asserts that the ''RHS'' is the initial value of ''Arg''&lt;br /&gt;
* &amp;lt;code&amp;gt;update(''Val&amp;lt;sub&amp;gt;1'', ''Val&amp;lt;sub&amp;gt;2'', ...)&amp;lt;/code&amp;gt; asserts that ''Val&amp;lt;sub&amp;gt;1'', ''Val&amp;lt;sub&amp;gt;2'', ... should be downloaded to the output component with ID of the ''RHS''. The arguments should match the legend assigned to the output component&lt;br /&gt;
&lt;br /&gt;
An identifier appearing on the ''LHS'' is defined by the expression on the ''RHS''.&lt;br /&gt;
&lt;br /&gt;
== Syntax Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be&lt;br /&gt;
: An identifier&lt;br /&gt;
: An array of identifiers&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be&lt;br /&gt;
: A constant, primop, or array of primops&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
mainGraph #= [legend(S,I,R), title(&amp;quot;SIR Model&amp;quot;)]&amp;lt;br&amp;gt;&lt;br /&gt;
statsGraph #= title(&amp;quot;Infection Stats&amp;quot;)&amp;lt;br&amp;gt;&lt;br /&gt;
statsGraph #= [statDat(I),statParam(Beta),statRuns(12),statLo(3.4),statHi(4.5)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param1 #= [legend(N),max(1000000),step(1000)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param2 #= [legend(Beta),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param3 #= [legend(I0),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param4 #= [legend(Sigma),max(10),step(0.1)];&amp;lt;br&amp;gt;&lt;br /&gt;
[Param5, Param6] #= legend(&amp;quot;&amp;quot;);&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
* Identifiers on the ''LHS'' reference component IDs or parameters such as &amp;lt;code&amp;gt;dt&amp;lt;/code&amp;gt;&lt;br /&gt;
* Constants on the ''RHS'' are only used with parameters and assign values to them.&lt;br /&gt;
* Primops on the ''RHS'' are only used with component IDs and define attributes such as legend, max value, etc.&lt;br /&gt;
* Arrays on either side &amp;quot;multiply out&amp;quot; to as sequence of statements and are there for convenience.&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
====Random Number Generation====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(size)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Randomly picks a number from 0 to ''size-1'' with uniform probability.&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to 1, then this function randomly picks a number from 0 to ''n-1'' with the indicated probabilities. If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to less than 1, then the function returns ''n'' with probability 1 - ''&amp;amp;Sigma; p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;flip(p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns 1 with probability ''p''; 0 otherwise&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;binomial(n, p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns the sum of ''n'' independent ''flip(p)'' calls.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;multinomial(N, p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Performs ''N'' independent ''choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)'' calls and returns a vector of ''n'' (or ''n+1'') values ''(v&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, v&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ...)'' where ''v&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' is the number of times ''i'' was selected.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;poisson(lambda)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value 0, 1, ... distributed using the Poisson distribution with density ''lambda''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;normal(m, s)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value distributed using a Gaussian distribution with mean ''m'' and standard deviation ''s''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between 0 and ''y''.&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(x, y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between ''x'' and ''y''.&lt;br /&gt;
&lt;br /&gt;
====Trigonometric Functions====&lt;br /&gt;
;&amp;lt;code&amp;gt;cos, sin, tan, acos, asin, atan, atan2, cosh, sinh, tanh, acosh, asinh, atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
:Note: &amp;lt;code&amp;gt;(atan2 y x)&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;(atan y/x)&amp;lt;/code&amp;gt; extended to handle the case where ''x == 0''.&lt;br /&gt;
&lt;br /&gt;
====Constants====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;PI, PI2, Pi2, Pi34&amp;lt;/code&amp;gt;&lt;br /&gt;
:Respectively, &amp;amp;pi;, 2&amp;amp;pi;, &amp;amp;pi;/2, 3&amp;amp;pi;/4&lt;br /&gt;
&lt;br /&gt;
;degToRad&lt;br /&gt;
:&amp;amp;pi;/180&lt;br /&gt;
&lt;br /&gt;
;radToDeg&lt;br /&gt;
:180/&amp;amp;pi;&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Assigned to runtime graphs and displays:&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''title'''&lt;br /&gt;
:'''xlabel'''&lt;br /&gt;
:'''ylabel'''&lt;br /&gt;
:'''interval''' (between plots)&lt;br /&gt;
&lt;br /&gt;
Assigned to input sliders&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''min'''&lt;br /&gt;
:'''max'''&lt;br /&gt;
:'''step'''&lt;br /&gt;
&lt;br /&gt;
Integration Control&lt;br /&gt;
:'''dt'''&lt;br /&gt;
::Integration step size&lt;br /&gt;
:'''method''' ('''RK4''' or '''Euler''')&lt;br /&gt;
&lt;br /&gt;
Sensitivity Analysis Platform&lt;br /&gt;
:'''statParam'''&lt;br /&gt;
::Parameter varied by sensitivity test&lt;br /&gt;
:'''statDat'''&lt;br /&gt;
::Value to be graphed&lt;br /&gt;
:'''statRuns'''&lt;br /&gt;
::Number of runs&lt;br /&gt;
:'''StatLo, StatHi'''&lt;br /&gt;
::Testing boundaries&lt;br /&gt;
&lt;br /&gt;
Integration notes:&lt;br /&gt;
:'''method #= RK4'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using the Runge-Kutte 4 algorithm. If dt is not specified, it defaults to 0.5. RK4 requires that dt be some fraction of 1.0.&lt;br /&gt;
&lt;br /&gt;
:'''method #= Euler'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using Euler's method. Any value can be used for dt.&lt;br /&gt;
&lt;br /&gt;
:'''method'' and '''dt''' are both ignored for any quantity defined by '''next'''.&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2569</id>
		<title>NuML Language Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2569"/>
		<updated>2026-04-01T17:41:00Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What is NuML?==&lt;br /&gt;
&lt;br /&gt;
NuML is a small, domain-specific language (dsl) for coding SD models and configuring the UI of a NuWebKit (NWK) site. It is used in DynSS models and in the Configuration Window. This document serves as reference for NWK authors and users wishing to use NuML in their  designs.&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
NuML serves two purposes: (1) to specify a system dynamics (SD) model program; and (2) to override the factory settings configuration for inputs, displays, and model operation. The choice of operator in an NuML statement, from the two described in the next section, respectively determines its purpose. To specify an SD program, NuML has special operators for defining a differential or difference equation with initial values. There are also primitive operators (primops) to supply random values and compute useful mathematical functions. To override factory settings there are operators to configure properties of input and display components, and to fix integration parameters. Finally, there are operators to configure properties of the analytical platforms. Currently there is only 1 of these (sensitivity analysis), and NuML will be extended as more such platforms become available.&lt;br /&gt;
&lt;br /&gt;
==NuML Operators==&lt;br /&gt;
NuML uses Javascript syntax extended with 2 infix operators (&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt;) that are not recognized as meaningful to Javascript. NWK uses a Javascript parser extended to accept these operators to analyze NuML code and respectively generate code or change the value of specific configuration parameters. Each NuML statement has the form:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS'';&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS'';&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
with slightly different rules for what is allowed on each side of the operator. In discussing NuML syntax we use the following terminology:&lt;br /&gt;
&lt;br /&gt;
==Language Categories==&lt;br /&gt;
;Constant&lt;br /&gt;
:Either a string constant enclosed in single or double quotes (&amp;lt;code&amp;gt;'Infection Stats'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;SIR Model&amp;quot;&amp;quot;&amp;lt;/code&amp;gt;) or a number in decimal (&amp;lt;code&amp;gt;3.1415&amp;lt;/code&amp;gt;) or scientific notation (&amp;lt;code&amp;gt;3.14159e5&amp;lt;/code&amp;gt;).&lt;br /&gt;
;Identifier&lt;br /&gt;
:Equivalent of a Javascript variable such as &amp;lt;code&amp;gt;Sigma&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;beta&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
;Unary Expression&lt;br /&gt;
:An unary operator modifying a term, such as &amp;lt;code&amp;gt;-10&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-Sigma&amp;lt;/code&amp;gt;.&lt;br /&gt;
;Call Expression&lt;br /&gt;
:A function name followed by a comma-separated sequence of arguments enclosed in parentheses. The function name must be an identifier; the arguments can be any list of terms.&lt;br /&gt;
;Term&lt;br /&gt;
:Either a constant, identifier, unary expression, or a call expression using one of the following function names, which differ for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;. These functions are called '''primops''' and are discussed below.&lt;br /&gt;
:&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;code&amp;gt;choose&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;multinomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;binomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;poisson&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;flip&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;irandom&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;random&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi34&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;degToRad&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;radToDeg&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tanh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;legend&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;phase&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;title&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statDat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statParam&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integration&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;statRuns&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statLo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statHi&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;min&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;max&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;step&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;xlabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ylabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;interval&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Computational Expression&lt;br /&gt;
:A single term or a sequence of terms connected using arithmetic operators &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt;, or any other legal Javascript operators.&lt;br /&gt;
;Array&lt;br /&gt;
:A comma-separated sequence of terms enclosed in square brackets; e.g., &amp;lt;code&amp;gt;[Sigma, foo(1,2,3), 15.123e3]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be:&lt;br /&gt;
:An identifier&lt;br /&gt;
:A call expression of the form:&lt;br /&gt;
::&amp;lt;code&amp;gt;deriv(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;next(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;initial(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;update(''ident&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ''ident&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;'', ...)&amp;lt;/code&amp;gt;&lt;br /&gt;
:these are discussed below.&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be &lt;br /&gt;
: A computational expression when ''LHS'' is either &amp;lt;code&amp;gt;deriv&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;next&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initial&amp;lt;/code&amp;gt; or an identifier.&lt;br /&gt;
: An identifier when ''LHS'' is &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Examples&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(S) @=  -beta * S * I / N&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(I) @= beta * S * I / N - sigma * I&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(R) @= sigma * I&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
initial(S) @= N - I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(I) @= I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(R) @= 0&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
update(S,I,R) @= mainGraph&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
N @= Param1&amp;lt;br&amp;gt;&lt;br /&gt;
beta @= Param2&amp;lt;br&amp;gt;&lt;br /&gt;
I0 @= Param3&amp;lt;br&amp;gt;&lt;br /&gt;
sigma @= Param4&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
next(L) @= R * L * (1 - L)&amp;lt;br&amp;gt;&lt;br /&gt;
initial(L) @= 0.5&amp;lt;br&amp;gt;&lt;br /&gt;
update(L) @= TimeGraph&amp;lt;br&amp;gt;&lt;br /&gt;
R @= Slider1&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;deriv(''Arg'')&amp;lt;/code&amp;gt; asserts a that the ''RHS'' equation is the time derivative of ''Arg''(t)&lt;br /&gt;
* &amp;lt;code&amp;gt;next(''Arg'')&amp;lt;/code&amp;gt; asserts a that the ''RHS'' equation is the next element in the time sequence ''Arg&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;'', ''Arg&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ...&lt;br /&gt;
: e.g., &amp;lt;code&amp;gt; next(X) @= X + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;initial(''Arg'')&amp;lt;/code&amp;gt; asserts that the ''RHS'' is the initial value of ''Arg''&lt;br /&gt;
* &amp;lt;code&amp;gt;update(''Val&amp;lt;sub&amp;gt;1'', ''Val&amp;lt;sub&amp;gt;2'', ...)&amp;lt;/code&amp;gt; asserts that ''Val&amp;lt;sub&amp;gt;1'', ''Val&amp;lt;sub&amp;gt;2'', ... should be downloaded to the output component with ID of the ''RHS''. The arguments should match the legend assigned to the output component&lt;br /&gt;
&lt;br /&gt;
An identifier appearing on the ''LHS'' is defined by the expression on the ''RHS''.&lt;br /&gt;
&lt;br /&gt;
== Syntax Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be&lt;br /&gt;
: An identifier&lt;br /&gt;
: An array of identifiers&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be&lt;br /&gt;
: A constant, primop, or array of primops&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
mainGraph #= [legend(S,I,R), title(&amp;quot;SIR Model&amp;quot;)]&amp;lt;br&amp;gt;&lt;br /&gt;
statsGraph #= title(&amp;quot;Infection Stats&amp;quot;)&amp;lt;br&amp;gt;&lt;br /&gt;
statsGraph #= [statDat(I),statParam(Beta),statRuns(12),statLo(3.4),statHi(4.5)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param1 #= [legend(N),max(1000000),step(1000)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param2 #= [legend(Beta),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param3 #= [legend(I0),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param4 #= [legend(Sigma),max(10),step(0.1)];&amp;lt;br&amp;gt;&lt;br /&gt;
[Param5, Param6] #= legend(&amp;quot;&amp;quot;);&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
* Identifiers on the ''LHS'' reference component IDs or parameters such as &amp;lt;code&amp;gt;dt&amp;lt;/code&amp;gt;&lt;br /&gt;
* Constants on the ''RHS'' are only used with parameters and assign values to them.&lt;br /&gt;
* Primops on the ''RHS'' are only used with component IDs and define attributes such as legend, max value, etc.&lt;br /&gt;
* Arrays on either side &amp;quot;multiply out&amp;quot; to as sequence of statements and are there for convenience.&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
====Random Number Generation====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(size)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Randomly picks a number from 0 to ''size-1'' with uniform probability.&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to 1, then this function randomly picks a number from 0 to ''n-1'' with the indicated probabilities. If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to less than 1, then the function returns ''n'' with probability 1 - ''&amp;amp;Sigma; p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;flip(p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns 1 with probability ''p''; 0 otherwise&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;binomial(n, p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns the sum of ''n'' independent ''flip(p)'' calls.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;multinomial(N, p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Performs ''N'' independent ''choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)'' calls and returns a vector of ''n'' (or ''n+1'') values ''(v&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, v&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ...)'' where ''v&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' is the number of times ''i'' was selected.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;poisson(lambda)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value 0, 1, ... distributed using the Poisson distribution with density ''lambda''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;normal(m, s)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value distributed using a Gaussian distribution with mean ''m'' and standard deviation ''s''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between 0 and ''y''.&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(x, y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between ''x'' and ''y''.&lt;br /&gt;
&lt;br /&gt;
====Trigonometric Functions====&lt;br /&gt;
;&amp;lt;code&amp;gt;cos, sin, tan, acos, asin, atan, atan2, cosh, sinh, tanh, acosh, asinh, atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
:Note: &amp;lt;code&amp;gt;(atan2 y x)&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;(atan y/x)&amp;lt;/code&amp;gt; extended to handle the case where ''x == 0''.&lt;br /&gt;
&lt;br /&gt;
====Constants====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;PI, PI2, Pi2, Pi34&amp;lt;/code&amp;gt;&lt;br /&gt;
:Respectively, &amp;amp;pi;, 2&amp;amp;pi;, &amp;amp;pi;/2, 3&amp;amp;pi;/4&lt;br /&gt;
&lt;br /&gt;
;degToRad&lt;br /&gt;
:&amp;amp;pi;/180&lt;br /&gt;
&lt;br /&gt;
;radToDeg&lt;br /&gt;
:180/&amp;amp;pi;&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Assigned to runtime graphs and displays:&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''title'''&lt;br /&gt;
:'''xlabel'''&lt;br /&gt;
:'''ylabel'''&lt;br /&gt;
:'''interval''' (between plots)&lt;br /&gt;
&lt;br /&gt;
Assigned to input sliders&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''min'''&lt;br /&gt;
:'''max'''&lt;br /&gt;
:'''step'''&lt;br /&gt;
&lt;br /&gt;
Integration Control&lt;br /&gt;
:'''dt'''&lt;br /&gt;
::Integration step size&lt;br /&gt;
:'''method''' ('''RK4''' or '''Euler''')&lt;br /&gt;
&lt;br /&gt;
Sensitivity Analysis Platform&lt;br /&gt;
:'''statParam'''&lt;br /&gt;
::Parameter varied by sensitivity test&lt;br /&gt;
:'''statDat'''&lt;br /&gt;
::Value to be graphed&lt;br /&gt;
:'''statRuns'''&lt;br /&gt;
::Number of runs&lt;br /&gt;
:'''StatLo, StatHi'''&lt;br /&gt;
::Testing boundaries&lt;br /&gt;
&lt;br /&gt;
Integration notes:&lt;br /&gt;
:'''method #= RK4'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using the Runge-Kutte 4 algorithm. If dt is not specified, it defaults to 0.5. RK4 requires that dt be some fraction of 1.0.&lt;br /&gt;
&lt;br /&gt;
:'''method #= Euler'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using Euler's method. Any value can be used for dt.&lt;br /&gt;
&lt;br /&gt;
:If &amp;lt;code&amp;gt;next&amp;lt;/code&amp;gt; is used to define a sequence, method and dt are both ignored.&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2568</id>
		<title>NuML Language Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2568"/>
		<updated>2026-04-01T17:40:34Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What is NuML?==&lt;br /&gt;
&lt;br /&gt;
NuML is a small, domain-specific language (dsl) for coding SD models and configuring the UI of a NuWebKit (NWK) site. It is used in DynSS models and in the Configuration Window. This document serves as reference for NWK authors and users wishing to use NuML in their  designs.&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
NuML serves two purposes: (1) to specify a system dynamics (SD) model program; and (2) to override the factory settings configuration for inputs, displays, and model operation. The choice of operator in an NuML statement, from the two described in the next section, respectively determines its purpose. To specify an SD program, NuML has special operators for defining a differential or difference equation with initial values. There are also primitive operators (primops) to supply random values and compute useful mathematical functions. To override factory settings there are operators to configure properties of input and display components, and to fix integration parameters. Finally, there are operators to configure properties of the analytical platforms. Currently there is only 1 of these (sensitivity analysis), and NuML will be extended as more such platforms become available.&lt;br /&gt;
&lt;br /&gt;
==NuML Operators==&lt;br /&gt;
NuML uses Javascript syntax extended with 2 infix operators (&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt;) that are not recognized as meaningful to Javascript. NWK uses a Javascript parser extended to accept these operators to analyze NuML code and respectively generate code or change the value of specific configuration parameters. Each NuML statement has the form:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS'';&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS'';&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
with slightly different rules for what is allowed on each side of the operator. In discussing NuML syntax we use the following terminology:&lt;br /&gt;
&lt;br /&gt;
==Language Categories==&lt;br /&gt;
;Constant&lt;br /&gt;
:Either a string constant enclosed in single or double quotes (&amp;lt;code&amp;gt;'Infection Stats'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;SIR Model&amp;quot;&amp;quot;&amp;lt;/code&amp;gt;) or a number in decimal (&amp;lt;code&amp;gt;3.1415&amp;lt;/code&amp;gt;) or scientific notation (&amp;lt;code&amp;gt;3.14159e5&amp;lt;/code&amp;gt;).&lt;br /&gt;
;Identifier&lt;br /&gt;
:Equivalent of a Javascript variable such as &amp;lt;code&amp;gt;Sigma&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;beta&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
;Unary Expression&lt;br /&gt;
:An unary operator modifying a term, such as &amp;lt;code&amp;gt;-10&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-Sigma&amp;lt;/code&amp;gt;.&lt;br /&gt;
;Call Expression&lt;br /&gt;
:A function name followed by a comma-separated sequence of arguments enclosed in parentheses. The function name must be an identifier; the arguments can be any list of terms.&lt;br /&gt;
;Term&lt;br /&gt;
:Either a constant, identifier, unary expression, or a call expression using one of the following function names, which differ for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;. These functions are called '''primops''' and are discussed below.&lt;br /&gt;
:&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;code&amp;gt;choose&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;multinomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;binomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;poisson&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;flip&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;irandom&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;random&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi34&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;degToRad&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;radToDeg&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tanh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;legend&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;phase&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;title&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statDat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statParam&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integration&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;statRuns&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statLo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statHi&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;min&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;max&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;step&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;xlabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ylabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;interval&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Computational Expression&lt;br /&gt;
:A single term or a sequence of terms connected using arithmetic operators &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt;, or any other legal Javascript operators.&lt;br /&gt;
;Array&lt;br /&gt;
:A comma-separated sequence of terms enclosed in square brackets; e.g., &amp;lt;code&amp;gt;[Sigma, foo(1,2,3), 15.123e3]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be:&lt;br /&gt;
:An identifier&lt;br /&gt;
:A call expression of the form:&lt;br /&gt;
::&amp;lt;code&amp;gt;deriv(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;next(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;initial(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;update(''ident&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ''ident&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;'', ...)&amp;lt;/code&amp;gt;&lt;br /&gt;
:these are discussed below.&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be &lt;br /&gt;
: A computational expression when ''LHS'' is either &amp;lt;code&amp;gt;deriv&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;next&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initial&amp;lt;/code&amp;gt; or an identifier.&lt;br /&gt;
: An identifier when ''LHS'' is &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Examples&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(S) @=  -beta * S * I / N&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(I) @= beta * S * I / N - sigma * I&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(R) @= sigma * I&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
initial(S) @= N - I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(I) @= I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(R) @= 0&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
update(S,I,R) @= mainGraph&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
N @= Param1&amp;lt;br&amp;gt;&lt;br /&gt;
beta @= Param2&amp;lt;br&amp;gt;&lt;br /&gt;
I0 @= Param3&amp;lt;br&amp;gt;&lt;br /&gt;
sigma @= Param4&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
next(L) @= R * L * (1 - L)&amp;lt;br&amp;gt;&lt;br /&gt;
initial(L) @= 0.5&amp;lt;br&amp;gt;&lt;br /&gt;
update(L) @= TimeGraph&amp;lt;br&amp;gt;&lt;br /&gt;
R @= Slider1&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;deriv(''Arg'')&amp;lt;/code&amp;gt; asserts a that the ''RHS'' equation is the time derivative of ''Arg''(t)&lt;br /&gt;
* &amp;lt;code&amp;gt;next(''Arg'')&amp;lt;/code&amp;gt; asserts a that the ''RHS'' equation is the next element in the time sequence ''Arg&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;'', ''Arg&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ...&lt;br /&gt;
: e.g., &amp;lt;code&amp;gt; next(X) @= X + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;initial(''Arg'')&amp;lt;/code&amp;gt; asserts that the ''RHS'' is the initial value of ''Arg''&lt;br /&gt;
* &amp;lt;code&amp;gt;update(''Val&amp;lt;sub&amp;gt;1'', ''Val&amp;lt;sub&amp;gt;2'', ...)&amp;lt;/code&amp;gt; asserts that ''Val&amp;lt;sub&amp;gt;1'', ''Val&amp;lt;sub&amp;gt;2'', ... should be downloaded to the output component with ID of the ''RHS''. The arguments should match the legend assigned to the output component&lt;br /&gt;
&lt;br /&gt;
An identifier appearing on the ''LHS'' is defined by the expression on the ''RHS''.&lt;br /&gt;
&lt;br /&gt;
== Syntax Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be&lt;br /&gt;
: An identifier&lt;br /&gt;
: An array of identifiers&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be&lt;br /&gt;
: A constant, primop, or array of primops&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
mainGraph #= [legend(S,I,R), title(&amp;quot;SIR Model&amp;quot;)]&amp;lt;br&amp;gt;&lt;br /&gt;
statsGraph #= title(&amp;quot;Infection Stats&amp;quot;)&amp;lt;br&amp;gt;&lt;br /&gt;
statsGraph #= [statDat(I),statParam(Beta),statRuns(12),statLo(3.4),statHi(4.5)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param1 #= [legend(N),max(1000000),step(1000)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param2 #= [legend(Beta),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param3 #= [legend(I0),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param4 #= [legend(Sigma),max(10),step(0.1)];&amp;lt;br&amp;gt;&lt;br /&gt;
[Param5, Param6] #= legend(&amp;quot;&amp;quot;);&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
* Identifiers on the ''LHS'' reference component IDs or parameters such as &amp;lt;code&amp;gt;dt&amp;lt;/code&amp;gt;&lt;br /&gt;
* Constants on the ''RHS'' are only used with parameters and assign values to them.&lt;br /&gt;
* Primops on the ''RHS'' are only used with component IDs and define attributes such as legend, max value, etc.&lt;br /&gt;
* Arrays on either side &amp;quot;multiply out&amp;quot; to as sequence of statements and are there for convenience.&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
====Random Number Generation====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(size)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Randomly picks a number from 0 to ''size-1'' with uniform probability.&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to 1, then this function randomly picks a number from 0 to ''n-1'' with the indicated probabilities. If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to less than 1, then the function returns ''n'' with probability 1 - ''&amp;amp;Sigma; p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;flip(p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns 1 with probability ''p''; 0 otherwise&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;binomial(n, p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns the sum of ''n'' independent ''flip(p)'' calls.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;multinomial(N, p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Performs ''N'' independent ''choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)'' calls and returns a vector of ''n'' (or ''n+1'') values ''(v&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, v&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ...)'' where ''v&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' is the number of times ''i'' was selected.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;poisson(lambda)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value 0, 1, ... distributed using the Poisson distribution with density ''lambda''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;normal(m, s)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value distributed using a Gaussian distribution with mean ''m'' and standard deviation ''s''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between 0 and ''y''.&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(x, y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between ''x'' and ''y''.&lt;br /&gt;
&lt;br /&gt;
====Trigonometric Functions====&lt;br /&gt;
;&amp;lt;code&amp;gt;cos, sin, tan, acos, asin, atan, atan2, cosh, sinh, tanh, acosh, asinh, atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
:Note: &amp;lt;code&amp;gt;(atan2 y x)&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;(atan y/x)&amp;lt;/code&amp;gt; extended to handle the case where ''x == 0''.&lt;br /&gt;
&lt;br /&gt;
====Constants====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;PI, PI2, Pi2, Pi34&amp;lt;/code&amp;gt;&lt;br /&gt;
:Respectively, &amp;amp;pi;, 2&amp;amp;pi;, &amp;amp;pi;/2, 3&amp;amp;pi;/4&lt;br /&gt;
&lt;br /&gt;
;degToRad&lt;br /&gt;
:&amp;amp;pi;/180&lt;br /&gt;
&lt;br /&gt;
;radToDeg&lt;br /&gt;
:180/&amp;amp;pi;&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Assigned to runtime graphs and displays:&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''title'''&lt;br /&gt;
:'''xlabel'''&lt;br /&gt;
:'''ylabel'''&lt;br /&gt;
:'''interval''' (between plots)&lt;br /&gt;
&lt;br /&gt;
Assigned to input sliders&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''min'''&lt;br /&gt;
:'''max'''&lt;br /&gt;
:'''step'''&lt;br /&gt;
&lt;br /&gt;
Integration Control&lt;br /&gt;
:'''dt'''&lt;br /&gt;
::Integration step size&lt;br /&gt;
:'''method''' ('''RK4''' or '''Euler''')&lt;br /&gt;
&lt;br /&gt;
Sensitivity Analysis Platform&lt;br /&gt;
:'''statParam'''&lt;br /&gt;
::Parameter varied by sensitivity test&lt;br /&gt;
:'''statDat'''&lt;br /&gt;
::Value to be graphed&lt;br /&gt;
:'''statRuns'''&lt;br /&gt;
::Number of runs&lt;br /&gt;
:'''StatLo, StatHi'''&lt;br /&gt;
::Testing boundaries&lt;br /&gt;
&lt;br /&gt;
Integration notes:&lt;br /&gt;
:'''method #= RK4'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using the Runge-Kutte 4 algorithm. If dt is not specified, it defaults to 0.5. RK4 requires that dt be some fraction of 1.0.&lt;br /&gt;
&lt;br /&gt;
:'''method #= Euler'''&lt;br /&gt;
::Solves a differential equation  dx/dt = f(x) numerically using Euler's method. Any value can be used for dt.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;code&amp;gt;next&amp;lt;/code&amp;gt; is used to define a sequence, method and dt are both ignored.&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2567</id>
		<title>NuML Language Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2567"/>
		<updated>2026-04-01T17:20:08Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What is NuML?==&lt;br /&gt;
&lt;br /&gt;
NuML is a small, domain-specific language (dsl) for coding SD models and configuring the UI of a NuWebKit (NWK) site. It is used in DynSS models and in the Configuration Window. This document serves as reference for NWK authors and users wishing to use NuML in their  designs.&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
NuML serves two purposes: (1) to specify a system dynamics (SD) model program; and (2) to override the factory settings configuration for inputs, displays, and model operation. The choice of operator in an NuML statement, from the two described in the next section, respectively determines its purpose. To specify an SD program, NuML has special operators for defining a differential or difference equation with initial values. There are also primitive operators (primops) to supply random values and compute useful mathematical functions. To override factory settings there are operators to configure properties of input and display components, and to fix integration parameters. Finally, there are operators to configure properties of the analytical platforms. Currently there is only 1 of these (sensitivity analysis), and NuML will be extended as more such platforms become available.&lt;br /&gt;
&lt;br /&gt;
==NuML Operators==&lt;br /&gt;
NuML uses Javascript syntax extended with 2 infix operators (&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt;) that are not recognized as meaningful to Javascript. NWK uses a Javascript parser extended to accept these operators to analyze NuML code and respectively generate code or change the value of specific configuration parameters. Each NuML statement has the form:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS'';&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS'';&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
with slightly different rules for what is allowed on each side of the operator. In discussing NuML syntax we use the following terminology:&lt;br /&gt;
&lt;br /&gt;
==Language Categories==&lt;br /&gt;
;Constant&lt;br /&gt;
:Either a string constant enclosed in single or double quotes (&amp;lt;code&amp;gt;'Infection Stats'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;SIR Model&amp;quot;&amp;quot;&amp;lt;/code&amp;gt;) or a number in decimal (&amp;lt;code&amp;gt;3.1415&amp;lt;/code&amp;gt;) or scientific notation (&amp;lt;code&amp;gt;3.14159e5&amp;lt;/code&amp;gt;).&lt;br /&gt;
;Identifier&lt;br /&gt;
:Equivalent of a Javascript variable such as &amp;lt;code&amp;gt;Sigma&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;beta&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
;Unary Expression&lt;br /&gt;
:An unary operator modifying a term, such as &amp;lt;code&amp;gt;-10&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-Sigma&amp;lt;/code&amp;gt;.&lt;br /&gt;
;Call Expression&lt;br /&gt;
:A function name followed by a comma-separated sequence of arguments enclosed in parentheses. The function name must be an identifier; the arguments can be any list of terms.&lt;br /&gt;
;Term&lt;br /&gt;
:Either a constant, identifier, unary expression, or a call expression using one of the following function names, which differ for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;. These functions are called '''primops''' and are discussed below.&lt;br /&gt;
:&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;code&amp;gt;choose&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;multinomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;binomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;poisson&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;flip&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;irandom&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;random&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi34&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;degToRad&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;radToDeg&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tanh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;legend&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;phase&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;title&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statDat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statParam&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integration&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;statRuns&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statLo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statHi&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;min&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;max&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;step&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;xlabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ylabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;interval&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Computational Expression&lt;br /&gt;
:A single term or a sequence of terms connected using arithmetic operators &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt;, or any other legal Javascript operators.&lt;br /&gt;
;Array&lt;br /&gt;
:A comma-separated sequence of terms enclosed in square brackets; e.g., &amp;lt;code&amp;gt;[Sigma, foo(1,2,3), 15.123e3]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be:&lt;br /&gt;
:An identifier&lt;br /&gt;
:A call expression of the form:&lt;br /&gt;
::&amp;lt;code&amp;gt;deriv(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;next(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;initial(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;update(''ident&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ''ident&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;'', ...)&amp;lt;/code&amp;gt;&lt;br /&gt;
:these are discussed below.&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be &lt;br /&gt;
: A computational expression when ''LHS'' is either &amp;lt;code&amp;gt;deriv&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;next&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initial&amp;lt;/code&amp;gt; or an identifier.&lt;br /&gt;
: An identifier when ''LHS'' is &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Examples&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(S) @=  -beta * S * I / N&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(I) @= beta * S * I / N - sigma * I&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(R) @= sigma * I&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
initial(S) @= N - I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(I) @= I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(R) @= 0&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
update(S,I,R) @= mainGraph&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
N @= Param1&amp;lt;br&amp;gt;&lt;br /&gt;
beta @= Param2&amp;lt;br&amp;gt;&lt;br /&gt;
I0 @= Param3&amp;lt;br&amp;gt;&lt;br /&gt;
sigma @= Param4&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;deriv(''Arg'')&amp;lt;/code&amp;gt; asserts a that the ''RHS'' equation is the time derivative of ''Arg''(t)&lt;br /&gt;
* &amp;lt;code&amp;gt;next(''Arg'')&amp;lt;/code&amp;gt; asserts a that the ''RHS'' equation is the next element in the time sequence ''Arg&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;'', ''Arg&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ...&lt;br /&gt;
: e.g., &amp;lt;code&amp;gt; next(X) @= X + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;initial(''Arg'')&amp;lt;/code&amp;gt; asserts that the ''RHS'' is the initial value of ''Arg''&lt;br /&gt;
* &amp;lt;code&amp;gt;update(''Val&amp;lt;sub&amp;gt;1'', ''Val&amp;lt;sub&amp;gt;2'', ...)&amp;lt;/code&amp;gt; asserts that ''Val&amp;lt;sub&amp;gt;1'', ''Val&amp;lt;sub&amp;gt;2'', ... should be downloaded to the output component with ID of the ''RHS''. The arguments should match the legend assigned to the output component&lt;br /&gt;
&lt;br /&gt;
An identifier appearing on the ''LHS'' is defined by the expression on the ''RHS''.&lt;br /&gt;
&lt;br /&gt;
== Syntax Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be&lt;br /&gt;
: An identifier&lt;br /&gt;
: An array of identifiers&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be&lt;br /&gt;
: A constant, primop, or array of primops&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
mainGraph #= [legend(S,I,R), title(&amp;quot;SIR Model&amp;quot;)]&amp;lt;br&amp;gt;&lt;br /&gt;
statsGraph #= title(&amp;quot;Infection Stats&amp;quot;)&amp;lt;br&amp;gt;&lt;br /&gt;
statsGraph #= [statDat(I),statParam(Beta),statRuns(12),statLo(3.4),statHi(4.5)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param1 #= [legend(N),max(1000000),step(1000)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param2 #= [legend(Beta),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param3 #= [legend(I0),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param4 #= [legend(Sigma),max(10),step(0.1)];&amp;lt;br&amp;gt;&lt;br /&gt;
[Param5, Param6] #= legend(&amp;quot;&amp;quot;);&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
* Identifiers on the ''LHS'' reference component IDs or parameters such as &amp;lt;code&amp;gt;dt&amp;lt;/code&amp;gt;&lt;br /&gt;
* Constants on the ''RHS'' are only used with parameters and assign values to them.&lt;br /&gt;
* Primops on the ''RHS'' are only used with component IDs and define attributes such as legend, max value, etc.&lt;br /&gt;
* Arrays on either side &amp;quot;multiply out&amp;quot; to as sequence of statements and are there for convenience.&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
====Random Number Generation====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(size)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Randomly picks a number from 0 to ''size-1'' with uniform probability.&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to 1, then this function randomly picks a number from 0 to ''n-1'' with the indicated probabilities. If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to less than 1, then the function returns ''n'' with probability 1 - ''&amp;amp;Sigma; p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;flip(p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns 1 with probability ''p''; 0 otherwise&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;binomial(n, p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns the sum of ''n'' independent ''flip(p)'' calls.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;multinomial(N, p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Performs ''N'' independent ''choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)'' calls and returns a vector of ''n'' (or ''n+1'') values ''(v&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, v&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ...)'' where ''v&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' is the number of times ''i'' was selected.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;poisson(lambda)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value 0, 1, ... distributed using the Poisson distribution with density ''lambda''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;normal(m, s)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value distributed using a Gaussian distribution with mean ''m'' and standard deviation ''s''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between 0 and ''y''.&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(x, y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between ''x'' and ''y''.&lt;br /&gt;
&lt;br /&gt;
====Trigonometric Functions====&lt;br /&gt;
;&amp;lt;code&amp;gt;cos, sin, tan, acos, asin, atan, atan2, cosh, sinh, tanh, acosh, asinh, atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
:Note: &amp;lt;code&amp;gt;(atan2 y x)&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;(atan y/x)&amp;lt;/code&amp;gt; extended to handle the case where ''x == 0''.&lt;br /&gt;
&lt;br /&gt;
====Constants====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;PI, PI2, Pi2, Pi34&amp;lt;/code&amp;gt;&lt;br /&gt;
:Respectively, &amp;amp;pi;, 2&amp;amp;pi;, &amp;amp;pi;/2, 3&amp;amp;pi;/4&lt;br /&gt;
&lt;br /&gt;
;degToRad&lt;br /&gt;
:&amp;amp;pi;/180&lt;br /&gt;
&lt;br /&gt;
;radToDeg&lt;br /&gt;
:180/&amp;amp;pi;&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Assigned to runtime graphs and displays:&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''title'''&lt;br /&gt;
:'''xlabel'''&lt;br /&gt;
:'''ylabel'''&lt;br /&gt;
:'''interval''' (between plots)&lt;br /&gt;
&lt;br /&gt;
Assigned to input sliders&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''min'''&lt;br /&gt;
:'''max'''&lt;br /&gt;
:'''step'''&lt;br /&gt;
&lt;br /&gt;
Integration Control&lt;br /&gt;
:'''dt'''&lt;br /&gt;
:'''method''' ('''RK4''' or '''Euler''' or '''Map''')&lt;br /&gt;
&lt;br /&gt;
Sensitivity Analysis Platform&lt;br /&gt;
;statParam&lt;br /&gt;
:Parameter varied by sensitivity test&lt;br /&gt;
;statDat&lt;br /&gt;
:Value to be graphed&lt;br /&gt;
;statRuns&lt;br /&gt;
:Number of runs&lt;br /&gt;
;StatLo, StatHi&lt;br /&gt;
:Testing boundaries&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2566</id>
		<title>NuML Language Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2566"/>
		<updated>2026-03-31T19:25:30Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: /* Primops for @# */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What is NuML?==&lt;br /&gt;
&lt;br /&gt;
NuML is a small, domain-specific language (dsl) for coding SD models and configuring the UI of a NuWebKit (NWK) site. It is used in DynSS models and in the Configuration Window. This document serves as reference for NWK authors and users wishing to use NuML in their  designs.&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
NuML serves two purposes: (1) to specify a system dynamics (SD) model program; and (2) to override the factory settings configuration for inputs, displays, and model operation. The choice of operator in an NuML statement, from the two described in the next section, respectively determines its purpose. To specify an SD program, NuML has special operators for defining a differential or difference equation with initial values. There are also primitive operators (primops) to supply random values and compute useful mathematical functions. To override factory settings there are operators to configure properties of input and display components, and to fix integration parameters. Finally, there are operators to configure properties of the analytical platforms. Currently there is only 1 of these (sensitivity analysis), and NuML will be extended as more such platforms become available.&lt;br /&gt;
&lt;br /&gt;
==NuML Operators==&lt;br /&gt;
NuML uses Javascript syntax extended with 2 infix operators (&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt;) that are not recognized as meaningful to Javascript. NWK uses a Javascript parser extended to accept these operators to analyze NuML code and respectively generate code or change the value of specific configuration parameters. Each NuML statement has the form:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS'';&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS'';&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
with slightly different rules for what is allowed on each side of the operator. In discussing NuML syntax we use the following terminology:&lt;br /&gt;
&lt;br /&gt;
==Language Categories==&lt;br /&gt;
;Constant&lt;br /&gt;
:Either a string constant enclosed in single or double quotes (&amp;lt;code&amp;gt;'Infection Stats'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;SIR Model&amp;quot;&amp;quot;&amp;lt;/code&amp;gt;) or a number in decimal (&amp;lt;code&amp;gt;3.1415&amp;lt;/code&amp;gt;) or scientific notation (&amp;lt;code&amp;gt;3.14159e5&amp;lt;/code&amp;gt;).&lt;br /&gt;
;Identifier&lt;br /&gt;
:Equivalent of a Javascript variable such as &amp;lt;code&amp;gt;Sigma&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;beta&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
;Unary Expression&lt;br /&gt;
:An unary operator modifying a term, such as &amp;lt;code&amp;gt;-10&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-Sigma&amp;lt;/code&amp;gt;.&lt;br /&gt;
;Call Expression&lt;br /&gt;
:A function name followed by a comma-separated sequence of arguments enclosed in parentheses. The function name must be an identifier; the arguments can be any list of terms.&lt;br /&gt;
;Term&lt;br /&gt;
:Either a constant, identifier, unary expression, or a call expression using one of the following function names, which differ for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;. These functions are called '''primops''' and are discussed below.&lt;br /&gt;
:&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;code&amp;gt;choose&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;multinomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;binomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;poisson&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;flip&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;irandom&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;random&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi34&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;degToRad&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;radToDeg&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tanh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;legend&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;phase&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;title&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statDat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statParam&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integration&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;statRuns&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statLo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statHi&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;min&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;max&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;step&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;xlabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ylabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;interval&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Computational Expression&lt;br /&gt;
:A single term or a sequence of terms connected using arithmetic operators &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt;, or any other legal Javascript operators.&lt;br /&gt;
;Array&lt;br /&gt;
:A comma-separated sequence of terms enclosed in square brackets; e.g., &amp;lt;code&amp;gt;[Sigma, foo(1,2,3), 15.123e3]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be:&lt;br /&gt;
:An identifier&lt;br /&gt;
:A call expression of the form:&lt;br /&gt;
::&amp;lt;code&amp;gt;deriv(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;initial(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;update(''ident&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ''ident&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;'', ...)&amp;lt;/code&amp;gt;&lt;br /&gt;
:these are discussed below.&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be &lt;br /&gt;
: A computational expression when ''LHS'' is either &amp;lt;code&amp;gt;deriv&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initial&amp;lt;/code&amp;gt; or an identifier.&lt;br /&gt;
: An identifier when ''LHS'' is &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Examples&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(S) @=  -beta * S * I / N&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(I) @= beta * S * I / N - sigma * I&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(R) @= sigma * I&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
initial(S) @= N - I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(I) @= I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(R) @= 0&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
update(S,I,R) @= mainGraph&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
N @= Param1&amp;lt;br&amp;gt;&lt;br /&gt;
beta @= Param2&amp;lt;br&amp;gt;&lt;br /&gt;
I0 @= Param3&amp;lt;br&amp;gt;&lt;br /&gt;
sigma @= Param4&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;deriv(''Arg'')&amp;lt;/code&amp;gt; asserts a that the ''RHS'' equation is the time derivative of ''Arg''&lt;br /&gt;
* &amp;lt;code&amp;gt;initial(''Arg'')&amp;lt;/code&amp;gt; asserts that the ''RHS'' is the initial value of ''Arg''&lt;br /&gt;
* &amp;lt;code&amp;gt;update(''Arg&amp;lt;sub&amp;gt;1'', ''Arg&amp;lt;sub&amp;gt;2'', ...)&amp;lt;/code&amp;gt; asserts that ''Arg&amp;lt;sub&amp;gt;1'', ''Arg&amp;lt;sub&amp;gt;2'', ... should be downloaded to the output component with ID of the ''RHS''. The arguments should match the legend assigned to the output component&lt;br /&gt;
&lt;br /&gt;
An identifier appearing on the ''LHS'' is defined by the expression on the ''RHS''.&lt;br /&gt;
&lt;br /&gt;
== Syntax Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be&lt;br /&gt;
: An identifier&lt;br /&gt;
: An array of identifiers&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be&lt;br /&gt;
: A constant, primop, or array of primops&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
mainGraph #= [legend(S,I,R), title(&amp;quot;SIR Model&amp;quot;)]&amp;lt;br&amp;gt;&lt;br /&gt;
statsGraph #= title(&amp;quot;Infection Stats&amp;quot;)&amp;lt;br&amp;gt;&lt;br /&gt;
statsGraph #= [statDat(I),statParam(Beta),statRuns(12),statLo(3.4),statHi(4.5)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param1 #= [legend(N),max(1000000),step(1000)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param2 #= [legend(Beta),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param3 #= [legend(I0),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param4 #= [legend(Sigma),max(10),step(0.1)];&amp;lt;br&amp;gt;&lt;br /&gt;
[Param5, Param6] #= legend(&amp;quot;&amp;quot;);&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
* Identifiers on the ''LHS'' reference component IDs or parameters such as &amp;lt;code&amp;gt;dt&amp;lt;/code&amp;gt;&lt;br /&gt;
* Constants on the ''RHS'' are only used with parameters and assign values to them.&lt;br /&gt;
* Primops on the ''RHS'' are only used with component IDs and define attributes such as legend, max value, etc.&lt;br /&gt;
* Arrays on either side &amp;quot;multiply out&amp;quot; to as sequence of statements and are there for convenience.&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
====Random Number Generation====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(size)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Randomly picks a number from 0 to ''size-1'' with uniform probability.&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to 1, then this function randomly picks a number from 0 to ''n-1'' with the indicated probabilities. If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to less than 1, then the function returns ''n'' with probability 1 - ''&amp;amp;Sigma; p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;flip(p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns 1 with probability ''p''; 0 otherwise&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;binomial(n, p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns the sum of ''n'' independent ''flip(p)'' calls.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;multinomial(N, p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Performs ''N'' independent ''choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)'' calls and returns a vector of ''n'' (or ''n+1'') values ''(v&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, v&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ...)'' where ''v&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' is the number of times ''i'' was selected.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;poisson(lambda)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value 0, 1, ... distributed using the Poisson distribution with density ''lambda''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;normal(m, s)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value distributed using a Gaussian distribution with mean ''m'' and standard deviation ''s''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between 0 and ''y''.&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(x, y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between ''x'' and ''y''.&lt;br /&gt;
&lt;br /&gt;
====Trigonometric Functions====&lt;br /&gt;
;&amp;lt;code&amp;gt;cos, sin, tan, acos, asin, atan, atan2, cosh, sinh, tanh, acosh, asinh, atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
:Note: &amp;lt;code&amp;gt;(atan2 y x)&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;(atan y/x)&amp;lt;/code&amp;gt; extended to handle the case where ''x == 0''.&lt;br /&gt;
&lt;br /&gt;
====Constants====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;PI, PI2, Pi2, Pi34&amp;lt;/code&amp;gt;&lt;br /&gt;
:Respectively, &amp;amp;pi;, 2&amp;amp;pi;, &amp;amp;pi;/2, 3&amp;amp;pi;/4&lt;br /&gt;
&lt;br /&gt;
;degToRad&lt;br /&gt;
:&amp;amp;pi;/180&lt;br /&gt;
&lt;br /&gt;
;radToDeg&lt;br /&gt;
:180/&amp;amp;pi;&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Assigned to runtime graphs and displays:&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''title'''&lt;br /&gt;
:'''xlabel'''&lt;br /&gt;
:'''ylabel'''&lt;br /&gt;
:'''interval''' (between plots)&lt;br /&gt;
&lt;br /&gt;
Assigned to input sliders&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''min'''&lt;br /&gt;
:'''max'''&lt;br /&gt;
:'''step'''&lt;br /&gt;
&lt;br /&gt;
Integration Control&lt;br /&gt;
:'''dt'''&lt;br /&gt;
:'''method''' ('''RK4''' or '''Euler''' or '''Map''')&lt;br /&gt;
&lt;br /&gt;
Sensitivity Analysis Platform&lt;br /&gt;
;statParam&lt;br /&gt;
:Parameter varied by sensitivity test&lt;br /&gt;
;statDat&lt;br /&gt;
:Value to be graphed&lt;br /&gt;
;statRuns&lt;br /&gt;
:Number of runs&lt;br /&gt;
;StatLo, StatHi&lt;br /&gt;
:Testing boundaries&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=Main_Page&amp;diff=2565</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=Main_Page&amp;diff=2565"/>
		<updated>2026-03-20T19:48:37Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: Rsalter moved page Main Page to Numerus Wiki&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Numerus Wiki]]&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=Numerus_Wiki&amp;diff=2564</id>
		<title>Numerus Wiki</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=Numerus_Wiki&amp;diff=2564"/>
		<updated>2026-03-20T19:48:37Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: Rsalter moved page Main Page to Numerus Wiki&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
&amp;lt;strong&amp;gt;MediaWiki has been installed.&amp;lt;/strong&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Consult the [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide] for information on using the wiki software.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
== Numerus Wiki Content ==&lt;br /&gt;
===Numerus WebKit===&lt;br /&gt;
'''Numerus WebKit''' (NuWebKit) 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, but using conventional languages such as Java, JavaScript and Python. These applications are deployed either from a remote server, or run locally without using any network.&lt;br /&gt;
* [[NuWebKit | About NuWebKit]]&lt;br /&gt;
* [[Example NuWebKit Models]] (Javascript platform only)&lt;br /&gt;
* [[NuWebKit Examples]] (Java &amp;amp; Javascript platforms)&lt;br /&gt;
* [[NuWebKit Users Guide]]&lt;br /&gt;
* [[NuML Language Reference]]&lt;br /&gt;
&lt;br /&gt;
===Numerus Designer/Studio and Model Builder===&lt;br /&gt;
* [[Example WebKit Models]]* [[Numerus Designer]]&lt;br /&gt;
* [[Numerus Studio]]&lt;br /&gt;
* [http://wiki.numerusinc.com/index.php/Numerus_Model_Builder_Wiki:_The_Place_for_NumerusMB_Documentation Numerus Model Builder]&lt;br /&gt;
&lt;br /&gt;
===Numerus Downloadable / On-line Apps===&lt;br /&gt;
* [[SEIVAgent IBM Epidemic Simulator]]&lt;br /&gt;
* [[NMB DASA Covid-19 User Guide]]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
== Getting started ==&lt;br /&gt;
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Configuration_settings Configuration settings list]&lt;br /&gt;
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]&lt;br /&gt;
* [https://lists.wikimedia.org/mailman/listinfo/mediawiki-announce MediaWiki release mailing list]&lt;br /&gt;
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation#Translation_resources Localise MediaWiki for your language]&lt;br /&gt;
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Combating_spam Learn how to combat spam on your wiki]&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=Example_NuWebKit_Models&amp;diff=2563</id>
		<title>Example NuWebKit Models</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=Example_NuWebKit_Models&amp;diff=2563"/>
		<updated>2026-03-20T19:04:15Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: /* Numerus Originals */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;These models illustrate the NuWebKit modeling technology. To use, load the model into your browser and click '''Connect''' to initialize the model. This will enable the other 4 buttons: '''Disconnect''', '''Reset''', '''Step''' and '''Start'''. Use the '''Start/Stop''' button to run the program continuously. '''Step''' single-steps the program. '''Reset''' returns to the beginning. A '''Double-Reset''' reinitializes the simulation. You can also reinitialize with '''Disconnect/Connect''', or simply reloading the web page. See the [[WebKit Users Guide]] for complete documentation.&lt;br /&gt;
&lt;br /&gt;
Be aware of the side panel, which you open and close by clicking on the side panel icon, [[File:sideicon.png]], and adjust using the purple stripe. This panel contains documentation, preset control and RAM access.&lt;br /&gt;
&lt;br /&gt;
NetLogo is an established platform for implementing agent-based models. NuWebKit uses an API analogous to that of NetLogo, keeping the &amp;quot;Patches&amp;quot; and &amp;quot;Turtles&amp;quot; nomenclature and making the translation from NetLogo the NuWebKit straightforward. Many of the agent-based models in this collection were derived from the NetLogo model library. All such examples include NetLogo documentation, which for now serves to describe the model but may not totally match the NuWebKit implementation. &lt;br /&gt;
&lt;br /&gt;
===Numerus Originals===&lt;br /&gt;
&lt;br /&gt;
* [https://www.cs.oberlin.edu/~rms/wk/egol3/index.html Three State Extended Game of Life]&lt;br /&gt;
:A 3-state extended version of Conway's Game of Life (GoL). The mathematical equations behind this GoL are described in a paper that can be downloaded at [https://www.biorxiv.org/content/10.1101/2022.08.30.505937v1 mathRxiv]. Click through the 8 presets to view different starting configurations, and feel free to save your own interesting discoveries in unused presets. This model is a focus of the [[WebKit Users Guide]] as an example that makes extensive use of the RAM and preset features.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sirsdet/index.html SIRS WebKit App]&lt;br /&gt;
:Fully developed platform for teaching the SIRS Model. Documented extensively [https://e56600a52a1b6dbf8d29-34f1371aa433cd9fb9d20baa556ed72a.ssl.cf1.rackcdn.com/webapps/webkit/EPI_LESSONS.pdf here].&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sirsdtvdet/index.html Deterministic SIRS with Vaccinations]&lt;br /&gt;
:A mass-action SIRS model with vaccinations described in the publication [https://doi.org/10.1101/2022.02.09.22270752 Simulation Platforms to Support Teaching and Research in Epidemiological Dynamics]. This app was merged into the previous example to create a fully developed platform for teaching the SIRS model.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sirsdtvsto/index.html Stochastic SIRS with Vaccinations]&lt;br /&gt;
:A stochastic version of the previous model. See [https://doi.org/10.1101/2022.02.09.22270752 Simulation Platforms to Support Teaching and Research in Epidemiological Dynamics]&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sdsir/index.html SD SIR]&lt;br /&gt;
:A simple mass-action SIR model demonstrating the WebKit Sensitivity analysis platform.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/dynss/index.html DynSS Examples]&lt;br /&gt;
:An app in which the user programs the models. Discussed extensively in the [[WebKit Users Guide]].&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/agents/index.html Agents]&lt;br /&gt;
:Simple agent motion.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/ani2/index.html Animover 2]&lt;br /&gt;
: '''Animover''' is a model of a group of agents foraging in an area for a food resource. Animover 2 is a preliminary version. It is the most complex WebKit simulation to date, with several thousand lines of code required to implement the model logic.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/forest/index.html Forest]&lt;br /&gt;
:Cell automata model depicting a forest fire.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/life/index.html Life]]&lt;br /&gt;
:Conway's Game of Life. Enough said. See the [[WebKit Users Guide]] to learn how to initialize the starting configuration.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/lifeagents/index.html Life Agents]&lt;br /&gt;
:Game of Life with agent motion. An agent passing over a live cell colors the cell with the agent's color.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/lorenz/index.html Lorenz Attractor]&lt;br /&gt;
:The Lorenz system is a system of ordinary differential equations first studied by mathematician and meteorologist Edward Lorenz. It is notable for having chaotic solutions for certain parameter values and initial conditions. The term &amp;quot;butterfly effect&amp;quot; in popular media may stem from the real-world implications of the Lorenz attractor, namely that tiny changes in initial conditions evolve to completely different trajectories. &lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/lotka/index.html Lotka-Volterra Model]&lt;br /&gt;
:Shows both time and phase graphs.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/mongoose/index.html Mongoose Behavior] &lt;br /&gt;
:Companion to &amp;quot;Computational Assessment of Population Resilience Mechanisms in the Banded Mongoose (Mungos mungo) of Northern Botswana&amp;quot; (manuscript in progress).&lt;br /&gt;
&lt;br /&gt;
===NetLogo Translations===&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/antz/index.html Ants]&lt;br /&gt;
:NetLogo model. A colony of ants forages for food. Though each ant follows a set of simple rules, the colony as a whole acts in a sophisticated way.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/diffuse/index.html Diffusion]&lt;br /&gt;
:NetLogo diffusion example. Diffusion Graphics is unlike most other NetLogo models, in that it really doesn’t ‘model’ anything. It simply explores the power behind an interesting patch primitive: ‘diffuse’.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/dla/index.html Diffusion Limited Aggregration]&lt;br /&gt;
:This model demonstrates diffusion-limited aggregation, in which randomly moving (diffusing) particles stick together (aggregate) to form beautiful treelike branching fractal structures. There are many patterns found in nature that resemble the patterns produced by this model: crystals, coral, fungi, lightning, and so on.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/flock/index.html Flock]&lt;br /&gt;
:NetLogo model showing the flocking of birds. The resulting motion also resembles schools of fish.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/fng/index.html Fungal Growth]&lt;br /&gt;
:NetLogo model showing the spread of fungal hyphae throughout a section of earth in which moisture is spreading.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/follower/index.html Follower]&lt;br /&gt;
:NetLogo model. In Follower, turtles attempt to “connect” with other turtles, forming long chains according to a small set of simple rules.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/fworks/index.html Fireworks]&lt;br /&gt;
:NetLogo model. This program models the action of fireworks. Rockets begin at the bottom of the view, shoot upwards into the sky and then explode, emitting showers of falling sparks. Works best at lower speed.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/river/index.html Meandering River]&lt;br /&gt;
:Netlogo Model. This model demonstrates the meandering of a river along its “middle course”, where the gradient of the landscape is gradual and the river runs within a U-shaped river valley. The evolution of the shape of the river is governed by the path of its highest-velocity flow, as well as erosion and deposition.&lt;br /&gt;
:This example has documentation extracted from the Netlogo version. Click the icon on the top-right of the page.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/rps/index.html Rock Paper Scissors]&lt;br /&gt;
:NetLogo Model. This model explores the role of movement and space in a three species ecosystem. The system consists of three species, represented by red patches, green patches, and blue patches, which compete over space. The interactions between the species are based on the game Rock-Paper-Scissors. That is, red beats green, green beats blue, and blue beats red. Organisms compete with their neighbors, move throughout the environment, and reproduce. These interactions result in spiral patterns whose size and stability depends on the movement rate of the organisms.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/wolfsheep/index.html Wolf Sheep Predation]&lt;br /&gt;
:NetLogo Model. A population of sheep that wander around the landscape. For each step the sheep take it costs them some energy and if there energy gets too low they die. However, the sheep can eat grass in the environment to regain energy and the grass regrows over time. If the energy of the sheep gets above a certain level then they can reproduce. There are also wolves that have the same behaviors as sheep except for eating; rather than grass, they eat sheep.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/wvmach/index.html Wave Machine]&lt;br /&gt;
:Netlogo Model. This model simulates wave motion in a membrane. The four edges of the membrane are fixed to a frame. A green rectangular area represents a driver plate that moves up and down, exhibiting sinusoidal motion.&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=NuWebKit_Users_Guide&amp;diff=2562</id>
		<title>NuWebKit Users Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=NuWebKit_Users_Guide&amp;diff=2562"/>
		<updated>2026-03-19T17:05:58Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;NuWebKit 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.&amp;lt;ref&amp;gt;This API is under development.&amp;lt;/ref&amp;gt; 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.&lt;br /&gt;
&lt;br /&gt;
This Guide will introduce the NuWebKit 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.&lt;br /&gt;
&lt;br /&gt;
== Terminology ==&lt;br /&gt;
; Model&lt;br /&gt;
: 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. NuWebKit supports System Dynamic (SD), Spatial (Sp) and Individual-based (IB) models. Models in NuWebKit are currently implemented either in Javascript or Java.&lt;br /&gt;
&lt;br /&gt;
;Simulation&lt;br /&gt;
: A model in execution. Simulations are managed from the UI.&lt;br /&gt;
&lt;br /&gt;
;Spatial (Sp) and Individual-based (IB) models&lt;br /&gt;
: 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 &amp;quot;wrap-around&amp;quot; horizontally and vertically to create a torus. In many simulations with fixed boundaries, agents &amp;quot;bounce off&amp;quot; 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 site's author, and in some cases may be overridden.&lt;br /&gt;
&lt;br /&gt;
;System Dynamics (SD) &lt;br /&gt;
: The behavior of SD models over time can often be characterized using differential or difference equations. An SD model might be the entirety of site, or might characterize the local behavior of a cell or agent in Sp and IB models.&lt;br /&gt;
&lt;br /&gt;
;Project&lt;br /&gt;
: A single unit deploying 1 or more simulations, usually employing a single Web page. Projects are specified using a '''project file''', containing [https://www.json.org/json-en.html JSON] code detailing the UI and at least providing parameters for the model. Small SD models may be specified in the project file.&lt;br /&gt;
&lt;br /&gt;
;Site&lt;br /&gt;
:The Webpage or pages associated with a particular project.&lt;br /&gt;
&lt;br /&gt;
;&amp;quot;Factory Settings&amp;quot;&lt;br /&gt;
: Sites are uploaded with parameters and settings determined by the author. Users may change parameters and override some setting, however factory settings can always be recovered.&lt;br /&gt;
&lt;br /&gt;
;&amp;quot;The Drawer&amp;quot;&lt;br /&gt;
: The NuWebKit 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.&lt;br /&gt;
&lt;br /&gt;
;Presets&lt;br /&gt;
: NuWebKit provides a storage facility to record and recall various choices for settings and parameters. The presets are like &amp;quot;radio buttons&amp;quot; selecting various alternative sets of configurations.&lt;br /&gt;
&lt;br /&gt;
;RAMs&lt;br /&gt;
: 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 DynSS apps).&lt;br /&gt;
&lt;br /&gt;
;NuML&lt;br /&gt;
: NuML (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 DynSS's; and 2) to assert configuration changes to factory settings.&lt;br /&gt;
&lt;br /&gt;
;Analysis Platforms&lt;br /&gt;
:These are special tabs used in some sites to enable such facilities as sensitivity analysis, curve fitting, MCMC, etc.&lt;br /&gt;
&lt;br /&gt;
;CSV&lt;br /&gt;
:This refers to the option of saving data from a graph to a comma separated list.&lt;br /&gt;
&lt;br /&gt;
== Platform Overview==&lt;br /&gt;
[[File:ui0.png|thumb|NuWebKit User Interface]]&lt;br /&gt;
This image shows the browser window running the sample individual-based site [https://www.cs.oberlin.edu/~rms/wk/rps/ &amp;quot;Rock Paper Scissors&amp;quot;]. The features are all described later in this guide.&lt;br /&gt;
;Model Inputs&lt;br /&gt;
:These sliders set parameters for the simulation. Changes are forwarded even while the simulation is running and may have immediate effect.&lt;br /&gt;
;Timers&lt;br /&gt;
: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.&lt;br /&gt;
;Operating Buttons&lt;br /&gt;
: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.&lt;br /&gt;
: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.&lt;br /&gt;
[[File:ui1.png|thumb|UI With Drawer Opened]]&lt;br /&gt;
;Speed Control&lt;br /&gt;
:This determines the real-time interval between steps. &lt;br /&gt;
;Displays&lt;br /&gt;
:A spatial or agent-based simulation will include a &amp;quot;SimWorld&amp;quot; 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.&lt;br /&gt;
:Other displays such as Spys (showing a single current value) graphs, tables, etc. are specified in the Project file (see below).&lt;br /&gt;
;Side Panel&lt;br /&gt;
:The browser page has a side panel contained in a &amp;quot;drawer&amp;quot;. Use [[File:sideicon.png]] 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 site uses RAMs the side panel will be wider and will contain access to RAM controls.&lt;br /&gt;
[[File:ui2.png|thumb|UI with SD Model]]&lt;br /&gt;
;System Dynamics&lt;br /&gt;
:The third image shows the model library SD [https://www.cs.oberlin.edu/~rms/wk/lotka Lotka-Volterra] site. An SD site will display the current choices for ''dt'' and integration method (Euler or RK4). These can be overridden from factory settings using the configuration window.&lt;br /&gt;
&amp;lt;br clear='both'&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In subsequent sections we describe the platform's features with illustrations using one or more of the sites 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.&lt;br /&gt;
&lt;br /&gt;
'''When opening the Model Library examples you are advised to right-click and open the link in a new tab.'''&lt;br /&gt;
&lt;br /&gt;
Among the topics covered are:&lt;br /&gt;
* User initialization of spatial and agent-based models&lt;br /&gt;
* Presets&lt;br /&gt;
* NuML language&lt;br /&gt;
* RAMS and DynSS apps&lt;br /&gt;
* Configuration overrides&lt;br /&gt;
* Analysis platforms&lt;br /&gt;
* Downloading CSVs&lt;br /&gt;
&lt;br /&gt;
== Model Initialization and Using Presets with Conway's Game of Life and Agents (1) ==&lt;br /&gt;
[[File:lifeinit.gif|thumb|Initializing Conway's Game of Life]]&lt;br /&gt;
[[File:agentsinit.gif|thumb|Initializing Agents (1)]]&lt;br /&gt;
[https://www.cs.oberlin.edu/~rms/wk/life/index.html Conway's Game of Life (CGOL)] uses a 128 x 128 board with solid edge and an initial configuration consisting of the &amp;quot;R-pentomino&amp;quot;. (Try it!) CGOL's model operates on a cellular automaton with 2 possible states, dead and alive. &lt;br /&gt;
&lt;br /&gt;
[https://www.cs.oberlin.edu/~rms/wk/agents/index.html 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 site's author.) [https://www.cs.oberlin.edu/~rms/wk/agents1/index.html Agents (1)] has the same model, only initially empty. &lt;br /&gt;
&lt;br /&gt;
With NuWebKit you can:&lt;br /&gt;
* Click and drag to create new initial configurations;&lt;br /&gt;
* Save your configuration in the Presets.&lt;br /&gt;
&lt;br /&gt;
=== Creating new initial configurations in CGOL ===&lt;br /&gt;
&lt;br /&gt;
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. &lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Creating new initial configurations in Agents (1) ===&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
When done, '''double-click''' '''Reset''', and then '''Run'''. To restore factory settings you must reload the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=&amp;quot;both&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Preset Basics ==&lt;br /&gt;
[[File:preset.png|thumb|Preset Control in Drawer Panel]]&lt;br /&gt;
The Preset feature provides a quick way to save and restore a configuration, modeled on the &amp;quot;radio buttons&amp;quot; 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 &amp;quot;green&amp;quot; label will restore the configuration saved in that preset. Selecting a red label has no effect on the configuration.&lt;br /&gt;
&lt;br /&gt;
'''Note that preset 0 is permanently bound to factory settings and cannot be changed'''.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
[[File:presetDemo.gif|thumb|Preset Control in Main Control Panel]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
Presets are stored in the Web browser and will be there when you return to the site. 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.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Something to try&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== One more thing about Presets ===&lt;br /&gt;
Some site include ready-made presets. These will be installed the first time you access the site. 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 site.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=&amp;quot;both&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Using RAMs with the Extended Game of Life 3 (EGOL3) ==&lt;br /&gt;
[[File:egol3.png|thumb|Extended Game of Life Showing RAM Panel]]&lt;br /&gt;
[[File:egol3RAM.gif|thumb|Preset Selection Showing RAM Choices]]&lt;br /&gt;
RAMs provide the means for changing some aspect of the site's 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.&lt;br /&gt;
&lt;br /&gt;
[https://www.biorxiv.org/content/10.1101/2022.08.30.505937v1 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).&lt;br /&gt;
&lt;br /&gt;
The RAM Selection Panel appears whenever a site 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).&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The '''Display''' RAM setting is analogous to the conventional GOL we explored earlier. You can set your own initial configuration through click and drag like before. The '''Random''' setting lets you choose the probabilities for initial live cells. '''Reg6''' and '''Reg Custom''' produce diagonal stripes that repeat with, respectively, a fixed interval of 6 or with an interval between 2 and 12.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Something to try&lt;br /&gt;
&lt;br /&gt;
Make changes to the existing presets. When editing a textfield input, be sure to hit '''Enter''' when you are ready to register the change. Save configurations in any of the remaining empty presets, or override the factory presets (except for Preset 0).&lt;br /&gt;
&lt;br /&gt;
When you are done you can restore the initial preset configuration by deleting ''all'' presets with '''Cl All''' and then reloading.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Using RAMs with the Deterministic SIRS w/ Vaccination (SIRS) ==&lt;br /&gt;
SIRS is rich with RAMs with one ('''Immune to Vaccinated''') containing an alternative ('''User Input''') requiring code. This alternative lets you program how individuals in class R (recovering) are vaccinated and transferred to class V (vaccinated), as a function of model time. A set of variables that can be referenced in the code is provided.&lt;br /&gt;
&lt;br /&gt;
An example is contained in Preset 1. Here we choose to use apply the vaccination rate from the vaccination onset time (both set with the main input sliders) to a time determined using the RAM slider '''User 1'''. In other words, you add a shut-off time for vaccinations which has not been provided by the original model. Other possibilities for this RAM could be, for example, to let the vaccination rate decay to account for depletion of vaccine, using the '''User 1''' slider to determine the decay rate.&lt;br /&gt;
&lt;br /&gt;
The code used in Preset 1 is Javascript. Press the '''Compile''' button when your are ready. The '''Enlarge''' button opens a browser-wide editor window, making code entry easier. If you want to try your own User Input RAM, be sure to save in a preset or your code will be lost.&lt;br /&gt;
&lt;br /&gt;
== DynSS apps with Sensitivity Analysis ==&lt;br /&gt;
&lt;br /&gt;
The RAM interface makes it possible to easily implement SD simulations defined entirely by the user. An example from the model library containing 4 user-defined presets is [https://www.cs.oberlin.edu/~rms/wk/sdnumml1/index.html SD User Defined]. &lt;br /&gt;
&lt;br /&gt;
Such sites are initially defined only by the input and output components they support. Their operation relies on a user-defined program, specifying the model and its UI, that is entered using a RAM. The example site has a RAM with one option, that option showing a text area for the program. It also provides sufficient input and output components to support the UI needs of models implemented on the site.&lt;br /&gt;
&lt;br /&gt;
The example site includes 6 slider inputs, a line graph and a phase graph. Each of these 8 components need a &amp;quot;handle&amp;quot;, an ID by which they can be referenced in the program. The sliders all run from 0 to 1 with 0.01 step size and have the IDs &amp;lt;code&amp;gt;Param1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Param2&amp;lt;/code&amp;gt;..., &amp;lt;code&amp;gt;Param6&amp;lt;/code&amp;gt;. The line and phase graphs are respectively given IDs &amp;lt;code&amp;gt;mainGraph&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;phaseGraph&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Visit the model using the link and open the '''Model Definition''' RAM. It contains a single option ('''NuML Code''') with a Code text area. Notice that, although 6 sliders were allotted, only 1 is visible in the default preset. This is a result of the UI configuration contained in the program. As you step through presets note that the input sliders appear and disappear as needed, and that slider and graph legends (names and titles) change to suit the model.&lt;br /&gt;
&lt;br /&gt;
Consider the code for the default Exponential Curve model:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
[[File:expocode.png|400px|Code for Exponential Model]]&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The first line consists of the string &amp;quot;numml&amp;quot;. This is required to indicate that the contents are in NuML rather than Javascript. There are 2 sections: '''model''' and '''configurations'''. (Note that &amp;quot;//&amp;quot; is the comment character meaning that this line is ignored by the compiler).  In the model section are 4 statements using the operator &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;. In fact, each NuML statement uses Javascript syntax, but with 2 non-Javascript operators:  &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt;, which completely program the behavior and look and feel of the simulation. The former is used to specify the model generally in terms of differential (or difference) equations using program variables; the latter asserts properties for the visual components that fit with the particular model&lt;br /&gt;
&lt;br /&gt;
The first block (lines 4 - 8) consists of 3 statements defining the variable of interest, &amp;lt;code&amp;gt;Exp&amp;lt;/code&amp;gt;, and one defining an auxiliary variable &amp;lt;code&amp;gt;Rate&amp;lt;/code&amp;gt; used in line 4. The latter is not entirely necessary; we could instead have written line 4 as &amp;lt;code&amp;gt;deriv(Exp) @= Param1 * Exp&amp;lt;/code&amp;gt;, however the style we used relates the model directly to relabeling of the &amp;lt;code&amp;gt;Param1&amp;lt;/code&amp;gt; slider to &amp;lt;code&amp;gt;Rate&amp;lt;/code&amp;gt; and consequently is more readable. We will continue to see this approach used in the other models in this site.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;deriv(Exp)&amp;lt;/code&amp;gt; specifies a differential equation on line 4 relating &amp;lt;code&amp;gt;Exp&amp;lt;/code&amp;gt; to itself and local variable &amp;lt;code&amp;gt;Rate&amp;lt;/code&amp;gt;. Line 8 binds &amp;lt;code&amp;gt;Rate&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;Param1&amp;lt;/code&amp;gt;, which is the alias we assign to &amp;lt;code&amp;gt;Param1&amp;lt;/code&amp;gt; on line 14. Line 5 provides an initial value for &amp;lt;code&amp;gt;Exp&amp;lt;/code&amp;gt;, and line 6 links &amp;lt;code&amp;gt;Exp&amp;lt;/code&amp;gt; with the line graph &amp;lt;code&amp;gt;mainGraph&amp;lt;/code&amp;gt;, which displays its output..&lt;br /&gt;
&lt;br /&gt;
Lines 11 through 16 use operator &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; to detail the appearance of the input sliders and output graphs. This is mostly self- explanatory, except for the entry for &amp;lt;code&amp;gt;statsGraph&amp;lt;/code&amp;gt;, which will be discussed below. This code is not required, however the result will be a generic display with 6 input sliders labeled &amp;lt;code&amp;gt;Param1&amp;lt;/code&amp;gt; through &amp;lt;code&amp;gt;Param6&amp;lt;/code&amp;gt;, and graphs with no labels. Note that on line 16, setting the legend for the unused sliders to an empty string hides them. &lt;br /&gt;
&lt;br /&gt;
Look at the remaining preset code. Preset 3, in particular, is a good example of the extent to which input sliders can be detailed. This is required because the generic slider properties do not match the value range required in the simulation. Refer to the [[NuML Language Reference]] for a complete description of the NuML language.&lt;br /&gt;
&lt;br /&gt;
'''If you make changes to any of these that you want to save to presets, you should compile before saving so that the compiled code will be loaded when you activate the preset.'''&lt;br /&gt;
&lt;br /&gt;
=== Sensitivity Analysis ===&lt;br /&gt;
&lt;br /&gt;
One of the goals of NuWebKit is to provide secondary platforms for optimization and analysis. To date one such platform exists to perform sensitivity analysis, primarily but not exclusively for SD models. Once again, refer to [https://www.cs.oberlin.edu/~rms/wk/sdnumml1/index.html SD User Defined] to see this in action. Open this site and click on the tab labeled '''Sensitivity'''.&lt;br /&gt;
&lt;br /&gt;
[[File:sens0.png|thumb|Sensitivity Analysis Platform after a run]]&lt;br /&gt;
The figure show on the right shows the Sensitivity Analysis platform for the logistic model (Preset 1) after a run. There are 4 user parameters that govern the behavior as shown:&lt;br /&gt;
&lt;br /&gt;
* '''Parameter''': which parameter is varied (in this model it is '''Rate''').&lt;br /&gt;
* '''Runs''': how many runs (20); &lt;br /&gt;
* '''From''': initial value (0.25);&lt;br /&gt;
* '''To''': final value (0.54);&lt;br /&gt;
&lt;br /&gt;
Clicking '''Start''' initiates 20 runs with the '''Rate''' parameter uniformly stepping through intermediate values between 0.25 and 0.54. During this run, clicking '''Stop''' allows the most recent run to finish, allowing the process to continue by subsequently clicking '''Start'''. Alternatively, clicking '''Step''' proceeds one run at a time until the process concludes. Double-clicking '''Reset''' reinitializes the run.&lt;br /&gt;
&lt;br /&gt;
Results are displayed on 2 graphs, the first being identical to the one on the '''Run''' platform. To its right is a graph showing mean &amp;amp;#177; standard deviation of the point-wise variations seen in the run.&lt;br /&gt;
&lt;br /&gt;
Now open the '''Model Definition''' RAM and look at the code in lines 12 - 15 to see how the Sensitivity Analysis platform was programmed. The statistics display has ID ''statsGraph''. In addition to specifying a title (&amp;quot;Logistic Statistics&amp;quot;), we see the following entries:&lt;br /&gt;
;statDat(N)&lt;br /&gt;
:''N'' is output variable of interest&lt;br /&gt;
;statParam(Rate)&lt;br /&gt;
:''Rate'' is the input parameter to be varied&lt;br /&gt;
;statRuns(20), statLo(0.25), statHi(0.54)&lt;br /&gt;
:20 runs with ''Rate'' varying uniformly between 0.25 and 0.54&lt;br /&gt;
Note that except for '''statDat''', these settings are shown in textfields and merely initialize their parameters. They can be changed, and changes are saved to presets.&lt;br /&gt;
&lt;br /&gt;
== Configuration Overrides ==&lt;br /&gt;
[[File:config.png|thumb|Configuration Window]]&lt;br /&gt;
NuML statements using &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; can be used to configure most models using the Configuration window below the Preset selection window. Shown at right is an override of the factory settings that changes the ''dt'' value and asserts Euler as the integration method. Other overrides will become available soon.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;both&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== CSV Downloads ==&lt;br /&gt;
If a graph contains a '''CSV''' button, clicking that button once the graph has been filled will bring about a download of a CSV (comma separate values) file of the data from that graph. The settings used by the simulation will be recorded above the CSV header.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=&amp;quot;both&amp;quot;&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2561</id>
		<title>NuML Language Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2561"/>
		<updated>2026-03-19T17:01:47Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What is NuML?==&lt;br /&gt;
&lt;br /&gt;
NuML is a small, domain-specific language (dsl) for coding SD models and configuring the UI of a NuWebKit (NWK) site. It is used in DynSS models and in the Configuration Window. This document serves as reference for NWK authors and users wishing to use NuML in their  designs.&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
NuML serves two purposes: (1) to specify a system dynamics (SD) model program; and (2) to override the factory settings configuration for inputs, displays, and model operation. The choice of operator in an NuML statement, from the two described in the next section, respectively determines its purpose. To specify an SD program, NuML has special operators for defining a differential or difference equation with initial values. There are also primitive operators (primops) to supply random values and compute useful mathematical functions. To override factory settings there are operators to configure properties of input and display components, and to fix integration parameters. Finally, there are operators to configure properties of the analytical platforms. Currently there is only 1 of these (sensitivity analysis), and NuML will be extended as more such platforms become available.&lt;br /&gt;
&lt;br /&gt;
==NuML Operators==&lt;br /&gt;
NuML uses Javascript syntax extended with 2 infix operators (&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt;) that are not recognized as meaningful to Javascript. NWK uses a Javascript parser extended to accept these operators to analyze NuML code and respectively generate code or change the value of specific configuration parameters. Each NuML statement has the form:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS'';&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS'';&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
with slightly different rules for what is allowed on each side of the operator. In discussing NuML syntax we use the following terminology:&lt;br /&gt;
&lt;br /&gt;
==Language Categories==&lt;br /&gt;
;Constant&lt;br /&gt;
:Either a string constant enclosed in single or double quotes (&amp;lt;code&amp;gt;'Infection Stats'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;SIR Model&amp;quot;&amp;quot;&amp;lt;/code&amp;gt;) or a number in decimal (&amp;lt;code&amp;gt;3.1415&amp;lt;/code&amp;gt;) or scientific notation (&amp;lt;code&amp;gt;3.14159e5&amp;lt;/code&amp;gt;).&lt;br /&gt;
;Identifier&lt;br /&gt;
:Equivalent of a Javascript variable such as &amp;lt;code&amp;gt;Sigma&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;beta&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
;Unary Expression&lt;br /&gt;
:An unary operator modifying a term, such as &amp;lt;code&amp;gt;-10&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-Sigma&amp;lt;/code&amp;gt;.&lt;br /&gt;
;Call Expression&lt;br /&gt;
:A function name followed by a comma-separated sequence of arguments enclosed in parentheses. The function name must be an identifier; the arguments can be any list of terms.&lt;br /&gt;
;Term&lt;br /&gt;
:Either a constant, identifier, unary expression, or a call expression using one of the following function names, which differ for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;. These functions are called '''primops''' and are discussed below.&lt;br /&gt;
:&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;code&amp;gt;choose&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;multinomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;binomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;poisson&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;flip&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;irandom&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;random&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi34&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;degToRad&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;radToDeg&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tanh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;legend&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;phase&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;title&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statDat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statParam&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integration&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;statRuns&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statLo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statHi&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;min&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;max&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;step&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;xlabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ylabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;interval&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Computational Expression&lt;br /&gt;
:A single term or a sequence of terms connected using arithmetic operators &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt;, or any other legal Javascript operators.&lt;br /&gt;
;Array&lt;br /&gt;
:A comma-separated sequence of terms enclosed in square brackets; e.g., &amp;lt;code&amp;gt;[Sigma, foo(1,2,3), 15.123e3]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be:&lt;br /&gt;
:An identifier&lt;br /&gt;
:A call expression of the form:&lt;br /&gt;
::&amp;lt;code&amp;gt;deriv(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;initial(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;update(''ident&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ''ident&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;'', ...)&amp;lt;/code&amp;gt;&lt;br /&gt;
:these are discussed below.&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be &lt;br /&gt;
: A computational expression when ''LHS'' is either &amp;lt;code&amp;gt;deriv&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initial&amp;lt;/code&amp;gt; or an identifier.&lt;br /&gt;
: An identifier when ''LHS'' is &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Examples&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(S) @=  -beta * S * I / N&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(I) @= beta * S * I / N - sigma * I&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(R) @= sigma * I&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
initial(S) @= N - I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(I) @= I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(R) @= 0&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
update(S,I,R) @= mainGraph&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
N @= Param1&amp;lt;br&amp;gt;&lt;br /&gt;
beta @= Param2&amp;lt;br&amp;gt;&lt;br /&gt;
I0 @= Param3&amp;lt;br&amp;gt;&lt;br /&gt;
sigma @= Param4&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;deriv(''Arg'')&amp;lt;/code&amp;gt; asserts a that the ''RHS'' equation is the time derivative of ''Arg''&lt;br /&gt;
* &amp;lt;code&amp;gt;initial(''Arg'')&amp;lt;/code&amp;gt; asserts that the ''RHS'' is the initial value of ''Arg''&lt;br /&gt;
* &amp;lt;code&amp;gt;update(''Arg&amp;lt;sub&amp;gt;1'', ''Arg&amp;lt;sub&amp;gt;2'', ...)&amp;lt;/code&amp;gt; asserts that ''Arg&amp;lt;sub&amp;gt;1'', ''Arg&amp;lt;sub&amp;gt;2'', ... should be downloaded to the output component with ID of the ''RHS''. The arguments should match the legend assigned to the output component&lt;br /&gt;
&lt;br /&gt;
An identifier appearing on the ''LHS'' is defined by the expression on the ''RHS''.&lt;br /&gt;
&lt;br /&gt;
== Syntax Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be&lt;br /&gt;
: An identifier&lt;br /&gt;
: An array of identifiers&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be&lt;br /&gt;
: A constant, primop, or array of primops&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
mainGraph #= [legend(S,I,R), title(&amp;quot;SIR Model&amp;quot;)]&amp;lt;br&amp;gt;&lt;br /&gt;
statsGraph #= title(&amp;quot;Infection Stats&amp;quot;)&amp;lt;br&amp;gt;&lt;br /&gt;
statsGraph #= [statDat(I),statParam(Beta),statRuns(12),statLo(3.4),statHi(4.5)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param1 #= [legend(N),max(1000000),step(1000)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param2 #= [legend(Beta),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param3 #= [legend(I0),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param4 #= [legend(Sigma),max(10),step(0.1)];&amp;lt;br&amp;gt;&lt;br /&gt;
[Param5, Param6] #= legend(&amp;quot;&amp;quot;);&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
* Identifiers on the ''LHS'' reference component IDs or parameters such as &amp;lt;code&amp;gt;dt&amp;lt;/code&amp;gt;&lt;br /&gt;
* Constants on the ''RHS'' are only used with parameters and assign values to them.&lt;br /&gt;
* Primops on the ''RHS'' are only used with component IDs and define attributes such as legend, max value, etc.&lt;br /&gt;
* Arrays on either side &amp;quot;multiply out&amp;quot; to as sequence of statements and are there for convenience.&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
====Random Number Generation====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(size)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Randomly picks a number from 0 to ''size-1'' with uniform probability.&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to 1, then this function randomly picks a number from 0 to ''n-1'' with the indicated probabilities. If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to less than 1, then the function returns ''n'' with probability 1 - ''&amp;amp;Sigma; p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;flip(p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns 1 with probability ''p''; 0 otherwise&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;binomial(n, p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns the sum of ''n'' independent ''flip(p)'' calls.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;multinomial(N, p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Performs ''N'' independent ''choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)'' calls and returns a vector of ''n'' (or ''n+1'') values ''(v&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, v&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ...)'' where ''v&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' is the number of times ''i'' was selected.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;poisson(lambda)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value 0, 1, ... distributed using the Poisson distribution with density ''lambda''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;normal(m, s)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value distributed using a Gaussian distribution with mean ''m'' and standard deviation ''s''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between 0 and ''y''.&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(x, y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between ''x'' and ''y''.&lt;br /&gt;
&lt;br /&gt;
====Trigonometric Functions====&lt;br /&gt;
;&amp;lt;code&amp;gt;cos, sin, tan, acos, asin, atan, atan2, cosh, sinh, tanh, acosh, asinh, atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
:Note: &amp;lt;code&amp;gt;(atan2 y x)&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;(atan y/x)&amp;lt;/code&amp;gt; extended to handle the case where ''x == 0''.&lt;br /&gt;
&lt;br /&gt;
====Constants====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;PI, PI2, Pi2, Pi34&amp;lt;/code&amp;gt;&lt;br /&gt;
:Respectively, &amp;amp;pi;, 2&amp;amp;pi;, &amp;amp;pi;/2, 3&amp;amp;pi;/4&lt;br /&gt;
&lt;br /&gt;
;degToRad&lt;br /&gt;
:&amp;amp;pi;/180&lt;br /&gt;
&lt;br /&gt;
;radToDeg&lt;br /&gt;
:180/&amp;amp;pi;&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Assigned to runtime graphs and displays:&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''title'''&lt;br /&gt;
:'''xlabel'''&lt;br /&gt;
:'''ylabel'''&lt;br /&gt;
:'''interval''' (between plots)&lt;br /&gt;
&lt;br /&gt;
Assigned to input sliders&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''min'''&lt;br /&gt;
:'''max'''&lt;br /&gt;
:'''step'''&lt;br /&gt;
&lt;br /&gt;
Integration Control&lt;br /&gt;
:'''dt'''&lt;br /&gt;
:'''integration''' ('''RK4''' or '''Euler''')&lt;br /&gt;
&lt;br /&gt;
Sensitivity Analysis Platform&lt;br /&gt;
;statParam&lt;br /&gt;
:Parameter varied by sensitivity test&lt;br /&gt;
;statDat&lt;br /&gt;
:Value to be graphed&lt;br /&gt;
;statRuns&lt;br /&gt;
:Number of runs&lt;br /&gt;
;StatLo, StatHi&lt;br /&gt;
:Testing boundaries&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=MediaWiki:Sidebar&amp;diff=2560</id>
		<title>MediaWiki:Sidebar</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=MediaWiki:Sidebar&amp;diff=2560"/>
		<updated>2026-03-19T16:59:41Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* navigation&lt;br /&gt;
** mainpage|mainpage-description&lt;br /&gt;
** NuWebKit|NuWebKit&lt;br /&gt;
** Example NuWebKit Models | Example NuWebKit Models (Javascript platform)&lt;br /&gt;
** NuWebKit Examples|NuWebKit Examples (Java and Javascript platforms)&lt;br /&gt;
** NuWebKit Users Guide | NuWebKit Users Guide&lt;br /&gt;
** NuML Language Reference | NuML Language Reference&lt;br /&gt;
*&lt;br /&gt;
** Numerus_Designer|Numerus Designer&lt;br /&gt;
** Numerus Studio|Numerus Studio&lt;br /&gt;
** Numerus_Model_Builder_Wiki:_The_Place_for_NumerusMB_Documentation|Numerus Model Builder&lt;br /&gt;
&lt;br /&gt;
* Numerus Users Manual&lt;br /&gt;
** About Numerus Model Builder|About Numerus Model Builder&lt;br /&gt;
** How To Get Help While Using Numerus|How To Get Help While Using Numerus &lt;br /&gt;
** Tutorials|Tutorials&lt;br /&gt;
* Modeling Concepts&lt;br /&gt;
** Modeling 101|Modeling 101&lt;br /&gt;
** Modeling in Numerus|Modeling in Numerus&lt;br /&gt;
** Numerus Simulation Architecture|Numerus Simulation Architecture&lt;br /&gt;
* User Guide&lt;br /&gt;
** Frames, Menus, Toolbars| Frames, Menus, Toolbars&lt;br /&gt;
** Modeling Actions | Modeling Actions&lt;br /&gt;
** Running Your Model | Running Your Model&lt;br /&gt;
** Component Guide I: Atomic Components | Component Guide I: Atomic Components&lt;br /&gt;
** Component Guide II: Containers | Component Guide II: Containers &lt;br /&gt;
** Component Guide III: Displays and Controls | Component Guide III: Displays and Controls&lt;br /&gt;
** Component Guide IV: Plugins | Component Guide IV: Plugins&lt;br /&gt;
** Documenting Your Model | Documenting Your Model&lt;br /&gt;
** Preferences | Preferences&lt;br /&gt;
** Javascript Light | Javascript Light&lt;br /&gt;
** NovaScript Introduction | NovaScript Introduction&lt;br /&gt;
* Reference&lt;br /&gt;
** Primitive Operators and Properties|Primitive Operators and Properties&lt;br /&gt;
** Glossary|Glossary&lt;br /&gt;
&lt;br /&gt;
** recentchanges-url&lt;br /&gt;
** randompage-url&lt;br /&gt;
** helppage&lt;br /&gt;
&lt;br /&gt;
* SEARCH&lt;br /&gt;
* TOOLBOX&lt;br /&gt;
* LANGUAGES&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=MediaWiki:Sidebar&amp;diff=2559</id>
		<title>MediaWiki:Sidebar</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=MediaWiki:Sidebar&amp;diff=2559"/>
		<updated>2026-03-19T16:58:57Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* navigation&lt;br /&gt;
** mainpage|mainpage-description&lt;br /&gt;
** NuWebKit|NuWebKit&lt;br /&gt;
** Example NuWebKit Models | Example NuWebKit Models (Javascript platform)&lt;br /&gt;
** NuWebKit Examples|NuWebKit Examples (Java and Javascript platforms)&lt;br /&gt;
** NuWebKit Users Guide | WebKit Users Guide&lt;br /&gt;
** NuML Language Reference | NuML Language Reference&lt;br /&gt;
*&lt;br /&gt;
** Numerus_Designer|Numerus Designer&lt;br /&gt;
** Numerus Studio|Numerus Studio&lt;br /&gt;
** Numerus_Model_Builder_Wiki:_The_Place_for_NumerusMB_Documentation|Numerus Model Builder&lt;br /&gt;
&lt;br /&gt;
* Numerus Users Manual&lt;br /&gt;
** About Numerus Model Builder|About Numerus Model Builder&lt;br /&gt;
** How To Get Help While Using Numerus|How To Get Help While Using Numerus &lt;br /&gt;
** Tutorials|Tutorials&lt;br /&gt;
* Modeling Concepts&lt;br /&gt;
** Modeling 101|Modeling 101&lt;br /&gt;
** Modeling in Numerus|Modeling in Numerus&lt;br /&gt;
** Numerus Simulation Architecture|Numerus Simulation Architecture&lt;br /&gt;
* User Guide&lt;br /&gt;
** Frames, Menus, Toolbars| Frames, Menus, Toolbars&lt;br /&gt;
** Modeling Actions | Modeling Actions&lt;br /&gt;
** Running Your Model | Running Your Model&lt;br /&gt;
** Component Guide I: Atomic Components | Component Guide I: Atomic Components&lt;br /&gt;
** Component Guide II: Containers | Component Guide II: Containers &lt;br /&gt;
** Component Guide III: Displays and Controls | Component Guide III: Displays and Controls&lt;br /&gt;
** Component Guide IV: Plugins | Component Guide IV: Plugins&lt;br /&gt;
** Documenting Your Model | Documenting Your Model&lt;br /&gt;
** Preferences | Preferences&lt;br /&gt;
** Javascript Light | Javascript Light&lt;br /&gt;
** NovaScript Introduction | NovaScript Introduction&lt;br /&gt;
* Reference&lt;br /&gt;
** Primitive Operators and Properties|Primitive Operators and Properties&lt;br /&gt;
** Glossary|Glossary&lt;br /&gt;
&lt;br /&gt;
** recentchanges-url&lt;br /&gt;
** randompage-url&lt;br /&gt;
** helppage&lt;br /&gt;
&lt;br /&gt;
* SEARCH&lt;br /&gt;
* TOOLBOX&lt;br /&gt;
* LANGUAGES&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=NuWebKit_Users_Guide&amp;diff=2558</id>
		<title>NuWebKit Users Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=NuWebKit_Users_Guide&amp;diff=2558"/>
		<updated>2026-03-19T16:57:14Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;NuWebKit 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.&amp;lt;ref&amp;gt;This API is under development.&amp;lt;/ref&amp;gt; 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.&lt;br /&gt;
&lt;br /&gt;
This Guide will introduce the NuWebKit 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.&lt;br /&gt;
&lt;br /&gt;
== Terminology ==&lt;br /&gt;
; Model&lt;br /&gt;
: 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. NuWebKit supports System Dynamic (SD), Spatial (Sp) and Individual-based (IB) models. Models in NuWebKit are currently implemented either in Javascript or Java.&lt;br /&gt;
&lt;br /&gt;
;Simulation&lt;br /&gt;
: A model in execution. Simulations are managed from the UI.&lt;br /&gt;
&lt;br /&gt;
;Spatial (Sp) and Individual-based (IB) models&lt;br /&gt;
: 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 &amp;quot;wrap-around&amp;quot; horizontally and vertically to create a torus. In many simulations with fixed boundaries, agents &amp;quot;bounce off&amp;quot; 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 site's author, and in some cases may be overridden.&lt;br /&gt;
&lt;br /&gt;
;System Dynamics (SD) &lt;br /&gt;
: The behavior of SD models over time can often be characterized using differential or difference equations. An SD model might be the entirety of site, or might characterize the local behavior of a cell or agent in Sp and IB models.&lt;br /&gt;
&lt;br /&gt;
;Project&lt;br /&gt;
: A single unit deploying 1 or more simulations, usually employing a single Web page. Projects are specified using a '''project file''', containing [https://www.json.org/json-en.html JSON] code detailing the UI and at least providing parameters for the model. Small SD models may be specified in the project file.&lt;br /&gt;
&lt;br /&gt;
;Site&lt;br /&gt;
:The Webpage or pages associated with a particular project.&lt;br /&gt;
&lt;br /&gt;
;&amp;quot;Factory Settings&amp;quot;&lt;br /&gt;
: Sites are uploaded with parameters and settings determined by the author. Users may change parameters and override some setting, however factory settings can always be recovered.&lt;br /&gt;
&lt;br /&gt;
;&amp;quot;The Drawer&amp;quot;&lt;br /&gt;
: The NuWebKit 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.&lt;br /&gt;
&lt;br /&gt;
;Presets&lt;br /&gt;
: NuWebKit provides a storage facility to record and recall various choices for settings and parameters. The presets are like &amp;quot;radio buttons&amp;quot; selecting various alternative sets of configurations.&lt;br /&gt;
&lt;br /&gt;
;RAMs&lt;br /&gt;
: 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).&lt;br /&gt;
&lt;br /&gt;
;NuML&lt;br /&gt;
: NuML (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.&lt;br /&gt;
&lt;br /&gt;
;Analysis Platforms&lt;br /&gt;
:These are special tabs used in some sites to enable such facilities as sensitivity analysis, curve fitting, MCMC, etc.&lt;br /&gt;
&lt;br /&gt;
;CSV&lt;br /&gt;
:This refers to the option of saving data from a graph to a comma separated list.&lt;br /&gt;
&lt;br /&gt;
== Platform Overview==&lt;br /&gt;
[[File:ui0.png|thumb|NuWebKit User Interface]]&lt;br /&gt;
This image shows the browser window running the sample individual-based site [https://www.cs.oberlin.edu/~rms/wk/rps/ &amp;quot;Rock Paper Scissors&amp;quot;]. The features are all described later in this guide.&lt;br /&gt;
;Model Inputs&lt;br /&gt;
:These sliders set parameters for the simulation. Changes are forwarded even while the simulation is running and may have immediate effect.&lt;br /&gt;
;Timers&lt;br /&gt;
: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.&lt;br /&gt;
;Operating Buttons&lt;br /&gt;
: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.&lt;br /&gt;
: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.&lt;br /&gt;
[[File:ui1.png|thumb|UI With Drawer Opened]]&lt;br /&gt;
;Speed Control&lt;br /&gt;
:This determines the real-time interval between steps. &lt;br /&gt;
;Displays&lt;br /&gt;
:A spatial or agent-based simulation will include a &amp;quot;SimWorld&amp;quot; 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.&lt;br /&gt;
:Other displays such as Spys (showing a single current value) graphs, tables, etc. are specified in the Project file (see below).&lt;br /&gt;
;Side Panel&lt;br /&gt;
:The browser page has a side panel contained in a &amp;quot;drawer&amp;quot;. Use [[File:sideicon.png]] 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 site uses RAMs the side panel will be wider and will contain access to RAM controls.&lt;br /&gt;
[[File:ui2.png|thumb|UI with SD Model]]&lt;br /&gt;
;System Dynamics&lt;br /&gt;
:The third image shows the model library SD [https://www.cs.oberlin.edu/~rms/wk/lotka Lotka-Volterra] site. An SD site will display the current choices for ''dt'' and integration method (Euler or RK4). These can be overridden from factory settings using the configuration window.&lt;br /&gt;
&amp;lt;br clear='both'&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In subsequent sections we describe the platform's features with illustrations using one or more of the sites 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.&lt;br /&gt;
&lt;br /&gt;
'''When opening the Model Library examples you are advised to right-click and open the link in a new tab.'''&lt;br /&gt;
&lt;br /&gt;
Among the topics covered are:&lt;br /&gt;
* User initialization of spatial and agent-based models&lt;br /&gt;
* Presets&lt;br /&gt;
* NuML language&lt;br /&gt;
* RAMS and URAMS&lt;br /&gt;
* Configuration overrides&lt;br /&gt;
* Analysis platforms&lt;br /&gt;
* Downloading CSVs&lt;br /&gt;
&lt;br /&gt;
== Model Initialization and Using Presets with Conway's Game of Life and Agents (1) ==&lt;br /&gt;
[[File:lifeinit.gif|thumb|Initializing Conway's Game of Life]]&lt;br /&gt;
[[File:agentsinit.gif|thumb|Initializing Agents (1)]]&lt;br /&gt;
[https://www.cs.oberlin.edu/~rms/wk/life/index.html Conway's Game of Life (CGOL)] uses a 128 x 128 board with solid edge and an initial configuration consisting of the &amp;quot;R-pentomino&amp;quot;. (Try it!) CGOL's model operates on a cellular automaton with 2 possible states, dead and alive. &lt;br /&gt;
&lt;br /&gt;
[https://www.cs.oberlin.edu/~rms/wk/agents/index.html 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 site's author.) [https://www.cs.oberlin.edu/~rms/wk/agents1/index.html Agents (1)] has the same model, only initially empty. &lt;br /&gt;
&lt;br /&gt;
With NuWebKit you can:&lt;br /&gt;
* Click and drag to create new initial configurations;&lt;br /&gt;
* Save your configuration in the Presets.&lt;br /&gt;
&lt;br /&gt;
=== Creating new initial configurations in CGOL ===&lt;br /&gt;
&lt;br /&gt;
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. &lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Creating new initial configurations in Agents (1) ===&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
When done, '''double-click''' '''Reset''', and then '''Run'''. To restore factory settings you must reload the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=&amp;quot;both&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Preset Basics ==&lt;br /&gt;
[[File:preset.png|thumb|Preset Control in Drawer Panel]]&lt;br /&gt;
The Preset feature provides a quick way to save and restore a configuration, modeled on the &amp;quot;radio buttons&amp;quot; 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 &amp;quot;green&amp;quot; label will restore the configuration saved in that preset. Selecting a red label has no effect on the configuration.&lt;br /&gt;
&lt;br /&gt;
'''Note that preset 0 is permanently bound to factory settings and cannot be changed'''.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
[[File:presetDemo.gif|thumb|Preset Control in Main Control Panel]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
Presets are stored in the Web browser and will be there when you return to the site. 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.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Something to try&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== One more thing about Presets ===&lt;br /&gt;
Some site include ready-made presets. These will be installed the first time you access the site. 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 site.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=&amp;quot;both&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Using RAMs with the Extended Game of Life 3 (EGOL3) ==&lt;br /&gt;
[[File:egol3.png|thumb|Extended Game of Life Showing RAM Panel]]&lt;br /&gt;
[[File:egol3RAM.gif|thumb|Preset Selection Showing RAM Choices]]&lt;br /&gt;
RAMs provide the means for changing some aspect of the site's 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.&lt;br /&gt;
&lt;br /&gt;
[https://www.biorxiv.org/content/10.1101/2022.08.30.505937v1 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).&lt;br /&gt;
&lt;br /&gt;
The RAM Selection Panel appears whenever a site 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).&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The '''Display''' RAM setting is analogous to the conventional GOL we explored earlier. You can set your own initial configuration through click and drag like before. The '''Random''' setting lets you choose the probabilities for initial live cells. '''Reg6''' and '''Reg Custom''' produce diagonal stripes that repeat with, respectively, a fixed interval of 6 or with an interval between 2 and 12.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Something to try&lt;br /&gt;
&lt;br /&gt;
Make changes to the existing presets. When editing a textfield input, be sure to hit '''Enter''' when you are ready to register the change. Save configurations in any of the remaining empty presets, or override the factory presets (except for Preset 0).&lt;br /&gt;
&lt;br /&gt;
When you are done you can restore the initial preset configuration by deleting ''all'' presets with '''Cl All''' and then reloading.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Using RAMs with the Deterministic SIRS w/ Vaccination (SIRS) ==&lt;br /&gt;
SIRS is rich with RAMs with one ('''Immune to Vaccinated''') containing an alternative ('''User Input''') requiring code. This alternative lets you program how individuals in class R (recovering) are vaccinated and transferred to class V (vaccinated), as a function of model time. A set of variables that can be referenced in the code is provided.&lt;br /&gt;
&lt;br /&gt;
An example is contained in Preset 1. Here we choose to use apply the vaccination rate from the vaccination onset time (both set with the main input sliders) to a time determined using the RAM slider '''User 1'''. In other words, you add a shut-off time for vaccinations which has not been provided by the original model. Other possibilities for this RAM could be, for example, to let the vaccination rate decay to account for depletion of vaccine, using the '''User 1''' slider to determine the decay rate.&lt;br /&gt;
&lt;br /&gt;
The code used in Preset 1 is Javascript. Press the '''Compile''' button when your are ready. The '''Enlarge''' button opens a browser-wide editor window, making code entry easier. If you want to try your own User Input RAM, be sure to save in a preset or your code will be lost.&lt;br /&gt;
&lt;br /&gt;
== User-Defined Models (URAMs) with Sensitivity Analysis ==&lt;br /&gt;
&lt;br /&gt;
The RAM interface makes it possible to easily implement SD simulations defined entirely by the user. An example from the model library containing 4 user-defined presets is [https://www.cs.oberlin.edu/~rms/wk/sdnumml1/index.html SD User Defined]. &lt;br /&gt;
&lt;br /&gt;
Such sites are initially defined only by the input and output components they support. Their operation relies on a user-defined program, specifying the model and its UI, that is entered using a RAM. The example site has a RAM with one option, that option showing a text area for the program. It also provides sufficient input and output components to support the UI needs of models implemented on the site.&lt;br /&gt;
&lt;br /&gt;
The example site includes 6 slider inputs, a line graph and a phase graph. Each of these 8 components need a &amp;quot;handle&amp;quot;, an ID by which they can be referenced in the program. The sliders all run from 0 to 1 with 0.01 step size and have the IDs &amp;lt;code&amp;gt;Param1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Param2&amp;lt;/code&amp;gt;..., &amp;lt;code&amp;gt;Param6&amp;lt;/code&amp;gt;. The line and phase graphs are respectively given IDs &amp;lt;code&amp;gt;mainGraph&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;phaseGraph&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Visit the model using the link and open the '''Model Definition''' RAM. It contains a single option ('''NuML Code''') with a Code text area. Notice that, although 6 sliders were allotted, only 1 is visible in the default preset. This is a result of the UI configuration contained in the program. As you step through presets note that the input sliders appear and disappear as needed, and that slider and graph legends (names and titles) change to suit the model.&lt;br /&gt;
&lt;br /&gt;
Consider the code for the default Exponential Curve model:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
[[File:expocode.png|400px|Code for Exponential Model]]&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The first line consists of the string &amp;quot;numml&amp;quot;. This is required to indicate that the contents are in NuML rather than Javascript. There are 2 sections: '''model''' and '''configurations'''. (Note that &amp;quot;//&amp;quot; is the comment character meaning that this line is ignored by the compiler).  In the model section are 4 statements using the operator &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;. In fact, each NuML statement uses Javascript syntax, but with 2 non-Javascript operators:  &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt;, which completely program the behavior and look and feel of the simulation. The former is used to specify the model generally in terms of differential (or difference) equations using program variables; the latter asserts properties for the visual components that fit with the particular model&lt;br /&gt;
&lt;br /&gt;
The first block (lines 4 - 8) consists of 3 statements defining the variable of interest, &amp;lt;code&amp;gt;Exp&amp;lt;/code&amp;gt;, and one defining an auxiliary variable &amp;lt;code&amp;gt;Rate&amp;lt;/code&amp;gt; used in line 4. The latter is not entirely necessary; we could instead have written line 4 as &amp;lt;code&amp;gt;deriv(Exp) @= Param1 * Exp&amp;lt;/code&amp;gt;, however the style we used relates the model directly to relabeling of the &amp;lt;code&amp;gt;Param1&amp;lt;/code&amp;gt; slider to &amp;lt;code&amp;gt;Rate&amp;lt;/code&amp;gt; and consequently is more readable. We will continue to see this approach used in the other models in this site.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;deriv(Exp)&amp;lt;/code&amp;gt; specifies a differential equation on line 4 relating &amp;lt;code&amp;gt;Exp&amp;lt;/code&amp;gt; to itself and local variable &amp;lt;code&amp;gt;Rate&amp;lt;/code&amp;gt;. Line 8 binds &amp;lt;code&amp;gt;Rate&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;Param1&amp;lt;/code&amp;gt;, which is the alias we assign to &amp;lt;code&amp;gt;Param1&amp;lt;/code&amp;gt; on line 14. Line 5 provides an initial value for &amp;lt;code&amp;gt;Exp&amp;lt;/code&amp;gt;, and line 6 links &amp;lt;code&amp;gt;Exp&amp;lt;/code&amp;gt; with the line graph &amp;lt;code&amp;gt;mainGraph&amp;lt;/code&amp;gt;, which displays its output..&lt;br /&gt;
&lt;br /&gt;
Lines 11 through 16 use operator &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; to detail the appearance of the input sliders and output graphs. This is mostly self- explanatory, except for the entry for &amp;lt;code&amp;gt;statsGraph&amp;lt;/code&amp;gt;, which will be discussed below. This code is not required, however the result will be a generic display with 6 input sliders labeled &amp;lt;code&amp;gt;Param1&amp;lt;/code&amp;gt; through &amp;lt;code&amp;gt;Param6&amp;lt;/code&amp;gt;, and graphs with no labels. Note that on line 16, setting the legend for the unused sliders to an empty string hides them. &lt;br /&gt;
&lt;br /&gt;
Look at the remaining preset code. Preset 3, in particular, is a good example of the extent to which input sliders can be detailed. This is required because the generic slider properties do not match the value range required in the simulation. Refer to the [[NuML Language Reference]] for a complete description of the NuML language.&lt;br /&gt;
&lt;br /&gt;
'''If you make changes to any of these that you want to save to presets, you should compile before saving so that the compiled code will be loaded when you activate the preset.'''&lt;br /&gt;
&lt;br /&gt;
=== Sensitivity Analysis ===&lt;br /&gt;
&lt;br /&gt;
One of the goals of NuWebKit is to provide secondary platforms for optimization and analysis. To date one such platform exists to perform sensitivity analysis, primarily but not exclusively for SD models. Once again, refer to [https://www.cs.oberlin.edu/~rms/wk/sdnumml1/index.html SD User Defined] to see this in action. Open this site and click on the tab labeled '''Sensitivity'''.&lt;br /&gt;
&lt;br /&gt;
[[File:sens0.png|thumb|Sensitivity Analysis Platform after a run]]&lt;br /&gt;
The figure show on the right shows the Sensitivity Analysis platform for the logistic model (Preset 1) after a run. There are 4 user parameters that govern the behavior as shown:&lt;br /&gt;
&lt;br /&gt;
* '''Parameter''': which parameter is varied (in this model it is '''Rate''').&lt;br /&gt;
* '''Runs''': how many runs (20); &lt;br /&gt;
* '''From''': initial value (0.25);&lt;br /&gt;
* '''To''': final value (0.54);&lt;br /&gt;
&lt;br /&gt;
Clicking '''Start''' initiates 20 runs with the '''Rate''' parameter uniformly stepping through intermediate values between 0.25 and 0.54. During this run, clicking '''Stop''' allows the most recent run to finish, allowing the process to continue by subsequently clicking '''Start'''. Alternatively, clicking '''Step''' proceeds one run at a time until the process concludes. Double-clicking '''Reset''' reinitializes the run.&lt;br /&gt;
&lt;br /&gt;
Results are displayed on 2 graphs, the first being identical to the one on the '''Run''' platform. To its right is a graph showing mean &amp;amp;#177; standard deviation of the point-wise variations seen in the run.&lt;br /&gt;
&lt;br /&gt;
Now open the '''Model Definition''' RAM and look at the code in lines 12 - 15 to see how the Sensitivity Analysis platform was programmed. The statistics display has ID ''statsGraph''. In addition to specifying a title (&amp;quot;Logistic Statistics&amp;quot;), we see the following entries:&lt;br /&gt;
;statDat(N)&lt;br /&gt;
:''N'' is output variable of interest&lt;br /&gt;
;statParam(Rate)&lt;br /&gt;
:''Rate'' is the input parameter to be varied&lt;br /&gt;
;statRuns(20), statLo(0.25), statHi(0.54)&lt;br /&gt;
:20 runs with ''Rate'' varying uniformly between 0.25 and 0.54&lt;br /&gt;
Note that except for '''statDat''', these settings are shown in textfields and merely initialize their parameters. They can be changed, and changes are saved to presets.&lt;br /&gt;
&lt;br /&gt;
== Configuration Overrides ==&lt;br /&gt;
[[File:config.png|thumb|Configuration Window]]&lt;br /&gt;
NuML statements using &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; can be used to configure most models using the Configuration window below the Preset selection window. Shown at right is an override of the factory settings that changes the ''dt'' value and asserts Euler as the integration method. Other overrides will become available soon.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;both&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== CSV Downloads ==&lt;br /&gt;
If a graph contains a '''CSV''' button, clicking that button once the graph has been filled will bring about a download of a CSV (comma separate values) file of the data from that graph. The settings used by the simulation will be recorded above the CSV header.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=&amp;quot;both&amp;quot;&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=Numerus_Wiki&amp;diff=2557</id>
		<title>Numerus Wiki</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=Numerus_Wiki&amp;diff=2557"/>
		<updated>2026-03-19T16:55:58Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: /* Numerus WebKit */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
&amp;lt;strong&amp;gt;MediaWiki has been installed.&amp;lt;/strong&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Consult the [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide] for information on using the wiki software.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
== Numerus Wiki Content ==&lt;br /&gt;
===Numerus WebKit===&lt;br /&gt;
'''Numerus WebKit''' (NuWebKit) 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, but using conventional languages such as Java, JavaScript and Python. These applications are deployed either from a remote server, or run locally without using any network.&lt;br /&gt;
* [[NuWebKit | About NuWebKit]]&lt;br /&gt;
* [[Example NuWebKit Models]] (Javascript platform only)&lt;br /&gt;
* [[NuWebKit Examples]] (Java &amp;amp; Javascript platforms)&lt;br /&gt;
* [[NuWebKit Users Guide]]&lt;br /&gt;
* [[NuML Language Reference]]&lt;br /&gt;
&lt;br /&gt;
===Numerus Designer/Studio and Model Builder===&lt;br /&gt;
* [[Example WebKit Models]]* [[Numerus Designer]]&lt;br /&gt;
* [[Numerus Studio]]&lt;br /&gt;
* [http://wiki.numerusinc.com/index.php/Numerus_Model_Builder_Wiki:_The_Place_for_NumerusMB_Documentation Numerus Model Builder]&lt;br /&gt;
&lt;br /&gt;
===Numerus Downloadable / On-line Apps===&lt;br /&gt;
* [[SEIVAgent IBM Epidemic Simulator]]&lt;br /&gt;
* [[NMB DASA Covid-19 User Guide]]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
== Getting started ==&lt;br /&gt;
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Configuration_settings Configuration settings list]&lt;br /&gt;
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]&lt;br /&gt;
* [https://lists.wikimedia.org/mailman/listinfo/mediawiki-announce MediaWiki release mailing list]&lt;br /&gt;
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation#Translation_resources Localise MediaWiki for your language]&lt;br /&gt;
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Combating_spam Learn how to combat spam on your wiki]&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=NuWebKit&amp;diff=2556</id>
		<title>NuWebKit</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=NuWebKit&amp;diff=2556"/>
		<updated>2026-03-19T16:55:34Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;NuWebKit 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), but using conventional languages such as Java, JavaScript (JS) and Python.&amp;lt;ref&amp;gt;This API is under development.&amp;lt;/ref&amp;gt; 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.&lt;br /&gt;
&lt;br /&gt;
NuWebKit uses the D3 JavaScript library for rendering high quality dynamic visualizations.&lt;br /&gt;
&lt;br /&gt;
This document describes the NuWebKit architecture, APIs and applications. Tutorials, documents describing example models, and a complete user manual, are forthcoming. Click [[WebKit Examples|here]] to access NuWebKit examples.&lt;br /&gt;
&lt;br /&gt;
== NuWebKit Concepts ==&lt;br /&gt;
A simulation program is a system that maintains a global state that evolves over time. A simulation is starts in some initial state, and incurs state changes following successive strobes from an external source (which we call the '''clock'''). The state may consist of a single data value or multiple data values mapped out over the internal structure of the simulation. An example of the former is a simple simulation of exponential growth, where the current population is the only value of interest. The latter is exemplified by a spatial or agent based model where simulation state is distributed over individual agents or cells. At each time step the state change algorithm determines the new state from the current and possibly past states of the system. As the simulation runs, the user is presented with displays that illustrate the simulation's state. Time in a simulation is measured in clock ticks which may be mapped to model-time values. A simulation may run for a fixed interval, or may operate in an unbounded time frame.&lt;br /&gt;
&lt;br /&gt;
A ''spatial'' simulation models a domain of cells or network nodes organized topologically as a tesselation of 2- or 3-dimensional space, in a Cartesian, or, possibly, hexagonal lattice. Cells have a fixed location and one intrinsically allocated state value, a real number which is associated with a color.&lt;br /&gt;
&lt;br /&gt;
In an agent-, or individual-based model, agents exist in the space defined by the spatial topology and are mobile. In addition to location, their intrinsic state values include color and size. Optionally, speed and direction (&amp;quot;theta&amp;quot;&amp;lt;ref&amp;gt;&amp;quot;phi&amp;quot; values are also intrinsic for 3-d models&amp;lt;/ref&amp;gt;) values can be assigned that direct movement. We use the term ''SimWorld'' to refer to the combined cell/agent universe.&lt;br /&gt;
&lt;br /&gt;
The NuWebKit platform uses a Web browser to create a ''presentation'' of the simulation to the user. The presentation is separate from the model logic that determines the state evolution of the program, even when both are running on the client. When client and server are both used to execute a simulation, a WebSocket facilitates communication between the presentation and model logic. Consequently, the user must first connect the presentation to the model logic. This step is maintained even for client-side-only deployment, for the sake of uniformity. Disconnecting and reconnecting is a simple and reliable way of restarting a session.&lt;br /&gt;
&lt;br /&gt;
To assist with model creation NuWebKit provides a '''Project Manager''' application. Using this, the programmer creates a Project '''blueprint''', essentially a file containing the Project DNA, stored separately from the project directories. The Project Manager reads this file and first parses the JSON contained in the blueprint to weed out any errors. Once a blueprint is correct, the Project Manager creates directory structures for the project, adds the project DNA file constructed from the blueprint, and inserts runnable but empty Java or JS source files for the model logic. As the project develops, changes may be made to the actual project DNA to fine tune the application. The Project Manager also has a function for retrieving deployed Project DNA files and correcting the blueprint, so that using the workflow recommended in a later section, the blueprint will always be current.&lt;br /&gt;
&lt;br /&gt;
We next explore simulation programs from the point of view of the user, and then discuss how these programs are organized architecturally and in terms of their model logic.&lt;br /&gt;
&lt;br /&gt;
=== User Experience ===&lt;br /&gt;
[[File:app.png|thumb|NuWebKit User Interface]]&lt;br /&gt;
This image shows the browser window running the sample agent-based application &amp;quot;Rock Paper Scissors&amp;quot;, with the following features:&lt;br /&gt;
;Model Inputs&lt;br /&gt;
:These sliders set parameters for the simulation. Changes are forwarded even while the simulation is running and my have immediate effect.&lt;br /&gt;
;Timers&lt;br /&gt;
: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.&lt;br /&gt;
;Operating Buttons&lt;br /&gt;
:The '''Connect/Disconnect''' buttons activate/deactivate the WebSocket, with the '''Connect''' button initializing the application. (Note that this functionality is maintained in the JS platform for the sake of uniformity.) Disconnecting and Connecting is one way to restart the application; reloading the page is another.&lt;br /&gt;
: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.&lt;br /&gt;
[[File:browser.png|thumb|Web Page With Side Panel Displayed]]&lt;br /&gt;
;Speed Control&lt;br /&gt;
:This determines the real-time interval between steps. &lt;br /&gt;
;Displays&lt;br /&gt;
:A spatial or agent-based simulation will include a &amp;quot;SimWorld&amp;quot; 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.&lt;br /&gt;
:Other displays such as Spys (showing a single current value) graphs, tables, etc. are specified in the Project file (see below).&lt;br /&gt;
;Side Panel&lt;br /&gt;
:The browser page has a side panel. Use [[File:sideicon.png]] to toggle visibility (you may have to make the browswer wider to see the panel). Currently this side panel contains model documentation and a log window for WebSocket status reports. A dashboard for altering some properties of the displays, such as the dimensions of the SimWorld, is forthcoming.&lt;br /&gt;
&lt;br /&gt;
=== System Architecture ===&lt;br /&gt;
[[File:arch0.png|thumb||Basic Architecture]]&lt;br /&gt;
NuWebKit architecture revolves around 5 major structures. Refer to the diagram on the right to understand the organization of these items.&lt;br /&gt;
;Project&lt;br /&gt;
:The ''Project'' (or Project &amp;quot;DNA&amp;quot;), is a JSON&amp;lt;ref&amp;gt;JSON (JavaScript Object Notation) is a standard format for storing and exchanging data. It's a lightweight, text-based format that's easy to read by humans and machines.&amp;lt;/ref&amp;gt; object contained in a text file, specifying the parameters that configure the elements of both the simulation and the presentation. Details will be given below. If the Project Manager is used to initialize a a project, the programmer first creates a '''blueprint''', essentially the Project DNA file in a separate directory. As mentioned above, the Project Manager uses the blueprint to create a new runnable (but semantically empty) project.&lt;br /&gt;
&lt;br /&gt;
;Presentation&lt;br /&gt;
:The ''Presentation'' supports visualization and user inputs in the browser. This structure is usually constructed directly in the Presentation API from the data contained in the Project JSON object. All elements of the project pertaining to the visualization and input portal required by the project. These include the agent/cell display (the &amp;quot;SimWorld&amp;quot; display), graphs, tables, etc. Specifications for this aspect are almost always covered by the contents of the Project file and require no attention from the model programmer.&amp;lt;ref&amp;gt;There are exceptions. One will be presented in a subsequent example.&amp;lt;/ref&amp;gt;&lt;br /&gt;
;Simulator&lt;br /&gt;
:The ''Simulation'' structure, which contains the &amp;quot;business logic&amp;quot; for the model. This consists of 2 parts:  the simulation API, which defines the data structures and methods used in the model, and the model itself. The simulation API supports the &amp;quot;turtle/patch&amp;quot; abstraction for agent-based models (ABMs), familiar from NL, but contains some additional capabilities, such as a network basis that substitutes for the patch abstraction, and support for system dynamics models using stocks and flows that can integrate with the ABMs. The simulation API is also configured directly by the Project DNA structure. Model designers can focus entirely on the model structure. One crucial property that we will insist be maintained is that changes to all parts of state occur simultaneously. In other words, any algorithm used to determine one part of a new state only relies on the current or past state of itself and any other part of the state, so that the order in which different parts of the state are computed is immaterial to the outcome.&lt;br /&gt;
;Clock&lt;br /&gt;
:''Clock'' refers to an external module that provides signals or ''strobes'' to the simulation for it to update its state. The clock is controlled from the user console in the browser and can be programmed so that the interval between strobes represents a particular interval of model time (called ''dt'').&lt;br /&gt;
;Dispatcher&lt;br /&gt;
:This unit facilitates communication between presentation and simulation elements of the application. When a project is loaded into the browser and communication is established, the dispatcher initializes a new simulator with its required parameters. The dispatcher communicates control signals from the presentation to operate the simulator, and any parameter changes that result from user gestures on sliders, switches or other input components. In response, the simulator uses the dispatcher to forward data (called a ''status report'') to the presentation that it needs to update its visual elements.&lt;br /&gt;
&lt;br /&gt;
==== Architecture in Client/Server and Client/Client Modes ====&lt;br /&gt;
&lt;br /&gt;
Depending upon the language chosen for programming the model, this architecture is mapped out either across the client and server platforms, or is contained entirely in the client.&lt;br /&gt;
&lt;br /&gt;
=====Java Platform=====&lt;br /&gt;
[[File:arch1.png||thumb||Java Architecture]]&lt;br /&gt;
Since Java is not native to the browser, programming the model in Java requires server-side support. We use WebSockets to facilitate communication between server and client. The illustration shows the dispatcher divided into two asynchronous units operating separately with the simulator and the presentation. The WebSocket&amp;lt;ref&amp;gt;There exist a number of tutorials on WebSockets. Here is the [https://en.wikipedia.org/wiki/WebSocket Wikipedia entry].&amp;lt;/ref&amp;gt; is a robust protocol that manages communication with significant fault tolerance. This robustness translates to a highly robust execution environment for the final application.&lt;br /&gt;
&lt;br /&gt;
The preceding remarks also apply to Python or other model logic coding using an appropriate server. Our experience with Java makes use of the Apache Tomcat server and the Eclipse J2EE design platform. Deploying Tomcat applications is particularly easy: the code is archived in a &amp;quot;.war&amp;quot; file and dropped into a Tomcat &amp;quot;webapp&amp;quot; directory (or, in the case of Elastic Beanstalk, uploaded to the server). Subsequent updates simply overwrite the archive. However, an external server is not needed if one installs a local Tomcat server on their computer.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;both&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====JavaScript Platform=====&lt;br /&gt;
[[File:arch2.png||thumb||JavaScript Architecture]]&lt;br /&gt;
The JavaScript platform requires no special server features inasmuch as the entire application is downloaded and run in the client. In this case we maintain the same communication regimen but replace the WebSocket with a local function callback protocol. Consequently the client/server and client/client configurations offer identical structures, which facilitates Numerus' obligation for program maintenance of these platforms. Similarly, activating a local server obviates the need for an external delivery method.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;both&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Model Organization==&lt;br /&gt;
We now provide a summary of the model algorithm for agent-based projects using the Java platform (the JS platform follows the same pattern). The code uses NetLogo terminology ''turtle'' and ''patch'', respectively, in the class names used for agent and cell base and derived classes. A main class given the name specified in the Project blueprint, oversees simulation operation. These 3 classes respectively extend &amp;lt;code&amp;gt;NLTurtle&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;NLPatch&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;NLSimMain&amp;lt;/code&amp;gt;. Each turtle or patch object corresponds to a single agent or cell in the model. The main class has data structures &amp;lt;code&amp;gt;turtles&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; to hold all of these objects. Initializing the simulation causes these data structures to be filled according to the Project DNA.&lt;br /&gt;
&lt;br /&gt;
===Simulation Cycle===&lt;br /&gt;
In spatial and agent-based systems, turtle and patch individuals maintain local state. During a clock cycle these object compute their next state.  Usually each cycle requires one or two ''visits'' to some set of turtles and/or patches, possibly all of them, asking each to compute its next state. This is generally the most computationally intensive part of the cycle. But with efficient design, there are ways to minimize the number of individuals that must be visited, knowing that their states will not change. The base classes have ways to distinguish and control which individuals the cycle must visit, thus greatly improving performance.&lt;br /&gt;
&lt;br /&gt;
Each clock step of the simulation is subdivided as follows:&lt;br /&gt;
&lt;br /&gt;
;Step&lt;br /&gt;
:The next state is computed by the following operations:&lt;br /&gt;
:;Coordinate&lt;br /&gt;
::The main program performs any preliminary action on global data, or on the turtle or patch collections.&lt;br /&gt;
:;Visit&lt;br /&gt;
::Individual patches and turtles compute their next local state.&lt;br /&gt;
;Shift&lt;br /&gt;
:The next state becomes the current state, and the clock is advanced. &lt;br /&gt;
:;Visit&lt;br /&gt;
::Shifting may require a second visit pass.&lt;br /&gt;
;Update&lt;br /&gt;
: Any required cleanup is performed. State data is sent to the browser.&lt;br /&gt;
&lt;br /&gt;
===Stores===&lt;br /&gt;
States are represented using the &amp;lt;code&amp;gt;Store&amp;lt;/code&amp;gt; class, a generic class which can hold any data type. Newly computed states are assigned to the store's &amp;lt;code&amp;gt;next&amp;lt;/code&amp;gt; property. If a store is registered with the main program, the main program will perform the shift from next to current during the '''Shift''' cycle. Turtles and patches have registered stores for properties such as color, size, location, speed, and direction. Additional application-specific stores can be declared and registered. If shifting the store value from next to current is all is required, (and it usually is), a second visit during the shift cycle can be avoided.&lt;br /&gt;
&lt;br /&gt;
===Stocks===&lt;br /&gt;
A special type of store, called a &amp;lt;code&amp;gt;Stock&amp;lt;/code&amp;gt;, is used in system dynamics (SD) settings to model continuous functions. NuWebKit stocks operate like those in well-known system dynamics modeling platforms, such as Stella, Vensim and Berkeley Madonna, using RK4 integration to maintain accuracy. Stocks may be used in a purely SD model, or may be part of the environment modeled in a spatial or agent-based model.&lt;br /&gt;
&lt;br /&gt;
===VisitMode===&lt;br /&gt;
Control of the visit schedule is specified with the VisitMode parameter, in particular the order in which visits to turtles and stocks occurs. As an exception that proves the rule, it may be advantageous to visit turtles before patches, or patches before turtles, and use the newly computed ''next'' values in, say, patches when computing the next state of the turtles, or visa versa. The VisitMode values currently supported are:&amp;lt;br&amp;gt;&lt;br /&gt;
:'''A_C''': turtles before patches&lt;br /&gt;
:'''C_A''': patches before turtles&lt;br /&gt;
:'''A''': turtles only&lt;br /&gt;
:'''C''': patches only&lt;br /&gt;
:'''No''': no visits&lt;br /&gt;
:'''SD''': system dynamics using Euler method integration (no visits)&lt;br /&gt;
:'''SDRK4''': system dynamics using Runge-Kutta&amp;lt;ref&amp;gt;See [https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods Runge-Kutta in the Wikipedia]&amp;lt;/ref&amp;gt; 4 integration (no visits).&lt;br /&gt;
Additional VisitModes may be added as this platform develops.&lt;br /&gt;
&lt;br /&gt;
==Directory Structures==&lt;br /&gt;
===Java Platform===&lt;br /&gt;
[[File:dir0.png||thumb|Java Eclipse Project Directory Structure]]&lt;br /&gt;
[[File:jssite2.png||thumb|JavaScript Presentation API Directory Structure]]&lt;br /&gt;
&lt;br /&gt;
The picture shows the directory structure used by the Java platform, created as a dynamic web project for deployment on Tomcat, by EclipseEE. The project name (&amp;lt;code&amp;gt;WX&amp;lt;/code&amp;gt;) acts as a group id for a set of related simulation applications. Each application specifies a name in its Project DNA. These directories are constructed by the Project Manager app using the Project blueprint file, and the code templates generated during project initialization use the name to prefix the names of the Java and JS model logic classes. The model logic code for each application is thus contained in the java directory subdirectory corresponding to that name. The classes created by the Project Manager are generally sufficient for models with a level of complexity comparable to NetLogo, and in any case serve as the root of the computational environment. The opportunity exists, however, to create more complex simulations by extending the code base with additional classes and/or dependencies. &lt;br /&gt;
&lt;br /&gt;
Similarly named subdirectories of &amp;lt;code&amp;gt;webapp&amp;lt;/code&amp;gt; each contain the HTML code for the application and have the identical structure shown below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
File:jsite.png|left|Java Model Code Directory&lt;br /&gt;
File:jsite1.png|left|Java HTML and Presentation Directories&lt;br /&gt;
File:javapresent.png|thumb|left|Java Presentation and Dispatch Structures&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These images respectively show the contents of the model code directory (subdirectory of &amp;lt;code&amp;gt;java&amp;lt;/code&amp;gt;) and the HTML/presentation directories (subdirectory of &amp;lt;code&amp;gt;webapp&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Three of the HTML files are automatically generated by the Project Manager app from data contained in the Project blueprint file, using the project name as prefix. These files constitute the HTML loaded into the browser. The fourth (&amp;lt;code&amp;gt;riverDoc.html&amp;lt;/code&amp;gt;) was added and appears in the documentation window of the side panel.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;js&amp;lt;/code&amp;gt; subdirectory contains the Project DNA file itself (i.e., &amp;lt;code&amp;gt;river.js&amp;lt;/code&amp;gt;). These files are generally complete when deployed.&lt;br /&gt;
&lt;br /&gt;
The right-most image shows the JavaScript, CSS and image files used to implement the Presentation and Dispatch elements of the application, as subdirectories of the &amp;lt;code&amp;gt;common&amp;lt;/code&amp;gt; directory. Most of the heavy lifting is done by &amp;lt;code&amp;gt;main.js&amp;lt;/code&amp;gt;, which contains the drivers for the dispatcher, input and visualization components. Code for particular components (e.g., &amp;lt;code&amp;gt;lchart.js&amp;lt;/code&amp;gt; for linechart, etc.) are contained in their respective files. Consequently, new &amp;quot;widgets&amp;quot; in later releases are easily added to the API.&lt;br /&gt;
&lt;br /&gt;
===JavaScript Platform===&lt;br /&gt;
[[File:jssite.png|thumb|left|JavaScript Application Directory Structure]]&lt;br /&gt;
The JavaScript platform is simpler since it does not have a &amp;lt;code&amp;gt;java&amp;lt;/code&amp;gt; directory. The &amp;lt;code&amp;gt;common&amp;lt;/code&amp;gt; directory is extended to include the JS model API, along with the same files used for Java Presentation support, with a small change to substitute callbacks for WebSocket interactions.&lt;br /&gt;
&lt;br /&gt;
Looking at the JS application directory, we see the same 3 HTML files, but now the js subdirectory contains additional files implementing model logic. Note here that the Project DNA file is labeled &amp;lt;code&amp;gt;river.prj&amp;lt;/code&amp;gt;, so that &amp;lt;code&amp;gt;river.js&amp;lt;/code&amp;gt; can be used for the model logic main class. It is worth noting once again that the Project Manager creates these files under the guidance of the Project blueprint file, and they generally need not concern the model author.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;both&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Project File Contents==&lt;br /&gt;
[[File:projectdna.png|thumb]]&lt;br /&gt;
We now provide a brief overview of the Project blueprint file. Contents will vary depending on the specific needs of the simulation application. Designers will benefit from existing Project blueprint files when building JSON structures for their applications. The following descriptions refer to the sample Project blueprint file shown at here. &lt;br /&gt;
&lt;br /&gt;
Complete documentation for constructing a blueprint file will be presented in the user manual currently under development.&lt;br /&gt;
&lt;br /&gt;
Note that, as this file presents a JSON structure, the order of the entries is immaterial.&lt;br /&gt;
&lt;br /&gt;
===Lines 1 - 9: Title, Directories and Frame Size===&lt;br /&gt;
;Lines 2-3, Name, Title&lt;br /&gt;
:The '''Name''' was mentioned in the discussion on directory structure, and is used as a prefix in the class names of model logic files generated by the Project Manager. The '''Title''' is the title of the HTML main frame and appears at the top of the browser page.&lt;br /&gt;
;Lines 4-7, Directory Specifications&lt;br /&gt;
:The '''jroot''' and '''jbase''' entries identify the project's Java directories. The former points to the root directory of the Eclipse workspace, while the latter identifies the Eclipse project (and group id) for the group of project this one will be part of.&lt;br /&gt;
:Analogously, '''jsroot''' and '''jsbase''' identify the directories associated with JS. Since the Tomcat server is not required, these should be, respectively, the user's '''localhost''' root directory. &amp;lt;ref&amp;gt;On Mac systems this is &amp;lt;code&amp;gt;~/Sites&amp;lt;/code&amp;gt;. See [https://discussions.apple.com/docs/DOC-3083 Setting up a local web server on Mac]&amp;lt;/ref&amp;gt;, and a group id identifying a subdirectory for the group. &lt;br /&gt;
:The Project Manager uses these entries to construct directories, HTML files and model logic templates.&lt;br /&gt;
;Lines 8-9, Width and Height Specifications&lt;br /&gt;
:These specify the size of the main frame in the browser. They can be adjusted as need as the application takes shape.&lt;br /&gt;
;Line 10, VisitMode&lt;br /&gt;
:This is used by the model API to configure the main loop of the program. It will be discussed in detail later.&lt;br /&gt;
&lt;br /&gt;
===Lines 11-17, Cell Specifications===&lt;br /&gt;
These configure the cell matrix of a spatial or agent-based model. &lt;br /&gt;
;Line 12, cellSize&lt;br /&gt;
:'''cellSize''' indicates the number of pixels used by each cell in the display. In the coordinate system of the cell matrix each cell occupies a 1 by 1 square. CellSize maps that to specific spatial coordinates on the screen, making it easy to re-scale the visual display.&lt;br /&gt;
;Line 13, palette&lt;br /&gt;
:The '''palette''' is a list of CSS colors using the &amp;quot;#xxxxxxyy&amp;quot; or any other acceptable CSS format.&amp;lt;ref&amp;gt;The hex format should be used if color blending is to take place.&amp;lt;/ref&amp;gt; All cell color references are references to this palette.&lt;br /&gt;
;Lines 14-15, rowDim, colDim&lt;br /&gt;
:Row and column dimensions define the operational space of the model. Using '''rowDim''' and '''colDim''' and '''cellSize''', you can compute the size of the real estate occupied by display.&lt;br /&gt;
;Line 16, initial cell color&lt;br /&gt;
:The default assumption for cell color is palette entry 0. Any initial cell color other than 0 are specified by this array. Since the array will be transmitted via the WebSocket (in the Java platform), it is flattened. Every 3 entries indicate 1 cell (e.g., &amp;quot;64, 63 1&amp;quot; means that the cell at coordinates (64, 63) is to be colored with the second palette entry, &amp;lt;code&amp;gt;#ffffff&amp;lt;/code&amp;gt;, or white.&lt;br /&gt;
&lt;br /&gt;
===Lines 18-34, Agent Specifications===&lt;br /&gt;
A similar section is devoted to specifying agent properties. The palette entry is analogous to that used by cell specifications. Defaults are provided for the 5 fundamental agent properties (&amp;lt;code&amp;gt;color, size, shape, speed, theta&amp;lt;ref&amp;gt;a ''null'' value for theta means a random assignment&amp;lt;/ref&amp;gt;&amp;lt;/code&amp;gt;). &amp;lt;code&amp;gt;count&amp;lt;/code&amp;gt; determines the initial agent count. It can either be a number or the code of an input whose value will be used. &amp;lt;code&amp;gt;start&amp;lt;/code&amp;gt; can be a list of agents with initial configurations, or the string &amp;quot;random&amp;quot;, indicating random assignment of properties to &amp;lt;code&amp;gt;count&amp;lt;/code&amp;gt; agents. Other properties defined in this section will be discussed in a subsequent document.&lt;br /&gt;
&lt;br /&gt;
===Lines 36-48, Displays===&lt;br /&gt;
This entry consists of an array of display specifications for graphs, tables, spys&amp;lt;ref&amp;gt;Recall a ''spy'' is a component showing a single data point. Spys show up on the page at the top of the display area&amp;lt;/ref&amp;gt;, etc. Each display includes a 3-letter &amp;quot;airport code&amp;quot; that identifies the display. Other parameters depend on the type of display. The ''site'' property point to 1 of 6 slots reserved on the Web page for locating the display (If more that 6 displays are required the programmer can modify the HTML file accommodate them). Shown here is a linechart with the indicated domain and range.&lt;br /&gt;
&lt;br /&gt;
===Lines 49-51, Inputs ===&lt;br /&gt;
This is an array of slider or other input specifications, also using airport codes to identify them (note that this slider's airport code corresponds to the code used by the count property in the agent section.) The array containing the inputs may be multi-dimensional, creating a multi-row layout on the page.&lt;br /&gt;
&lt;br /&gt;
== Sample Workflow ==&lt;br /&gt;
Here is an outline of workflow for a project called &amp;quot;MyProject&amp;quot; using the Project Manager and developed on the Java platform using Eclipse J2EE (now called Jakarta) and Tomcat.&lt;br /&gt;
&lt;br /&gt;
# Install Eclipse Jakarta, open a workspace and create a Dynamic Web project.&lt;br /&gt;
# In a separate directory open '''myproject.prj''' in a text editor (emacs, vi, etc.)&lt;br /&gt;
# Edit '''myproject.prj''' to include a project blueprint containing the desired features and parameters. Be sure to reference to appropriate directories in the Eclipse workspace.&lt;br /&gt;
# Launch the Project Manager app and load '''myproject.prj'''; correct any errors and save the corrected version.&lt;br /&gt;
# Use the Project Manager to construct directories and template files in the Eclipse Workspace.&lt;br /&gt;
# Launch Tomcat from Eclipse.&lt;br /&gt;
# Navigate to the project in Chrome or a Web browser of your choice. A fully-featured Web page should appear.&lt;br /&gt;
# Connect and run the model; the timers will show that the model is running, but no changes occur in the display since the model logic has not yet been programmed.&lt;br /&gt;
# View the project DNA file, contained in '''js/myproject.js''', in Eclipse. Make any desired cosmetic changes to the size and appearance of the components by altering the project DNA file and reloading the page. When you are satisfied, use the Project Manager to update the blueprint with the current contents of the project DNA file.&lt;br /&gt;
# Define the model logic in the Java files '''MyProject.java''', '''MyProjectTurtle.java''' and '''MyProjectPatch.java'''. The Tomcat server will reload with every saved change. Occasionally the Tomcat server is unable to keep up and will offer to terminate or restart. You may want to terminate the Tomcat server while writing code to avoid this interruption. Restarting the Tomcat server and reloading the Web page will refresh the presentation.&lt;br /&gt;
# You may also want to open the browser's DevTools to monitor Web page execution.&lt;br /&gt;
&lt;br /&gt;
==Glossary of Terms==&lt;br /&gt;
;simulation&lt;br /&gt;
:a system that maintains a global state that evolves over time.&lt;br /&gt;
;simulator&lt;br /&gt;
:a computational structure for executing a simulation&lt;br /&gt;
;clock&lt;br /&gt;
:issues a sequence of signals to a simulation to cause it to change state.&lt;br /&gt;
;presentation&lt;br /&gt;
:A Web page displaying data and controls for a simulation program.&lt;br /&gt;
;dispatcher&lt;br /&gt;
:expedites communication between presentation, clock and simulator.&lt;br /&gt;
;system dynamics&lt;br /&gt;
:an approach to understanding the nonlinear behaviour of complex systems over time using stocks, flows, internal feedback loops, table functions and time delays.&lt;br /&gt;
;spatial model&lt;br /&gt;
:a particular form of disaggregation, in which an area is divided into a number (often a large number) of similar units: typically grid squares or polygons (also called cells).&lt;br /&gt;
;agent- (or individual- ) based model&lt;br /&gt;
:a computational model for simulating the actions and interactions of autonomous agents (both individual or collective entities such as organizations or groups) in order to understand the behavior of a system and what governs its outcomes.&lt;br /&gt;
;turtle&lt;br /&gt;
:NetLogo terminology for agent.&lt;br /&gt;
;patch&lt;br /&gt;
:NetLogo terminology for cell.&lt;br /&gt;
;network&lt;br /&gt;
:as used here, an alternative to the patch topology in which agents reside in nodes and travel along connections between nodes.&lt;br /&gt;
;SimWorld&lt;br /&gt;
:A visual Web page component showing the cells and agents of the model.&lt;br /&gt;
;display&lt;br /&gt;
:graphs, tables, etc. shown in the Web page.&lt;br /&gt;
;JSON (JavaScript Object Notation) &lt;br /&gt;
:a format for storing and exchanging data that's readable by both humans and machines.&lt;br /&gt;
;project &amp;quot;DNA&amp;quot;&lt;br /&gt;
:a file containing a JSON definition for defining and parameterizing a simulation project.&lt;br /&gt;
;project blueprint&lt;br /&gt;
:a JSON file constructed by the application developer for use as Project DNA&lt;br /&gt;
;Project Manager&lt;br /&gt;
:a Numerus application that reads the project blueprint and creates or updates the project's Website.&lt;br /&gt;
;step&lt;br /&gt;
:a phase of the simulator cycle during which new state values are computed&lt;br /&gt;
;shift&lt;br /&gt;
:a phase of the simulator cycle during which the new state becomes the current state&lt;br /&gt;
;Store&lt;br /&gt;
:a data structure used by the simulator to hold the current and next state.&lt;br /&gt;
;Stock&lt;br /&gt;
:an extension of the Store data type for system dynamics, capable of modeling continuous functions.&lt;br /&gt;
;VisitMode&lt;br /&gt;
:a parameter that determines the behavior of the simulator during each cycle.&lt;br /&gt;
;Eclipse&lt;br /&gt;
:a free, Java-based development platform known for its plugins that allow developers to develop and test code written in Java and other programming languages.&lt;br /&gt;
;Apache Tomcat&lt;br /&gt;
:a free, lightweight web server and servlet container that's used to run Java-based web applications.&lt;br /&gt;
;D3&lt;br /&gt;
:the JavaScript library for ''bespoke'' (their description) data visualization.&lt;br /&gt;
;palette&lt;br /&gt;
:a list of color specifications for display purposes.&lt;br /&gt;
;side panel&lt;br /&gt;
:an area of the NuWebKit Web page containing documentation and other features.&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=Numerus_WebKit&amp;diff=2555</id>
		<title>Numerus WebKit</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=Numerus_WebKit&amp;diff=2555"/>
		<updated>2026-03-19T16:55:11Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: Rsalter moved page Numerus WebKit to NuWebKit: Change of app name&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[NuWebKit]]&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=NuWebKit&amp;diff=2554</id>
		<title>NuWebKit</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=NuWebKit&amp;diff=2554"/>
		<updated>2026-03-19T16:55:11Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: Rsalter moved page Numerus WebKit to NuWebKit: Change of app name&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Numerus WebKit (NuWebKit) 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), but using conventional languages such as Java, JavaScript (JS) and Python.&amp;lt;ref&amp;gt;This API is under development.&amp;lt;/ref&amp;gt; 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.&lt;br /&gt;
&lt;br /&gt;
NuWebKit uses the D3 JavaScript library for rendering high quality dynamic visualizations.&lt;br /&gt;
&lt;br /&gt;
This document describes the NuWebKit architecture, APIs and applications. Tutorials, documents describing example models, and a complete user manual, are forthcoming. Click [[WebKit Examples|here]] to access NuWebKit examples.&lt;br /&gt;
&lt;br /&gt;
== NuWebKit Concepts ==&lt;br /&gt;
A simulation program is a system that maintains a global state that evolves over time. A simulation is starts in some initial state, and incurs state changes following successive strobes from an external source (which we call the '''clock'''). The state may consist of a single data value or multiple data values mapped out over the internal structure of the simulation. An example of the former is a simple simulation of exponential growth, where the current population is the only value of interest. The latter is exemplified by a spatial or agent based model where simulation state is distributed over individual agents or cells. At each time step the state change algorithm determines the new state from the current and possibly past states of the system. As the simulation runs, the user is presented with displays that illustrate the simulation's state. Time in a simulation is measured in clock ticks which may be mapped to model-time values. A simulation may run for a fixed interval, or may operate in an unbounded time frame.&lt;br /&gt;
&lt;br /&gt;
A ''spatial'' simulation models a domain of cells or network nodes organized topologically as a tesselation of 2- or 3-dimensional space, in a Cartesian, or, possibly, hexagonal lattice. Cells have a fixed location and one intrinsically allocated state value, a real number which is associated with a color.&lt;br /&gt;
&lt;br /&gt;
In an agent-, or individual-based model, agents exist in the space defined by the spatial topology and are mobile. In addition to location, their intrinsic state values include color and size. Optionally, speed and direction (&amp;quot;theta&amp;quot;&amp;lt;ref&amp;gt;&amp;quot;phi&amp;quot; values are also intrinsic for 3-d models&amp;lt;/ref&amp;gt;) values can be assigned that direct movement. We use the term ''SimWorld'' to refer to the combined cell/agent universe.&lt;br /&gt;
&lt;br /&gt;
The NuWebKit platform uses a Web browser to create a ''presentation'' of the simulation to the user. The presentation is separate from the model logic that determines the state evolution of the program, even when both are running on the client. When client and server are both used to execute a simulation, a WebSocket facilitates communication between the presentation and model logic. Consequently, the user must first connect the presentation to the model logic. This step is maintained even for client-side-only deployment, for the sake of uniformity. Disconnecting and reconnecting is a simple and reliable way of restarting a session.&lt;br /&gt;
&lt;br /&gt;
To assist with model creation NuWebKit provides a '''Project Manager''' application. Using this, the programmer creates a Project '''blueprint''', essentially a file containing the Project DNA, stored separately from the project directories. The Project Manager reads this file and first parses the JSON contained in the blueprint to weed out any errors. Once a blueprint is correct, the Project Manager creates directory structures for the project, adds the project DNA file constructed from the blueprint, and inserts runnable but empty Java or JS source files for the model logic. As the project develops, changes may be made to the actual project DNA to fine tune the application. The Project Manager also has a function for retrieving deployed Project DNA files and correcting the blueprint, so that using the workflow recommended in a later section, the blueprint will always be current.&lt;br /&gt;
&lt;br /&gt;
We next explore simulation programs from the point of view of the user, and then discuss how these programs are organized architecturally and in terms of their model logic.&lt;br /&gt;
&lt;br /&gt;
=== User Experience ===&lt;br /&gt;
[[File:app.png|thumb|NuWebKit User Interface]]&lt;br /&gt;
This image shows the browser window running the sample agent-based application &amp;quot;Rock Paper Scissors&amp;quot;, with the following features:&lt;br /&gt;
;Model Inputs&lt;br /&gt;
:These sliders set parameters for the simulation. Changes are forwarded even while the simulation is running and my have immediate effect.&lt;br /&gt;
;Timers&lt;br /&gt;
: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.&lt;br /&gt;
;Operating Buttons&lt;br /&gt;
:The '''Connect/Disconnect''' buttons activate/deactivate the WebSocket, with the '''Connect''' button initializing the application. (Note that this functionality is maintained in the JS platform for the sake of uniformity.) Disconnecting and Connecting is one way to restart the application; reloading the page is another.&lt;br /&gt;
: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.&lt;br /&gt;
[[File:browser.png|thumb|Web Page With Side Panel Displayed]]&lt;br /&gt;
;Speed Control&lt;br /&gt;
:This determines the real-time interval between steps. &lt;br /&gt;
;Displays&lt;br /&gt;
:A spatial or agent-based simulation will include a &amp;quot;SimWorld&amp;quot; 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.&lt;br /&gt;
:Other displays such as Spys (showing a single current value) graphs, tables, etc. are specified in the Project file (see below).&lt;br /&gt;
;Side Panel&lt;br /&gt;
:The browser page has a side panel. Use [[File:sideicon.png]] to toggle visibility (you may have to make the browswer wider to see the panel). Currently this side panel contains model documentation and a log window for WebSocket status reports. A dashboard for altering some properties of the displays, such as the dimensions of the SimWorld, is forthcoming.&lt;br /&gt;
&lt;br /&gt;
=== System Architecture ===&lt;br /&gt;
[[File:arch0.png|thumb||Basic Architecture]]&lt;br /&gt;
NuWebKit architecture revolves around 5 major structures. Refer to the diagram on the right to understand the organization of these items.&lt;br /&gt;
;Project&lt;br /&gt;
:The ''Project'' (or Project &amp;quot;DNA&amp;quot;), is a JSON&amp;lt;ref&amp;gt;JSON (JavaScript Object Notation) is a standard format for storing and exchanging data. It's a lightweight, text-based format that's easy to read by humans and machines.&amp;lt;/ref&amp;gt; object contained in a text file, specifying the parameters that configure the elements of both the simulation and the presentation. Details will be given below. If the Project Manager is used to initialize a a project, the programmer first creates a '''blueprint''', essentially the Project DNA file in a separate directory. As mentioned above, the Project Manager uses the blueprint to create a new runnable (but semantically empty) project.&lt;br /&gt;
&lt;br /&gt;
;Presentation&lt;br /&gt;
:The ''Presentation'' supports visualization and user inputs in the browser. This structure is usually constructed directly in the Presentation API from the data contained in the Project JSON object. All elements of the project pertaining to the visualization and input portal required by the project. These include the agent/cell display (the &amp;quot;SimWorld&amp;quot; display), graphs, tables, etc. Specifications for this aspect are almost always covered by the contents of the Project file and require no attention from the model programmer.&amp;lt;ref&amp;gt;There are exceptions. One will be presented in a subsequent example.&amp;lt;/ref&amp;gt;&lt;br /&gt;
;Simulator&lt;br /&gt;
:The ''Simulation'' structure, which contains the &amp;quot;business logic&amp;quot; for the model. This consists of 2 parts:  the simulation API, which defines the data structures and methods used in the model, and the model itself. The simulation API supports the &amp;quot;turtle/patch&amp;quot; abstraction for agent-based models (ABMs), familiar from NL, but contains some additional capabilities, such as a network basis that substitutes for the patch abstraction, and support for system dynamics models using stocks and flows that can integrate with the ABMs. The simulation API is also configured directly by the Project DNA structure. Model designers can focus entirely on the model structure. One crucial property that we will insist be maintained is that changes to all parts of state occur simultaneously. In other words, any algorithm used to determine one part of a new state only relies on the current or past state of itself and any other part of the state, so that the order in which different parts of the state are computed is immaterial to the outcome.&lt;br /&gt;
;Clock&lt;br /&gt;
:''Clock'' refers to an external module that provides signals or ''strobes'' to the simulation for it to update its state. The clock is controlled from the user console in the browser and can be programmed so that the interval between strobes represents a particular interval of model time (called ''dt'').&lt;br /&gt;
;Dispatcher&lt;br /&gt;
:This unit facilitates communication between presentation and simulation elements of the application. When a project is loaded into the browser and communication is established, the dispatcher initializes a new simulator with its required parameters. The dispatcher communicates control signals from the presentation to operate the simulator, and any parameter changes that result from user gestures on sliders, switches or other input components. In response, the simulator uses the dispatcher to forward data (called a ''status report'') to the presentation that it needs to update its visual elements.&lt;br /&gt;
&lt;br /&gt;
==== Architecture in Client/Server and Client/Client Modes ====&lt;br /&gt;
&lt;br /&gt;
Depending upon the language chosen for programming the model, this architecture is mapped out either across the client and server platforms, or is contained entirely in the client.&lt;br /&gt;
&lt;br /&gt;
=====Java Platform=====&lt;br /&gt;
[[File:arch1.png||thumb||Java Architecture]]&lt;br /&gt;
Since Java is not native to the browser, programming the model in Java requires server-side support. We use WebSockets to facilitate communication between server and client. The illustration shows the dispatcher divided into two asynchronous units operating separately with the simulator and the presentation. The WebSocket&amp;lt;ref&amp;gt;There exist a number of tutorials on WebSockets. Here is the [https://en.wikipedia.org/wiki/WebSocket Wikipedia entry].&amp;lt;/ref&amp;gt; is a robust protocol that manages communication with significant fault tolerance. This robustness translates to a highly robust execution environment for the final application.&lt;br /&gt;
&lt;br /&gt;
The preceding remarks also apply to Python or other model logic coding using an appropriate server. Our experience with Java makes use of the Apache Tomcat server and the Eclipse J2EE design platform. Deploying Tomcat applications is particularly easy: the code is archived in a &amp;quot;.war&amp;quot; file and dropped into a Tomcat &amp;quot;webapp&amp;quot; directory (or, in the case of Elastic Beanstalk, uploaded to the server). Subsequent updates simply overwrite the archive. However, an external server is not needed if one installs a local Tomcat server on their computer.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;both&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====JavaScript Platform=====&lt;br /&gt;
[[File:arch2.png||thumb||JavaScript Architecture]]&lt;br /&gt;
The JavaScript platform requires no special server features inasmuch as the entire application is downloaded and run in the client. In this case we maintain the same communication regimen but replace the WebSocket with a local function callback protocol. Consequently the client/server and client/client configurations offer identical structures, which facilitates Numerus' obligation for program maintenance of these platforms. Similarly, activating a local server obviates the need for an external delivery method.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;both&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Model Organization==&lt;br /&gt;
We now provide a summary of the model algorithm for agent-based projects using the Java platform (the JS platform follows the same pattern). The code uses NetLogo terminology ''turtle'' and ''patch'', respectively, in the class names used for agent and cell base and derived classes. A main class given the name specified in the Project blueprint, oversees simulation operation. These 3 classes respectively extend &amp;lt;code&amp;gt;NLTurtle&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;NLPatch&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;NLSimMain&amp;lt;/code&amp;gt;. Each turtle or patch object corresponds to a single agent or cell in the model. The main class has data structures &amp;lt;code&amp;gt;turtles&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; to hold all of these objects. Initializing the simulation causes these data structures to be filled according to the Project DNA.&lt;br /&gt;
&lt;br /&gt;
===Simulation Cycle===&lt;br /&gt;
In spatial and agent-based systems, turtle and patch individuals maintain local state. During a clock cycle these object compute their next state.  Usually each cycle requires one or two ''visits'' to some set of turtles and/or patches, possibly all of them, asking each to compute its next state. This is generally the most computationally intensive part of the cycle. But with efficient design, there are ways to minimize the number of individuals that must be visited, knowing that their states will not change. The base classes have ways to distinguish and control which individuals the cycle must visit, thus greatly improving performance.&lt;br /&gt;
&lt;br /&gt;
Each clock step of the simulation is subdivided as follows:&lt;br /&gt;
&lt;br /&gt;
;Step&lt;br /&gt;
:The next state is computed by the following operations:&lt;br /&gt;
:;Coordinate&lt;br /&gt;
::The main program performs any preliminary action on global data, or on the turtle or patch collections.&lt;br /&gt;
:;Visit&lt;br /&gt;
::Individual patches and turtles compute their next local state.&lt;br /&gt;
;Shift&lt;br /&gt;
:The next state becomes the current state, and the clock is advanced. &lt;br /&gt;
:;Visit&lt;br /&gt;
::Shifting may require a second visit pass.&lt;br /&gt;
;Update&lt;br /&gt;
: Any required cleanup is performed. State data is sent to the browser.&lt;br /&gt;
&lt;br /&gt;
===Stores===&lt;br /&gt;
States are represented using the &amp;lt;code&amp;gt;Store&amp;lt;/code&amp;gt; class, a generic class which can hold any data type. Newly computed states are assigned to the store's &amp;lt;code&amp;gt;next&amp;lt;/code&amp;gt; property. If a store is registered with the main program, the main program will perform the shift from next to current during the '''Shift''' cycle. Turtles and patches have registered stores for properties such as color, size, location, speed, and direction. Additional application-specific stores can be declared and registered. If shifting the store value from next to current is all is required, (and it usually is), a second visit during the shift cycle can be avoided.&lt;br /&gt;
&lt;br /&gt;
===Stocks===&lt;br /&gt;
A special type of store, called a &amp;lt;code&amp;gt;Stock&amp;lt;/code&amp;gt;, is used in system dynamics (SD) settings to model continuous functions. NuWebKit stocks operate like those in well-known system dynamics modeling platforms, such as Stella, Vensim and Berkeley Madonna, using RK4 integration to maintain accuracy. Stocks may be used in a purely SD model, or may be part of the environment modeled in a spatial or agent-based model.&lt;br /&gt;
&lt;br /&gt;
===VisitMode===&lt;br /&gt;
Control of the visit schedule is specified with the VisitMode parameter, in particular the order in which visits to turtles and stocks occurs. As an exception that proves the rule, it may be advantageous to visit turtles before patches, or patches before turtles, and use the newly computed ''next'' values in, say, patches when computing the next state of the turtles, or visa versa. The VisitMode values currently supported are:&amp;lt;br&amp;gt;&lt;br /&gt;
:'''A_C''': turtles before patches&lt;br /&gt;
:'''C_A''': patches before turtles&lt;br /&gt;
:'''A''': turtles only&lt;br /&gt;
:'''C''': patches only&lt;br /&gt;
:'''No''': no visits&lt;br /&gt;
:'''SD''': system dynamics using Euler method integration (no visits)&lt;br /&gt;
:'''SDRK4''': system dynamics using Runge-Kutta&amp;lt;ref&amp;gt;See [https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods Runge-Kutta in the Wikipedia]&amp;lt;/ref&amp;gt; 4 integration (no visits).&lt;br /&gt;
Additional VisitModes may be added as this platform develops.&lt;br /&gt;
&lt;br /&gt;
==Directory Structures==&lt;br /&gt;
===Java Platform===&lt;br /&gt;
[[File:dir0.png||thumb|Java Eclipse Project Directory Structure]]&lt;br /&gt;
[[File:jssite2.png||thumb|JavaScript Presentation API Directory Structure]]&lt;br /&gt;
&lt;br /&gt;
The picture shows the directory structure used by the Java platform, created as a dynamic web project for deployment on Tomcat, by EclipseEE. The project name (&amp;lt;code&amp;gt;WX&amp;lt;/code&amp;gt;) acts as a group id for a set of related simulation applications. Each application specifies a name in its Project DNA. These directories are constructed by the Project Manager app using the Project blueprint file, and the code templates generated during project initialization use the name to prefix the names of the Java and JS model logic classes. The model logic code for each application is thus contained in the java directory subdirectory corresponding to that name. The classes created by the Project Manager are generally sufficient for models with a level of complexity comparable to NetLogo, and in any case serve as the root of the computational environment. The opportunity exists, however, to create more complex simulations by extending the code base with additional classes and/or dependencies. &lt;br /&gt;
&lt;br /&gt;
Similarly named subdirectories of &amp;lt;code&amp;gt;webapp&amp;lt;/code&amp;gt; each contain the HTML code for the application and have the identical structure shown below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
File:jsite.png|left|Java Model Code Directory&lt;br /&gt;
File:jsite1.png|left|Java HTML and Presentation Directories&lt;br /&gt;
File:javapresent.png|thumb|left|Java Presentation and Dispatch Structures&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These images respectively show the contents of the model code directory (subdirectory of &amp;lt;code&amp;gt;java&amp;lt;/code&amp;gt;) and the HTML/presentation directories (subdirectory of &amp;lt;code&amp;gt;webapp&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Three of the HTML files are automatically generated by the Project Manager app from data contained in the Project blueprint file, using the project name as prefix. These files constitute the HTML loaded into the browser. The fourth (&amp;lt;code&amp;gt;riverDoc.html&amp;lt;/code&amp;gt;) was added and appears in the documentation window of the side panel.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;js&amp;lt;/code&amp;gt; subdirectory contains the Project DNA file itself (i.e., &amp;lt;code&amp;gt;river.js&amp;lt;/code&amp;gt;). These files are generally complete when deployed.&lt;br /&gt;
&lt;br /&gt;
The right-most image shows the JavaScript, CSS and image files used to implement the Presentation and Dispatch elements of the application, as subdirectories of the &amp;lt;code&amp;gt;common&amp;lt;/code&amp;gt; directory. Most of the heavy lifting is done by &amp;lt;code&amp;gt;main.js&amp;lt;/code&amp;gt;, which contains the drivers for the dispatcher, input and visualization components. Code for particular components (e.g., &amp;lt;code&amp;gt;lchart.js&amp;lt;/code&amp;gt; for linechart, etc.) are contained in their respective files. Consequently, new &amp;quot;widgets&amp;quot; in later releases are easily added to the API.&lt;br /&gt;
&lt;br /&gt;
===JavaScript Platform===&lt;br /&gt;
[[File:jssite.png|thumb|left|JavaScript Application Directory Structure]]&lt;br /&gt;
The JavaScript platform is simpler since it does not have a &amp;lt;code&amp;gt;java&amp;lt;/code&amp;gt; directory. The &amp;lt;code&amp;gt;common&amp;lt;/code&amp;gt; directory is extended to include the JS model API, along with the same files used for Java Presentation support, with a small change to substitute callbacks for WebSocket interactions.&lt;br /&gt;
&lt;br /&gt;
Looking at the JS application directory, we see the same 3 HTML files, but now the js subdirectory contains additional files implementing model logic. Note here that the Project DNA file is labeled &amp;lt;code&amp;gt;river.prj&amp;lt;/code&amp;gt;, so that &amp;lt;code&amp;gt;river.js&amp;lt;/code&amp;gt; can be used for the model logic main class. It is worth noting once again that the Project Manager creates these files under the guidance of the Project blueprint file, and they generally need not concern the model author.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;both&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Project File Contents==&lt;br /&gt;
[[File:projectdna.png|thumb]]&lt;br /&gt;
We now provide a brief overview of the Project blueprint file. Contents will vary depending on the specific needs of the simulation application. Designers will benefit from existing Project blueprint files when building JSON structures for their applications. The following descriptions refer to the sample Project blueprint file shown at here. &lt;br /&gt;
&lt;br /&gt;
Complete documentation for constructing a blueprint file will be presented in the user manual currently under development.&lt;br /&gt;
&lt;br /&gt;
Note that, as this file presents a JSON structure, the order of the entries is immaterial.&lt;br /&gt;
&lt;br /&gt;
===Lines 1 - 9: Title, Directories and Frame Size===&lt;br /&gt;
;Lines 2-3, Name, Title&lt;br /&gt;
:The '''Name''' was mentioned in the discussion on directory structure, and is used as a prefix in the class names of model logic files generated by the Project Manager. The '''Title''' is the title of the HTML main frame and appears at the top of the browser page.&lt;br /&gt;
;Lines 4-7, Directory Specifications&lt;br /&gt;
:The '''jroot''' and '''jbase''' entries identify the project's Java directories. The former points to the root directory of the Eclipse workspace, while the latter identifies the Eclipse project (and group id) for the group of project this one will be part of.&lt;br /&gt;
:Analogously, '''jsroot''' and '''jsbase''' identify the directories associated with JS. Since the Tomcat server is not required, these should be, respectively, the user's '''localhost''' root directory. &amp;lt;ref&amp;gt;On Mac systems this is &amp;lt;code&amp;gt;~/Sites&amp;lt;/code&amp;gt;. See [https://discussions.apple.com/docs/DOC-3083 Setting up a local web server on Mac]&amp;lt;/ref&amp;gt;, and a group id identifying a subdirectory for the group. &lt;br /&gt;
:The Project Manager uses these entries to construct directories, HTML files and model logic templates.&lt;br /&gt;
;Lines 8-9, Width and Height Specifications&lt;br /&gt;
:These specify the size of the main frame in the browser. They can be adjusted as need as the application takes shape.&lt;br /&gt;
;Line 10, VisitMode&lt;br /&gt;
:This is used by the model API to configure the main loop of the program. It will be discussed in detail later.&lt;br /&gt;
&lt;br /&gt;
===Lines 11-17, Cell Specifications===&lt;br /&gt;
These configure the cell matrix of a spatial or agent-based model. &lt;br /&gt;
;Line 12, cellSize&lt;br /&gt;
:'''cellSize''' indicates the number of pixels used by each cell in the display. In the coordinate system of the cell matrix each cell occupies a 1 by 1 square. CellSize maps that to specific spatial coordinates on the screen, making it easy to re-scale the visual display.&lt;br /&gt;
;Line 13, palette&lt;br /&gt;
:The '''palette''' is a list of CSS colors using the &amp;quot;#xxxxxxyy&amp;quot; or any other acceptable CSS format.&amp;lt;ref&amp;gt;The hex format should be used if color blending is to take place.&amp;lt;/ref&amp;gt; All cell color references are references to this palette.&lt;br /&gt;
;Lines 14-15, rowDim, colDim&lt;br /&gt;
:Row and column dimensions define the operational space of the model. Using '''rowDim''' and '''colDim''' and '''cellSize''', you can compute the size of the real estate occupied by display.&lt;br /&gt;
;Line 16, initial cell color&lt;br /&gt;
:The default assumption for cell color is palette entry 0. Any initial cell color other than 0 are specified by this array. Since the array will be transmitted via the WebSocket (in the Java platform), it is flattened. Every 3 entries indicate 1 cell (e.g., &amp;quot;64, 63 1&amp;quot; means that the cell at coordinates (64, 63) is to be colored with the second palette entry, &amp;lt;code&amp;gt;#ffffff&amp;lt;/code&amp;gt;, or white.&lt;br /&gt;
&lt;br /&gt;
===Lines 18-34, Agent Specifications===&lt;br /&gt;
A similar section is devoted to specifying agent properties. The palette entry is analogous to that used by cell specifications. Defaults are provided for the 5 fundamental agent properties (&amp;lt;code&amp;gt;color, size, shape, speed, theta&amp;lt;ref&amp;gt;a ''null'' value for theta means a random assignment&amp;lt;/ref&amp;gt;&amp;lt;/code&amp;gt;). &amp;lt;code&amp;gt;count&amp;lt;/code&amp;gt; determines the initial agent count. It can either be a number or the code of an input whose value will be used. &amp;lt;code&amp;gt;start&amp;lt;/code&amp;gt; can be a list of agents with initial configurations, or the string &amp;quot;random&amp;quot;, indicating random assignment of properties to &amp;lt;code&amp;gt;count&amp;lt;/code&amp;gt; agents. Other properties defined in this section will be discussed in a subsequent document.&lt;br /&gt;
&lt;br /&gt;
===Lines 36-48, Displays===&lt;br /&gt;
This entry consists of an array of display specifications for graphs, tables, spys&amp;lt;ref&amp;gt;Recall a ''spy'' is a component showing a single data point. Spys show up on the page at the top of the display area&amp;lt;/ref&amp;gt;, etc. Each display includes a 3-letter &amp;quot;airport code&amp;quot; that identifies the display. Other parameters depend on the type of display. The ''site'' property point to 1 of 6 slots reserved on the Web page for locating the display (If more that 6 displays are required the programmer can modify the HTML file accommodate them). Shown here is a linechart with the indicated domain and range.&lt;br /&gt;
&lt;br /&gt;
===Lines 49-51, Inputs ===&lt;br /&gt;
This is an array of slider or other input specifications, also using airport codes to identify them (note that this slider's airport code corresponds to the code used by the count property in the agent section.) The array containing the inputs may be multi-dimensional, creating a multi-row layout on the page.&lt;br /&gt;
&lt;br /&gt;
== Sample Workflow ==&lt;br /&gt;
Here is an outline of workflow for a project called &amp;quot;MyProject&amp;quot; using the Project Manager and developed on the Java platform using Eclipse J2EE (now called Jakarta) and Tomcat.&lt;br /&gt;
&lt;br /&gt;
# Install Eclipse Jakarta, open a workspace and create a Dynamic Web project.&lt;br /&gt;
# In a separate directory open '''myproject.prj''' in a text editor (emacs, vi, etc.)&lt;br /&gt;
# Edit '''myproject.prj''' to include a project blueprint containing the desired features and parameters. Be sure to reference to appropriate directories in the Eclipse workspace.&lt;br /&gt;
# Launch the Project Manager app and load '''myproject.prj'''; correct any errors and save the corrected version.&lt;br /&gt;
# Use the Project Manager to construct directories and template files in the Eclipse Workspace.&lt;br /&gt;
# Launch Tomcat from Eclipse.&lt;br /&gt;
# Navigate to the project in Chrome or a Web browser of your choice. A fully-featured Web page should appear.&lt;br /&gt;
# Connect and run the model; the timers will show that the model is running, but no changes occur in the display since the model logic has not yet been programmed.&lt;br /&gt;
# View the project DNA file, contained in '''js/myproject.js''', in Eclipse. Make any desired cosmetic changes to the size and appearance of the components by altering the project DNA file and reloading the page. When you are satisfied, use the Project Manager to update the blueprint with the current contents of the project DNA file.&lt;br /&gt;
# Define the model logic in the Java files '''MyProject.java''', '''MyProjectTurtle.java''' and '''MyProjectPatch.java'''. The Tomcat server will reload with every saved change. Occasionally the Tomcat server is unable to keep up and will offer to terminate or restart. You may want to terminate the Tomcat server while writing code to avoid this interruption. Restarting the Tomcat server and reloading the Web page will refresh the presentation.&lt;br /&gt;
# You may also want to open the browser's DevTools to monitor Web page execution.&lt;br /&gt;
&lt;br /&gt;
==Glossary of Terms==&lt;br /&gt;
;simulation&lt;br /&gt;
:a system that maintains a global state that evolves over time.&lt;br /&gt;
;simulator&lt;br /&gt;
:a computational structure for executing a simulation&lt;br /&gt;
;clock&lt;br /&gt;
:issues a sequence of signals to a simulation to cause it to change state.&lt;br /&gt;
;presentation&lt;br /&gt;
:A Web page displaying data and controls for a simulation program.&lt;br /&gt;
;dispatcher&lt;br /&gt;
:expedites communication between presentation, clock and simulator.&lt;br /&gt;
;system dynamics&lt;br /&gt;
:an approach to understanding the nonlinear behaviour of complex systems over time using stocks, flows, internal feedback loops, table functions and time delays.&lt;br /&gt;
;spatial model&lt;br /&gt;
:a particular form of disaggregation, in which an area is divided into a number (often a large number) of similar units: typically grid squares or polygons (also called cells).&lt;br /&gt;
;agent- (or individual- ) based model&lt;br /&gt;
:a computational model for simulating the actions and interactions of autonomous agents (both individual or collective entities such as organizations or groups) in order to understand the behavior of a system and what governs its outcomes.&lt;br /&gt;
;turtle&lt;br /&gt;
:NetLogo terminology for agent.&lt;br /&gt;
;patch&lt;br /&gt;
:NetLogo terminology for cell.&lt;br /&gt;
;network&lt;br /&gt;
:as used here, an alternative to the patch topology in which agents reside in nodes and travel along connections between nodes.&lt;br /&gt;
;SimWorld&lt;br /&gt;
:A visual Web page component showing the cells and agents of the model.&lt;br /&gt;
;display&lt;br /&gt;
:graphs, tables, etc. shown in the Web page.&lt;br /&gt;
;JSON (JavaScript Object Notation) &lt;br /&gt;
:a format for storing and exchanging data that's readable by both humans and machines.&lt;br /&gt;
;project &amp;quot;DNA&amp;quot;&lt;br /&gt;
:a file containing a JSON definition for defining and parameterizing a simulation project.&lt;br /&gt;
;project blueprint&lt;br /&gt;
:a JSON file constructed by the application developer for use as Project DNA&lt;br /&gt;
;Project Manager&lt;br /&gt;
:a Numerus application that reads the project blueprint and creates or updates the project's Website.&lt;br /&gt;
;step&lt;br /&gt;
:a phase of the simulator cycle during which new state values are computed&lt;br /&gt;
;shift&lt;br /&gt;
:a phase of the simulator cycle during which the new state becomes the current state&lt;br /&gt;
;Store&lt;br /&gt;
:a data structure used by the simulator to hold the current and next state.&lt;br /&gt;
;Stock&lt;br /&gt;
:an extension of the Store data type for system dynamics, capable of modeling continuous functions.&lt;br /&gt;
;VisitMode&lt;br /&gt;
:a parameter that determines the behavior of the simulator during each cycle.&lt;br /&gt;
;Eclipse&lt;br /&gt;
:a free, Java-based development platform known for its plugins that allow developers to develop and test code written in Java and other programming languages.&lt;br /&gt;
;Apache Tomcat&lt;br /&gt;
:a free, lightweight web server and servlet container that's used to run Java-based web applications.&lt;br /&gt;
;D3&lt;br /&gt;
:the JavaScript library for ''bespoke'' (their description) data visualization.&lt;br /&gt;
;palette&lt;br /&gt;
:a list of color specifications for display purposes.&lt;br /&gt;
;side panel&lt;br /&gt;
:an area of the NuWebKit Web page containing documentation and other features.&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=Numerus_Wiki&amp;diff=2553</id>
		<title>Numerus Wiki</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=Numerus_Wiki&amp;diff=2553"/>
		<updated>2026-03-19T16:54:20Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: /* Numerus WebKit */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
&amp;lt;strong&amp;gt;MediaWiki has been installed.&amp;lt;/strong&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Consult the [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide] for information on using the wiki software.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
== Numerus Wiki Content ==&lt;br /&gt;
===Numerus WebKit===&lt;br /&gt;
'''Numerus WebKit''' (NuWebKit) 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, but using conventional languages such as Java, JavaScript and Python. These applications are deployed either from a remote server, or run locally without using any network.&lt;br /&gt;
* [[Numerus WebKit | About Numerus WebKit]]&lt;br /&gt;
* [[Example NuWebKit Models]] (Javascript platform only)&lt;br /&gt;
* [[NuWebKit Examples]] (Java &amp;amp; Javascript platforms)&lt;br /&gt;
* [[NuWebKit Users Guide]]&lt;br /&gt;
* [[NuML Language Reference]]&lt;br /&gt;
&lt;br /&gt;
===Numerus Designer/Studio and Model Builder===&lt;br /&gt;
* [[Example WebKit Models]]* [[Numerus Designer]]&lt;br /&gt;
* [[Numerus Studio]]&lt;br /&gt;
* [http://wiki.numerusinc.com/index.php/Numerus_Model_Builder_Wiki:_The_Place_for_NumerusMB_Documentation Numerus Model Builder]&lt;br /&gt;
&lt;br /&gt;
===Numerus Downloadable / On-line Apps===&lt;br /&gt;
* [[SEIVAgent IBM Epidemic Simulator]]&lt;br /&gt;
* [[NMB DASA Covid-19 User Guide]]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
== Getting started ==&lt;br /&gt;
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Configuration_settings Configuration settings list]&lt;br /&gt;
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]&lt;br /&gt;
* [https://lists.wikimedia.org/mailman/listinfo/mediawiki-announce MediaWiki release mailing list]&lt;br /&gt;
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation#Translation_resources Localise MediaWiki for your language]&lt;br /&gt;
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Combating_spam Learn how to combat spam on your wiki]&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=WebKit_Examples&amp;diff=2552</id>
		<title>WebKit Examples</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=WebKit_Examples&amp;diff=2552"/>
		<updated>2026-03-19T16:53:53Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: Rsalter moved page WebKit Examples to NuWebKit Examples: Change of app name&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[NuWebKit Examples]]&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=NuWebKit_Examples&amp;diff=2551</id>
		<title>NuWebKit Examples</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=NuWebKit_Examples&amp;diff=2551"/>
		<updated>2026-03-19T16:53:53Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: Rsalter moved page WebKit Examples to NuWebKit Examples: Change of app name&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;These examples illustrate a new Web-based technology for building and deploying Numerus simulations. Models are specified using a JSON project file (the model &amp;quot;DNA&amp;quot;) and are built directly as Web applications. The model logic is programmed in one of two ways:  1) using Java code that runs on the server and interacts with the browser using web sockets; or 2) in Javascript that is downloaded and executed in the browser. The server-side execution model is intended for larger applications and minimal data exchange; a server-side Python API is also under development. The Javascript model executes very efficiently on the sample programs.&lt;br /&gt;
&lt;br /&gt;
The distribution includes an application that sets up the directories and provides templates for the programmer.&lt;br /&gt;
&lt;br /&gt;
To use, click '''Connect''' to initiate the web socket connection. This will enable the other 4 buttons:  '''Disconnect''', '''Reset''', '''Step''' and '''Start'''. Use the '''Start/Stop''' button to run the program continuously. '''Step''' single-steps the program. '''Reset''' returns to the beginning. A '''Double-Reset''' reinitializes the simulation. You can also reinitialize with '''Disconnect/Connect''', or simply reloading the web page.&lt;br /&gt;
&lt;br /&gt;
All of the NetLogo-based translations include the NetLogo documentation. View documentation and other important features by clicking on the side panel icon: [[File:sideicon.png]].&lt;br /&gt;
&lt;br /&gt;
A user guide is currently under construction. An overview showing how Numerus WebKit works can be found [[Numerus WebKit | here]]&lt;br /&gt;
&lt;br /&gt;
==Java Versions Running on AWS Elastic Beanstalk==&lt;br /&gt;
&lt;br /&gt;
'''New Releases'''&lt;br /&gt;
&lt;br /&gt;
;[http://wx-test.us-east-2.elasticbeanstalk.com/egol3/ Three State Extended Game of Life]&lt;br /&gt;
:A 3-state extended version of Conway's Game of Life (GoL). The mathematical equations behind this GoL are described in a paper that can be downloaded at [https://www.biorxiv.org/content/10.1101/2022.08.30.505937v1 mathRxiv]. Click through the 8 presets to view different starting configurations, and feel free to save your own interesting discoveries in unused presets.&lt;br /&gt;
&lt;br /&gt;
;[http://wx-test.us-east-2.elasticbeanstalk.com/sirsdet/ Deterministic SIRS]&lt;br /&gt;
:A mass-action SIRS model described in the publication [https://doi.org/10.1101/2022.02.09.22270752 Simulation Platforms to Support Teaching and Research in Epidemiological Dynamics].&lt;br /&gt;
&lt;br /&gt;
;[http://wx-test.us-east-2.elasticbeanstalk.com/sirsdtvdet/ Deterministic SIRS With Vaccinations]&lt;br /&gt;
:A mass-action SIRS model, with vaccinations, described in the publication [https://doi.org/10.1101/2022.02.09.22270752 Simulation Platforms to Support Teaching and Research in Epidemiological Dynamics].&lt;br /&gt;
&lt;br /&gt;
;[http://wx-test.us-east-2.elasticbeanstalk.com/sirsdtvsto/ Stochastic SIRS with Vaccinations]&lt;br /&gt;
:A stochastic version of the previous model. See [https://doi.org/10.1101/2022.02.09.22270752 Simulation Platforms to Support Teaching and Research in Epidemiological Dynamics]&lt;br /&gt;
&lt;br /&gt;
;[http://wx-test.us-east-2.elasticbeanstalk.com/sdsir SD SIR]&lt;br /&gt;
:A simple mass-action SIR model demonstrating the WebKit Sensitivity analysis platform.&lt;br /&gt;
&lt;br /&gt;
These new examples take advantage of 2 new WebKit features: Settings Presets and RAMs (runtime configurable modules). Settings Presets are a set of &amp;quot;radio&amp;quot; buttons that can be programmed to retain and recall the current settings (Preset 0 is always the &amp;quot;factory&amp;quot; default). Presets will persist in a given browser from session to session. They can be saved for safe keeping and/or for transferring between browsers.&lt;br /&gt;
&lt;br /&gt;
RAMs are significant choices in the algorithm of the model and are always documented. If a project includes one or more RAMs, radio buttons will appear at the top of the side panel (open using [[File:sideicon.png]]) to access each individual RAM. Each RAM displays a set of alternatives, some of which may require parameters. The Default RAM always represents &amp;quot;factory&amp;quot; settings.&lt;br /&gt;
&lt;br /&gt;
The '''Immune to Vaccinated''' RAM in '''Deterministic SIRS w/ Vaccinations''' contains a '''User Input''' RAM selection in which users can create their own expressions using a set of parameters provided by the RAM. An example is contained in Preset 1.&lt;br /&gt;
&lt;br /&gt;
The best way to use RAMs is to save the current settings in a preset, since the settings saved in a preset includes the current RAM selection and any RAM configuration parameters. Recalling that preset properly selects and initializes the desired RAM alternative.&lt;br /&gt;
&lt;br /&gt;
The Extended Game of Life includes 8 interesting choices for the Initial State RAM that it supports. Use the New Preset spinner to view and run each of these.&lt;br /&gt;
&lt;br /&gt;
'''More detailed documentation for Presets and RAMs is currently underway and will be available soon'''.&lt;br /&gt;
&lt;br /&gt;
;[http://wx-test.us-east-2.elasticbeanstalk.com/agents/ Agents]&lt;br /&gt;
:Simple agent motion.&lt;br /&gt;
&lt;br /&gt;
;[http://wx-test.us-east-2.elasticbeanstalk.com/antz/ Ants]&lt;br /&gt;
:NetLogo model. A colony of ants forages for food. Though each ant follows a set of simple rules, the colony as a whole acts in a sophisticated way.&lt;br /&gt;
&lt;br /&gt;
;[http://wx-test.us-east-2.elasticbeanstalk.com/diffuse/ Diffusion]&lt;br /&gt;
:NetLogo diffusion example. Diffusion Graphics is unlike most other NetLogo models, in that it really doesn’t ‘model’ anything. It simply explores the power behind an interesting patch primitive: ‘diffuse’.&lt;br /&gt;
&lt;br /&gt;
;[http://wx-test.us-east-2.elasticbeanstalk.com/dla/ Diffusion Limited Aggregation]&lt;br /&gt;
:This model demonstrates diffusion-limited aggregation, in which randomly moving (diffusing) particles stick together (aggregate) to form beautiful treelike branching fractal structures. There are many patterns found in nature that resemble the patterns produced by this model: crystals, coral, fungi, lightning, and so on&lt;br /&gt;
&lt;br /&gt;
;[http://wx-test.us-east-2.elasticbeanstalk.com/exgrowth/ Exponential Growth]&lt;br /&gt;
:Exponential Growth.&lt;br /&gt;
&lt;br /&gt;
;[http://wx-test.us-east-2.elasticbeanstalk.com/fng/ Fungal Growth]&lt;br /&gt;
:From Whitney's NetLogo model&lt;br /&gt;
&lt;br /&gt;
;[http://wx-test.us-east-2.elasticbeanstalk.com/follower/ Follower]&lt;br /&gt;
:NetLogo model. In Follower, turtles attempt to “connect” with other turtles, forming long chains according to a small set of simple rules.&lt;br /&gt;
&lt;br /&gt;
;[http://wx-test.us-east-2.elasticbeanstalk.com/forest/ Forest]&lt;br /&gt;
:Forest fire model.&lt;br /&gt;
&lt;br /&gt;
;[http://wx-test.us-east-2.elasticbeanstalk.com/fworks/ Fire Works]&lt;br /&gt;
:NetLogo model. This program models the action of fireworks. Rockets begin at the bottom of the view, shoot upwards into the sky and then explode, emitting showers of falling sparks. Works best at lower speed.&lt;br /&gt;
&lt;br /&gt;
;[http://wx-test.us-east-2.elasticbeanstalk.com/life/ Life]&lt;br /&gt;
:Conway's Game of Life. Enough said.&lt;br /&gt;
&lt;br /&gt;
;[http://wx-test.us-east-2.elasticbeanstalk.com/lifeagents/ Life Agents]&lt;br /&gt;
:Game of Life with agent motion. An agent passing over a live cell colors the cell with the agent's color.&lt;br /&gt;
&lt;br /&gt;
;[http://wx-test.us-east-2.elasticbeanstalk.com/lotka/ Lotka-Volterra Model]&lt;br /&gt;
:Shows both time and phase graphs.&lt;br /&gt;
&lt;br /&gt;
;[http://wx-test.us-east-2.elasticbeanstalk.com/mongoose/ Mongoose]&lt;br /&gt;
:Current version of mongoose simulation.&lt;br /&gt;
&lt;br /&gt;
;[http://wx-test.us-east-2.elasticbeanstalk.com/river/ Meandering River]&lt;br /&gt;
:Netlogo Model. This model demonstrates the meandering of a river along its “middle course”, where the gradient of the landscape is gradual and the river runs within a U-shaped river valley. The evolution of the shape of the river is governed by the path of its highest-velocity flow, as well as erosion and deposition.&lt;br /&gt;
:This example has documentation extracted from the Netlogo version. Click the icon on the top-right of the page.&lt;br /&gt;
&lt;br /&gt;
[http://wx-test.us-east-2.elasticbeanstalk.com/rps/ Rock Paper Scissors]&lt;br /&gt;
:NetLogo Model. This model explores the role of movement and space in a three species ecosystem. The system consists of three species, represented by red patches, green patches, and blue patches, which compete over space. The interactions between the species are based on the game Rock-Paper-Scissors. That is, red beats green, green beats blue, and blue beats red. Organisms compete with their neighbors, move throughout the environment, and reproduce. These interactions result in spiral patterns whose size and stability depends on the movement rate of the organisms.&lt;br /&gt;
&lt;br /&gt;
;[http://wx-test.us-east-2.elasticbeanstalk.com/wolfsheep/ Wolf Sheep Predation]&lt;br /&gt;
:NetLogo Model. A population of sheep that wander around the landscape. For each step the sheep take it costs them some energy and if there energy gets too low they die. However, the sheep can eat grass in the environment to regain energy and the grass regrows over time. If the energy of the sheep gets above a certain level then they can reproduce. There are also wolves that have the same behaviors as sheep except for eating; rather than grass, they eat sheep.&lt;br /&gt;
&lt;br /&gt;
;[http://wx-test.us-east-2.elasticbeanstalk.com/wvmach/ Wave Machine]&lt;br /&gt;
:Netlogo Model. This model simulates wave motion in a membrane. The four edges of the membrane are fixed to a frame. A green rectangular area represents a driver plate that moves up and down, exhibiting sinusoidal motion.&lt;br /&gt;
&lt;br /&gt;
==Javascript Versions Running in Client Browser==&lt;br /&gt;
&lt;br /&gt;
'''New Releases'''&lt;br /&gt;
&lt;br /&gt;
;[https://www.cs.oberlin.edu/~rms/wk/egol3/index.html Three State Extended Game of Life]&lt;br /&gt;
:A 3-state extended version of Conway's Game of Life (GoL). The mathematical equations behind this GoL are described in a paper that can be downloaded at [https://www.biorxiv.org/content/10.1101/2022.08.30.505937v1 mathRxiv]. Click through the 8 presets to view different starting configurations, and feel free to save your own interesting discoveries in unused presets.&lt;br /&gt;
&lt;br /&gt;
;[https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sirsdet/index.html Deterministic SIRS]&lt;br /&gt;
:A mass-action SIRS model described in the publication [https://doi.org/10.1101/2022.02.09.22270752 Simulation Platforms to Support Teaching and Research in Epidemiological Dynamics].&lt;br /&gt;
&lt;br /&gt;
;[https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sirsdtvdet/index.html Deterministic SIRS with Vaccinations]&lt;br /&gt;
:A mass-action SIRS model with vaccinations described in the publication [https://doi.org/10.1101/2022.02.09.22270752 Simulation Platforms to Support Teaching and Research in Epidemiological Dynamics].&lt;br /&gt;
&lt;br /&gt;
;[https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sirsdtvsto/index.html Stochastic SIRS with Vaccinations]&lt;br /&gt;
:A stochastic version of the previous model. See [https://doi.org/10.1101/2022.02.09.22270752 Simulation Platforms to Support Teaching and Research in Epidemiological Dynamics]&lt;br /&gt;
&lt;br /&gt;
;[https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sdsir/index.html SD SIR]&lt;br /&gt;
:A simple mass-action SIR model demonstrating the WebKit Sensitivity analysis platform.&lt;br /&gt;
&lt;br /&gt;
These new examples take advantage of 2 new WebKit features: Settings Presets and RAMs (runtime configurable modules). Settings Presets are a set of &amp;quot;radio&amp;quot; buttons that can be programmed to retain and recall the current settings (Preset 0 is always the &amp;quot;factory&amp;quot; default). Presets will persist in a given browser from session to session. They can be saved for safe keeping and/or for transferring between browsers.&lt;br /&gt;
&lt;br /&gt;
RAMs are significant choices in the algorithm of the model and are always documented. If a project includes one or more RAMs, radio buttons will appear at the top of the side panel (open using [[File:sideicon.png]]) to access each individual RAM. Each RAM displays a set of alternatives, some of which may require parameters. The Default RAM always represents &amp;quot;factory&amp;quot; settings.&lt;br /&gt;
&lt;br /&gt;
The '''Immune to Vaccinated''' RAM in '''Deterministic SIRS w/ Vaccinations''' contains a '''User Input''' RAM selection in which users can create their own expressions using a set of parameters provided by the RAM. An example is contained in Preset 1.&lt;br /&gt;
&lt;br /&gt;
The best way to use RAMs is to save the current settings in a preset, since the settings saved in a preset includes the current RAM selection and any RAM configuration parameters. Recalling that preset properly selects and initializes the desired RAM alternative.&lt;br /&gt;
&lt;br /&gt;
The Extended Game of Life includes 8 interesting choices for the Initial State RAM that it supports. Use the New Preset spinner to view and run each of these.&lt;br /&gt;
&lt;br /&gt;
'''More detailed documentation for Presets and RAMs is currently underway and will be available soon'''.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/agents/index.html Agents]&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/antz/index.html Ants]&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/diffuse/index.html Diffusion]&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/dla/index.html Diffusion Limited Aggregration]&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/exgrowth/index.html Exponential Growth]&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/fng/index.html Fungal Growth]&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/follower/index.html Follower]&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/forest/index.html Forest]&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/fworks/index.html Fireworks]&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/life/index.html Life]&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/lifeagents/index.html Life Agents]&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/lotka/index.html Lotka-Volterra Model]&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/mongoose/index.html Mongoose]&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/river/index.html Meandering River]&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/rps/index.html Rock Paper Scissors]&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/wvmach/index.html Wave Machine]&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/wolfsheep/index.html Wolf Sheep Predation]&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=Numerus_Wiki&amp;diff=2550</id>
		<title>Numerus Wiki</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=Numerus_Wiki&amp;diff=2550"/>
		<updated>2026-03-19T16:53:32Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: /* Numerus Wiki Content */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
&amp;lt;strong&amp;gt;MediaWiki has been installed.&amp;lt;/strong&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Consult the [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide] for information on using the wiki software.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
== Numerus Wiki Content ==&lt;br /&gt;
===Numerus WebKit===&lt;br /&gt;
'''Numerus WebKit''' (NuWebKit) 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, but using conventional languages such as Java, JavaScript and Python. These applications are deployed either from a remote server, or run locally without using any network.&lt;br /&gt;
* [[Numerus WebKit | About Numerus WebKit]]&lt;br /&gt;
* [[Example NuWebKit Models]] (Javascript platform only)&lt;br /&gt;
* [[NuWebKit Examples]] (Java &amp;amp; Javascript platforms)&lt;br /&gt;
* [[NuWebKit Users Guide]]&lt;br /&gt;
* [[NumML Language Reference]]&lt;br /&gt;
&lt;br /&gt;
===Numerus Designer/Studio and Model Builder===&lt;br /&gt;
* [[Example WebKit Models]]* [[Numerus Designer]]&lt;br /&gt;
* [[Numerus Studio]]&lt;br /&gt;
* [http://wiki.numerusinc.com/index.php/Numerus_Model_Builder_Wiki:_The_Place_for_NumerusMB_Documentation Numerus Model Builder]&lt;br /&gt;
&lt;br /&gt;
===Numerus Downloadable / On-line Apps===&lt;br /&gt;
* [[SEIVAgent IBM Epidemic Simulator]]&lt;br /&gt;
* [[NMB DASA Covid-19 User Guide]]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
== Getting started ==&lt;br /&gt;
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Configuration_settings Configuration settings list]&lt;br /&gt;
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]&lt;br /&gt;
* [https://lists.wikimedia.org/mailman/listinfo/mediawiki-announce MediaWiki release mailing list]&lt;br /&gt;
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation#Translation_resources Localise MediaWiki for your language]&lt;br /&gt;
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Combating_spam Learn how to combat spam on your wiki]&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=WebKit_Users_Guide&amp;diff=2549</id>
		<title>WebKit Users Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=WebKit_Users_Guide&amp;diff=2549"/>
		<updated>2026-03-19T16:52:56Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: Rsalter moved page WebKit Users Guide to NuWebKit Users Guide: Change of app name&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[NuWebKit Users Guide]]&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=NuWebKit_Users_Guide&amp;diff=2548</id>
		<title>NuWebKit Users Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=NuWebKit_Users_Guide&amp;diff=2548"/>
		<updated>2026-03-19T16:52:56Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: Rsalter moved page WebKit Users Guide to NuWebKit Users Guide: Change of app name&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;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.&amp;lt;ref&amp;gt;This API is under development.&amp;lt;/ref&amp;gt; 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Terminology ==&lt;br /&gt;
; Model&lt;br /&gt;
: 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.&lt;br /&gt;
&lt;br /&gt;
;Simulation&lt;br /&gt;
: A model in execution. Simulations are managed from the UI.&lt;br /&gt;
&lt;br /&gt;
;Spatial (Sp) and Individual-based (IB) models&lt;br /&gt;
: 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 &amp;quot;wrap-around&amp;quot; horizontally and vertically to create a torus. In many simulations with fixed boundaries, agents &amp;quot;bounce off&amp;quot; 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 site's author, and in some cases may be overridden.&lt;br /&gt;
&lt;br /&gt;
;System Dynamics (SD) &lt;br /&gt;
: The behavior of SD models over time can often be characterized using differential or difference equations. An SD model might be the entirety of site, or might characterize the local behavior of a cell or agent in Sp and IB models.&lt;br /&gt;
&lt;br /&gt;
;Project&lt;br /&gt;
: A single unit deploying 1 or more simulations, usually employing a single Web page. Projects are specified using a '''project file''', containing [https://www.json.org/json-en.html JSON] code detailing the UI and at least providing parameters for the model. Small SD models may be specified in the project file.&lt;br /&gt;
&lt;br /&gt;
;Site&lt;br /&gt;
:The Webpage or pages associated with a particular project.&lt;br /&gt;
&lt;br /&gt;
;&amp;quot;Factory Settings&amp;quot;&lt;br /&gt;
: Sites are uploaded with parameters and settings determined by the author. Users may change parameters and override some setting, however factory settings can always be recovered.&lt;br /&gt;
&lt;br /&gt;
;&amp;quot;The Drawer&amp;quot;&lt;br /&gt;
: 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.&lt;br /&gt;
&lt;br /&gt;
;Presets&lt;br /&gt;
: NWK provides a storage facility to record and recall various choices for settings and parameters. The presets are like &amp;quot;radio buttons&amp;quot; selecting various alternative sets of configurations.&lt;br /&gt;
&lt;br /&gt;
;RAMs&lt;br /&gt;
: 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).&lt;br /&gt;
&lt;br /&gt;
;NuML&lt;br /&gt;
: NuML (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.&lt;br /&gt;
&lt;br /&gt;
;Analysis Platforms&lt;br /&gt;
:These are special tabs used in some sites to enable such facilities as sensitivity analysis, curve fitting, MCMC, etc.&lt;br /&gt;
&lt;br /&gt;
;CSV&lt;br /&gt;
:This refers to the option of saving data from a graph to a comma separated list.&lt;br /&gt;
&lt;br /&gt;
== Platform Overview==&lt;br /&gt;
[[File:ui0.png|thumb|NWK User Interface]]&lt;br /&gt;
This image shows the browser window running the sample individual-based site [https://www.cs.oberlin.edu/~rms/wk/rps/ &amp;quot;Rock Paper Scissors&amp;quot;]. The features are all described later in this guide.&lt;br /&gt;
;Model Inputs&lt;br /&gt;
:These sliders set parameters for the simulation. Changes are forwarded even while the simulation is running and may have immediate effect.&lt;br /&gt;
;Timers&lt;br /&gt;
: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.&lt;br /&gt;
;Operating Buttons&lt;br /&gt;
: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.&lt;br /&gt;
: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.&lt;br /&gt;
[[File:ui1.png|thumb|UI With Drawer Opened]]&lt;br /&gt;
;Speed Control&lt;br /&gt;
:This determines the real-time interval between steps. &lt;br /&gt;
;Displays&lt;br /&gt;
:A spatial or agent-based simulation will include a &amp;quot;SimWorld&amp;quot; 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.&lt;br /&gt;
:Other displays such as Spys (showing a single current value) graphs, tables, etc. are specified in the Project file (see below).&lt;br /&gt;
;Side Panel&lt;br /&gt;
:The browser page has a side panel contained in a &amp;quot;drawer&amp;quot;. Use [[File:sideicon.png]] 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 site uses RAMs the side panel will be wider and will contain access to RAM controls.&lt;br /&gt;
[[File:ui2.png|thumb|UI with SD Model]]&lt;br /&gt;
;System Dynamics&lt;br /&gt;
:The third image shows the model library SD [https://www.cs.oberlin.edu/~rms/wk/lotka Lotka-Volterra] site. An SD site will display the current choices for ''dt'' and integration method (Euler or RK4). These can be overridden from factory settings using the configuration window.&lt;br /&gt;
&amp;lt;br clear='both'&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In subsequent sections we describe the platform's features with illustrations using one or more of the sites 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.&lt;br /&gt;
&lt;br /&gt;
'''When opening the Model Library examples you are advised to right-click and open the link in a new tab.'''&lt;br /&gt;
&lt;br /&gt;
Among the topics covered are:&lt;br /&gt;
* User initialization of spatial and agent-based models&lt;br /&gt;
* Presets&lt;br /&gt;
* NuML language&lt;br /&gt;
* RAMS and URAMS&lt;br /&gt;
* Configuration overrides&lt;br /&gt;
* Analysis platforms&lt;br /&gt;
* Downloading CSVs&lt;br /&gt;
&lt;br /&gt;
== Model Initialization and Using Presets with Conway's Game of Life and Agents (1) ==&lt;br /&gt;
[[File:lifeinit.gif|thumb|Initializing Conway's Game of Life]]&lt;br /&gt;
[[File:agentsinit.gif|thumb|Initializing Agents (1)]]&lt;br /&gt;
[https://www.cs.oberlin.edu/~rms/wk/life/index.html Conway's Game of Life (CGOL)] uses a 128 x 128 board with solid edge and an initial configuration consisting of the &amp;quot;R-pentomino&amp;quot;. (Try it!) CGOL's model operates on a cellular automaton with 2 possible states, dead and alive. &lt;br /&gt;
&lt;br /&gt;
[https://www.cs.oberlin.edu/~rms/wk/agents/index.html 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 site's author.) [https://www.cs.oberlin.edu/~rms/wk/agents1/index.html Agents (1)] has the same model, only initially empty. &lt;br /&gt;
&lt;br /&gt;
With NWK you can:&lt;br /&gt;
* Click and drag to create new initial configurations;&lt;br /&gt;
* Save your configuration in the Presets.&lt;br /&gt;
&lt;br /&gt;
=== Creating new initial configurations in CGOL ===&lt;br /&gt;
&lt;br /&gt;
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. &lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Creating new initial configurations in Agents (1) ===&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
When done, '''double-click''' '''Reset''', and then '''Run'''. To restore factory settings you must reload the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=&amp;quot;both&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Preset Basics ==&lt;br /&gt;
[[File:preset.png|thumb|Preset Control in Drawer Panel]]&lt;br /&gt;
The Preset feature provides a quick way to save and restore a configuration, modeled on the &amp;quot;radio buttons&amp;quot; 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 &amp;quot;green&amp;quot; label will restore the configuration saved in that preset. Selecting a red label has no effect on the configuration.&lt;br /&gt;
&lt;br /&gt;
'''Note that preset 0 is permanently bound to factory settings and cannot be changed'''.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
[[File:presetDemo.gif|thumb|Preset Control in Main Control Panel]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
Presets are stored in the Web browser and will be there when you return to the site. 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.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Something to try&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== One more thing about Presets ===&lt;br /&gt;
Some site include ready-made presets. These will be installed the first time you access the site. 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 site.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=&amp;quot;both&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Using RAMs with the Extended Game of Life 3 (EGOL3) ==&lt;br /&gt;
[[File:egol3.png|thumb|Extended Game of Life Showing RAM Panel]]&lt;br /&gt;
[[File:egol3RAM.gif|thumb|Preset Selection Showing RAM Choices]]&lt;br /&gt;
RAMs provide the means for changing some aspect of the site's 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.&lt;br /&gt;
&lt;br /&gt;
[https://www.biorxiv.org/content/10.1101/2022.08.30.505937v1 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).&lt;br /&gt;
&lt;br /&gt;
The RAM Selection Panel appears whenever a site 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).&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The '''Display''' RAM setting is analogous to the conventional GOL we explored earlier. You can set your own initial configuration through click and drag like before. The '''Random''' setting lets you choose the probabilities for initial live cells. '''Reg6''' and '''Reg Custom''' produce diagonal stripes that repeat with, respectively, a fixed interval of 6 or with an interval between 2 and 12.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Something to try&lt;br /&gt;
&lt;br /&gt;
Make changes to the existing presets. When editing a textfield input, be sure to hit '''Enter''' when you are ready to register the change. Save configurations in any of the remaining empty presets, or override the factory presets (except for Preset 0).&lt;br /&gt;
&lt;br /&gt;
When you are done you can restore the initial preset configuration by deleting ''all'' presets with '''Cl All''' and then reloading.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Using RAMs with the Deterministic SIRS w/ Vaccination (SIRS) ==&lt;br /&gt;
SIRS is rich with RAMs with one ('''Immune to Vaccinated''') containing an alternative ('''User Input''') requiring code. This alternative lets you program how individuals in class R (recovering) are vaccinated and transferred to class V (vaccinated), as a function of model time. A set of variables that can be referenced in the code is provided.&lt;br /&gt;
&lt;br /&gt;
An example is contained in Preset 1. Here we choose to use apply the vaccination rate from the vaccination onset time (both set with the main input sliders) to a time determined using the RAM slider '''User 1'''. In other words, you add a shut-off time for vaccinations which has not been provided by the original model. Other possibilities for this RAM could be, for example, to let the vaccination rate decay to account for depletion of vaccine, using the '''User 1''' slider to determine the decay rate.&lt;br /&gt;
&lt;br /&gt;
The code used in Preset 1 is Javascript. Press the '''Compile''' button when your are ready. The '''Enlarge''' button opens a browser-wide editor window, making code entry easier. If you want to try your own User Input RAM, be sure to save in a preset or your code will be lost.&lt;br /&gt;
&lt;br /&gt;
== User-Defined Models (URAMs) with Sensitivity Analysis ==&lt;br /&gt;
&lt;br /&gt;
The RAM interface makes it possible to easily implement SD simulations defined entirely by the user. An example from the model library containing 4 user-defined presets is [https://www.cs.oberlin.edu/~rms/wk/sdnumml1/index.html SD User Defined]. &lt;br /&gt;
&lt;br /&gt;
Such sites are initially defined only by the input and output components they support. Their operation relies on a user-defined program, specifying the model and its UI, that is entered using a RAM. The example site has a RAM with one option, that option showing a text area for the program. It also provides sufficient input and output components to support the UI needs of models implemented on the site.&lt;br /&gt;
&lt;br /&gt;
The example site includes 6 slider inputs, a line graph and a phase graph. Each of these 8 components need a &amp;quot;handle&amp;quot;, an ID by which they can be referenced in the program. The sliders all run from 0 to 1 with 0.01 step size and have the IDs &amp;lt;code&amp;gt;Param1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Param2&amp;lt;/code&amp;gt;..., &amp;lt;code&amp;gt;Param6&amp;lt;/code&amp;gt;. The line and phase graphs are respectively given IDs &amp;lt;code&amp;gt;mainGraph&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;phaseGraph&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Visit the model using the link and open the '''Model Definition''' RAM. It contains a single option ('''NuML Code''') with a Code text area. Notice that, although 6 sliders were allotted, only 1 is visible in the default preset. This is a result of the UI configuration contained in the program. As you step through presets note that the input sliders appear and disappear as needed, and that slider and graph legends (names and titles) change to suit the model.&lt;br /&gt;
&lt;br /&gt;
Consider the code for the default Exponential Curve model:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
[[File:expocode.png|400px|Code for Exponential Model]]&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The first line consists of the string &amp;quot;numml&amp;quot;. This is required to indicate that the contents are in NuML rather than Javascript. There are 2 sections: '''model''' and '''configurations'''. (Note that &amp;quot;//&amp;quot; is the comment character meaning that this line is ignored by the compiler).  In the model section are 4 statements using the operator &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;. In fact, each NuML statement uses Javascript syntax, but with 2 non-Javascript operators:  &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt;, which completely program the behavior and look and feel of the simulation. The former is used to specify the model generally in terms of differential (or difference) equations using program variables; the latter asserts properties for the visual components that fit with the particular model&lt;br /&gt;
&lt;br /&gt;
The first block (lines 4 - 8) consists of 3 statements defining the variable of interest, &amp;lt;code&amp;gt;Exp&amp;lt;/code&amp;gt;, and one defining an auxiliary variable &amp;lt;code&amp;gt;Rate&amp;lt;/code&amp;gt; used in line 4. The latter is not entirely necessary; we could instead have written line 4 as &amp;lt;code&amp;gt;deriv(Exp) @= Param1 * Exp&amp;lt;/code&amp;gt;, however the style we used relates the model directly to relabeling of the &amp;lt;code&amp;gt;Param1&amp;lt;/code&amp;gt; slider to &amp;lt;code&amp;gt;Rate&amp;lt;/code&amp;gt; and consequently is more readable. We will continue to see this approach used in the other models in this site.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;deriv(Exp)&amp;lt;/code&amp;gt; specifies a differential equation on line 4 relating &amp;lt;code&amp;gt;Exp&amp;lt;/code&amp;gt; to itself and local variable &amp;lt;code&amp;gt;Rate&amp;lt;/code&amp;gt;. Line 8 binds &amp;lt;code&amp;gt;Rate&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;Param1&amp;lt;/code&amp;gt;, which is the alias we assign to &amp;lt;code&amp;gt;Param1&amp;lt;/code&amp;gt; on line 14. Line 5 provides an initial value for &amp;lt;code&amp;gt;Exp&amp;lt;/code&amp;gt;, and line 6 links &amp;lt;code&amp;gt;Exp&amp;lt;/code&amp;gt; with the line graph &amp;lt;code&amp;gt;mainGraph&amp;lt;/code&amp;gt;, which displays its output..&lt;br /&gt;
&lt;br /&gt;
Lines 11 through 16 use operator &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; to detail the appearance of the input sliders and output graphs. This is mostly self- explanatory, except for the entry for &amp;lt;code&amp;gt;statsGraph&amp;lt;/code&amp;gt;, which will be discussed below. This code is not required, however the result will be a generic display with 6 input sliders labeled &amp;lt;code&amp;gt;Param1&amp;lt;/code&amp;gt; through &amp;lt;code&amp;gt;Param6&amp;lt;/code&amp;gt;, and graphs with no labels. Note that on line 16, setting the legend for the unused sliders to an empty string hides them. &lt;br /&gt;
&lt;br /&gt;
Look at the remaining preset code. Preset 3, in particular, is a good example of the extent to which input sliders can be detailed. This is required because the generic slider properties do not match the value range required in the simulation. Refer to the [[NuML Language Reference]] for a complete description of the NuML language.&lt;br /&gt;
&lt;br /&gt;
'''If you make changes to any of these that you want to save to presets, you should compile before saving so that the compiled code will be loaded when you activate the preset.'''&lt;br /&gt;
&lt;br /&gt;
=== Sensitivity Analysis ===&lt;br /&gt;
&lt;br /&gt;
One of the goals of NWK is to provide secondary platforms for optimization and analysis. To date one such platform exists to perform sensitivity analysis, primarily but not exclusively for SD models. Once again, refer to [https://www.cs.oberlin.edu/~rms/wk/sdnumml1/index.html SD User Defined] to see this in action. Open this site and click on the tab labeled '''Sensitivity'''.&lt;br /&gt;
&lt;br /&gt;
[[File:sens0.png|thumb|Sensitivity Analysis Platform after a run]]&lt;br /&gt;
The figure show on the right shows the Sensitivity Analysis platform for the logistic model (Preset 1) after a run. There are 4 user parameters that govern the behavior as shown:&lt;br /&gt;
&lt;br /&gt;
* '''Parameter''': which parameter is varied (in this model it is '''Rate''').&lt;br /&gt;
* '''Runs''': how many runs (20); &lt;br /&gt;
* '''From''': initial value (0.25);&lt;br /&gt;
* '''To''': final value (0.54);&lt;br /&gt;
&lt;br /&gt;
Clicking '''Start''' initiates 20 runs with the '''Rate''' parameter uniformly stepping through intermediate values between 0.25 and 0.54. During this run, clicking '''Stop''' allows the most recent run to finish, allowing the process to continue by subsequently clicking '''Start'''. Alternatively, clicking '''Step''' proceeds one run at a time until the process concludes. Double-clicking '''Reset''' reinitializes the run.&lt;br /&gt;
&lt;br /&gt;
Results are displayed on 2 graphs, the first being identical to the one on the '''Run''' platform. To its right is a graph showing mean &amp;amp;#177; standard deviation of the point-wise variations seen in the run.&lt;br /&gt;
&lt;br /&gt;
Now open the '''Model Definition''' RAM and look at the code in lines 12 - 15 to see how the Sensitivity Analysis platform was programmed. The statistics display has ID ''statsGraph''. In addition to specifying a title (&amp;quot;Logistic Statistics&amp;quot;), we see the following entries:&lt;br /&gt;
;statDat(N)&lt;br /&gt;
:''N'' is output variable of interest&lt;br /&gt;
;statParam(Rate)&lt;br /&gt;
:''Rate'' is the input parameter to be varied&lt;br /&gt;
;statRuns(20), statLo(0.25), statHi(0.54)&lt;br /&gt;
:20 runs with ''Rate'' varying uniformly between 0.25 and 0.54&lt;br /&gt;
Note that except for '''statDat''', these settings are shown in textfields and merely initialize their parameters. They can be changed, and changes are saved to presets.&lt;br /&gt;
&lt;br /&gt;
== Configuration Overrides ==&lt;br /&gt;
[[File:config.png|thumb|Configuration Window]]&lt;br /&gt;
NuML statements using &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; can be used to configure most models using the Configuration window below the Preset selection window. Shown at right is an override of the factory settings that changes the ''dt'' value and asserts Euler as the integration method. Other overrides will become available soon.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;both&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== CSV Downloads ==&lt;br /&gt;
If a graph contains a '''CSV''' button, clicking that button once the graph has been filled will bring about a download of a CSV (comma separate values) file of the data from that graph. The settings used by the simulation will be recorded above the CSV header.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=&amp;quot;both&amp;quot;&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=Example_WebKit_Models&amp;diff=2547</id>
		<title>Example WebKit Models</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=Example_WebKit_Models&amp;diff=2547"/>
		<updated>2026-03-19T16:52:26Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: Rsalter moved page Example WebKit Models to Example NuWebKit Models: Change of app name&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Example NuWebKit Models]]&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=Example_NuWebKit_Models&amp;diff=2546</id>
		<title>Example NuWebKit Models</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=Example_NuWebKit_Models&amp;diff=2546"/>
		<updated>2026-03-19T16:52:25Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: Rsalter moved page Example WebKit Models to Example NuWebKit Models: Change of app name&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;These models illustrate the NuWebKit modeling technology. To use, load the model into your browser and click '''Connect''' to initialize the model. This will enable the other 4 buttons: '''Disconnect''', '''Reset''', '''Step''' and '''Start'''. Use the '''Start/Stop''' button to run the program continuously. '''Step''' single-steps the program. '''Reset''' returns to the beginning. A '''Double-Reset''' reinitializes the simulation. You can also reinitialize with '''Disconnect/Connect''', or simply reloading the web page. See the [[WebKit Users Guide]] for complete documentation.&lt;br /&gt;
&lt;br /&gt;
Be aware of the side panel, which you open and close by clicking on the side panel icon, [[File:sideicon.png]], and adjust using the purple stripe. This panel contains documentation, preset control and RAM access.&lt;br /&gt;
&lt;br /&gt;
NetLogo is an established platform for implementing agent-based models. NuWebKit uses an API analogous to that of NetLogo, keeping the &amp;quot;Patches&amp;quot; and &amp;quot;Turtles&amp;quot; nomenclature and making the translation from NetLogo the NuWebKit straightforward. Many of the agent-based models in this collection were derived from the NetLogo model library. All such examples include NetLogo documentation, which for now serves to describe the model but may not totally match the NuWebKit implementation. &lt;br /&gt;
&lt;br /&gt;
===Numerus Originals===&lt;br /&gt;
&lt;br /&gt;
* [https://www.cs.oberlin.edu/~rms/wk/egol3/index.html Three State Extended Game of Life]&lt;br /&gt;
:A 3-state extended version of Conway's Game of Life (GoL). The mathematical equations behind this GoL are described in a paper that can be downloaded at [https://www.biorxiv.org/content/10.1101/2022.08.30.505937v1 mathRxiv]. Click through the 8 presets to view different starting configurations, and feel free to save your own interesting discoveries in unused presets. This model is a focus of the [[WebKit Users Guide]] as an example that makes extensive use of the RAM and preset features.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sirsdet/index.html SIRS WebKit App]&lt;br /&gt;
:Fully developed platform for teaching the SIRS Model. Documented extensively [https://e56600a52a1b6dbf8d29-34f1371aa433cd9fb9d20baa556ed72a.ssl.cf1.rackcdn.com/webapps/webkit/EPI_LESSONS.pdf here].&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sirsdtvdet/index.html Deterministic SIRS with Vaccinations]&lt;br /&gt;
:A mass-action SIRS model with vaccinations described in the publication [https://doi.org/10.1101/2022.02.09.22270752 Simulation Platforms to Support Teaching and Research in Epidemiological Dynamics]. This app was merged into the previous example to create a fully developed platform for teaching the SIRS model.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sirsdtvsto/index.html Stochastic SIRS with Vaccinations]&lt;br /&gt;
:A stochastic version of the previous model. See [https://doi.org/10.1101/2022.02.09.22270752 Simulation Platforms to Support Teaching and Research in Epidemiological Dynamics]&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sdsir/index.html SD SIR]&lt;br /&gt;
:A simple mass-action SIR model demonstrating the WebKit Sensitivity analysis platform.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sdnumml1/index.html SD User Defined]&lt;br /&gt;
:An app in which the user programs the model. Discussed extensively in the [[WebKit Users Guide]].&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/agents/index.html Agents]&lt;br /&gt;
:Simple agent motion.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/ani2/index.html Animover 2]&lt;br /&gt;
: '''Animover''' is a model of a group of agents foraging in an area for a food resource. Animover 2 is a preliminary version. It is the most complex WebKit simulation to date, with several thousand lines of code required to implement the model logic.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/forest/index.html Forest]&lt;br /&gt;
:Cell automata model depicting a forest fire.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/life/index.html Life]]&lt;br /&gt;
:Conway's Game of Life. Enough said. See the [[WebKit Users Guide]] to learn how to initialize the starting configuration.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/lifeagents/index.html Life Agents]&lt;br /&gt;
:Game of Life with agent motion. An agent passing over a live cell colors the cell with the agent's color.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/lorenz/index.html Lorenz Attractor]&lt;br /&gt;
:The Lorenz system is a system of ordinary differential equations first studied by mathematician and meteorologist Edward Lorenz. It is notable for having chaotic solutions for certain parameter values and initial conditions. The term &amp;quot;butterfly effect&amp;quot; in popular media may stem from the real-world implications of the Lorenz attractor, namely that tiny changes in initial conditions evolve to completely different trajectories. &lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/lotka/index.html Lotka-Volterra Model]&lt;br /&gt;
:Shows both time and phase graphs.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/mongoose/index.html Mongoose Behavior] &lt;br /&gt;
:Companion to &amp;quot;Computational Assessment of Population Resilience Mechanisms in the Banded Mongoose (Mungos mungo) of Northern Botswana&amp;quot; (manuscript in progress).&lt;br /&gt;
&lt;br /&gt;
===NetLogo Translations===&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/antz/index.html Ants]&lt;br /&gt;
:NetLogo model. A colony of ants forages for food. Though each ant follows a set of simple rules, the colony as a whole acts in a sophisticated way.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/diffuse/index.html Diffusion]&lt;br /&gt;
:NetLogo diffusion example. Diffusion Graphics is unlike most other NetLogo models, in that it really doesn’t ‘model’ anything. It simply explores the power behind an interesting patch primitive: ‘diffuse’.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/dla/index.html Diffusion Limited Aggregration]&lt;br /&gt;
:This model demonstrates diffusion-limited aggregation, in which randomly moving (diffusing) particles stick together (aggregate) to form beautiful treelike branching fractal structures. There are many patterns found in nature that resemble the patterns produced by this model: crystals, coral, fungi, lightning, and so on.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/flock/index.html Flock]&lt;br /&gt;
:NetLogo model showing the flocking of birds. The resulting motion also resembles schools of fish.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/fng/index.html Fungal Growth]&lt;br /&gt;
:NetLogo model showing the spread of fungal hyphae throughout a section of earth in which moisture is spreading.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/follower/index.html Follower]&lt;br /&gt;
:NetLogo model. In Follower, turtles attempt to “connect” with other turtles, forming long chains according to a small set of simple rules.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/fworks/index.html Fireworks]&lt;br /&gt;
:NetLogo model. This program models the action of fireworks. Rockets begin at the bottom of the view, shoot upwards into the sky and then explode, emitting showers of falling sparks. Works best at lower speed.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/river/index.html Meandering River]&lt;br /&gt;
:Netlogo Model. This model demonstrates the meandering of a river along its “middle course”, where the gradient of the landscape is gradual and the river runs within a U-shaped river valley. The evolution of the shape of the river is governed by the path of its highest-velocity flow, as well as erosion and deposition.&lt;br /&gt;
:This example has documentation extracted from the Netlogo version. Click the icon on the top-right of the page.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/rps/index.html Rock Paper Scissors]&lt;br /&gt;
:NetLogo Model. This model explores the role of movement and space in a three species ecosystem. The system consists of three species, represented by red patches, green patches, and blue patches, which compete over space. The interactions between the species are based on the game Rock-Paper-Scissors. That is, red beats green, green beats blue, and blue beats red. Organisms compete with their neighbors, move throughout the environment, and reproduce. These interactions result in spiral patterns whose size and stability depends on the movement rate of the organisms.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/wolfsheep/index.html Wolf Sheep Predation]&lt;br /&gt;
:NetLogo Model. A population of sheep that wander around the landscape. For each step the sheep take it costs them some energy and if there energy gets too low they die. However, the sheep can eat grass in the environment to regain energy and the grass regrows over time. If the energy of the sheep gets above a certain level then they can reproduce. There are also wolves that have the same behaviors as sheep except for eating; rather than grass, they eat sheep.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/wvmach/index.html Wave Machine]&lt;br /&gt;
:Netlogo Model. This model simulates wave motion in a membrane. The four edges of the membrane are fixed to a frame. A green rectangular area represents a driver plate that moves up and down, exhibiting sinusoidal motion.&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=Example_NuWebKit_Models&amp;diff=2545</id>
		<title>Example NuWebKit Models</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=Example_NuWebKit_Models&amp;diff=2545"/>
		<updated>2026-03-19T16:52:03Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;These models illustrate the NuWebKit modeling technology. To use, load the model into your browser and click '''Connect''' to initialize the model. This will enable the other 4 buttons: '''Disconnect''', '''Reset''', '''Step''' and '''Start'''. Use the '''Start/Stop''' button to run the program continuously. '''Step''' single-steps the program. '''Reset''' returns to the beginning. A '''Double-Reset''' reinitializes the simulation. You can also reinitialize with '''Disconnect/Connect''', or simply reloading the web page. See the [[WebKit Users Guide]] for complete documentation.&lt;br /&gt;
&lt;br /&gt;
Be aware of the side panel, which you open and close by clicking on the side panel icon, [[File:sideicon.png]], and adjust using the purple stripe. This panel contains documentation, preset control and RAM access.&lt;br /&gt;
&lt;br /&gt;
NetLogo is an established platform for implementing agent-based models. NuWebKit uses an API analogous to that of NetLogo, keeping the &amp;quot;Patches&amp;quot; and &amp;quot;Turtles&amp;quot; nomenclature and making the translation from NetLogo the NuWebKit straightforward. Many of the agent-based models in this collection were derived from the NetLogo model library. All such examples include NetLogo documentation, which for now serves to describe the model but may not totally match the NuWebKit implementation. &lt;br /&gt;
&lt;br /&gt;
===Numerus Originals===&lt;br /&gt;
&lt;br /&gt;
* [https://www.cs.oberlin.edu/~rms/wk/egol3/index.html Three State Extended Game of Life]&lt;br /&gt;
:A 3-state extended version of Conway's Game of Life (GoL). The mathematical equations behind this GoL are described in a paper that can be downloaded at [https://www.biorxiv.org/content/10.1101/2022.08.30.505937v1 mathRxiv]. Click through the 8 presets to view different starting configurations, and feel free to save your own interesting discoveries in unused presets. This model is a focus of the [[WebKit Users Guide]] as an example that makes extensive use of the RAM and preset features.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sirsdet/index.html SIRS WebKit App]&lt;br /&gt;
:Fully developed platform for teaching the SIRS Model. Documented extensively [https://e56600a52a1b6dbf8d29-34f1371aa433cd9fb9d20baa556ed72a.ssl.cf1.rackcdn.com/webapps/webkit/EPI_LESSONS.pdf here].&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sirsdtvdet/index.html Deterministic SIRS with Vaccinations]&lt;br /&gt;
:A mass-action SIRS model with vaccinations described in the publication [https://doi.org/10.1101/2022.02.09.22270752 Simulation Platforms to Support Teaching and Research in Epidemiological Dynamics]. This app was merged into the previous example to create a fully developed platform for teaching the SIRS model.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sirsdtvsto/index.html Stochastic SIRS with Vaccinations]&lt;br /&gt;
:A stochastic version of the previous model. See [https://doi.org/10.1101/2022.02.09.22270752 Simulation Platforms to Support Teaching and Research in Epidemiological Dynamics]&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sdsir/index.html SD SIR]&lt;br /&gt;
:A simple mass-action SIR model demonstrating the WebKit Sensitivity analysis platform.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sdnumml1/index.html SD User Defined]&lt;br /&gt;
:An app in which the user programs the model. Discussed extensively in the [[WebKit Users Guide]].&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/agents/index.html Agents]&lt;br /&gt;
:Simple agent motion.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/ani2/index.html Animover 2]&lt;br /&gt;
: '''Animover''' is a model of a group of agents foraging in an area for a food resource. Animover 2 is a preliminary version. It is the most complex WebKit simulation to date, with several thousand lines of code required to implement the model logic.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/forest/index.html Forest]&lt;br /&gt;
:Cell automata model depicting a forest fire.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/life/index.html Life]]&lt;br /&gt;
:Conway's Game of Life. Enough said. See the [[WebKit Users Guide]] to learn how to initialize the starting configuration.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/lifeagents/index.html Life Agents]&lt;br /&gt;
:Game of Life with agent motion. An agent passing over a live cell colors the cell with the agent's color.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/lorenz/index.html Lorenz Attractor]&lt;br /&gt;
:The Lorenz system is a system of ordinary differential equations first studied by mathematician and meteorologist Edward Lorenz. It is notable for having chaotic solutions for certain parameter values and initial conditions. The term &amp;quot;butterfly effect&amp;quot; in popular media may stem from the real-world implications of the Lorenz attractor, namely that tiny changes in initial conditions evolve to completely different trajectories. &lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/lotka/index.html Lotka-Volterra Model]&lt;br /&gt;
:Shows both time and phase graphs.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/mongoose/index.html Mongoose Behavior] &lt;br /&gt;
:Companion to &amp;quot;Computational Assessment of Population Resilience Mechanisms in the Banded Mongoose (Mungos mungo) of Northern Botswana&amp;quot; (manuscript in progress).&lt;br /&gt;
&lt;br /&gt;
===NetLogo Translations===&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/antz/index.html Ants]&lt;br /&gt;
:NetLogo model. A colony of ants forages for food. Though each ant follows a set of simple rules, the colony as a whole acts in a sophisticated way.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/diffuse/index.html Diffusion]&lt;br /&gt;
:NetLogo diffusion example. Diffusion Graphics is unlike most other NetLogo models, in that it really doesn’t ‘model’ anything. It simply explores the power behind an interesting patch primitive: ‘diffuse’.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/dla/index.html Diffusion Limited Aggregration]&lt;br /&gt;
:This model demonstrates diffusion-limited aggregation, in which randomly moving (diffusing) particles stick together (aggregate) to form beautiful treelike branching fractal structures. There are many patterns found in nature that resemble the patterns produced by this model: crystals, coral, fungi, lightning, and so on.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/flock/index.html Flock]&lt;br /&gt;
:NetLogo model showing the flocking of birds. The resulting motion also resembles schools of fish.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/fng/index.html Fungal Growth]&lt;br /&gt;
:NetLogo model showing the spread of fungal hyphae throughout a section of earth in which moisture is spreading.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/follower/index.html Follower]&lt;br /&gt;
:NetLogo model. In Follower, turtles attempt to “connect” with other turtles, forming long chains according to a small set of simple rules.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/fworks/index.html Fireworks]&lt;br /&gt;
:NetLogo model. This program models the action of fireworks. Rockets begin at the bottom of the view, shoot upwards into the sky and then explode, emitting showers of falling sparks. Works best at lower speed.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/river/index.html Meandering River]&lt;br /&gt;
:Netlogo Model. This model demonstrates the meandering of a river along its “middle course”, where the gradient of the landscape is gradual and the river runs within a U-shaped river valley. The evolution of the shape of the river is governed by the path of its highest-velocity flow, as well as erosion and deposition.&lt;br /&gt;
:This example has documentation extracted from the Netlogo version. Click the icon on the top-right of the page.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/rps/index.html Rock Paper Scissors]&lt;br /&gt;
:NetLogo Model. This model explores the role of movement and space in a three species ecosystem. The system consists of three species, represented by red patches, green patches, and blue patches, which compete over space. The interactions between the species are based on the game Rock-Paper-Scissors. That is, red beats green, green beats blue, and blue beats red. Organisms compete with their neighbors, move throughout the environment, and reproduce. These interactions result in spiral patterns whose size and stability depends on the movement rate of the organisms.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/wolfsheep/index.html Wolf Sheep Predation]&lt;br /&gt;
:NetLogo Model. A population of sheep that wander around the landscape. For each step the sheep take it costs them some energy and if there energy gets too low they die. However, the sheep can eat grass in the environment to regain energy and the grass regrows over time. If the energy of the sheep gets above a certain level then they can reproduce. There are also wolves that have the same behaviors as sheep except for eating; rather than grass, they eat sheep.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/wvmach/index.html Wave Machine]&lt;br /&gt;
:Netlogo Model. This model simulates wave motion in a membrane. The four edges of the membrane are fixed to a frame. A green rectangular area represents a driver plate that moves up and down, exhibiting sinusoidal motion.&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=NuWebKit&amp;diff=2544</id>
		<title>NuWebKit</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=NuWebKit&amp;diff=2544"/>
		<updated>2026-03-19T16:50:01Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Numerus WebKit (NuWebKit) 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), but using conventional languages such as Java, JavaScript (JS) and Python.&amp;lt;ref&amp;gt;This API is under development.&amp;lt;/ref&amp;gt; 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.&lt;br /&gt;
&lt;br /&gt;
NuWebKit uses the D3 JavaScript library for rendering high quality dynamic visualizations.&lt;br /&gt;
&lt;br /&gt;
This document describes the NuWebKit architecture, APIs and applications. Tutorials, documents describing example models, and a complete user manual, are forthcoming. Click [[WebKit Examples|here]] to access NuWebKit examples.&lt;br /&gt;
&lt;br /&gt;
== NuWebKit Concepts ==&lt;br /&gt;
A simulation program is a system that maintains a global state that evolves over time. A simulation is starts in some initial state, and incurs state changes following successive strobes from an external source (which we call the '''clock'''). The state may consist of a single data value or multiple data values mapped out over the internal structure of the simulation. An example of the former is a simple simulation of exponential growth, where the current population is the only value of interest. The latter is exemplified by a spatial or agent based model where simulation state is distributed over individual agents or cells. At each time step the state change algorithm determines the new state from the current and possibly past states of the system. As the simulation runs, the user is presented with displays that illustrate the simulation's state. Time in a simulation is measured in clock ticks which may be mapped to model-time values. A simulation may run for a fixed interval, or may operate in an unbounded time frame.&lt;br /&gt;
&lt;br /&gt;
A ''spatial'' simulation models a domain of cells or network nodes organized topologically as a tesselation of 2- or 3-dimensional space, in a Cartesian, or, possibly, hexagonal lattice. Cells have a fixed location and one intrinsically allocated state value, a real number which is associated with a color.&lt;br /&gt;
&lt;br /&gt;
In an agent-, or individual-based model, agents exist in the space defined by the spatial topology and are mobile. In addition to location, their intrinsic state values include color and size. Optionally, speed and direction (&amp;quot;theta&amp;quot;&amp;lt;ref&amp;gt;&amp;quot;phi&amp;quot; values are also intrinsic for 3-d models&amp;lt;/ref&amp;gt;) values can be assigned that direct movement. We use the term ''SimWorld'' to refer to the combined cell/agent universe.&lt;br /&gt;
&lt;br /&gt;
The NuWebKit platform uses a Web browser to create a ''presentation'' of the simulation to the user. The presentation is separate from the model logic that determines the state evolution of the program, even when both are running on the client. When client and server are both used to execute a simulation, a WebSocket facilitates communication between the presentation and model logic. Consequently, the user must first connect the presentation to the model logic. This step is maintained even for client-side-only deployment, for the sake of uniformity. Disconnecting and reconnecting is a simple and reliable way of restarting a session.&lt;br /&gt;
&lt;br /&gt;
To assist with model creation NuWebKit provides a '''Project Manager''' application. Using this, the programmer creates a Project '''blueprint''', essentially a file containing the Project DNA, stored separately from the project directories. The Project Manager reads this file and first parses the JSON contained in the blueprint to weed out any errors. Once a blueprint is correct, the Project Manager creates directory structures for the project, adds the project DNA file constructed from the blueprint, and inserts runnable but empty Java or JS source files for the model logic. As the project develops, changes may be made to the actual project DNA to fine tune the application. The Project Manager also has a function for retrieving deployed Project DNA files and correcting the blueprint, so that using the workflow recommended in a later section, the blueprint will always be current.&lt;br /&gt;
&lt;br /&gt;
We next explore simulation programs from the point of view of the user, and then discuss how these programs are organized architecturally and in terms of their model logic.&lt;br /&gt;
&lt;br /&gt;
=== User Experience ===&lt;br /&gt;
[[File:app.png|thumb|NuWebKit User Interface]]&lt;br /&gt;
This image shows the browser window running the sample agent-based application &amp;quot;Rock Paper Scissors&amp;quot;, with the following features:&lt;br /&gt;
;Model Inputs&lt;br /&gt;
:These sliders set parameters for the simulation. Changes are forwarded even while the simulation is running and my have immediate effect.&lt;br /&gt;
;Timers&lt;br /&gt;
: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.&lt;br /&gt;
;Operating Buttons&lt;br /&gt;
:The '''Connect/Disconnect''' buttons activate/deactivate the WebSocket, with the '''Connect''' button initializing the application. (Note that this functionality is maintained in the JS platform for the sake of uniformity.) Disconnecting and Connecting is one way to restart the application; reloading the page is another.&lt;br /&gt;
: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.&lt;br /&gt;
[[File:browser.png|thumb|Web Page With Side Panel Displayed]]&lt;br /&gt;
;Speed Control&lt;br /&gt;
:This determines the real-time interval between steps. &lt;br /&gt;
;Displays&lt;br /&gt;
:A spatial or agent-based simulation will include a &amp;quot;SimWorld&amp;quot; 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.&lt;br /&gt;
:Other displays such as Spys (showing a single current value) graphs, tables, etc. are specified in the Project file (see below).&lt;br /&gt;
;Side Panel&lt;br /&gt;
:The browser page has a side panel. Use [[File:sideicon.png]] to toggle visibility (you may have to make the browswer wider to see the panel). Currently this side panel contains model documentation and a log window for WebSocket status reports. A dashboard for altering some properties of the displays, such as the dimensions of the SimWorld, is forthcoming.&lt;br /&gt;
&lt;br /&gt;
=== System Architecture ===&lt;br /&gt;
[[File:arch0.png|thumb||Basic Architecture]]&lt;br /&gt;
NuWebKit architecture revolves around 5 major structures. Refer to the diagram on the right to understand the organization of these items.&lt;br /&gt;
;Project&lt;br /&gt;
:The ''Project'' (or Project &amp;quot;DNA&amp;quot;), is a JSON&amp;lt;ref&amp;gt;JSON (JavaScript Object Notation) is a standard format for storing and exchanging data. It's a lightweight, text-based format that's easy to read by humans and machines.&amp;lt;/ref&amp;gt; object contained in a text file, specifying the parameters that configure the elements of both the simulation and the presentation. Details will be given below. If the Project Manager is used to initialize a a project, the programmer first creates a '''blueprint''', essentially the Project DNA file in a separate directory. As mentioned above, the Project Manager uses the blueprint to create a new runnable (but semantically empty) project.&lt;br /&gt;
&lt;br /&gt;
;Presentation&lt;br /&gt;
:The ''Presentation'' supports visualization and user inputs in the browser. This structure is usually constructed directly in the Presentation API from the data contained in the Project JSON object. All elements of the project pertaining to the visualization and input portal required by the project. These include the agent/cell display (the &amp;quot;SimWorld&amp;quot; display), graphs, tables, etc. Specifications for this aspect are almost always covered by the contents of the Project file and require no attention from the model programmer.&amp;lt;ref&amp;gt;There are exceptions. One will be presented in a subsequent example.&amp;lt;/ref&amp;gt;&lt;br /&gt;
;Simulator&lt;br /&gt;
:The ''Simulation'' structure, which contains the &amp;quot;business logic&amp;quot; for the model. This consists of 2 parts:  the simulation API, which defines the data structures and methods used in the model, and the model itself. The simulation API supports the &amp;quot;turtle/patch&amp;quot; abstraction for agent-based models (ABMs), familiar from NL, but contains some additional capabilities, such as a network basis that substitutes for the patch abstraction, and support for system dynamics models using stocks and flows that can integrate with the ABMs. The simulation API is also configured directly by the Project DNA structure. Model designers can focus entirely on the model structure. One crucial property that we will insist be maintained is that changes to all parts of state occur simultaneously. In other words, any algorithm used to determine one part of a new state only relies on the current or past state of itself and any other part of the state, so that the order in which different parts of the state are computed is immaterial to the outcome.&lt;br /&gt;
;Clock&lt;br /&gt;
:''Clock'' refers to an external module that provides signals or ''strobes'' to the simulation for it to update its state. The clock is controlled from the user console in the browser and can be programmed so that the interval between strobes represents a particular interval of model time (called ''dt'').&lt;br /&gt;
;Dispatcher&lt;br /&gt;
:This unit facilitates communication between presentation and simulation elements of the application. When a project is loaded into the browser and communication is established, the dispatcher initializes a new simulator with its required parameters. The dispatcher communicates control signals from the presentation to operate the simulator, and any parameter changes that result from user gestures on sliders, switches or other input components. In response, the simulator uses the dispatcher to forward data (called a ''status report'') to the presentation that it needs to update its visual elements.&lt;br /&gt;
&lt;br /&gt;
==== Architecture in Client/Server and Client/Client Modes ====&lt;br /&gt;
&lt;br /&gt;
Depending upon the language chosen for programming the model, this architecture is mapped out either across the client and server platforms, or is contained entirely in the client.&lt;br /&gt;
&lt;br /&gt;
=====Java Platform=====&lt;br /&gt;
[[File:arch1.png||thumb||Java Architecture]]&lt;br /&gt;
Since Java is not native to the browser, programming the model in Java requires server-side support. We use WebSockets to facilitate communication between server and client. The illustration shows the dispatcher divided into two asynchronous units operating separately with the simulator and the presentation. The WebSocket&amp;lt;ref&amp;gt;There exist a number of tutorials on WebSockets. Here is the [https://en.wikipedia.org/wiki/WebSocket Wikipedia entry].&amp;lt;/ref&amp;gt; is a robust protocol that manages communication with significant fault tolerance. This robustness translates to a highly robust execution environment for the final application.&lt;br /&gt;
&lt;br /&gt;
The preceding remarks also apply to Python or other model logic coding using an appropriate server. Our experience with Java makes use of the Apache Tomcat server and the Eclipse J2EE design platform. Deploying Tomcat applications is particularly easy: the code is archived in a &amp;quot;.war&amp;quot; file and dropped into a Tomcat &amp;quot;webapp&amp;quot; directory (or, in the case of Elastic Beanstalk, uploaded to the server). Subsequent updates simply overwrite the archive. However, an external server is not needed if one installs a local Tomcat server on their computer.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;both&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====JavaScript Platform=====&lt;br /&gt;
[[File:arch2.png||thumb||JavaScript Architecture]]&lt;br /&gt;
The JavaScript platform requires no special server features inasmuch as the entire application is downloaded and run in the client. In this case we maintain the same communication regimen but replace the WebSocket with a local function callback protocol. Consequently the client/server and client/client configurations offer identical structures, which facilitates Numerus' obligation for program maintenance of these platforms. Similarly, activating a local server obviates the need for an external delivery method.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;both&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Model Organization==&lt;br /&gt;
We now provide a summary of the model algorithm for agent-based projects using the Java platform (the JS platform follows the same pattern). The code uses NetLogo terminology ''turtle'' and ''patch'', respectively, in the class names used for agent and cell base and derived classes. A main class given the name specified in the Project blueprint, oversees simulation operation. These 3 classes respectively extend &amp;lt;code&amp;gt;NLTurtle&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;NLPatch&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;NLSimMain&amp;lt;/code&amp;gt;. Each turtle or patch object corresponds to a single agent or cell in the model. The main class has data structures &amp;lt;code&amp;gt;turtles&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; to hold all of these objects. Initializing the simulation causes these data structures to be filled according to the Project DNA.&lt;br /&gt;
&lt;br /&gt;
===Simulation Cycle===&lt;br /&gt;
In spatial and agent-based systems, turtle and patch individuals maintain local state. During a clock cycle these object compute their next state.  Usually each cycle requires one or two ''visits'' to some set of turtles and/or patches, possibly all of them, asking each to compute its next state. This is generally the most computationally intensive part of the cycle. But with efficient design, there are ways to minimize the number of individuals that must be visited, knowing that their states will not change. The base classes have ways to distinguish and control which individuals the cycle must visit, thus greatly improving performance.&lt;br /&gt;
&lt;br /&gt;
Each clock step of the simulation is subdivided as follows:&lt;br /&gt;
&lt;br /&gt;
;Step&lt;br /&gt;
:The next state is computed by the following operations:&lt;br /&gt;
:;Coordinate&lt;br /&gt;
::The main program performs any preliminary action on global data, or on the turtle or patch collections.&lt;br /&gt;
:;Visit&lt;br /&gt;
::Individual patches and turtles compute their next local state.&lt;br /&gt;
;Shift&lt;br /&gt;
:The next state becomes the current state, and the clock is advanced. &lt;br /&gt;
:;Visit&lt;br /&gt;
::Shifting may require a second visit pass.&lt;br /&gt;
;Update&lt;br /&gt;
: Any required cleanup is performed. State data is sent to the browser.&lt;br /&gt;
&lt;br /&gt;
===Stores===&lt;br /&gt;
States are represented using the &amp;lt;code&amp;gt;Store&amp;lt;/code&amp;gt; class, a generic class which can hold any data type. Newly computed states are assigned to the store's &amp;lt;code&amp;gt;next&amp;lt;/code&amp;gt; property. If a store is registered with the main program, the main program will perform the shift from next to current during the '''Shift''' cycle. Turtles and patches have registered stores for properties such as color, size, location, speed, and direction. Additional application-specific stores can be declared and registered. If shifting the store value from next to current is all is required, (and it usually is), a second visit during the shift cycle can be avoided.&lt;br /&gt;
&lt;br /&gt;
===Stocks===&lt;br /&gt;
A special type of store, called a &amp;lt;code&amp;gt;Stock&amp;lt;/code&amp;gt;, is used in system dynamics (SD) settings to model continuous functions. NuWebKit stocks operate like those in well-known system dynamics modeling platforms, such as Stella, Vensim and Berkeley Madonna, using RK4 integration to maintain accuracy. Stocks may be used in a purely SD model, or may be part of the environment modeled in a spatial or agent-based model.&lt;br /&gt;
&lt;br /&gt;
===VisitMode===&lt;br /&gt;
Control of the visit schedule is specified with the VisitMode parameter, in particular the order in which visits to turtles and stocks occurs. As an exception that proves the rule, it may be advantageous to visit turtles before patches, or patches before turtles, and use the newly computed ''next'' values in, say, patches when computing the next state of the turtles, or visa versa. The VisitMode values currently supported are:&amp;lt;br&amp;gt;&lt;br /&gt;
:'''A_C''': turtles before patches&lt;br /&gt;
:'''C_A''': patches before turtles&lt;br /&gt;
:'''A''': turtles only&lt;br /&gt;
:'''C''': patches only&lt;br /&gt;
:'''No''': no visits&lt;br /&gt;
:'''SD''': system dynamics using Euler method integration (no visits)&lt;br /&gt;
:'''SDRK4''': system dynamics using Runge-Kutta&amp;lt;ref&amp;gt;See [https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods Runge-Kutta in the Wikipedia]&amp;lt;/ref&amp;gt; 4 integration (no visits).&lt;br /&gt;
Additional VisitModes may be added as this platform develops.&lt;br /&gt;
&lt;br /&gt;
==Directory Structures==&lt;br /&gt;
===Java Platform===&lt;br /&gt;
[[File:dir0.png||thumb|Java Eclipse Project Directory Structure]]&lt;br /&gt;
[[File:jssite2.png||thumb|JavaScript Presentation API Directory Structure]]&lt;br /&gt;
&lt;br /&gt;
The picture shows the directory structure used by the Java platform, created as a dynamic web project for deployment on Tomcat, by EclipseEE. The project name (&amp;lt;code&amp;gt;WX&amp;lt;/code&amp;gt;) acts as a group id for a set of related simulation applications. Each application specifies a name in its Project DNA. These directories are constructed by the Project Manager app using the Project blueprint file, and the code templates generated during project initialization use the name to prefix the names of the Java and JS model logic classes. The model logic code for each application is thus contained in the java directory subdirectory corresponding to that name. The classes created by the Project Manager are generally sufficient for models with a level of complexity comparable to NetLogo, and in any case serve as the root of the computational environment. The opportunity exists, however, to create more complex simulations by extending the code base with additional classes and/or dependencies. &lt;br /&gt;
&lt;br /&gt;
Similarly named subdirectories of &amp;lt;code&amp;gt;webapp&amp;lt;/code&amp;gt; each contain the HTML code for the application and have the identical structure shown below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
File:jsite.png|left|Java Model Code Directory&lt;br /&gt;
File:jsite1.png|left|Java HTML and Presentation Directories&lt;br /&gt;
File:javapresent.png|thumb|left|Java Presentation and Dispatch Structures&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These images respectively show the contents of the model code directory (subdirectory of &amp;lt;code&amp;gt;java&amp;lt;/code&amp;gt;) and the HTML/presentation directories (subdirectory of &amp;lt;code&amp;gt;webapp&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Three of the HTML files are automatically generated by the Project Manager app from data contained in the Project blueprint file, using the project name as prefix. These files constitute the HTML loaded into the browser. The fourth (&amp;lt;code&amp;gt;riverDoc.html&amp;lt;/code&amp;gt;) was added and appears in the documentation window of the side panel.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;js&amp;lt;/code&amp;gt; subdirectory contains the Project DNA file itself (i.e., &amp;lt;code&amp;gt;river.js&amp;lt;/code&amp;gt;). These files are generally complete when deployed.&lt;br /&gt;
&lt;br /&gt;
The right-most image shows the JavaScript, CSS and image files used to implement the Presentation and Dispatch elements of the application, as subdirectories of the &amp;lt;code&amp;gt;common&amp;lt;/code&amp;gt; directory. Most of the heavy lifting is done by &amp;lt;code&amp;gt;main.js&amp;lt;/code&amp;gt;, which contains the drivers for the dispatcher, input and visualization components. Code for particular components (e.g., &amp;lt;code&amp;gt;lchart.js&amp;lt;/code&amp;gt; for linechart, etc.) are contained in their respective files. Consequently, new &amp;quot;widgets&amp;quot; in later releases are easily added to the API.&lt;br /&gt;
&lt;br /&gt;
===JavaScript Platform===&lt;br /&gt;
[[File:jssite.png|thumb|left|JavaScript Application Directory Structure]]&lt;br /&gt;
The JavaScript platform is simpler since it does not have a &amp;lt;code&amp;gt;java&amp;lt;/code&amp;gt; directory. The &amp;lt;code&amp;gt;common&amp;lt;/code&amp;gt; directory is extended to include the JS model API, along with the same files used for Java Presentation support, with a small change to substitute callbacks for WebSocket interactions.&lt;br /&gt;
&lt;br /&gt;
Looking at the JS application directory, we see the same 3 HTML files, but now the js subdirectory contains additional files implementing model logic. Note here that the Project DNA file is labeled &amp;lt;code&amp;gt;river.prj&amp;lt;/code&amp;gt;, so that &amp;lt;code&amp;gt;river.js&amp;lt;/code&amp;gt; can be used for the model logic main class. It is worth noting once again that the Project Manager creates these files under the guidance of the Project blueprint file, and they generally need not concern the model author.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;both&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Project File Contents==&lt;br /&gt;
[[File:projectdna.png|thumb]]&lt;br /&gt;
We now provide a brief overview of the Project blueprint file. Contents will vary depending on the specific needs of the simulation application. Designers will benefit from existing Project blueprint files when building JSON structures for their applications. The following descriptions refer to the sample Project blueprint file shown at here. &lt;br /&gt;
&lt;br /&gt;
Complete documentation for constructing a blueprint file will be presented in the user manual currently under development.&lt;br /&gt;
&lt;br /&gt;
Note that, as this file presents a JSON structure, the order of the entries is immaterial.&lt;br /&gt;
&lt;br /&gt;
===Lines 1 - 9: Title, Directories and Frame Size===&lt;br /&gt;
;Lines 2-3, Name, Title&lt;br /&gt;
:The '''Name''' was mentioned in the discussion on directory structure, and is used as a prefix in the class names of model logic files generated by the Project Manager. The '''Title''' is the title of the HTML main frame and appears at the top of the browser page.&lt;br /&gt;
;Lines 4-7, Directory Specifications&lt;br /&gt;
:The '''jroot''' and '''jbase''' entries identify the project's Java directories. The former points to the root directory of the Eclipse workspace, while the latter identifies the Eclipse project (and group id) for the group of project this one will be part of.&lt;br /&gt;
:Analogously, '''jsroot''' and '''jsbase''' identify the directories associated with JS. Since the Tomcat server is not required, these should be, respectively, the user's '''localhost''' root directory. &amp;lt;ref&amp;gt;On Mac systems this is &amp;lt;code&amp;gt;~/Sites&amp;lt;/code&amp;gt;. See [https://discussions.apple.com/docs/DOC-3083 Setting up a local web server on Mac]&amp;lt;/ref&amp;gt;, and a group id identifying a subdirectory for the group. &lt;br /&gt;
:The Project Manager uses these entries to construct directories, HTML files and model logic templates.&lt;br /&gt;
;Lines 8-9, Width and Height Specifications&lt;br /&gt;
:These specify the size of the main frame in the browser. They can be adjusted as need as the application takes shape.&lt;br /&gt;
;Line 10, VisitMode&lt;br /&gt;
:This is used by the model API to configure the main loop of the program. It will be discussed in detail later.&lt;br /&gt;
&lt;br /&gt;
===Lines 11-17, Cell Specifications===&lt;br /&gt;
These configure the cell matrix of a spatial or agent-based model. &lt;br /&gt;
;Line 12, cellSize&lt;br /&gt;
:'''cellSize''' indicates the number of pixels used by each cell in the display. In the coordinate system of the cell matrix each cell occupies a 1 by 1 square. CellSize maps that to specific spatial coordinates on the screen, making it easy to re-scale the visual display.&lt;br /&gt;
;Line 13, palette&lt;br /&gt;
:The '''palette''' is a list of CSS colors using the &amp;quot;#xxxxxxyy&amp;quot; or any other acceptable CSS format.&amp;lt;ref&amp;gt;The hex format should be used if color blending is to take place.&amp;lt;/ref&amp;gt; All cell color references are references to this palette.&lt;br /&gt;
;Lines 14-15, rowDim, colDim&lt;br /&gt;
:Row and column dimensions define the operational space of the model. Using '''rowDim''' and '''colDim''' and '''cellSize''', you can compute the size of the real estate occupied by display.&lt;br /&gt;
;Line 16, initial cell color&lt;br /&gt;
:The default assumption for cell color is palette entry 0. Any initial cell color other than 0 are specified by this array. Since the array will be transmitted via the WebSocket (in the Java platform), it is flattened. Every 3 entries indicate 1 cell (e.g., &amp;quot;64, 63 1&amp;quot; means that the cell at coordinates (64, 63) is to be colored with the second palette entry, &amp;lt;code&amp;gt;#ffffff&amp;lt;/code&amp;gt;, or white.&lt;br /&gt;
&lt;br /&gt;
===Lines 18-34, Agent Specifications===&lt;br /&gt;
A similar section is devoted to specifying agent properties. The palette entry is analogous to that used by cell specifications. Defaults are provided for the 5 fundamental agent properties (&amp;lt;code&amp;gt;color, size, shape, speed, theta&amp;lt;ref&amp;gt;a ''null'' value for theta means a random assignment&amp;lt;/ref&amp;gt;&amp;lt;/code&amp;gt;). &amp;lt;code&amp;gt;count&amp;lt;/code&amp;gt; determines the initial agent count. It can either be a number or the code of an input whose value will be used. &amp;lt;code&amp;gt;start&amp;lt;/code&amp;gt; can be a list of agents with initial configurations, or the string &amp;quot;random&amp;quot;, indicating random assignment of properties to &amp;lt;code&amp;gt;count&amp;lt;/code&amp;gt; agents. Other properties defined in this section will be discussed in a subsequent document.&lt;br /&gt;
&lt;br /&gt;
===Lines 36-48, Displays===&lt;br /&gt;
This entry consists of an array of display specifications for graphs, tables, spys&amp;lt;ref&amp;gt;Recall a ''spy'' is a component showing a single data point. Spys show up on the page at the top of the display area&amp;lt;/ref&amp;gt;, etc. Each display includes a 3-letter &amp;quot;airport code&amp;quot; that identifies the display. Other parameters depend on the type of display. The ''site'' property point to 1 of 6 slots reserved on the Web page for locating the display (If more that 6 displays are required the programmer can modify the HTML file accommodate them). Shown here is a linechart with the indicated domain and range.&lt;br /&gt;
&lt;br /&gt;
===Lines 49-51, Inputs ===&lt;br /&gt;
This is an array of slider or other input specifications, also using airport codes to identify them (note that this slider's airport code corresponds to the code used by the count property in the agent section.) The array containing the inputs may be multi-dimensional, creating a multi-row layout on the page.&lt;br /&gt;
&lt;br /&gt;
== Sample Workflow ==&lt;br /&gt;
Here is an outline of workflow for a project called &amp;quot;MyProject&amp;quot; using the Project Manager and developed on the Java platform using Eclipse J2EE (now called Jakarta) and Tomcat.&lt;br /&gt;
&lt;br /&gt;
# Install Eclipse Jakarta, open a workspace and create a Dynamic Web project.&lt;br /&gt;
# In a separate directory open '''myproject.prj''' in a text editor (emacs, vi, etc.)&lt;br /&gt;
# Edit '''myproject.prj''' to include a project blueprint containing the desired features and parameters. Be sure to reference to appropriate directories in the Eclipse workspace.&lt;br /&gt;
# Launch the Project Manager app and load '''myproject.prj'''; correct any errors and save the corrected version.&lt;br /&gt;
# Use the Project Manager to construct directories and template files in the Eclipse Workspace.&lt;br /&gt;
# Launch Tomcat from Eclipse.&lt;br /&gt;
# Navigate to the project in Chrome or a Web browser of your choice. A fully-featured Web page should appear.&lt;br /&gt;
# Connect and run the model; the timers will show that the model is running, but no changes occur in the display since the model logic has not yet been programmed.&lt;br /&gt;
# View the project DNA file, contained in '''js/myproject.js''', in Eclipse. Make any desired cosmetic changes to the size and appearance of the components by altering the project DNA file and reloading the page. When you are satisfied, use the Project Manager to update the blueprint with the current contents of the project DNA file.&lt;br /&gt;
# Define the model logic in the Java files '''MyProject.java''', '''MyProjectTurtle.java''' and '''MyProjectPatch.java'''. The Tomcat server will reload with every saved change. Occasionally the Tomcat server is unable to keep up and will offer to terminate or restart. You may want to terminate the Tomcat server while writing code to avoid this interruption. Restarting the Tomcat server and reloading the Web page will refresh the presentation.&lt;br /&gt;
# You may also want to open the browser's DevTools to monitor Web page execution.&lt;br /&gt;
&lt;br /&gt;
==Glossary of Terms==&lt;br /&gt;
;simulation&lt;br /&gt;
:a system that maintains a global state that evolves over time.&lt;br /&gt;
;simulator&lt;br /&gt;
:a computational structure for executing a simulation&lt;br /&gt;
;clock&lt;br /&gt;
:issues a sequence of signals to a simulation to cause it to change state.&lt;br /&gt;
;presentation&lt;br /&gt;
:A Web page displaying data and controls for a simulation program.&lt;br /&gt;
;dispatcher&lt;br /&gt;
:expedites communication between presentation, clock and simulator.&lt;br /&gt;
;system dynamics&lt;br /&gt;
:an approach to understanding the nonlinear behaviour of complex systems over time using stocks, flows, internal feedback loops, table functions and time delays.&lt;br /&gt;
;spatial model&lt;br /&gt;
:a particular form of disaggregation, in which an area is divided into a number (often a large number) of similar units: typically grid squares or polygons (also called cells).&lt;br /&gt;
;agent- (or individual- ) based model&lt;br /&gt;
:a computational model for simulating the actions and interactions of autonomous agents (both individual or collective entities such as organizations or groups) in order to understand the behavior of a system and what governs its outcomes.&lt;br /&gt;
;turtle&lt;br /&gt;
:NetLogo terminology for agent.&lt;br /&gt;
;patch&lt;br /&gt;
:NetLogo terminology for cell.&lt;br /&gt;
;network&lt;br /&gt;
:as used here, an alternative to the patch topology in which agents reside in nodes and travel along connections between nodes.&lt;br /&gt;
;SimWorld&lt;br /&gt;
:A visual Web page component showing the cells and agents of the model.&lt;br /&gt;
;display&lt;br /&gt;
:graphs, tables, etc. shown in the Web page.&lt;br /&gt;
;JSON (JavaScript Object Notation) &lt;br /&gt;
:a format for storing and exchanging data that's readable by both humans and machines.&lt;br /&gt;
;project &amp;quot;DNA&amp;quot;&lt;br /&gt;
:a file containing a JSON definition for defining and parameterizing a simulation project.&lt;br /&gt;
;project blueprint&lt;br /&gt;
:a JSON file constructed by the application developer for use as Project DNA&lt;br /&gt;
;Project Manager&lt;br /&gt;
:a Numerus application that reads the project blueprint and creates or updates the project's Website.&lt;br /&gt;
;step&lt;br /&gt;
:a phase of the simulator cycle during which new state values are computed&lt;br /&gt;
;shift&lt;br /&gt;
:a phase of the simulator cycle during which the new state becomes the current state&lt;br /&gt;
;Store&lt;br /&gt;
:a data structure used by the simulator to hold the current and next state.&lt;br /&gt;
;Stock&lt;br /&gt;
:an extension of the Store data type for system dynamics, capable of modeling continuous functions.&lt;br /&gt;
;VisitMode&lt;br /&gt;
:a parameter that determines the behavior of the simulator during each cycle.&lt;br /&gt;
;Eclipse&lt;br /&gt;
:a free, Java-based development platform known for its plugins that allow developers to develop and test code written in Java and other programming languages.&lt;br /&gt;
;Apache Tomcat&lt;br /&gt;
:a free, lightweight web server and servlet container that's used to run Java-based web applications.&lt;br /&gt;
;D3&lt;br /&gt;
:the JavaScript library for ''bespoke'' (their description) data visualization.&lt;br /&gt;
;palette&lt;br /&gt;
:a list of color specifications for display purposes.&lt;br /&gt;
;side panel&lt;br /&gt;
:an area of the NuWebKit Web page containing documentation and other features.&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=Numerus_Wiki&amp;diff=2543</id>
		<title>Numerus Wiki</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=Numerus_Wiki&amp;diff=2543"/>
		<updated>2026-03-19T16:47:51Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: /* Numerus Wiki Content */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
&amp;lt;strong&amp;gt;MediaWiki has been installed.&amp;lt;/strong&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Consult the [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide] for information on using the wiki software.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
== Numerus Wiki Content ==&lt;br /&gt;
===Numerus WebKit===&lt;br /&gt;
'''Numerus WebKit''' (NuWebKit) 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, but using conventional languages such as Java, JavaScript and Python. These applications are deployed either from a remote server, or run locally without using any network.&lt;br /&gt;
* [[Numerus WebKit | About Numerus WebKit]]&lt;br /&gt;
* [[Example WebKit Models]] (Javascript platform only)&lt;br /&gt;
* [[WebKit Examples]] (Java &amp;amp; Javascript platforms)&lt;br /&gt;
* [[WebKit Users Guide]]&lt;br /&gt;
* [[NumML Language Reference]]&lt;br /&gt;
&lt;br /&gt;
===Numerus Designer/Studio and Model Builder===&lt;br /&gt;
* [[Example WebKit Models]]* [[Numerus Designer]]&lt;br /&gt;
* [[Numerus Studio]]&lt;br /&gt;
* [http://wiki.numerusinc.com/index.php/Numerus_Model_Builder_Wiki:_The_Place_for_NumerusMB_Documentation Numerus Model Builder]&lt;br /&gt;
&lt;br /&gt;
===Numerus Downloadable / On-line Apps===&lt;br /&gt;
* [[SEIVAgent IBM Epidemic Simulator]]&lt;br /&gt;
* [[NMB DASA Covid-19 User Guide]]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
== Getting started ==&lt;br /&gt;
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Configuration_settings Configuration settings list]&lt;br /&gt;
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]&lt;br /&gt;
* [https://lists.wikimedia.org/mailman/listinfo/mediawiki-announce MediaWiki release mailing list]&lt;br /&gt;
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation#Translation_resources Localise MediaWiki for your language]&lt;br /&gt;
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Combating_spam Learn how to combat spam on your wiki]&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=MediaWiki:Sidebar&amp;diff=2542</id>
		<title>MediaWiki:Sidebar</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=MediaWiki:Sidebar&amp;diff=2542"/>
		<updated>2026-03-19T16:46:25Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* navigation&lt;br /&gt;
** mainpage|mainpage-description&lt;br /&gt;
** Numerus WebKit|Numerus WebKit&lt;br /&gt;
** Example WebKit Models | Example WebKit Models (Javascript platform)&lt;br /&gt;
** WebKit Examples|WebKit Examples (Java and Javascript platforms)&lt;br /&gt;
** WebKit Users Guide | WebKit Users Guide&lt;br /&gt;
** NuML Language Reference | NuML Language Reference&lt;br /&gt;
*&lt;br /&gt;
** Numerus_Designer|Numerus Designer&lt;br /&gt;
** Numerus Studio|Numerus Studio&lt;br /&gt;
** Numerus_Model_Builder_Wiki:_The_Place_for_NumerusMB_Documentation|Numerus Model Builder&lt;br /&gt;
&lt;br /&gt;
* Numerus Users Manual&lt;br /&gt;
** About Numerus Model Builder|About Numerus Model Builder&lt;br /&gt;
** How To Get Help While Using Numerus|How To Get Help While Using Numerus &lt;br /&gt;
** Tutorials|Tutorials&lt;br /&gt;
* Modeling Concepts&lt;br /&gt;
** Modeling 101|Modeling 101&lt;br /&gt;
** Modeling in Numerus|Modeling in Numerus&lt;br /&gt;
** Numerus Simulation Architecture|Numerus Simulation Architecture&lt;br /&gt;
* User Guide&lt;br /&gt;
** Frames, Menus, Toolbars| Frames, Menus, Toolbars&lt;br /&gt;
** Modeling Actions | Modeling Actions&lt;br /&gt;
** Running Your Model | Running Your Model&lt;br /&gt;
** Component Guide I: Atomic Components | Component Guide I: Atomic Components&lt;br /&gt;
** Component Guide II: Containers | Component Guide II: Containers &lt;br /&gt;
** Component Guide III: Displays and Controls | Component Guide III: Displays and Controls&lt;br /&gt;
** Component Guide IV: Plugins | Component Guide IV: Plugins&lt;br /&gt;
** Documenting Your Model | Documenting Your Model&lt;br /&gt;
** Preferences | Preferences&lt;br /&gt;
** Javascript Light | Javascript Light&lt;br /&gt;
** NovaScript Introduction | NovaScript Introduction&lt;br /&gt;
* Reference&lt;br /&gt;
** Primitive Operators and Properties|Primitive Operators and Properties&lt;br /&gt;
** Glossary|Glossary&lt;br /&gt;
&lt;br /&gt;
** recentchanges-url&lt;br /&gt;
** randompage-url&lt;br /&gt;
** helppage&lt;br /&gt;
&lt;br /&gt;
* SEARCH&lt;br /&gt;
* TOOLBOX&lt;br /&gt;
* LANGUAGES&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=NumML_Language_Reference&amp;diff=2541</id>
		<title>NumML Language Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=NumML_Language_Reference&amp;diff=2541"/>
		<updated>2026-03-19T16:44:49Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: Rsalter moved page NumML Language Reference to NuML Language Reference: Change of Language Name&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[NuML Language Reference]]&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2540</id>
		<title>NuML Language Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2540"/>
		<updated>2026-03-19T16:44:49Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: Rsalter moved page NumML Language Reference to NuML Language Reference: Change of Language Name&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What is NuML?==&lt;br /&gt;
&lt;br /&gt;
NuML is a small, domain-specific language (dsl) for coding SD models and configuring the UI of a NuWebKit (NWK) site. It is used in URAM models and in the Configuration Window. This document serves as reference for NWK authors and users wishing to use NuML in their  designs.&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
NuML serves two purposes: (1) to specify a system dynamics (SD) model program; and (2) to override the factory settings configuration for inputs, displays, and model operation. The choice of operator in an NuML statement, from the two described in the next section, respectively determines its purpose. To specify an SD program, NuML has special operators for defining a differential or difference equation with initial values. There are also primitive operators (primops) to supply random values and compute useful mathematical functions. To override factory settings there are operators to configure properties of input and display components, and to fix integration parameters. Finally, there are operators to configure properties of the analytical platforms. Currently there is only 1 of these (sensitivity analysis), and NuML will be extended as more such platforms become available.&lt;br /&gt;
&lt;br /&gt;
==NuML Operators==&lt;br /&gt;
NuML uses Javascript syntax extended with 2 infix operators (&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt;) that are not recognized as meaningful to Javascript. NWK uses a Javascript parser extended to accept these operators to analyze NuML code and respectively generate code or change the value of specific configuration parameters. Each NuML statement has the form:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS'';&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS'';&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
with slightly different rules for what is allowed on each side of the operator. In discussing NuML syntax we use the following terminology:&lt;br /&gt;
&lt;br /&gt;
==Language Categories==&lt;br /&gt;
;Constant&lt;br /&gt;
:Either a string constant enclosed in single or double quotes (&amp;lt;code&amp;gt;'Infection Stats'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;SIR Model&amp;quot;&amp;quot;&amp;lt;/code&amp;gt;) or a number in decimal (&amp;lt;code&amp;gt;3.1415&amp;lt;/code&amp;gt;) or scientific notation (&amp;lt;code&amp;gt;3.14159e5&amp;lt;/code&amp;gt;).&lt;br /&gt;
;Identifier&lt;br /&gt;
:Equivalent of a Javascript variable such as &amp;lt;code&amp;gt;Sigma&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;beta&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
;Unary Expression&lt;br /&gt;
:An unary operator modifying a term, such as &amp;lt;code&amp;gt;-10&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-Sigma&amp;lt;/code&amp;gt;.&lt;br /&gt;
;Call Expression&lt;br /&gt;
:A function name followed by a comma-separated sequence of arguments enclosed in parentheses. The function name must be an identifier; the arguments can be any list of terms.&lt;br /&gt;
;Term&lt;br /&gt;
:Either a constant, identifier, unary expression, or a call expression using one of the following function names, which differ for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;. These functions are called '''primops''' and are discussed below.&lt;br /&gt;
:&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;code&amp;gt;choose&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;multinomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;binomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;poisson&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;flip&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;irandom&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;random&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi34&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;degToRad&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;radToDeg&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tanh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;legend&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;phase&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;title&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statDat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statParam&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integration&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;statRuns&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statLo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statHi&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;min&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;max&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;step&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;xlabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ylabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;interval&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Computational Expression&lt;br /&gt;
:A single term or a sequence of terms connected using arithmetic operators &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt;, or any other legal Javascript operators.&lt;br /&gt;
;Array&lt;br /&gt;
:A comma-separated sequence of terms enclosed in square brackets; e.g., &amp;lt;code&amp;gt;[Sigma, foo(1,2,3), 15.123e3]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be:&lt;br /&gt;
:An identifier&lt;br /&gt;
:A call expression of the form:&lt;br /&gt;
::&amp;lt;code&amp;gt;deriv(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;initial(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;update(''ident&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ''ident&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;'', ...)&amp;lt;/code&amp;gt;&lt;br /&gt;
:these are discussed below.&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be &lt;br /&gt;
: A computational expression when ''LHS'' is either &amp;lt;code&amp;gt;deriv&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initial&amp;lt;/code&amp;gt; or an identifier.&lt;br /&gt;
: An identifier when ''LHS'' is &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Examples&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(S) @=  -beta * S * I / N&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(I) @= beta * S * I / N - sigma * I&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(R) @= sigma * I&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
initial(S) @= N - I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(I) @= I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(R) @= 0&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
update(S,I,R) @= mainGraph&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
N @= Param1&amp;lt;br&amp;gt;&lt;br /&gt;
beta @= Param2&amp;lt;br&amp;gt;&lt;br /&gt;
I0 @= Param3&amp;lt;br&amp;gt;&lt;br /&gt;
sigma @= Param4&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;deriv(''Arg'')&amp;lt;/code&amp;gt; asserts a that the ''RHS'' equation is the time derivative of ''Arg''&lt;br /&gt;
* &amp;lt;code&amp;gt;initial(''Arg'')&amp;lt;/code&amp;gt; asserts that the ''RHS'' is the initial value of ''Arg''&lt;br /&gt;
* &amp;lt;code&amp;gt;update(''Arg&amp;lt;sub&amp;gt;1'', ''Arg&amp;lt;sub&amp;gt;2'', ...)&amp;lt;/code&amp;gt; asserts that ''Arg&amp;lt;sub&amp;gt;1'', ''Arg&amp;lt;sub&amp;gt;2'', ... should be downloaded to the output component with ID of the ''RHS''. The arguments should match the legend assigned to the output component&lt;br /&gt;
&lt;br /&gt;
An identifier appearing on the ''LHS'' is defined by the expression on the ''RHS''.&lt;br /&gt;
&lt;br /&gt;
== Syntax Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be&lt;br /&gt;
: An identifier&lt;br /&gt;
: An array of identifiers&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be&lt;br /&gt;
: A constant, primop, or array of primops&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
mainGraph #= [legend(S,I,R), title(&amp;quot;SIR Model&amp;quot;)]&amp;lt;br&amp;gt;&lt;br /&gt;
statsGraph #= title(&amp;quot;Infection Stats&amp;quot;)&amp;lt;br&amp;gt;&lt;br /&gt;
statsGraph #= [statDat(I),statParam(Beta),statRuns(12),statLo(3.4),statHi(4.5)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param1 #= [legend(N),max(1000000),step(1000)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param2 #= [legend(Beta),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param3 #= [legend(I0),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param4 #= [legend(Sigma),max(10),step(0.1)];&amp;lt;br&amp;gt;&lt;br /&gt;
[Param5, Param6] #= legend(&amp;quot;&amp;quot;);&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
* Identifiers on the ''LHS'' reference component IDs or parameters such as &amp;lt;code&amp;gt;dt&amp;lt;/code&amp;gt;&lt;br /&gt;
* Constants on the ''RHS'' are only used with parameters and assign values to them.&lt;br /&gt;
* Primops on the ''RHS'' are only used with component IDs and define attributes such as legend, max value, etc.&lt;br /&gt;
* Arrays on either side &amp;quot;multiply out&amp;quot; to as sequence of statements and are there for convenience.&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
====Random Number Generation====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(size)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Randomly picks a number from 0 to ''size-1'' with uniform probability.&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to 1, then this function randomly picks a number from 0 to ''n-1'' with the indicated probabilities. If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to less than 1, then the function returns ''n'' with probability 1 - ''&amp;amp;Sigma; p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;flip(p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns 1 with probability ''p''; 0 otherwise&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;binomial(n, p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns the sum of ''n'' independent ''flip(p)'' calls.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;multinomial(N, p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Performs ''N'' independent ''choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)'' calls and returns a vector of ''n'' (or ''n+1'') values ''(v&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, v&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ...)'' where ''v&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' is the number of times ''i'' was selected.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;poisson(lambda)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value 0, 1, ... distributed using the Poisson distribution with density ''lambda''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;normal(m, s)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value distributed using a Gaussian distribution with mean ''m'' and standard deviation ''s''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between 0 and ''y''.&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(x, y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between ''x'' and ''y''.&lt;br /&gt;
&lt;br /&gt;
====Trigonometric Functions====&lt;br /&gt;
;&amp;lt;code&amp;gt;cos, sin, tan, acos, asin, atan, atan2, cosh, sinh, tanh, acosh, asinh, atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
:Note: &amp;lt;code&amp;gt;(atan2 y x)&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;(atan y/x)&amp;lt;/code&amp;gt; extended to handle the case where ''x == 0''.&lt;br /&gt;
&lt;br /&gt;
====Constants====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;PI, PI2, Pi2, Pi34&amp;lt;/code&amp;gt;&lt;br /&gt;
:Respectively, &amp;amp;pi;, 2&amp;amp;pi;, &amp;amp;pi;/2, 3&amp;amp;pi;/4&lt;br /&gt;
&lt;br /&gt;
;degToRad&lt;br /&gt;
:&amp;amp;pi;/180&lt;br /&gt;
&lt;br /&gt;
;radToDeg&lt;br /&gt;
:180/&amp;amp;pi;&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Assigned to runtime graphs and displays:&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''title'''&lt;br /&gt;
:'''xlabel'''&lt;br /&gt;
:'''ylabel'''&lt;br /&gt;
:'''interval''' (between plots)&lt;br /&gt;
&lt;br /&gt;
Assigned to input sliders&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''min'''&lt;br /&gt;
:'''max'''&lt;br /&gt;
:'''step'''&lt;br /&gt;
&lt;br /&gt;
Integration Control&lt;br /&gt;
:'''dt'''&lt;br /&gt;
:'''integration''' ('''RK4''' or '''Euler''')&lt;br /&gt;
&lt;br /&gt;
Sensitivity Analysis Platform&lt;br /&gt;
;statParam&lt;br /&gt;
:Parameter varied by sensitivity test&lt;br /&gt;
;statDat&lt;br /&gt;
:Value to be graphed&lt;br /&gt;
;statRuns&lt;br /&gt;
:Number of runs&lt;br /&gt;
;StatLo, StatHi&lt;br /&gt;
:Testing boundaries&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2539</id>
		<title>NuML Language Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=NuML_Language_Reference&amp;diff=2539"/>
		<updated>2026-03-19T16:43:56Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What is NuML?==&lt;br /&gt;
&lt;br /&gt;
NuML is a small, domain-specific language (dsl) for coding SD models and configuring the UI of a NuWebKit (NWK) site. It is used in URAM models and in the Configuration Window. This document serves as reference for NWK authors and users wishing to use NuML in their  designs.&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
NuML serves two purposes: (1) to specify a system dynamics (SD) model program; and (2) to override the factory settings configuration for inputs, displays, and model operation. The choice of operator in an NuML statement, from the two described in the next section, respectively determines its purpose. To specify an SD program, NuML has special operators for defining a differential or difference equation with initial values. There are also primitive operators (primops) to supply random values and compute useful mathematical functions. To override factory settings there are operators to configure properties of input and display components, and to fix integration parameters. Finally, there are operators to configure properties of the analytical platforms. Currently there is only 1 of these (sensitivity analysis), and NuML will be extended as more such platforms become available.&lt;br /&gt;
&lt;br /&gt;
==NuML Operators==&lt;br /&gt;
NuML uses Javascript syntax extended with 2 infix operators (&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt;) that are not recognized as meaningful to Javascript. NWK uses a Javascript parser extended to accept these operators to analyze NuML code and respectively generate code or change the value of specific configuration parameters. Each NuML statement has the form:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ''RHS'';&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS''&amp;lt;br&amp;gt;&lt;br /&gt;
''LHS'' &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ''RHS'';&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
with slightly different rules for what is allowed on each side of the operator. In discussing NuML syntax we use the following terminology:&lt;br /&gt;
&lt;br /&gt;
==Language Categories==&lt;br /&gt;
;Constant&lt;br /&gt;
:Either a string constant enclosed in single or double quotes (&amp;lt;code&amp;gt;'Infection Stats'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;SIR Model&amp;quot;&amp;quot;&amp;lt;/code&amp;gt;) or a number in decimal (&amp;lt;code&amp;gt;3.1415&amp;lt;/code&amp;gt;) or scientific notation (&amp;lt;code&amp;gt;3.14159e5&amp;lt;/code&amp;gt;).&lt;br /&gt;
;Identifier&lt;br /&gt;
:Equivalent of a Javascript variable such as &amp;lt;code&amp;gt;Sigma&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;beta&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
;Unary Expression&lt;br /&gt;
:An unary operator modifying a term, such as &amp;lt;code&amp;gt;-10&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-Sigma&amp;lt;/code&amp;gt;.&lt;br /&gt;
;Call Expression&lt;br /&gt;
:A function name followed by a comma-separated sequence of arguments enclosed in parentheses. The function name must be an identifier; the arguments can be any list of terms.&lt;br /&gt;
;Term&lt;br /&gt;
:Either a constant, identifier, unary expression, or a call expression using one of the following function names, which differ for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;. These functions are called '''primops''' and are discussed below.&lt;br /&gt;
:&amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;code&amp;gt;choose&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;multinomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;binomial&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;poisson&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;flip&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;irandom&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;random&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PI2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Pi34&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;degToRad&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;radToDeg&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acos&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atan2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tanh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;acosh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;asinh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;legend&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;phase&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;title&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statDat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statParam&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integration&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;statRuns&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statLo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statHi&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;min&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;max&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;step&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;xlabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ylabel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;interval&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Computational Expression&lt;br /&gt;
:A single term or a sequence of terms connected using arithmetic operators &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt;, or any other legal Javascript operators.&lt;br /&gt;
;Array&lt;br /&gt;
:A comma-separated sequence of terms enclosed in square brackets; e.g., &amp;lt;code&amp;gt;[Sigma, foo(1,2,3), 15.123e3]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be:&lt;br /&gt;
:An identifier&lt;br /&gt;
:A call expression of the form:&lt;br /&gt;
::&amp;lt;code&amp;gt;deriv(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;initial(''ident'')&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;update(''ident&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;'', ''ident&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;'', ...)&amp;lt;/code&amp;gt;&lt;br /&gt;
:these are discussed below.&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be &lt;br /&gt;
: A computational expression when ''LHS'' is either &amp;lt;code&amp;gt;deriv&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initial&amp;lt;/code&amp;gt; or an identifier.&lt;br /&gt;
: An identifier when ''LHS'' is &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Examples&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(S) @=  -beta * S * I / N&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(I) @= beta * S * I / N - sigma * I&amp;lt;br&amp;gt;&lt;br /&gt;
deriv(R) @= sigma * I&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
initial(S) @= N - I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(I) @= I0&amp;lt;br&amp;gt;&lt;br /&gt;
initial(R) @= 0&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
update(S,I,R) @= mainGraph&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
N @= Param1&amp;lt;br&amp;gt;&lt;br /&gt;
beta @= Param2&amp;lt;br&amp;gt;&lt;br /&gt;
I0 @= Param3&amp;lt;br&amp;gt;&lt;br /&gt;
sigma @= Param4&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;deriv(''Arg'')&amp;lt;/code&amp;gt; asserts a that the ''RHS'' equation is the time derivative of ''Arg''&lt;br /&gt;
* &amp;lt;code&amp;gt;initial(''Arg'')&amp;lt;/code&amp;gt; asserts that the ''RHS'' is the initial value of ''Arg''&lt;br /&gt;
* &amp;lt;code&amp;gt;update(''Arg&amp;lt;sub&amp;gt;1'', ''Arg&amp;lt;sub&amp;gt;2'', ...)&amp;lt;/code&amp;gt; asserts that ''Arg&amp;lt;sub&amp;gt;1'', ''Arg&amp;lt;sub&amp;gt;2'', ... should be downloaded to the output component with ID of the ''RHS''. The arguments should match the legend assigned to the output component&lt;br /&gt;
&lt;br /&gt;
An identifier appearing on the ''LHS'' is defined by the expression on the ''RHS''.&lt;br /&gt;
&lt;br /&gt;
== Syntax Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
''LHS'' can be&lt;br /&gt;
: An identifier&lt;br /&gt;
: An array of identifiers&lt;br /&gt;
&lt;br /&gt;
''RHS'' can be&lt;br /&gt;
: A constant, primop, or array of primops&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
mainGraph #= [legend(S,I,R), title(&amp;quot;SIR Model&amp;quot;)]&amp;lt;br&amp;gt;&lt;br /&gt;
statsGraph #= title(&amp;quot;Infection Stats&amp;quot;)&amp;lt;br&amp;gt;&lt;br /&gt;
statsGraph #= [statDat(I),statParam(Beta),statRuns(12),statLo(3.4),statHi(4.5)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param1 #= [legend(N),max(1000000),step(1000)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param2 #= [legend(Beta),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param3 #= [legend(I0),max(10),step(0.1)]&amp;lt;br&amp;gt;&lt;br /&gt;
Param4 #= [legend(Sigma),max(10),step(0.1)];&amp;lt;br&amp;gt;&lt;br /&gt;
[Param5, Param6] #= legend(&amp;quot;&amp;quot;);&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantic Rules for &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
* Identifiers on the ''LHS'' reference component IDs or parameters such as &amp;lt;code&amp;gt;dt&amp;lt;/code&amp;gt;&lt;br /&gt;
* Constants on the ''RHS'' are only used with parameters and assign values to them.&lt;br /&gt;
* Primops on the ''RHS'' are only used with component IDs and define attributes such as legend, max value, etc.&lt;br /&gt;
* Arrays on either side &amp;quot;multiply out&amp;quot; to as sequence of statements and are there for convenience.&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
====Random Number Generation====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(size)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Randomly picks a number from 0 to ''size-1'' with uniform probability.&lt;br /&gt;
;&amp;lt;code&amp;gt;choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to 1, then this function randomly picks a number from 0 to ''n-1'' with the indicated probabilities. If the ''p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' sum to less than 1, then the function returns ''n'' with probability 1 - ''&amp;amp;Sigma; p&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;flip(p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns 1 with probability ''p''; 0 otherwise&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;binomial(n, p)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns the sum of ''n'' independent ''flip(p)'' calls.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;multinomial(N, p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Performs ''N'' independent ''choose(p&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, p&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ... p&amp;lt;sub&amp;gt;n-1&amp;lt;/sub&amp;gt;)'' calls and returns a vector of ''n'' (or ''n+1'') values ''(v&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, v&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ...)'' where ''v&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'' is the number of times ''i'' was selected.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;poisson(lambda)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value 0, 1, ... distributed using the Poisson distribution with density ''lambda''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;normal(m, s)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random value distributed using a Gaussian distribution with mean ''m'' and standard deviation ''s''.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between 0 and ''y''.&lt;br /&gt;
;&amp;lt;code&amp;gt;irandom(x, y)&amp;lt;/code&amp;gt;&lt;br /&gt;
:Returns a random integer between ''x'' and ''y''.&lt;br /&gt;
&lt;br /&gt;
====Trigonometric Functions====&lt;br /&gt;
;&amp;lt;code&amp;gt;cos, sin, tan, acos, asin, atan, atan2, cosh, sinh, tanh, acosh, asinh, atanh&amp;lt;/code&amp;gt;&lt;br /&gt;
:Note: &amp;lt;code&amp;gt;(atan2 y x)&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;(atan y/x)&amp;lt;/code&amp;gt; extended to handle the case where ''x == 0''.&lt;br /&gt;
&lt;br /&gt;
====Constants====&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;PI, PI2, Pi2, Pi34&amp;lt;/code&amp;gt;&lt;br /&gt;
:Respectively, &amp;amp;pi;, 2&amp;amp;pi;, &amp;amp;pi;/2, 3&amp;amp;pi;/4&lt;br /&gt;
&lt;br /&gt;
;degToRad&lt;br /&gt;
:&amp;amp;pi;/180&lt;br /&gt;
&lt;br /&gt;
;radToDeg&lt;br /&gt;
:180/&amp;amp;pi;&lt;br /&gt;
&lt;br /&gt;
== Primops for &amp;lt;code&amp;gt;@#&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Assigned to runtime graphs and displays:&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''title'''&lt;br /&gt;
:'''xlabel'''&lt;br /&gt;
:'''ylabel'''&lt;br /&gt;
:'''interval''' (between plots)&lt;br /&gt;
&lt;br /&gt;
Assigned to input sliders&lt;br /&gt;
:'''legend'''&lt;br /&gt;
:'''min'''&lt;br /&gt;
:'''max'''&lt;br /&gt;
:'''step'''&lt;br /&gt;
&lt;br /&gt;
Integration Control&lt;br /&gt;
:'''dt'''&lt;br /&gt;
:'''integration''' ('''RK4''' or '''Euler''')&lt;br /&gt;
&lt;br /&gt;
Sensitivity Analysis Platform&lt;br /&gt;
;statParam&lt;br /&gt;
:Parameter varied by sensitivity test&lt;br /&gt;
;statDat&lt;br /&gt;
:Value to be graphed&lt;br /&gt;
;statRuns&lt;br /&gt;
:Number of runs&lt;br /&gt;
;StatLo, StatHi&lt;br /&gt;
:Testing boundaries&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=NuWebKit_Users_Guide&amp;diff=2538</id>
		<title>NuWebKit Users Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=NuWebKit_Users_Guide&amp;diff=2538"/>
		<updated>2026-03-19T16:35:55Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;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.&amp;lt;ref&amp;gt;This API is under development.&amp;lt;/ref&amp;gt; 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Terminology ==&lt;br /&gt;
; Model&lt;br /&gt;
: 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.&lt;br /&gt;
&lt;br /&gt;
;Simulation&lt;br /&gt;
: A model in execution. Simulations are managed from the UI.&lt;br /&gt;
&lt;br /&gt;
;Spatial (Sp) and Individual-based (IB) models&lt;br /&gt;
: 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 &amp;quot;wrap-around&amp;quot; horizontally and vertically to create a torus. In many simulations with fixed boundaries, agents &amp;quot;bounce off&amp;quot; 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 site's author, and in some cases may be overridden.&lt;br /&gt;
&lt;br /&gt;
;System Dynamics (SD) &lt;br /&gt;
: The behavior of SD models over time can often be characterized using differential or difference equations. An SD model might be the entirety of site, or might characterize the local behavior of a cell or agent in Sp and IB models.&lt;br /&gt;
&lt;br /&gt;
;Project&lt;br /&gt;
: A single unit deploying 1 or more simulations, usually employing a single Web page. Projects are specified using a '''project file''', containing [https://www.json.org/json-en.html JSON] code detailing the UI and at least providing parameters for the model. Small SD models may be specified in the project file.&lt;br /&gt;
&lt;br /&gt;
;Site&lt;br /&gt;
:The Webpage or pages associated with a particular project.&lt;br /&gt;
&lt;br /&gt;
;&amp;quot;Factory Settings&amp;quot;&lt;br /&gt;
: Sites are uploaded with parameters and settings determined by the author. Users may change parameters and override some setting, however factory settings can always be recovered.&lt;br /&gt;
&lt;br /&gt;
;&amp;quot;The Drawer&amp;quot;&lt;br /&gt;
: 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.&lt;br /&gt;
&lt;br /&gt;
;Presets&lt;br /&gt;
: NWK provides a storage facility to record and recall various choices for settings and parameters. The presets are like &amp;quot;radio buttons&amp;quot; selecting various alternative sets of configurations.&lt;br /&gt;
&lt;br /&gt;
;RAMs&lt;br /&gt;
: 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).&lt;br /&gt;
&lt;br /&gt;
;NuML&lt;br /&gt;
: NuML (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.&lt;br /&gt;
&lt;br /&gt;
;Analysis Platforms&lt;br /&gt;
:These are special tabs used in some sites to enable such facilities as sensitivity analysis, curve fitting, MCMC, etc.&lt;br /&gt;
&lt;br /&gt;
;CSV&lt;br /&gt;
:This refers to the option of saving data from a graph to a comma separated list.&lt;br /&gt;
&lt;br /&gt;
== Platform Overview==&lt;br /&gt;
[[File:ui0.png|thumb|NWK User Interface]]&lt;br /&gt;
This image shows the browser window running the sample individual-based site [https://www.cs.oberlin.edu/~rms/wk/rps/ &amp;quot;Rock Paper Scissors&amp;quot;]. The features are all described later in this guide.&lt;br /&gt;
;Model Inputs&lt;br /&gt;
:These sliders set parameters for the simulation. Changes are forwarded even while the simulation is running and may have immediate effect.&lt;br /&gt;
;Timers&lt;br /&gt;
: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.&lt;br /&gt;
;Operating Buttons&lt;br /&gt;
: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.&lt;br /&gt;
: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.&lt;br /&gt;
[[File:ui1.png|thumb|UI With Drawer Opened]]&lt;br /&gt;
;Speed Control&lt;br /&gt;
:This determines the real-time interval between steps. &lt;br /&gt;
;Displays&lt;br /&gt;
:A spatial or agent-based simulation will include a &amp;quot;SimWorld&amp;quot; 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.&lt;br /&gt;
:Other displays such as Spys (showing a single current value) graphs, tables, etc. are specified in the Project file (see below).&lt;br /&gt;
;Side Panel&lt;br /&gt;
:The browser page has a side panel contained in a &amp;quot;drawer&amp;quot;. Use [[File:sideicon.png]] 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 site uses RAMs the side panel will be wider and will contain access to RAM controls.&lt;br /&gt;
[[File:ui2.png|thumb|UI with SD Model]]&lt;br /&gt;
;System Dynamics&lt;br /&gt;
:The third image shows the model library SD [https://www.cs.oberlin.edu/~rms/wk/lotka Lotka-Volterra] site. An SD site will display the current choices for ''dt'' and integration method (Euler or RK4). These can be overridden from factory settings using the configuration window.&lt;br /&gt;
&amp;lt;br clear='both'&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In subsequent sections we describe the platform's features with illustrations using one or more of the sites 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.&lt;br /&gt;
&lt;br /&gt;
'''When opening the Model Library examples you are advised to right-click and open the link in a new tab.'''&lt;br /&gt;
&lt;br /&gt;
Among the topics covered are:&lt;br /&gt;
* User initialization of spatial and agent-based models&lt;br /&gt;
* Presets&lt;br /&gt;
* NuML language&lt;br /&gt;
* RAMS and URAMS&lt;br /&gt;
* Configuration overrides&lt;br /&gt;
* Analysis platforms&lt;br /&gt;
* Downloading CSVs&lt;br /&gt;
&lt;br /&gt;
== Model Initialization and Using Presets with Conway's Game of Life and Agents (1) ==&lt;br /&gt;
[[File:lifeinit.gif|thumb|Initializing Conway's Game of Life]]&lt;br /&gt;
[[File:agentsinit.gif|thumb|Initializing Agents (1)]]&lt;br /&gt;
[https://www.cs.oberlin.edu/~rms/wk/life/index.html Conway's Game of Life (CGOL)] uses a 128 x 128 board with solid edge and an initial configuration consisting of the &amp;quot;R-pentomino&amp;quot;. (Try it!) CGOL's model operates on a cellular automaton with 2 possible states, dead and alive. &lt;br /&gt;
&lt;br /&gt;
[https://www.cs.oberlin.edu/~rms/wk/agents/index.html 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 site's author.) [https://www.cs.oberlin.edu/~rms/wk/agents1/index.html Agents (1)] has the same model, only initially empty. &lt;br /&gt;
&lt;br /&gt;
With NWK you can:&lt;br /&gt;
* Click and drag to create new initial configurations;&lt;br /&gt;
* Save your configuration in the Presets.&lt;br /&gt;
&lt;br /&gt;
=== Creating new initial configurations in CGOL ===&lt;br /&gt;
&lt;br /&gt;
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. &lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Creating new initial configurations in Agents (1) ===&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
When done, '''double-click''' '''Reset''', and then '''Run'''. To restore factory settings you must reload the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=&amp;quot;both&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Preset Basics ==&lt;br /&gt;
[[File:preset.png|thumb|Preset Control in Drawer Panel]]&lt;br /&gt;
The Preset feature provides a quick way to save and restore a configuration, modeled on the &amp;quot;radio buttons&amp;quot; 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 &amp;quot;green&amp;quot; label will restore the configuration saved in that preset. Selecting a red label has no effect on the configuration.&lt;br /&gt;
&lt;br /&gt;
'''Note that preset 0 is permanently bound to factory settings and cannot be changed'''.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
[[File:presetDemo.gif|thumb|Preset Control in Main Control Panel]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
Presets are stored in the Web browser and will be there when you return to the site. 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.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Something to try&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== One more thing about Presets ===&lt;br /&gt;
Some site include ready-made presets. These will be installed the first time you access the site. 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 site.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=&amp;quot;both&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Using RAMs with the Extended Game of Life 3 (EGOL3) ==&lt;br /&gt;
[[File:egol3.png|thumb|Extended Game of Life Showing RAM Panel]]&lt;br /&gt;
[[File:egol3RAM.gif|thumb|Preset Selection Showing RAM Choices]]&lt;br /&gt;
RAMs provide the means for changing some aspect of the site's 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.&lt;br /&gt;
&lt;br /&gt;
[https://www.biorxiv.org/content/10.1101/2022.08.30.505937v1 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).&lt;br /&gt;
&lt;br /&gt;
The RAM Selection Panel appears whenever a site 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).&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The '''Display''' RAM setting is analogous to the conventional GOL we explored earlier. You can set your own initial configuration through click and drag like before. The '''Random''' setting lets you choose the probabilities for initial live cells. '''Reg6''' and '''Reg Custom''' produce diagonal stripes that repeat with, respectively, a fixed interval of 6 or with an interval between 2 and 12.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Something to try&lt;br /&gt;
&lt;br /&gt;
Make changes to the existing presets. When editing a textfield input, be sure to hit '''Enter''' when you are ready to register the change. Save configurations in any of the remaining empty presets, or override the factory presets (except for Preset 0).&lt;br /&gt;
&lt;br /&gt;
When you are done you can restore the initial preset configuration by deleting ''all'' presets with '''Cl All''' and then reloading.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Using RAMs with the Deterministic SIRS w/ Vaccination (SIRS) ==&lt;br /&gt;
SIRS is rich with RAMs with one ('''Immune to Vaccinated''') containing an alternative ('''User Input''') requiring code. This alternative lets you program how individuals in class R (recovering) are vaccinated and transferred to class V (vaccinated), as a function of model time. A set of variables that can be referenced in the code is provided.&lt;br /&gt;
&lt;br /&gt;
An example is contained in Preset 1. Here we choose to use apply the vaccination rate from the vaccination onset time (both set with the main input sliders) to a time determined using the RAM slider '''User 1'''. In other words, you add a shut-off time for vaccinations which has not been provided by the original model. Other possibilities for this RAM could be, for example, to let the vaccination rate decay to account for depletion of vaccine, using the '''User 1''' slider to determine the decay rate.&lt;br /&gt;
&lt;br /&gt;
The code used in Preset 1 is Javascript. Press the '''Compile''' button when your are ready. The '''Enlarge''' button opens a browser-wide editor window, making code entry easier. If you want to try your own User Input RAM, be sure to save in a preset or your code will be lost.&lt;br /&gt;
&lt;br /&gt;
== User-Defined Models (URAMs) with Sensitivity Analysis ==&lt;br /&gt;
&lt;br /&gt;
The RAM interface makes it possible to easily implement SD simulations defined entirely by the user. An example from the model library containing 4 user-defined presets is [https://www.cs.oberlin.edu/~rms/wk/sdnumml1/index.html SD User Defined]. &lt;br /&gt;
&lt;br /&gt;
Such sites are initially defined only by the input and output components they support. Their operation relies on a user-defined program, specifying the model and its UI, that is entered using a RAM. The example site has a RAM with one option, that option showing a text area for the program. It also provides sufficient input and output components to support the UI needs of models implemented on the site.&lt;br /&gt;
&lt;br /&gt;
The example site includes 6 slider inputs, a line graph and a phase graph. Each of these 8 components need a &amp;quot;handle&amp;quot;, an ID by which they can be referenced in the program. The sliders all run from 0 to 1 with 0.01 step size and have the IDs &amp;lt;code&amp;gt;Param1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Param2&amp;lt;/code&amp;gt;..., &amp;lt;code&amp;gt;Param6&amp;lt;/code&amp;gt;. The line and phase graphs are respectively given IDs &amp;lt;code&amp;gt;mainGraph&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;phaseGraph&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Visit the model using the link and open the '''Model Definition''' RAM. It contains a single option ('''NuML Code''') with a Code text area. Notice that, although 6 sliders were allotted, only 1 is visible in the default preset. This is a result of the UI configuration contained in the program. As you step through presets note that the input sliders appear and disappear as needed, and that slider and graph legends (names and titles) change to suit the model.&lt;br /&gt;
&lt;br /&gt;
Consider the code for the default Exponential Curve model:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
[[File:expocode.png|400px|Code for Exponential Model]]&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The first line consists of the string &amp;quot;numml&amp;quot;. This is required to indicate that the contents are in NuML rather than Javascript. There are 2 sections: '''model''' and '''configurations'''. (Note that &amp;quot;//&amp;quot; is the comment character meaning that this line is ignored by the compiler).  In the model section are 4 statements using the operator &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt;. In fact, each NuML statement uses Javascript syntax, but with 2 non-Javascript operators:  &amp;lt;code&amp;gt;@=&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt;, which completely program the behavior and look and feel of the simulation. The former is used to specify the model generally in terms of differential (or difference) equations using program variables; the latter asserts properties for the visual components that fit with the particular model&lt;br /&gt;
&lt;br /&gt;
The first block (lines 4 - 8) consists of 3 statements defining the variable of interest, &amp;lt;code&amp;gt;Exp&amp;lt;/code&amp;gt;, and one defining an auxiliary variable &amp;lt;code&amp;gt;Rate&amp;lt;/code&amp;gt; used in line 4. The latter is not entirely necessary; we could instead have written line 4 as &amp;lt;code&amp;gt;deriv(Exp) @= Param1 * Exp&amp;lt;/code&amp;gt;, however the style we used relates the model directly to relabeling of the &amp;lt;code&amp;gt;Param1&amp;lt;/code&amp;gt; slider to &amp;lt;code&amp;gt;Rate&amp;lt;/code&amp;gt; and consequently is more readable. We will continue to see this approach used in the other models in this site.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;deriv(Exp)&amp;lt;/code&amp;gt; specifies a differential equation on line 4 relating &amp;lt;code&amp;gt;Exp&amp;lt;/code&amp;gt; to itself and local variable &amp;lt;code&amp;gt;Rate&amp;lt;/code&amp;gt;. Line 8 binds &amp;lt;code&amp;gt;Rate&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;Param1&amp;lt;/code&amp;gt;, which is the alias we assign to &amp;lt;code&amp;gt;Param1&amp;lt;/code&amp;gt; on line 14. Line 5 provides an initial value for &amp;lt;code&amp;gt;Exp&amp;lt;/code&amp;gt;, and line 6 links &amp;lt;code&amp;gt;Exp&amp;lt;/code&amp;gt; with the line graph &amp;lt;code&amp;gt;mainGraph&amp;lt;/code&amp;gt;, which displays its output..&lt;br /&gt;
&lt;br /&gt;
Lines 11 through 16 use operator &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; to detail the appearance of the input sliders and output graphs. This is mostly self- explanatory, except for the entry for &amp;lt;code&amp;gt;statsGraph&amp;lt;/code&amp;gt;, which will be discussed below. This code is not required, however the result will be a generic display with 6 input sliders labeled &amp;lt;code&amp;gt;Param1&amp;lt;/code&amp;gt; through &amp;lt;code&amp;gt;Param6&amp;lt;/code&amp;gt;, and graphs with no labels. Note that on line 16, setting the legend for the unused sliders to an empty string hides them. &lt;br /&gt;
&lt;br /&gt;
Look at the remaining preset code. Preset 3, in particular, is a good example of the extent to which input sliders can be detailed. This is required because the generic slider properties do not match the value range required in the simulation. Refer to the [[NuML Language Reference]] for a complete description of the NuML language.&lt;br /&gt;
&lt;br /&gt;
'''If you make changes to any of these that you want to save to presets, you should compile before saving so that the compiled code will be loaded when you activate the preset.'''&lt;br /&gt;
&lt;br /&gt;
=== Sensitivity Analysis ===&lt;br /&gt;
&lt;br /&gt;
One of the goals of NWK is to provide secondary platforms for optimization and analysis. To date one such platform exists to perform sensitivity analysis, primarily but not exclusively for SD models. Once again, refer to [https://www.cs.oberlin.edu/~rms/wk/sdnumml1/index.html SD User Defined] to see this in action. Open this site and click on the tab labeled '''Sensitivity'''.&lt;br /&gt;
&lt;br /&gt;
[[File:sens0.png|thumb|Sensitivity Analysis Platform after a run]]&lt;br /&gt;
The figure show on the right shows the Sensitivity Analysis platform for the logistic model (Preset 1) after a run. There are 4 user parameters that govern the behavior as shown:&lt;br /&gt;
&lt;br /&gt;
* '''Parameter''': which parameter is varied (in this model it is '''Rate''').&lt;br /&gt;
* '''Runs''': how many runs (20); &lt;br /&gt;
* '''From''': initial value (0.25);&lt;br /&gt;
* '''To''': final value (0.54);&lt;br /&gt;
&lt;br /&gt;
Clicking '''Start''' initiates 20 runs with the '''Rate''' parameter uniformly stepping through intermediate values between 0.25 and 0.54. During this run, clicking '''Stop''' allows the most recent run to finish, allowing the process to continue by subsequently clicking '''Start'''. Alternatively, clicking '''Step''' proceeds one run at a time until the process concludes. Double-clicking '''Reset''' reinitializes the run.&lt;br /&gt;
&lt;br /&gt;
Results are displayed on 2 graphs, the first being identical to the one on the '''Run''' platform. To its right is a graph showing mean &amp;amp;#177; standard deviation of the point-wise variations seen in the run.&lt;br /&gt;
&lt;br /&gt;
Now open the '''Model Definition''' RAM and look at the code in lines 12 - 15 to see how the Sensitivity Analysis platform was programmed. The statistics display has ID ''statsGraph''. In addition to specifying a title (&amp;quot;Logistic Statistics&amp;quot;), we see the following entries:&lt;br /&gt;
;statDat(N)&lt;br /&gt;
:''N'' is output variable of interest&lt;br /&gt;
;statParam(Rate)&lt;br /&gt;
:''Rate'' is the input parameter to be varied&lt;br /&gt;
;statRuns(20), statLo(0.25), statHi(0.54)&lt;br /&gt;
:20 runs with ''Rate'' varying uniformly between 0.25 and 0.54&lt;br /&gt;
Note that except for '''statDat''', these settings are shown in textfields and merely initialize their parameters. They can be changed, and changes are saved to presets.&lt;br /&gt;
&lt;br /&gt;
== Configuration Overrides ==&lt;br /&gt;
[[File:config.png|thumb|Configuration Window]]&lt;br /&gt;
NuML statements using &amp;lt;code&amp;gt;#=&amp;lt;/code&amp;gt; can be used to configure most models using the Configuration window below the Preset selection window. Shown at right is an override of the factory settings that changes the ''dt'' value and asserts Euler as the integration method. Other overrides will become available soon.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;both&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== CSV Downloads ==&lt;br /&gt;
If a graph contains a '''CSV''' button, clicking that button once the graph has been filled will bring about a download of a CSV (comma separate values) file of the data from that graph. The settings used by the simulation will be recorded above the CSV header.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=&amp;quot;both&amp;quot;&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=Example_NuWebKit_Models&amp;diff=2537</id>
		<title>Example NuWebKit Models</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=Example_NuWebKit_Models&amp;diff=2537"/>
		<updated>2026-02-06T18:59:58Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: /* Numerus Originals */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;These models illustrate the Numerus WebKit modeling technology. To use, load the model into your browser and click '''Connect''' to initialize the model. This will enable the other 4 buttons: '''Disconnect''', '''Reset''', '''Step''' and '''Start'''. Use the '''Start/Stop''' button to run the program continuously. '''Step''' single-steps the program. '''Reset''' returns to the beginning. A '''Double-Reset''' reinitializes the simulation. You can also reinitialize with '''Disconnect/Connect''', or simply reloading the web page. See the [[WebKit Users Guide]] for complete documentation.&lt;br /&gt;
&lt;br /&gt;
Be aware of the side panel, which you open and close by clicking on the side panel icon, [[File:sideicon.png]], and adjust using the purple stripe. This panel contains documentation, preset control and RAM access.&lt;br /&gt;
&lt;br /&gt;
NetLogo is an established platform for implementing agent-based models. Numerus WebKit uses an API analogous to that of NetLogo, keeping the &amp;quot;Patches&amp;quot; and &amp;quot;Turtles&amp;quot; nomenclature and making the translation from NetLogo the WebKit straightforward. Many of the agent-based models in this collection were derived from the NetLogo model library. All such examples include NetLogo documentation, which for now serves to describe the model but may not totally match the WebKit implementation. &lt;br /&gt;
&lt;br /&gt;
===Numerus Originals===&lt;br /&gt;
&lt;br /&gt;
* [https://www.cs.oberlin.edu/~rms/wk/egol3/index.html Three State Extended Game of Life]&lt;br /&gt;
:A 3-state extended version of Conway's Game of Life (GoL). The mathematical equations behind this GoL are described in a paper that can be downloaded at [https://www.biorxiv.org/content/10.1101/2022.08.30.505937v1 mathRxiv]. Click through the 8 presets to view different starting configurations, and feel free to save your own interesting discoveries in unused presets. This model is a focus of the [[WebKit Users Guide]] as an example that makes extensive use of the RAM and preset features.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sirsdet/index.html SIRS WebKit App]&lt;br /&gt;
:Fully developed platform for teaching the SIRS Model. Documented extensively [https://e56600a52a1b6dbf8d29-34f1371aa433cd9fb9d20baa556ed72a.ssl.cf1.rackcdn.com/webapps/webkit/EPI_LESSONS.pdf here].&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sirsdtvdet/index.html Deterministic SIRS with Vaccinations]&lt;br /&gt;
:A mass-action SIRS model with vaccinations described in the publication [https://doi.org/10.1101/2022.02.09.22270752 Simulation Platforms to Support Teaching and Research in Epidemiological Dynamics]. This app was merged into the previous example to create a fully developed platform for teaching the SIRS model.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sirsdtvsto/index.html Stochastic SIRS with Vaccinations]&lt;br /&gt;
:A stochastic version of the previous model. See [https://doi.org/10.1101/2022.02.09.22270752 Simulation Platforms to Support Teaching and Research in Epidemiological Dynamics]&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sdsir/index.html SD SIR]&lt;br /&gt;
:A simple mass-action SIR model demonstrating the WebKit Sensitivity analysis platform.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sdnumml1/index.html SD User Defined]&lt;br /&gt;
:An app in which the user programs the model. Discussed extensively in the [[WebKit Users Guide]].&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/agents/index.html Agents]&lt;br /&gt;
:Simple agent motion.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/ani2/index.html Animover 2]&lt;br /&gt;
: '''Animover''' is a model of a group of agents foraging in an area for a food resource. Animover 2 is a preliminary version. It is the most complex WebKit simulation to date, with several thousand lines of code required to implement the model logic.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/forest/index.html Forest]&lt;br /&gt;
:Cell automata model depicting a forest fire.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/life/index.html Life]]&lt;br /&gt;
:Conway's Game of Life. Enough said. See the [[WebKit Users Guide]] to learn how to initialize the starting configuration.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/lifeagents/index.html Life Agents]&lt;br /&gt;
:Game of Life with agent motion. An agent passing over a live cell colors the cell with the agent's color.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/lorenz/index.html Lorenz Attractor]&lt;br /&gt;
:The Lorenz system is a system of ordinary differential equations first studied by mathematician and meteorologist Edward Lorenz. It is notable for having chaotic solutions for certain parameter values and initial conditions. The term &amp;quot;butterfly effect&amp;quot; in popular media may stem from the real-world implications of the Lorenz attractor, namely that tiny changes in initial conditions evolve to completely different trajectories. &lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/lotka/index.html Lotka-Volterra Model]&lt;br /&gt;
:Shows both time and phase graphs.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/mongoose/index.html Mongoose Behavior] &lt;br /&gt;
:Companion to &amp;quot;Computational Assessment of Population Resilience Mechanisms in the Banded Mongoose (Mungos mungo) of Northern Botswana&amp;quot; (manuscript in progress).&lt;br /&gt;
&lt;br /&gt;
===NetLogo Translations===&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/antz/index.html Ants]&lt;br /&gt;
:NetLogo model. A colony of ants forages for food. Though each ant follows a set of simple rules, the colony as a whole acts in a sophisticated way.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/diffuse/index.html Diffusion]&lt;br /&gt;
:NetLogo diffusion example. Diffusion Graphics is unlike most other NetLogo models, in that it really doesn’t ‘model’ anything. It simply explores the power behind an interesting patch primitive: ‘diffuse’.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/dla/index.html Diffusion Limited Aggregration]&lt;br /&gt;
:This model demonstrates diffusion-limited aggregation, in which randomly moving (diffusing) particles stick together (aggregate) to form beautiful treelike branching fractal structures. There are many patterns found in nature that resemble the patterns produced by this model: crystals, coral, fungi, lightning, and so on.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/flock/index.html Flock]&lt;br /&gt;
:NetLogo model showing the flocking of birds. The resulting motion also resembles schools of fish.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/fng/index.html Fungal Growth]&lt;br /&gt;
:NetLogo model showing the spread of fungal hyphae throughout a section of earth in which moisture is spreading.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/follower/index.html Follower]&lt;br /&gt;
:NetLogo model. In Follower, turtles attempt to “connect” with other turtles, forming long chains according to a small set of simple rules.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/fworks/index.html Fireworks]&lt;br /&gt;
:NetLogo model. This program models the action of fireworks. Rockets begin at the bottom of the view, shoot upwards into the sky and then explode, emitting showers of falling sparks. Works best at lower speed.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/river/index.html Meandering River]&lt;br /&gt;
:Netlogo Model. This model demonstrates the meandering of a river along its “middle course”, where the gradient of the landscape is gradual and the river runs within a U-shaped river valley. The evolution of the shape of the river is governed by the path of its highest-velocity flow, as well as erosion and deposition.&lt;br /&gt;
:This example has documentation extracted from the Netlogo version. Click the icon on the top-right of the page.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/rps/index.html Rock Paper Scissors]&lt;br /&gt;
:NetLogo Model. This model explores the role of movement and space in a three species ecosystem. The system consists of three species, represented by red patches, green patches, and blue patches, which compete over space. The interactions between the species are based on the game Rock-Paper-Scissors. That is, red beats green, green beats blue, and blue beats red. Organisms compete with their neighbors, move throughout the environment, and reproduce. These interactions result in spiral patterns whose size and stability depends on the movement rate of the organisms.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/wolfsheep/index.html Wolf Sheep Predation]&lt;br /&gt;
:NetLogo Model. A population of sheep that wander around the landscape. For each step the sheep take it costs them some energy and if there energy gets too low they die. However, the sheep can eat grass in the environment to regain energy and the grass regrows over time. If the energy of the sheep gets above a certain level then they can reproduce. There are also wolves that have the same behaviors as sheep except for eating; rather than grass, they eat sheep.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/wvmach/index.html Wave Machine]&lt;br /&gt;
:Netlogo Model. This model simulates wave motion in a membrane. The four edges of the membrane are fixed to a frame. A green rectangular area represents a driver plate that moves up and down, exhibiting sinusoidal motion.&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=Example_NuWebKit_Models&amp;diff=2536</id>
		<title>Example NuWebKit Models</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=Example_NuWebKit_Models&amp;diff=2536"/>
		<updated>2025-12-26T18:25:15Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: /* NetLogo Translations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;These models illustrate the Numerus WebKit modeling technology. To use, load the model into your browser and click '''Connect''' to initialize the model. This will enable the other 4 buttons: '''Disconnect''', '''Reset''', '''Step''' and '''Start'''. Use the '''Start/Stop''' button to run the program continuously. '''Step''' single-steps the program. '''Reset''' returns to the beginning. A '''Double-Reset''' reinitializes the simulation. You can also reinitialize with '''Disconnect/Connect''', or simply reloading the web page. See the [[WebKit Users Guide]] for complete documentation.&lt;br /&gt;
&lt;br /&gt;
Be aware of the side panel, which you open and close by clicking on the side panel icon, [[File:sideicon.png]], and adjust using the purple stripe. This panel contains documentation, preset control and RAM access.&lt;br /&gt;
&lt;br /&gt;
NetLogo is an established platform for implementing agent-based models. Numerus WebKit uses an API analogous to that of NetLogo, keeping the &amp;quot;Patches&amp;quot; and &amp;quot;Turtles&amp;quot; nomenclature and making the translation from NetLogo the WebKit straightforward. Many of the agent-based models in this collection were derived from the NetLogo model library. All such examples include NetLogo documentation, which for now serves to describe the model but may not totally match the WebKit implementation. &lt;br /&gt;
&lt;br /&gt;
===Numerus Originals===&lt;br /&gt;
&lt;br /&gt;
* [https://www.cs.oberlin.edu/~rms/wk/egol3/index.html Three State Extended Game of Life]&lt;br /&gt;
:A 3-state extended version of Conway's Game of Life (GoL). The mathematical equations behind this GoL are described in a paper that can be downloaded at [https://www.biorxiv.org/content/10.1101/2022.08.30.505937v1 mathRxiv]. Click through the 8 presets to view different starting configurations, and feel free to save your own interesting discoveries in unused presets. This model is a focus of the [[WebKit Users Guide]] as an example that makes extensive use of the RAM and preset features.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sirsdet/index.html SIRS WebKit App]&lt;br /&gt;
:Fully developed platform for teaching the SIRS Model. Documented extensively [https://e56600a52a1b6dbf8d29-34f1371aa433cd9fb9d20baa556ed72a.ssl.cf1.rackcdn.com/webapps/webkit/EPI_LESSONS.pdf here].&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sirsdtvdet/index.html Deterministic SIRS with Vaccinations]&lt;br /&gt;
:A mass-action SIRS model with vaccinations described in the publication [https://doi.org/10.1101/2022.02.09.22270752 Simulation Platforms to Support Teaching and Research in Epidemiological Dynamics]. This app was merged into the previous example to create a fully developed platform for teaching the SIRS model.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sirsdtvsto/index.html Stochastic SIRS with Vaccinations]&lt;br /&gt;
:A stochastic version of the previous model. See [https://doi.org/10.1101/2022.02.09.22270752 Simulation Platforms to Support Teaching and Research in Epidemiological Dynamics]&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sdsir/index.html SD SIR]&lt;br /&gt;
:A simple mass-action SIR model demonstrating the WebKit Sensitivity analysis platform.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sdnumml1/index.html SD User Defined]&lt;br /&gt;
:An app in which the user programs the model. Discussed extensively in the [[WebKit Users Guide]].&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/agents/index.html Agents]&lt;br /&gt;
:Simple agent motion.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/ani2/index.html Animover 2]&lt;br /&gt;
: '''Animover''' is a model of a group of agents foraging in an area for a food resource. Animover 2 is a preliminary version. It is the most complex WebKit simulation to date, with several thousand lines of code required to implement the model logic.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/forest/index.html Forest]&lt;br /&gt;
:Cell automata model depicting a forest fire.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/life/index.html Life]]&lt;br /&gt;
:Conway's Game of Life. Enough said. See the [[WebKit Users Guide]] to learn how to initialize the starting configuration.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/lifeagents/index.html Life Agents]&lt;br /&gt;
:Game of Life with agent motion. An agent passing over a live cell colors the cell with the agent's color.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/lorenz/index.html Lorenz Attractor]&lt;br /&gt;
:The Lorenz system is a system of ordinary differential equations first studied by mathematician and meteorologist Edward Lorenz. It is notable for having chaotic solutions for certain parameter values and initial conditions. The term &amp;quot;butterfly effect&amp;quot; in popular media may stem from the real-world implications of the Lorenz attractor, namely that tiny changes in initial conditions evolve to completely different trajectories. &lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/lotka/index.html Lotka-Volterra Model]&lt;br /&gt;
:Shows both time and phase graphs.&lt;br /&gt;
&lt;br /&gt;
===NetLogo Translations===&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/antz/index.html Ants]&lt;br /&gt;
:NetLogo model. A colony of ants forages for food. Though each ant follows a set of simple rules, the colony as a whole acts in a sophisticated way.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/diffuse/index.html Diffusion]&lt;br /&gt;
:NetLogo diffusion example. Diffusion Graphics is unlike most other NetLogo models, in that it really doesn’t ‘model’ anything. It simply explores the power behind an interesting patch primitive: ‘diffuse’.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/dla/index.html Diffusion Limited Aggregration]&lt;br /&gt;
:This model demonstrates diffusion-limited aggregation, in which randomly moving (diffusing) particles stick together (aggregate) to form beautiful treelike branching fractal structures. There are many patterns found in nature that resemble the patterns produced by this model: crystals, coral, fungi, lightning, and so on.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/flock/index.html Flock]&lt;br /&gt;
:NetLogo model showing the flocking of birds. The resulting motion also resembles schools of fish.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/fng/index.html Fungal Growth]&lt;br /&gt;
:NetLogo model showing the spread of fungal hyphae throughout a section of earth in which moisture is spreading.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/follower/index.html Follower]&lt;br /&gt;
:NetLogo model. In Follower, turtles attempt to “connect” with other turtles, forming long chains according to a small set of simple rules.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/fworks/index.html Fireworks]&lt;br /&gt;
:NetLogo model. This program models the action of fireworks. Rockets begin at the bottom of the view, shoot upwards into the sky and then explode, emitting showers of falling sparks. Works best at lower speed.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/river/index.html Meandering River]&lt;br /&gt;
:Netlogo Model. This model demonstrates the meandering of a river along its “middle course”, where the gradient of the landscape is gradual and the river runs within a U-shaped river valley. The evolution of the shape of the river is governed by the path of its highest-velocity flow, as well as erosion and deposition.&lt;br /&gt;
:This example has documentation extracted from the Netlogo version. Click the icon on the top-right of the page.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/rps/index.html Rock Paper Scissors]&lt;br /&gt;
:NetLogo Model. This model explores the role of movement and space in a three species ecosystem. The system consists of three species, represented by red patches, green patches, and blue patches, which compete over space. The interactions between the species are based on the game Rock-Paper-Scissors. That is, red beats green, green beats blue, and blue beats red. Organisms compete with their neighbors, move throughout the environment, and reproduce. These interactions result in spiral patterns whose size and stability depends on the movement rate of the organisms.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/wolfsheep/index.html Wolf Sheep Predation]&lt;br /&gt;
:NetLogo Model. A population of sheep that wander around the landscape. For each step the sheep take it costs them some energy and if there energy gets too low they die. However, the sheep can eat grass in the environment to regain energy and the grass regrows over time. If the energy of the sheep gets above a certain level then they can reproduce. There are also wolves that have the same behaviors as sheep except for eating; rather than grass, they eat sheep.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/wvmach/index.html Wave Machine]&lt;br /&gt;
:Netlogo Model. This model simulates wave motion in a membrane. The four edges of the membrane are fixed to a frame. A green rectangular area represents a driver plate that moves up and down, exhibiting sinusoidal motion.&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=Example_NuWebKit_Models&amp;diff=2535</id>
		<title>Example NuWebKit Models</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=Example_NuWebKit_Models&amp;diff=2535"/>
		<updated>2025-11-13T16:11:06Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;These models illustrate the Numerus WebKit modeling technology. To use, load the model into your browser and click '''Connect''' to initialize the model. This will enable the other 4 buttons: '''Disconnect''', '''Reset''', '''Step''' and '''Start'''. Use the '''Start/Stop''' button to run the program continuously. '''Step''' single-steps the program. '''Reset''' returns to the beginning. A '''Double-Reset''' reinitializes the simulation. You can also reinitialize with '''Disconnect/Connect''', or simply reloading the web page. See the [[WebKit Users Guide]] for complete documentation.&lt;br /&gt;
&lt;br /&gt;
Be aware of the side panel, which you open and close by clicking on the side panel icon, [[File:sideicon.png]], and adjust using the purple stripe. This panel contains documentation, preset control and RAM access.&lt;br /&gt;
&lt;br /&gt;
NetLogo is an established platform for implementing agent-based models. Numerus WebKit uses an API analogous to that of NetLogo, keeping the &amp;quot;Patches&amp;quot; and &amp;quot;Turtles&amp;quot; nomenclature and making the translation from NetLogo the WebKit straightforward. Many of the agent-based models in this collection were derived from the NetLogo model library. All such examples include NetLogo documentation, which for now serves to describe the model but may not totally match the WebKit implementation. &lt;br /&gt;
&lt;br /&gt;
===Numerus Originals===&lt;br /&gt;
&lt;br /&gt;
* [https://www.cs.oberlin.edu/~rms/wk/egol3/index.html Three State Extended Game of Life]&lt;br /&gt;
:A 3-state extended version of Conway's Game of Life (GoL). The mathematical equations behind this GoL are described in a paper that can be downloaded at [https://www.biorxiv.org/content/10.1101/2022.08.30.505937v1 mathRxiv]. Click through the 8 presets to view different starting configurations, and feel free to save your own interesting discoveries in unused presets. This model is a focus of the [[WebKit Users Guide]] as an example that makes extensive use of the RAM and preset features.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sirsdet/index.html SIRS WebKit App]&lt;br /&gt;
:Fully developed platform for teaching the SIRS Model. Documented extensively [https://e56600a52a1b6dbf8d29-34f1371aa433cd9fb9d20baa556ed72a.ssl.cf1.rackcdn.com/webapps/webkit/EPI_LESSONS.pdf here].&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sirsdtvdet/index.html Deterministic SIRS with Vaccinations]&lt;br /&gt;
:A mass-action SIRS model with vaccinations described in the publication [https://doi.org/10.1101/2022.02.09.22270752 Simulation Platforms to Support Teaching and Research in Epidemiological Dynamics]. This app was merged into the previous example to create a fully developed platform for teaching the SIRS model.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sirsdtvsto/index.html Stochastic SIRS with Vaccinations]&lt;br /&gt;
:A stochastic version of the previous model. See [https://doi.org/10.1101/2022.02.09.22270752 Simulation Platforms to Support Teaching and Research in Epidemiological Dynamics]&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sdsir/index.html SD SIR]&lt;br /&gt;
:A simple mass-action SIR model demonstrating the WebKit Sensitivity analysis platform.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sdnumml1/index.html SD User Defined]&lt;br /&gt;
:An app in which the user programs the model. Discussed extensively in the [[WebKit Users Guide]].&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/agents/index.html Agents]&lt;br /&gt;
:Simple agent motion.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/ani2/index.html Animover 2]&lt;br /&gt;
: '''Animover''' is a model of a group of agents foraging in an area for a food resource. Animover 2 is a preliminary version. It is the most complex WebKit simulation to date, with several thousand lines of code required to implement the model logic.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/forest/index.html Forest]&lt;br /&gt;
:Cell automata model depicting a forest fire.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/life/index.html Life]]&lt;br /&gt;
:Conway's Game of Life. Enough said. See the [[WebKit Users Guide]] to learn how to initialize the starting configuration.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/lifeagents/index.html Life Agents]&lt;br /&gt;
:Game of Life with agent motion. An agent passing over a live cell colors the cell with the agent's color.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/lorenz/index.html Lorenz Attractor]&lt;br /&gt;
:The Lorenz system is a system of ordinary differential equations first studied by mathematician and meteorologist Edward Lorenz. It is notable for having chaotic solutions for certain parameter values and initial conditions. The term &amp;quot;butterfly effect&amp;quot; in popular media may stem from the real-world implications of the Lorenz attractor, namely that tiny changes in initial conditions evolve to completely different trajectories. &lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/lotka/index.html Lotka-Volterra Model]&lt;br /&gt;
:Shows both time and phase graphs.&lt;br /&gt;
&lt;br /&gt;
===NetLogo Translations===&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/antz/index.html Ants]&lt;br /&gt;
:NetLogo model. A colony of ants forages for food. Though each ant follows a set of simple rules, the colony as a whole acts in a sophisticated way.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/diffuse/index.html Diffusion]&lt;br /&gt;
:NetLogo diffusion example. Diffusion Graphics is unlike most other NetLogo models, in that it really doesn’t ‘model’ anything. It simply explores the power behind an interesting patch primitive: ‘diffuse’.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/dla/index.html Diffusion Limited Aggregration]&lt;br /&gt;
:This model demonstrates diffusion-limited aggregation, in which randomly moving (diffusing) particles stick together (aggregate) to form beautiful treelike branching fractal structures. There are many patterns found in nature that resemble the patterns produced by this model: crystals, coral, fungi, lightning, and so on.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/fng/index.html Fungal Growth]&lt;br /&gt;
:NetLogo model showing the spread of fungal hyphae throughout a section of earth in which moisture is spreading.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/follower/index.html Follower]&lt;br /&gt;
:NetLogo model. In Follower, turtles attempt to “connect” with other turtles, forming long chains according to a small set of simple rules.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/fworks/index.html Fireworks]&lt;br /&gt;
:NetLogo model. This program models the action of fireworks. Rockets begin at the bottom of the view, shoot upwards into the sky and then explode, emitting showers of falling sparks. Works best at lower speed.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/river/index.html Meandering River]&lt;br /&gt;
:Netlogo Model. This model demonstrates the meandering of a river along its “middle course”, where the gradient of the landscape is gradual and the river runs within a U-shaped river valley. The evolution of the shape of the river is governed by the path of its highest-velocity flow, as well as erosion and deposition.&lt;br /&gt;
:This example has documentation extracted from the Netlogo version. Click the icon on the top-right of the page.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/rps/index.html Rock Paper Scissors]&lt;br /&gt;
:NetLogo Model. This model explores the role of movement and space in a three species ecosystem. The system consists of three species, represented by red patches, green patches, and blue patches, which compete over space. The interactions between the species are based on the game Rock-Paper-Scissors. That is, red beats green, green beats blue, and blue beats red. Organisms compete with their neighbors, move throughout the environment, and reproduce. These interactions result in spiral patterns whose size and stability depends on the movement rate of the organisms.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/wolfsheep/index.html Wolf Sheep Predation]&lt;br /&gt;
:NetLogo Model. A population of sheep that wander around the landscape. For each step the sheep take it costs them some energy and if there energy gets too low they die. However, the sheep can eat grass in the environment to regain energy and the grass regrows over time. If the energy of the sheep gets above a certain level then they can reproduce. There are also wolves that have the same behaviors as sheep except for eating; rather than grass, they eat sheep.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/wvmach/index.html Wave Machine]&lt;br /&gt;
:Netlogo Model. This model simulates wave motion in a membrane. The four edges of the membrane are fixed to a frame. A green rectangular area represents a driver plate that moves up and down, exhibiting sinusoidal motion.&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
	<entry>
		<id>https://wiki.numerusinc.com/index.php?title=Example_NuWebKit_Models&amp;diff=2534</id>
		<title>Example NuWebKit Models</title>
		<link rel="alternate" type="text/html" href="https://wiki.numerusinc.com/index.php?title=Example_NuWebKit_Models&amp;diff=2534"/>
		<updated>2025-11-12T16:17:37Z</updated>

		<summary type="html">&lt;p&gt;Rsalter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;These models illustrate the Numerus WebKit modeling technology. To use, load the model into your browser and click '''Connect''' to initialize the model. This will enable the other 4 buttons: '''Disconnect''', '''Reset''', '''Step''' and '''Start'''. Use the '''Start/Stop''' button to run the program continuously. '''Step''' single-steps the program. '''Reset''' returns to the beginning. A '''Double-Reset''' reinitializes the simulation. You can also reinitialize with '''Disconnect/Connect''', or simply reloading the web page. See the [[WebKit Users Guide]] for complete documentation.&lt;br /&gt;
&lt;br /&gt;
Be aware of the side panel, which you open and close by clicking on the side panel icon, [[File:sideicon.png]], and adjust using the purple stripe. This panel contains documentation, preset control and RAM access.&lt;br /&gt;
&lt;br /&gt;
NetLogo is an established platform for implementing agent-based models. Numerus WebKit uses an API analogous to that of NetLogo, keeping the &amp;quot;Patches&amp;quot; and &amp;quot;Turtles&amp;quot; nomenclature and making the translation from NetLogo the WebKit straightforward. Many of the agent-based models in this collection were derived from the NetLogo model library. All such examples include NetLogo documentation, which for now serves to describe the model but may not totally match the WebKit implementation. &lt;br /&gt;
&lt;br /&gt;
===Numerus Originals===&lt;br /&gt;
&lt;br /&gt;
* [https://www.cs.oberlin.edu/~rms/wk/egol3/index.html Three State Extended Game of Life]&lt;br /&gt;
:A 3-state extended version of Conway's Game of Life (GoL). The mathematical equations behind this GoL are described in a paper that can be downloaded at [https://www.biorxiv.org/content/10.1101/2022.08.30.505937v1 mathRxiv]. Click through the 8 presets to view different starting configurations, and feel free to save your own interesting discoveries in unused presets. This model is a focus of the [[WebKit Users Guide]] as an example that makes extensive use of the RAM and preset features.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sirsdet/index.html SIRS WebKit App]&lt;br /&gt;
:Fully developed platform for teaching the SIRS Model. Documented extensively [https://e56600a52a1b6dbf8d29-34f1371aa433cd9fb9d20baa556ed72a.ssl.cf1.rackcdn.com/webapps/webkit/EPI_LESSONS.pdf here].&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sirsdtvdet/index.html Deterministic SIRS with Vaccinations]&lt;br /&gt;
:A mass-action SIRS model with vaccinations described in the publication [https://doi.org/10.1101/2022.02.09.22270752 Simulation Platforms to Support Teaching and Research in Epidemiological Dynamics]. This app was merged into the previous example to create a fully developed platform for teaching the SIRS model.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sirsdtvsto/index.html Stochastic SIRS with Vaccinations]&lt;br /&gt;
:A stochastic version of the previous model. See [https://doi.org/10.1101/2022.02.09.22270752 Simulation Platforms to Support Teaching and Research in Epidemiological Dynamics]&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sdsir/index.html SD SIR]&lt;br /&gt;
:A simple mass-action SIR model demonstrating the WebKit Sensitivity analysis platform.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/sdnumml1/index.html SD User Defined]&lt;br /&gt;
:An app in which the user programs the model. Discussed extensively in the [[WebKit Users Guide]].&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/agents/index.html Agents]&lt;br /&gt;
:Simple agent motion.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/forest/index.html Forest]&lt;br /&gt;
:Cell automata model depicting a forest fire.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/life/index.html Life]]&lt;br /&gt;
:Conway's Game of Life. Enough said. See the [[WebKit Users Guide]] to learn how to initialize the starting configuration.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/lifeagents/index.html Life Agents]&lt;br /&gt;
:Game of Life with agent motion. An agent passing over a live cell colors the cell with the agent's color.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/lorenz/index.html Lorenz Attractor]&lt;br /&gt;
:The Lorenz system is a system of ordinary differential equations first studied by mathematician and meteorologist Edward Lorenz. It is notable for having chaotic solutions for certain parameter values and initial conditions. The term &amp;quot;butterfly effect&amp;quot; in popular media may stem from the real-world implications of the Lorenz attractor, namely that tiny changes in initial conditions evolve to completely different trajectories. &lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/lotka/index.html Lotka-Volterra Model]&lt;br /&gt;
:Shows both time and phase graphs.&lt;br /&gt;
&lt;br /&gt;
===NetLogo Translations===&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/antz/index.html Ants]&lt;br /&gt;
:NetLogo model. A colony of ants forages for food. Though each ant follows a set of simple rules, the colony as a whole acts in a sophisticated way.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/diffuse/index.html Diffusion]&lt;br /&gt;
:NetLogo diffusion example. Diffusion Graphics is unlike most other NetLogo models, in that it really doesn’t ‘model’ anything. It simply explores the power behind an interesting patch primitive: ‘diffuse’.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/dla/index.html Diffusion Limited Aggregration]&lt;br /&gt;
:This model demonstrates diffusion-limited aggregation, in which randomly moving (diffusing) particles stick together (aggregate) to form beautiful treelike branching fractal structures. There are many patterns found in nature that resemble the patterns produced by this model: crystals, coral, fungi, lightning, and so on.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/fng/index.html Fungal Growth]&lt;br /&gt;
:NetLogo model showing the spread of fungal hyphae throughout a section of earth in which moisture is spreading.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/follower/index.html Follower]&lt;br /&gt;
:NetLogo model. In Follower, turtles attempt to “connect” with other turtles, forming long chains according to a small set of simple rules.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/fworks/index.html Fireworks]&lt;br /&gt;
:NetLogo model. This program models the action of fireworks. Rockets begin at the bottom of the view, shoot upwards into the sky and then explode, emitting showers of falling sparks. Works best at lower speed.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/river/index.html Meandering River]&lt;br /&gt;
:Netlogo Model. This model demonstrates the meandering of a river along its “middle course”, where the gradient of the landscape is gradual and the river runs within a U-shaped river valley. The evolution of the shape of the river is governed by the path of its highest-velocity flow, as well as erosion and deposition.&lt;br /&gt;
:This example has documentation extracted from the Netlogo version. Click the icon on the top-right of the page.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/rps/index.html Rock Paper Scissors]&lt;br /&gt;
:NetLogo Model. This model explores the role of movement and space in a three species ecosystem. The system consists of three species, represented by red patches, green patches, and blue patches, which compete over space. The interactions between the species are based on the game Rock-Paper-Scissors. That is, red beats green, green beats blue, and blue beats red. Organisms compete with their neighbors, move throughout the environment, and reproduce. These interactions result in spiral patterns whose size and stability depends on the movement rate of the organisms.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/wolfsheep/index.html Wolf Sheep Predation]&lt;br /&gt;
:NetLogo Model. A population of sheep that wander around the landscape. For each step the sheep take it costs them some energy and if there energy gets too low they die. However, the sheep can eat grass in the environment to regain energy and the grass regrows over time. If the energy of the sheep gets above a certain level then they can reproduce. There are also wolves that have the same behaviors as sheep except for eating; rather than grass, they eat sheep.&lt;br /&gt;
&lt;br /&gt;
* [https://94803ca8ae7275c8ec82-af69fe8046cb86ce613bfe795f3569f4.ssl.cf1.rackcdn.com/NumerusOL/WebKit/wvmach/index.html Wave Machine]&lt;br /&gt;
:Netlogo Model. This model simulates wave motion in a membrane. The four edges of the membrane are fixed to a frame. A green rectangular area represents a driver plate that moves up and down, exhibiting sinusoidal motion.&lt;/div&gt;</summary>
		<author><name>Rsalter</name></author>
	</entry>
</feed>