{"data":{"markdownRemark":{"html":"<h2 id=\"overview\"><a href=\"#overview\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Overview</h2>\n<p>In this introductory tutorial, we will cover all the components needed to build the classical agent-based Susceptible, Infected, Recovered infection model. </p>\n<p>In our implementation we will build a fully connected network of people agents in which some initial portion of the population will be infected with an infectious disease. At each step in our simulation, infectious people agents have the possibility of infecting a susceptible agent based on a user-defined infection probability.</p>\n<p>Realistic infection dynamics emerge from the model based on the simple rule above.</p>\n<p>This tutorial is structured in 3 sections:</p>\n<ol>\n<li>Project Structure</li>\n<li>Model</li>\n<li>Console</li>\n</ol>\n<p>The code for this tutorial is available as a zip download, containing a complete model as a Maven project. This project should be able to be run from any Maven or Java IDE environment.</p>\n<a href=\"https://simudynecontent.blob.core.windows.net/$web/tutorials/zips/sir_model_v2.4.zip\" class=\"ui button primary\" download>\n\tDownload Tutorial Files\n</a>\n<h2 id=\"project-structure\"><a href=\"#project-structure\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Project Structure</h2>\n<p>The downloaded zip consists of files defining a Maven build. Some of these files will be common to every Simudyne model project, while others are specific to the model being built.</p>\n<div class=\"gatsby-highlight\" data-language=\"shell\"><pre class=\"language-shell\"><code class=\"language-shell\">/README.md                <span class=\"token comment\"># Human readable description</span>\n/pom.xml                  <span class=\"token comment\"># Maven configuration (dependencies, etc)</span>\n/simudyneSDK.properties   <span class=\"token comment\"># Simudyne SDK configuration</span>\n/.gitignore               <span class=\"token comment\"># Git version control ignore rules</span>\n\n/src/main/resources/log4j.properties              <span class=\"token comment\"># Logging configuration</span>\n\n/src/main/java/Main.java                          <span class=\"token comment\"># Application entrypoint</span>\n/src/main/java/SimudyneSIR/SimudyneSIR.java       <span class=\"token comment\"># Model class</span>\n/src/main/java/SimudyneSIR/SirAgent.java          <span class=\"token comment\"># Agent class</span>\n/src/main/java/SimudyneSIR/Messages.java          <span class=\"token comment\"># Message classes</span>\n/src/main/java/SimudyneSIR/Links.java             <span class=\"token comment\"># Link classes</span></code></pre></div>\n<h3 id=\"project-configuration-and-documentation\"><a href=\"#project-configuration-and-documentation\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><a href=\"https://portal.simudyne.com/tutorials/trader#project-configuration-and-documentation\"></a>Project configuration and documentation</h3>\n<p>The top level files define some project configuration and helpful documentation.</p>\n<ul>\n<li><code class=\"language-text\">README.md</code>  is a markdown file, and a good place to put documentation relating to the model for others (and yourself) to refer to. If hosted on version control services such as GitHub or BitBucket then it will display nicely to other users.</li>\n<li><code class=\"language-text\">pom.xml</code>  contains the Maven configuration, and is where you can change or add dependencies to your project. This is important for changing version of the SDK, as well as adding additional libraries you may need for modelling.</li>\n<li><code class=\"language-text\">simudyneSDK.properties</code>  allows configuration of the SDK libraries, such as enabling, disabling or tuning certain features.</li>\n<li><code class=\"language-text\">.gitignore</code>  is a file for the Git version control system, to ignore certain files from being tracked. These files include files generated by compilation (inside the  <code class=\"language-text\">target</code>  folder) as well as caches created by IDE programs such as IntelliJ or Eclipse.</li>\n<li><code class=\"language-text\">log4j.properties</code>  inside resources defines a default logging setup, writing helpful information to the console. More information on configuration of logging can be found in the  <a href=\"https://portal.simudyne.com/reference/logging\">reference</a>.</li>\n</ul>\n<h3 id=\"model-definition\"><a href=\"#model-definition\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><a href=\"https://portal.simudyne.com/tutorials/trader#model-definition\"></a>Model definition</h3>\n<p>The files under  <code class=\"language-text\">/src/main/java</code>  define your project.</p>\n<p><code class=\"language-text\">Main.java</code>  defines the entrypoint for your application. The included file is setup to simply register the  <code class=\"language-text\">SimudyneSIR</code>  (with a name) and start the server. Your project can include multiple models, but you should think carefully if you need to collaborate with others. A separate project per model will make collaborating and versioning each individual model easier.</p>\n<p>The model files themselves are then inside  <code class=\"language-text\">SimudyneSIR</code>. The Java convention is to use packages, where a package matches the folder structure to the file itself. So the model class  <code class=\"language-text\">models.SimudyneSIR</code>  is located at  <code class=\"language-text\">models/SimudyneSIR/SimudyneSIR.java</code>.</p>\n<ul>\n<li><code class=\"language-text\">SimudyneSIR.java</code>  defines the model itself (referred to as the  <strong>Model class</strong>).</li>\n<li>Agents are then defined in their own files, each defining a single  <strong>Agent class</strong>  of the same name.</li>\n<li>By convention, message and link classes are nested inside a wrapping class, to help reduce the number of files.</li>\n</ul>\n<h1 id=\"model\"><a href=\"#model\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Model</h1>\n<p>The Model class (<code class=\"language-text\">SimudyneSIR</code>, inside  <code class=\"language-text\">SimudyneSIR.java</code>) is the root of your model. Broadly, it ties together 3 concerns:</p>\n<ul>\n<li>\n<p>Initialisation</p>\n<ul>\n<li>Define global state, including accumulators</li>\n<li>Define inputs and outputs of the model</li>\n<li>Register Agent and Link types</li>\n</ul>\n</li>\n<li>\n<p>Setup</p>\n<ul>\n<li>Create the agents within the model (from the console, this is what happens when the  <strong>Initialise</strong>  button is pressed).</li>\n</ul>\n</li>\n<li>\n<p>Simulation</p>\n<ul>\n<li>Define a  <code class=\"language-text\">step</code>  method which moves the simulation from one tick to the next.</li>\n</ul>\n</li>\n</ul>\n<h2 id=\"initialisation\"><a href=\"#initialisation\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Initialisation</h2>\n<p>Initialisation covers any top level fields on the model, the  <code class=\"language-text\">Globals</code>  class, as well as an implementation of the  <code class=\"language-text\">init</code>  method.</p>\n<div class=\"ui segment warning message\" \n><h4>Constructors</h4>  \n<p>If you're familiar with Java (or other languages with classes) then you may be tempted to do initialisation within a constructor. If you do define a constructor, then it must take no arguments. Also, if you want to use any contextual APIs (through <code class=\"language-text\">getContext()</code>) this must be done inside <code class=\"language-text\">init</code> and not within the constructor or during field declaration.</p></div>\n<h3 id=\"model-fields\"><a href=\"#model-fields\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Model Fields</h3>\n<p>Defining inputs and outputs can be done through fields on your Model class. These define model-level properties that only the top level model has access to (agents cannot access these). These fields are useful for defining model constants needed for  <code class=\"language-text\">setup</code>, as well as variables that are computed by the model at the top level.</p>\n<blockquote>\n<p>SimudyneSIR.java</p>\n</blockquote>\n<div class=\"gatsby-highlight\" data-language=\"java\"><pre class=\"language-java\"><code class=\"language-java\"> <span class=\"token annotation punctuation\">@Constant</span><span class=\"token punctuation\">(</span>name <span class=\"token operator\">=</span> <span class=\"token string\">\"Number of SIR Agents\"</span><span class=\"token punctuation\">)</span>\n    <span class=\"token keyword\">public</span> <span class=\"token keyword\">int</span> numAgents <span class=\"token operator\">=</span> <span class=\"token number\">100</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p>Fields (on the model, as well as within Globals or on Agents or Links) can be annotated to make them visible to the SDK. There are 3 common annotations needed for most models:</p>\n<ul>\n<li>\n<p><code class=\"language-text\">@Input</code>  denotes a field as being accessible by the outside world, and available at any time during the simulation. This is useful for parameters that may be controlled by an end user, or exogeneous factors to be varied by scenarios.</p>\n</li>\n<li>\n<p><code class=\"language-text\">@Constant</code>  denotes an  <code class=\"language-text\">@Input</code>  which can only be changed prior to  <code class=\"language-text\">setup</code>. This is useful for fixed parameters of the model, such as the initial number of agents, which will make no difference after  <code class=\"language-text\">setup</code>  has been called.</p>\n</li>\n<li>\n<p><code class=\"language-text\">@Variable</code>  denotes an output of the model, which is available only after  <code class=\"language-text\">setup</code>  has been called. This means it is safe for fields marked as  <code class=\"language-text\">@Variable</code>  to be uninitialised, as long as they are initialised by the  <code class=\"language-text\">setup</code>  method.</p>\n<ul>\n<li><code class=\"language-text\">@Variable</code>  can also be used to annotate methods. The method must take no argument, and return a supported type. The method will only be called after  <code class=\"language-text\">setup</code>  has been run, and so can depend on internal state such as agents being initialised.</li>\n</ul>\n</li>\n</ul>\n<div class=\"ui segment warning message\" \n><h4>Public vs Private fields</h4>  \n<p>If you are using Java version 9 or above, you will need to make all annotated fields or methods  <code class=\"language-text\">public</code>. On Java version 8, fields and methods can also be private or package-private.</p></div>\n<h3 id=\"globals\"><a href=\"#globals\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Globals</h3>\n<p>Simudyne ABM makes visible to all agents a single instance of a class extending  <code class=\"language-text\">simudyne.core.abm.GlobalState</code>, as defined by the type in  <code class=\"language-text\">extends AgentBasedModel&lt;SimudyneSIR.Globals&gt;</code>. This class may exist in another file, but by convention it is placed inside the Model class as a  <code class=\"language-text\">public static final</code>  class.</p>\n<p>Fields on the  <code class=\"language-text\">Globals</code>  class can be annotated as with fields. The console interface will treat any annotated fields on the  <code class=\"language-text\">Globals</code>  just like fields on the Model class itself.</p>\n<p>The  <code class=\"language-text\">Globals</code>  class is accessible to all agents within the system, however agents should  <strong>not</strong>  mutate (change) any fields in this object. Because agents operate in parallel, the results of agents modifying any information in the  <code class=\"language-text\">Globals</code>  class is undefined. Agents should instead contribute to global statistics either eagerly (through  <code class=\"language-text\">Accumulators</code>) or lazily (through model-level queries into agent state).</p>\n<blockquote>\n<p>SimudyneSIR.java</p>\n</blockquote>\n<div class=\"gatsby-highlight\" data-language=\"java\"><pre class=\"language-java\"><code class=\"language-java\"><span class=\"token keyword\">public</span> <span class=\"token keyword\">static</span> <span class=\"token keyword\">final</span> <span class=\"token keyword\">class</span> <span class=\"token class-name\">Globals</span> <span class=\"token keyword\">extends</span> <span class=\"token class-name\">GlobalState</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token annotation punctuation\">@Input</span><span class=\"token punctuation\">(</span>name <span class=\"token operator\">=</span> \"Infection Probability<span class=\"token punctuation\">)</span>  \n    <span class=\"token keyword\">public</span> <span class=\"token keyword\">double</span> infectionProbability <span class=\"token operator\">=</span> <span class=\"token number\">0.01</span><span class=\"token punctuation\">;</span>  \n      \n    <span class=\"token annotation punctuation\">@Input</span><span class=\"token punctuation\">(</span>name <span class=\"token operator\">=</span> <span class=\"token string\">\"Initial Outbreak\"</span><span class=\"token punctuation\">)</span>  \n    <span class=\"token keyword\">public</span> <span class=\"token keyword\">int</span> initialOutbreak <span class=\"token operator\">=</span> <span class=\"token number\">1</span><span class=\"token punctuation\">;</span>  \n      \n    <span class=\"token annotation punctuation\">@Input</span><span class=\"token punctuation\">(</span>name <span class=\"token operator\">=</span> <span class=\"token string\">\"Infection Duration\"</span><span class=\"token punctuation\">)</span>  \n    <span class=\"token keyword\">public</span> <span class=\"token keyword\">int</span> infectionDuration <span class=\"token operator\">=</span> <span class=\"token number\">1</span><span class=\"token punctuation\">;</span>\n <span class=\"token punctuation\">}</span></code></pre></div>\n<p>Fields marked as <code class=\"language-text\">@Input</code> allow you to change the values from the console. These parameters are selected by default and are used to tune the infection dynamics in the model. These parameters can be accessed by agents in the system and can be used by the behaviours on the agents.</p>\n<div class=\"ui segment warning message\" \n><h4>Setting Globals During Setup</h4>  \n<p>Globals allows you to define variables that can be accessed and modified by both the model and agents within the system. However, during the setup process when you are creating agents via an injector, you should not by modifying globals. This is due to Java 8 lambda's. If you wish to properly modify Globals, make sure it is part of the message passing action of an agent, or make usage of an accumulator.</p></div>\n<h3 id=\"accumulators\"><a href=\"#accumulators\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Accumulators</h3>\n<p>Accumulators can be thought of as named numeric counters that agents can read, add or remove from. As agents act in parallel, they will not see updates to the accumulator within a single phase (even their own), but every agent will see the same value of the counter on the next phase (with all changes to the accumulator from all agents summed together).</p>\n<p>Accumulators can be either  <code class=\"language-text\">Long</code>  (64bit integer) or  <code class=\"language-text\">Double</code>  (64bit floating point), created through  <code class=\"language-text\">createLongAccumulator</code>/<code class=\"language-text\">createDoubleAccumulator</code>.</p>\n<blockquote>\n<p>SimudyneSIR.java</p>\n</blockquote>\n<div class=\"gatsby-highlight\" data-language=\"java\"><pre class=\"language-java\"><code class=\"language-java\">\t<span class=\"token function\">createLongAccumulator</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"susceptible\"</span><span class=\"token punctuation\">,</span> <span class=\"token string\">\"Number of Susceptible\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>  \n    <span class=\"token function\">createLongAccumulator</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"infected\"</span><span class=\"token punctuation\">,</span> <span class=\"token string\">\"Number of Infected\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>  \n    <span class=\"token function\">createLongAccumulator</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"recovered\"</span><span class=\"token punctuation\">,</span> <span class=\"token string\">\"Number of Recovered\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p>We have created 3 accumulators, identified by a key, e.g. <code class=\"language-text\">susceptible</code>, and a friendly display name for the console, e.g. <code class=\"language-text\">Number of Susceptible</code>. Note that the display name is optional so you could have <code class=\"language-text\">createDoubleAccumulator(&quot;susceptible&quot;)</code> if you were happy with that name appearing on the console.</p>\n<p>The <code class=\"language-text\">susceptible</code>, <code class=\"language-text\">infected</code>, and <code class=\"language-text\">recovered</code> accumulators are used to report the state of an agent so we can track the dynamics of our infection and track the number of agents in each state.</p>\n<h3 id=\"type-registration\"><a href=\"#type-registration\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Type registration</h3>\n<p>As part of initialisation, you also need to register all  <code class=\"language-text\">Agent</code>  and  <code class=\"language-text\">Link</code>  types that will be used in the simulation. This allows the SDK to properly handle and output data for these types, even if they might be created dynamically.</p>\n<blockquote>\n<p>SimudyneSIR.java</p>\n</blockquote>\n<div class=\"gatsby-highlight\" data-language=\"java\"><pre class=\"language-java\"><code class=\"language-java\"><span class=\"token function\">registerAgentTypes</span><span class=\"token punctuation\">(</span>SirAgent<span class=\"token punctuation\">.</span><span class=\"token keyword\">class</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token function\">registerLinkTypes</span><span class=\"token punctuation\">(</span>Links<span class=\"token punctuation\">.</span>SirLink<span class=\"token punctuation\">.</span><span class=\"token keyword\">class</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p>In this model we have two agent types, and a single link type, as shown above. We'll see how these Agent and Link types are brought to life next, in setup.</p>\n<h2 id=\"setup\"><a href=\"#setup\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Setup</h2>\n<h3 id=\"topology\"><a href=\"#topology\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Topology</h3>\n<p>Where  <code class=\"language-text\">init</code>  is concerned with declaring the component pieces of a model, the  <code class=\"language-text\">setup</code>  method is concerned with declaring an initial state for our model using those pieces. At the time that  <code class=\"language-text\">setup</code>  is called, a user on the console (or other client to the model) will have had the chance to change inputs and constants. The  <code class=\"language-text\">setup</code>  method can then take these inputs and customise the creation of the model accordingly.</p>\n<p>Creating the initial agents is done through the concept of a topology of groups. A group represents a parameterised set of agents, where each group has a type of agent, a number of agents in that group, and optionally an initialiser, which can customise the state for each agent.</p>\n<blockquote>\n<p>SimudyneSIR.java</p>\n</blockquote>\n<div class=\"gatsby-highlight\" data-language=\"java\"><pre class=\"language-java\"><code class=\"language-java\">Group<span class=\"token generics function\"><span class=\"token punctuation\">&lt;</span>SirAgent<span class=\"token punctuation\">></span></span> sirAgentGroup <span class=\"token operator\">=</span> <span class=\"token function\">generateGroup</span><span class=\"token punctuation\">(</span>SirAgent<span class=\"token punctuation\">.</span><span class=\"token keyword\">class</span><span class=\"token punctuation\">,</span> numAgents<span class=\"token punctuation\">,</span> a <span class=\"token operator\">-</span><span class=\"token operator\">></span> <span class=\"token punctuation\">{</span>  \n\t<span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>a<span class=\"token punctuation\">.</span><span class=\"token function\">getID</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">&lt;</span> <span class=\"token function\">getGlobals</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span>initialOutbreak<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span> \n\t  <span class=\"token comment\">// expose  </span>\n\t  a<span class=\"token punctuation\">.</span>status <span class=\"token operator\">=</span> SirAgent<span class=\"token punctuation\">.</span>Status<span class=\"token punctuation\">.</span>INFECTED<span class=\"token punctuation\">;</span>  \n <span class=\"token punctuation\">}</span><span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p>In this model we have a group of people agents or <code class=\"language-text\">SirAgent</code>, the size of which is taken as an input. As part of it's logic, the SIR agent also needs to decide whether it will start the simulation in the infected state. The initial outbreak could be handled in a number of ways. We use a Java lambda function and use the agent ID's to create our initial outbreak.</p>\n<p>The reason behind this choice is due to the fact that we only have one group of agents whose static ID's will be generated in the generateGroup loop function called above. Starting at 0, each iteration of the loop will generate a new agent with a unique ID incrementing by 1 at each iteration. This means the first agent generated in this group will have an ID of 0, the second agent generated will have an ID of 1, and so on. </p>\n<p>Note that if there are more than one group of agents, the value of ID's of the second group will continue from the numbering that was left after the first group has completed generating. For example, imagine we have 2 agent groups; AgentGroup1 and AgentGroup2. if AgentGroup1 has 3 agents and was generated first, the first Agent ID of AgentGroup2 will be 3, the next will be 4, etc.</p>\n<p>We're programmatically defining agents here, as it's quick to get started, but you can also load groups from external data sources.</p>\n<blockquote>\n<p>SimudyneSIR.java</p>\n</blockquote>\n<div class=\"gatsby-highlight\" data-language=\"java\"><pre class=\"language-java\"><code class=\"language-java\">sirAgentGroup<span class=\"token punctuation\">.</span><span class=\"token function\">fullyConnected</span><span class=\"token punctuation\">(</span>sirAgentGroup<span class=\"token punctuation\">,</span>Links<span class=\"token punctuation\">.</span>SirLink<span class=\"token punctuation\">.</span><span class=\"token keyword\">class</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p>With our group generated, we now need to give them knowledge of each other. This is done through links, which represent knowledge agents have of other agents. In the simple case, the link itself has no attributes, which means it simply represents knowledge that another agent exists. Here we use a pre-defined connector, which gives every agent in that group a link to every agent to the target group. There are many other strategies for linking agents together, including loading from data sources, detailed in the reference on  <a href=\"https://portal.simudyne.com/reference/agents/topologies\">topologies</a>.</p>\n<p>Here we give each agent a link to every other agent in the system. Links are unidirectional, and only visible to the originating group.</p>\n<h3 id=\"super\"><a href=\"#super\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Super</h3>\n<p>A vital final part of  <code class=\"language-text\">setup</code>  is to call  <code class=\"language-text\">super.setup()</code>. This tells the underlying system to actually initialise and setup the topology we have described. Usually this will be the last part of your setup method, however a useful pattern can be to call  <code class=\"language-text\">step</code>  at the final part of  <code class=\"language-text\">setup</code>. This runs the model forward a step, and can be very useful to avoid a jump on a chart for example, should the agents need to run forwards initially to produce sensible values.</p>\n<h2 id=\"step\"><a href=\"#step\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Step</h2>\n<p>Step is called once every time the model is run forwards a step. Step takes care of the logic that happens between each tick, in an ABM this is mostly concerned with running behavioural sequences over the system to move the system forwards through time.</p>\n<h3 id=\"super-1\"><a href=\"#super-1\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Super</h3>\n<p>The start of  <code class=\"language-text\">step</code>  calls  <code class=\"language-text\">super.step</code>, signalling to the system that another step is beginning. This performs general lifecycle hooks necessary for agents, and other tasks such as resetting any non-persistent accumulators back to  <code class=\"language-text\">0</code>.</p>\n<h3 id=\"run-sequences\"><a href=\"#run-sequences\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Run Sequences</h3>\n<blockquote>\n<p>SimudyneSIR.java</p>\n</blockquote>\n<div class=\"gatsby-highlight\" data-language=\"java\"><pre class=\"language-java\"><code class=\"language-java\"><span class=\"token function\">run</span><span class=\"token punctuation\">(</span>SirAgent<span class=\"token punctuation\">.</span>step<span class=\"token punctuation\">,</span> SirAgent<span class=\"token punctuation\">.</span>exposed<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p>we run a  <a href=\"https://portal.simudyne.com/reference/agents/actions-and-sequencing\">sequence of actions</a>. In this model, this consists of running the  <code class=\"language-text\">SirAgent#step</code>  and  <code class=\"language-text\">SirAgent#exposed</code>  actions in sequence. The general idea is that at each step an infected agent will determine whether it will infect another agent and any agent that receives an infection message will become infected. We'll look at these behaviours in depth soon.</p>\n<p>The important thing to note above is that  <strong>only agents that receive messages get to act</strong>. The first action in any sequence is special, as at that point every agent gets to act (otherwise no agent would ever get to act, which would be unfortunate).</p>\n<h2 id=\"behaviours\"><a href=\"#behaviours\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Behaviours</h2>\n<p>We'll run through the actions in this sequence in order, to see how they progress. When we see each agent for the first time, we'll also have a quick look at how it's defined.</p>\n<h3 id=\"siragentstep\"><a href=\"#siragentstep\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>SirAgent#step</h3>\n<blockquote>\n<p>SirAgent.java</p>\n</blockquote>\n<div class=\"gatsby-highlight\" data-language=\"java\"><pre class=\"language-java\"><code class=\"language-java\"><span class=\"token keyword\">public</span> <span class=\"token keyword\">class</span> <span class=\"token class-name\">SirAgent</span> <span class=\"token keyword\">extends</span> <span class=\"token class-name\">Agent</span><span class=\"token generics function\"><span class=\"token punctuation\">&lt;</span>SimudyneSIR<span class=\"token punctuation\">.</span>Globals<span class=\"token punctuation\">></span></span> <span class=\"token punctuation\">{</span>  \n  <span class=\"token keyword\">public</span> <span class=\"token keyword\">enum</span> Status <span class=\"token punctuation\">{</span> SUSCEPTIBLE<span class=\"token punctuation\">,</span> INFECTED<span class=\"token punctuation\">,</span> RECOVERED <span class=\"token punctuation\">}</span><span class=\"token punctuation\">;</span>  \n  <span class=\"token keyword\">public</span> Status status <span class=\"token operator\">=</span> Status<span class=\"token punctuation\">.</span>SUSCEPTIBLE<span class=\"token punctuation\">;</span>  s\n  <span class=\"token keyword\">public</span> <span class=\"token keyword\">int</span> timeSinceInfected <span class=\"token operator\">=</span> <span class=\"token number\">0</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p>Our SirAgent is defined as an agent which has a <code class=\"language-text\">status</code> and a <code class=\"language-text\">timeSinceInfected</code> variable, as well as an enum for categorizing agents into their respective bins.</p>\n<blockquote>\n<p>SirAgent.java</p>\n</blockquote>\n<div class=\"gatsby-highlight\" data-language=\"java\"><pre class=\"language-java\"><code class=\"language-java\"><span class=\"token keyword\">public</span> <span class=\"token keyword\">static</span> Action<span class=\"token generics function\"><span class=\"token punctuation\">&lt;</span>SirAgent<span class=\"token punctuation\">></span></span> step <span class=\"token operator\">=</span>  \n  Action<span class=\"token punctuation\">.</span><span class=\"token function\">create</span><span class=\"token punctuation\">(</span>SirAgent<span class=\"token punctuation\">.</span><span class=\"token keyword\">class</span><span class=\"token punctuation\">,</span> a <span class=\"token operator\">-</span><span class=\"token operator\">></span> <span class=\"token punctuation\">{</span>  \n  \n\t  <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>a<span class=\"token punctuation\">.</span>status <span class=\"token operator\">==</span> Status<span class=\"token punctuation\">.</span>INFECTED<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>  \n\t  \n\t\t  <span class=\"token comment\">// Loop through neighbors and stochastically expose them  </span>\n\t\t  a<span class=\"token punctuation\">.</span><span class=\"token function\">getLinks</span><span class=\"token punctuation\">(</span>Links<span class=\"token punctuation\">.</span>SirLink<span class=\"token punctuation\">.</span><span class=\"token keyword\">class</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span><span class=\"token function\">forEach</span><span class=\"token punctuation\">(</span>l <span class=\"token operator\">-</span><span class=\"token operator\">></span> <span class=\"token punctuation\">{</span>  \n\t\t\t  <span class=\"token keyword\">double</span> val <span class=\"token operator\">=</span> a<span class=\"token punctuation\">.</span><span class=\"token function\">getPrng</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span><span class=\"token function\">uniform</span><span class=\"token punctuation\">(</span><span class=\"token number\">0</span><span class=\"token punctuation\">,</span> <span class=\"token number\">1</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span><span class=\"token function\">sample</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>  \n\t\t\t  <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>val <span class=\"token operator\">&lt;</span> a<span class=\"token punctuation\">.</span><span class=\"token function\">getGlobals</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span>infectionProbability<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>  \n\t\t\t\t  a<span class=\"token punctuation\">.</span><span class=\"token function\">send</span><span class=\"token punctuation\">(</span>Messages<span class=\"token punctuation\">.</span>InfectMessage<span class=\"token punctuation\">.</span><span class=\"token keyword\">class</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span><span class=\"token function\">to</span><span class=\"token punctuation\">(</span>l<span class=\"token punctuation\">.</span><span class=\"token function\">getTo</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>  \n\t\t\t  <span class=\"token punctuation\">}</span> \n\t\t  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> \n\t\t   \n\t\t  <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>a<span class=\"token punctuation\">.</span>timeSinceInfected<span class=\"token operator\">++</span> <span class=\"token operator\">></span> a<span class=\"token punctuation\">.</span><span class=\"token function\">getGlobals</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span>infectionDuration<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>  \n\t\t\t  a<span class=\"token punctuation\">.</span>status <span class=\"token operator\">=</span> Status<span class=\"token punctuation\">.</span>RECOVERED<span class=\"token punctuation\">;</span>  \n\t\t  <span class=\"token punctuation\">}</span> \n\t  <span class=\"token punctuation\">}</span>  \n\t  <span class=\"token keyword\">switch</span> <span class=\"token punctuation\">(</span>a<span class=\"token punctuation\">.</span>status<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>  \n\t\t  <span class=\"token keyword\">case</span> SUSCEPTIBLE<span class=\"token operator\">:</span>  \n\t\t\t  a<span class=\"token punctuation\">.</span><span class=\"token function\">getLongAccumulator</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"susceptible\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span><span class=\"token function\">add</span><span class=\"token punctuation\">(</span><span class=\"token number\">1</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>  \n\t\t\t  <span class=\"token keyword\">break</span><span class=\"token punctuation\">;</span>  \n\t\t  <span class=\"token keyword\">case</span> INFECTED<span class=\"token operator\">:</span>  \n\t\t\t  a<span class=\"token punctuation\">.</span><span class=\"token function\">getLongAccumulator</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"infected\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span><span class=\"token function\">add</span><span class=\"token punctuation\">(</span><span class=\"token number\">1</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>  \n\t\t\t  <span class=\"token keyword\">break</span><span class=\"token punctuation\">;</span>  \n\t\t  <span class=\"token keyword\">case</span> RECOVERED<span class=\"token operator\">:</span>  \n\t\t\t  a<span class=\"token punctuation\">.</span><span class=\"token function\">getLongAccumulator</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"recovered\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span><span class=\"token function\">add</span><span class=\"token punctuation\">(</span><span class=\"token number\">1</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>  \n\t\t\t  <span class=\"token keyword\">break</span><span class=\"token punctuation\">;</span>  \n\t  <span class=\"token punctuation\">}</span> \n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p>Our action is a function that operates on a given SirAgent. In this models formulation, each agent will check their status and determine whether they are infected or not. If an agent is infected, it will iterate through each of it's links of type <code class=\"language-text\">Links.SirLink.class</code> and stochastically expose (send an infection message) other agents. </p>\n<p>Each agent has their own PRNG, available through <code class=\"language-text\">getPrng()</code>, which is similarly carefully controlled by the Simudyne SDK to be a good source of randomness, and controllable for repeatability. We use this random sample and check it against our <code class=\"language-text\">infectionProbability</code> which we retrieved through <code class=\"language-text\">getGlobals()</code> which grabs the value from the GlobalState.</p>\n<p>If our random value is less than our <code class=\"language-text\">infectionProbability</code> then this condition will evaluate true and this agent will send an <code class=\"language-text\">InfectMessage</code> along the link in the loop.</p>\n<p>We check the <code class=\"language-text\">timeSinceInfected</code> against the <code class=\"language-text\">infectionDuration</code> and set the agent's status to <code class=\"language-text\">status.RECOVERED</code>.</p>\n<p>Lastly we update our accumulators with the current state of our agent for visualizing in our console.</p>\n<p>Infected agents stochastically selected other agents to infect and sent a message to every agent it decided to infect. These message are empty messages, as defined in the <code class=\"language-text\">Messages</code> container class, serving as signal messages to other agents. A more elaborate model could add properties to the messages, however for our purposes we use this message to signal a state change.</p>\n<h3 id=\"siragentexposed\"><a href=\"#siragentexposed\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>SirAgent#exposed</h3>\n<blockquote>\n<p>SirAgent.java</p>\n</blockquote>\n<div class=\"gatsby-highlight\" data-language=\"java\"><pre class=\"language-java\"><code class=\"language-java\"><span class=\"token keyword\">public</span> <span class=\"token keyword\">static</span> Action<span class=\"token generics function\"><span class=\"token punctuation\">&lt;</span>SirAgent<span class=\"token punctuation\">></span></span> exposed <span class=\"token operator\">=</span>  \n  Action<span class=\"token punctuation\">.</span><span class=\"token function\">create</span><span class=\"token punctuation\">(</span>SirAgent<span class=\"token punctuation\">.</span><span class=\"token keyword\">class</span><span class=\"token punctuation\">,</span> a <span class=\"token operator\">-</span><span class=\"token operator\">></span> <span class=\"token punctuation\">{</span>  \n\t  <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>a<span class=\"token punctuation\">.</span><span class=\"token function\">hasMessageOfType</span><span class=\"token punctuation\">(</span>Messages<span class=\"token punctuation\">.</span>InfectMessage<span class=\"token punctuation\">.</span><span class=\"token keyword\">class</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>  \n\t\t  <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>a<span class=\"token punctuation\">.</span>status <span class=\"token operator\">==</span> Status<span class=\"token punctuation\">.</span>SUSCEPTIBLE<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>  \n\t\t\t  a<span class=\"token punctuation\">.</span>status <span class=\"token operator\">=</span> Status<span class=\"token punctuation\">.</span>INFECTED<span class=\"token punctuation\">;</span>  \n\t\t  <span class=\"token punctuation\">}</span> \n\t  <span class=\"token punctuation\">}</span> \n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p>Agents that were sent a message in the <code class=\"language-text\">SirAgent#step</code> action are now infected and must change their state from <code class=\"language-text\">Status.SUSCEPTIBLE</code> to <code class=\"language-text\">Status.INFECTED</code>. We call our <code class=\"language-text\">hasMessageOfType()</code> function to check if we received a signal message from another agent and change the status of the agent should it evaluate to true.</p>\n<h2 id=\"console\"><a href=\"#console\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Console</h2>\n<p>The console is the visualization layer is one way to interact with your simulation and visualize the dynamics or statistics of your system.</p>\n<p>From a command line you can run (with Maven installed globally) <code class=\"language-text\">mvn package exec:java</code> to run the server. This will download all library dependencies, build the project, run any tests and then run the Simudyne server locally with the web console. You can then open the server at <a href=\"http://localhost:8080/\">http://localhost:8080/</a>.</p>\n<p>Once you've opened the local server, you will be greeted by the model selection landing page:</p>\n<p>\n  <span\n    class=\"gatsby-resp-image-wrapper\"\n    style=\"position: relative; display: block; padding: 20px; max-width: 690px; margin-left: auto; margin-right: auto;\"\n  >\n    <span\n      class=\"gatsby-resp-image-background-image\"\n      style=\"padding-bottom: 55.33124822291726%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAbklEQVQoz2MQlwv9T03MgEtCTDYEjY8pRrSBMI0gGhljs4gsAyXkw4gyjKCXZZQj/xuYpf/X0E/6LyoTgjM4iDIQZICcStR/U+vs/wpq0QjD5EIojxRppQgwRg5LigxEN4gsL2PTRJELqZ6wycUA/ddSibwO1NEAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n    >\n      <picture>\n        <source\n          srcset=\"/static/sir_home-777738679d1b133b1d067dc163931d18-8e416.webp 173w,\n/static/sir_home-777738679d1b133b1d067dc163931d18-0b506.webp 345w,\n/static/sir_home-777738679d1b133b1d067dc163931d18-58be5.webp 690w,\n/static/sir_home-777738679d1b133b1d067dc163931d18-59b8d.webp 1035w,\n/static/sir_home-777738679d1b133b1d067dc163931d18-4a474.webp 1380w,\n/static/sir_home-777738679d1b133b1d067dc163931d18-bc809.webp 2070w,\n/static/sir_home-777738679d1b133b1d067dc163931d18-6967c.webp 3517w\"\n          sizes=\"(max-width: 690px) 100vw, 690px\"\n          type=\"image/webp\"\n        />\n        <source\n          srcset=\"/static/sir_home-777738679d1b133b1d067dc163931d18-7e3fa.png 173w,\n/static/sir_home-777738679d1b133b1d067dc163931d18-7f1d4.png 345w,\n/static/sir_home-777738679d1b133b1d067dc163931d18-13856.png 690w,\n/static/sir_home-777738679d1b133b1d067dc163931d18-045bb.png 1035w,\n/static/sir_home-777738679d1b133b1d067dc163931d18-f46ab.png 1380w,\n/static/sir_home-777738679d1b133b1d067dc163931d18-ea5f6.png 2070w,\n/static/sir_home-777738679d1b133b1d067dc163931d18-222e2.png 3517w\"\n          sizes=\"(max-width: 690px) 100vw, 690px\"\n          type=\"image/png\"\n        />\n        <img\n          class=\"gatsby-resp-image-image\"\n          style=\"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;\"\n          src=\"/static/sir_home-777738679d1b133b1d067dc163931d18-13856.png\"\n          alt=\"sir home\"\n          title=\"\"\n          src=\"/static/sir_home-777738679d1b133b1d067dc163931d18-13856.png\"\n        />\n      </picture>\n      </span>\n  </span>\n  </p>\n<p>Clicking on \"SIR Model\" will take you into the console for that model. When the console is first opened, a model is not setup, and so there isn't much to show. The sidepanel contains the main controls for interacting with a models configuration/inputs.</p>\n<p>\n  <span\n    class=\"gatsby-resp-image-wrapper\"\n    style=\"position: relative; display: block; padding: 20px; max-width: 690px; margin-left: auto; margin-right: auto;\"\n  >\n    <span\n      class=\"gatsby-resp-image-background-image\"\n      style=\"padding-bottom: 55.55555555555556%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAA7DAAAOwwHHb6hkAAABGElEQVQoz6WS8U6DMBCHeQGHOihQ2sKcvoLGRAMzW8wImhHpfDKzOR/251GYQmRi3B9fri3Xr9ejVjx5QzhJwKNHnPspmJiDhUuKOcbBEk6QweEZjbN6TmNfPcOTucnx1RPcMK/XaG7J6ANBvKDFzHxUlxquKOCpNaF7YbIkdEPZiZZQOzppgejqFXL6Yk5lRrhP+kktLht0J5JwS9e4xchJcDK+wylLBoW/YQm5JcE99W9Oshn1jHoov4WHrn0IqvCdhFVlD0SKM2/W9PCfQhXtwOO0I2THCLnYwGY3X8IKV6yOEIYbjNxrI7TdpEf4B1p/3gjtHiGT69ZbG6D1NjsVVrJKyuMC4qJEoFYIomIYypNTTXs0PgEbfk5q8l0zoQAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n    >\n      <picture>\n        <source\n          srcset=\"/static/sir_landing_page_not_init-5badc665f7cd65f6f81d1921178a846c-8e416.webp 173w,\n/static/sir_landing_page_not_init-5badc665f7cd65f6f81d1921178a846c-0b506.webp 345w,\n/static/sir_landing_page_not_init-5badc665f7cd65f6f81d1921178a846c-58be5.webp 690w,\n/static/sir_landing_page_not_init-5badc665f7cd65f6f81d1921178a846c-59b8d.webp 1035w,\n/static/sir_landing_page_not_init-5badc665f7cd65f6f81d1921178a846c-4a474.webp 1380w,\n/static/sir_landing_page_not_init-5badc665f7cd65f6f81d1921178a846c-bc809.webp 2070w,\n/static/sir_landing_page_not_init-5badc665f7cd65f6f81d1921178a846c-b85f8.webp 3519w\"\n          sizes=\"(max-width: 690px) 100vw, 690px\"\n          type=\"image/webp\"\n        />\n        <source\n          srcset=\"/static/sir_landing_page_not_init-5badc665f7cd65f6f81d1921178a846c-7e3fa.png 173w,\n/static/sir_landing_page_not_init-5badc665f7cd65f6f81d1921178a846c-7f1d4.png 345w,\n/static/sir_landing_page_not_init-5badc665f7cd65f6f81d1921178a846c-13856.png 690w,\n/static/sir_landing_page_not_init-5badc665f7cd65f6f81d1921178a846c-045bb.png 1035w,\n/static/sir_landing_page_not_init-5badc665f7cd65f6f81d1921178a846c-f46ab.png 1380w,\n/static/sir_landing_page_not_init-5badc665f7cd65f6f81d1921178a846c-ea5f6.png 2070w,\n/static/sir_landing_page_not_init-5badc665f7cd65f6f81d1921178a846c-9af25.png 3519w\"\n          sizes=\"(max-width: 690px) 100vw, 690px\"\n          type=\"image/png\"\n        />\n        <img\n          class=\"gatsby-resp-image-image\"\n          style=\"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;\"\n          src=\"/static/sir_landing_page_not_init-5badc665f7cd65f6f81d1921178a846c-13856.png\"\n          alt=\"sir landing page not init\"\n          title=\"\"\n          src=\"/static/sir_landing_page_not_init-5badc665f7cd65f6f81d1921178a846c-13856.png\"\n        />\n      </picture>\n      </span>\n  </span>\n  </p>\n<p><strong>Initialise</strong>  will setup your model using the defined parameters. After setup, some things cannot be changed (such as the seed, or constants for the model). You can open types of inputs using the headers. In this model we have a single constant, defining the number of traders in the simulation, along with 3 inputs controlling parameters of the trading process.</p>\n<p>For now we can leave things as they are, and click  <strong>Initialise</strong>, upon which a few more elements become active.</p>\n<p>\n  <span\n    class=\"gatsby-resp-image-wrapper\"\n    style=\"position: relative; display: block; padding: 20px; max-width: 690px; margin-left: auto; margin-right: auto;\"\n  >\n    <span\n      class=\"gatsby-resp-image-background-image\"\n      style=\"padding-bottom: 55.37893840476866%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAB30lEQVQoz41Sy24TQRD0F2A7+5rZndmNbR4C5YCQEAiUxHZsJ/FjvfHmISIhhDjwNdyIwo0L/1nU9GyMDyBxaG13TXdtTde0eoN7ZPvvkRZT7KkRAj2GyldQRYUgXUqETQR6IV+VV0hsidiUzNeIslL6Y7NCK+/9hHnyBZH9xINzIQuzNbL8CspuoIsaSb5h8waGWEJMudpeSK5tLbluekj4C68O73Dw+htevPyKpwefqWKBSJ8hUDOEekZlZ/zZitjpFgvTOTEqZx2oqcfY07LFPZnfYi855pUnHJ5SUcl8jHZ0LNFNZnK1TjJEO/ZYoOdUuESHdSceCubWQcIfbB5yaNI0nrAuOTxqho94diqE7Z1hRxibheR/CKnQ5E7hIYdO5KBLoojLzYolVU8RZ55M5dyTnQuWmHPeouLeaAZzwazbf+0V7hI6ZYmtMHh8C1tc0f0LpPu1LL0/+ABTXPJnzqwNbP8avf4N65ovxZslChN7xJ15wlBP6Folzj2EuGy9s/GDw3ktEbHXnSfS6witJ+zEYyF0ZviBa+J8JnwqcfPdDYf9DW9l5g5d9W5L6CIyVTNw+d8R8Q2GGRWm2Xc8it6QaLR1Sxdr7o07sWVjyD/C+j63596zWwyef8RvyeNLocGJu+oAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n    >\n      <picture>\n        <source\n          srcset=\"/static/sir_landing_page_initialized-6735b90f3bcf7399a84332c40113eae5-8e416.webp 173w,\n/static/sir_landing_page_initialized-6735b90f3bcf7399a84332c40113eae5-0b506.webp 345w,\n/static/sir_landing_page_initialized-6735b90f3bcf7399a84332c40113eae5-58be5.webp 690w,\n/static/sir_landing_page_initialized-6735b90f3bcf7399a84332c40113eae5-59b8d.webp 1035w,\n/static/sir_landing_page_initialized-6735b90f3bcf7399a84332c40113eae5-4a474.webp 1380w,\n/static/sir_landing_page_initialized-6735b90f3bcf7399a84332c40113eae5-bc809.webp 2070w,\n/static/sir_landing_page_initialized-6735b90f3bcf7399a84332c40113eae5-df1d9.webp 3523w\"\n          sizes=\"(max-width: 690px) 100vw, 690px\"\n          type=\"image/webp\"\n        />\n        <source\n          srcset=\"/static/sir_landing_page_initialized-6735b90f3bcf7399a84332c40113eae5-7e3fa.png 173w,\n/static/sir_landing_page_initialized-6735b90f3bcf7399a84332c40113eae5-7f1d4.png 345w,\n/static/sir_landing_page_initialized-6735b90f3bcf7399a84332c40113eae5-13856.png 690w,\n/static/sir_landing_page_initialized-6735b90f3bcf7399a84332c40113eae5-045bb.png 1035w,\n/static/sir_landing_page_initialized-6735b90f3bcf7399a84332c40113eae5-f46ab.png 1380w,\n/static/sir_landing_page_initialized-6735b90f3bcf7399a84332c40113eae5-ea5f6.png 2070w,\n/static/sir_landing_page_initialized-6735b90f3bcf7399a84332c40113eae5-570f3.png 3523w\"\n          sizes=\"(max-width: 690px) 100vw, 690px\"\n          type=\"image/png\"\n        />\n        <img\n          class=\"gatsby-resp-image-image\"\n          style=\"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;\"\n          src=\"/static/sir_landing_page_initialized-6735b90f3bcf7399a84332c40113eae5-13856.png\"\n          alt=\"sir landing page initialized\"\n          title=\"\"\n          src=\"/static/sir_landing_page_initialized-6735b90f3bcf7399a84332c40113eae5-13856.png\"\n        />\n      </picture>\n      </span>\n  </span>\n  </p>\n<p>We now have a set of charts, showing different outputs of our model. Because we have only just setup, there is only a single tick of data to inspect. However, some of these charts are showing top level values, whereas others are showing aggregations over agent attributes. You can tell the difference by colour, and by the information in the lower left of agent level charts, showing the type of agent, and how many agents of that type are present.</p>\n<p>In this model, there are only 3 charts, Number of Susceptible, Number of Infected and Number of Recovered. The aggregation mode of the chart, available through the  <code class=\"language-text\">···</code>  menu to the right of the name can be used to visualize the data in different ways, e.g. line or bar charts, etc.</p>\n<p>\n  <span\n    class=\"gatsby-resp-image-wrapper\"\n    style=\"position: relative; display: block; padding: 20px; max-width: 690px; margin-left: auto; margin-right: auto;\"\n  >\n    <span\n      class=\"gatsby-resp-image-background-image\"\n      style=\"padding-bottom: 55.558714813761725%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAA7DAAAOwwHHb6hkAAACSUlEQVQoz31STU9TQRTtihiNAu376pt57/VDqgZiVIqWUj5KSdGW0va10LRArLAw8SPGRKNGVyzcuVOLcePCxIVbN/4X1270PxzPTAFJTFzc3Jkz9557z50bCRJv4SZycIMVjNuLiMWLcPw12joMtwrTXdOmzkfm+HXYXg2WrOm4oSdGH/H8T/AyfRhyhw8VxAMSiTriXptJIaKixrc6TNmEKRpwiNleU99tGWoz5RBXWMQLvmB6YYDJ7BukL20hkekwkR0KduOsYuZiH8lkB16ijSwLR50yLHGLycOO4oxzRIU5FY1FpDdgxRuIUu6ouUTZy3D9BkaMPDazz/D76S/0C68RpDbwMfyKMauIM0YBRryKMbGK6pWHmJ7YxqloXo+GhAdkLpBoRRPG4iUWWMdZaxGD+mf8fPQD3esvYXJm37a+4+bl+4jZJcggxGn6/fI7hNceY4SEtscOhTzg7OZIWGL1JXZaQowy0qkQvZnneDC/j9zUXc6xhjtzr9C8+gSzk7tIpbv6Q7ZzL1CeusdzlfNXM/Q/8DKvCcctJbnISg2kLvT07wXpHregzeCWxhSxTG4wJ4SgF8kQDruVhzERQcm2V9CEUaeoCS0ON8h0SdTSSRZ/1fZb8Cc6mtxNtokpohYkZ6vutq9iwqFkQ+Qpd1lLVoR6RaQiGprtH55l+1/sxF2ZJoy5s8eE6hcttWO+2sOW7szyhqbOJzHb+/tmSuXbiLjiPc4Z2WPCUXNBSxSpXUq6DSfxH+O7SO1xFHvc4R345zfxB2DyXUjBio7KAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n    >\n      <picture>\n        <source\n          srcset=\"/static/sir_graphs-1038f893d2368759d45600c47a289e9e-8e416.webp 173w,\n/static/sir_graphs-1038f893d2368759d45600c47a289e9e-0b506.webp 345w,\n/static/sir_graphs-1038f893d2368759d45600c47a289e9e-58be5.webp 690w,\n/static/sir_graphs-1038f893d2368759d45600c47a289e9e-59b8d.webp 1035w,\n/static/sir_graphs-1038f893d2368759d45600c47a289e9e-4a474.webp 1380w,\n/static/sir_graphs-1038f893d2368759d45600c47a289e9e-bc809.webp 2070w,\n/static/sir_graphs-1038f893d2368759d45600c47a289e9e-6967c.webp 3517w\"\n          sizes=\"(max-width: 690px) 100vw, 690px\"\n          type=\"image/webp\"\n        />\n        <source\n          srcset=\"/static/sir_graphs-1038f893d2368759d45600c47a289e9e-7e3fa.png 173w,\n/static/sir_graphs-1038f893d2368759d45600c47a289e9e-7f1d4.png 345w,\n/static/sir_graphs-1038f893d2368759d45600c47a289e9e-13856.png 690w,\n/static/sir_graphs-1038f893d2368759d45600c47a289e9e-045bb.png 1035w,\n/static/sir_graphs-1038f893d2368759d45600c47a289e9e-f46ab.png 1380w,\n/static/sir_graphs-1038f893d2368759d45600c47a289e9e-ea5f6.png 2070w,\n/static/sir_graphs-1038f893d2368759d45600c47a289e9e-222e2.png 3517w\"\n          sizes=\"(max-width: 690px) 100vw, 690px\"\n          type=\"image/png\"\n        />\n        <img\n          class=\"gatsby-resp-image-image\"\n          style=\"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;\"\n          src=\"/static/sir_graphs-1038f893d2368759d45600c47a289e9e-13856.png\"\n          alt=\"sir graphs\"\n          title=\"\"\n          src=\"/static/sir_graphs-1038f893d2368759d45600c47a289e9e-13856.png\"\n        />\n      </picture>\n      </span>\n  </span>\n  </p>\n<p>If your charts view gets cluttered, you can turn on and off different charts from the data search bar at the top.</p>\n<p>\n  <span\n    class=\"gatsby-resp-image-wrapper\"\n    style=\"position: relative; display: block; padding: 20px; max-width: 690px; margin-left: auto; margin-right: auto;\"\n  >\n    <span\n      class=\"gatsby-resp-image-background-image\"\n      style=\"padding-bottom: 55.58714813761729%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAB9klEQVQoz3VSyW4TQRD1F2SZrWfpnplYUYQIQpGIlAAhdmzHC7EzHnsslkSCC+JvuCCRcMstn/l41TOxhQSHUne9qnr1qqtbWf4TcX6KOBvACTtwox5CM0GgR9gJethVfZh2AT+5ghNN4MVXCNMCysyYM4NKZ4xNiV3Tn6Jl0geYgy/w9C0DYwYk8T3tEtt+h6QXePbyBmFWITIViRbWfF1C6QVCWiB3I+eChNkjXp3f4fD4Bw6PvuPgxVerRpmxVScW5wWTqSAaw4tG8OMRPOYEVObTd8PhGmtpc8fiEziqy3EHHGlI/5rj96muS+uQdGjHlLtgotzl+DLuEyYmz0HCe8o/Y9GAiedM7FvCHXVhCwVzwhGLC2zxvh10mryJfbMNJk1ImJAw0G/taNJlV/Vsos6ncNUlRxF1czYpkKRcDDGlx2wwR8QmkZ7ACQbMkWeay1J+03m3JhRlYVqivf8ZOluxqESULxFlS2KfSFrxRyysr/dWyPc+IMk2WK3QnLFzn7K7zchzYiUCksmpUm5Qtki8vgu2rLfdYKrJayX6ntt5Y/+cKHTCXv0N0hULK9rKmvjq6W42sTqvidMsoRu/XhPKv5M/Zoma5L/Of92bBl5ChXHyC1ve8ZpQthXnJd+HH1kePiv/b4zrdmUt3f+I50ff8AdMHktveHsFoQAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n    >\n      <picture>\n        <source\n          srcset=\"/static/sir_search data-4e4671115a012ac9a2f8c46eeb3b39ad-8e416.webp 173w,\n/static/sir_search data-4e4671115a012ac9a2f8c46eeb3b39ad-0b506.webp 345w,\n/static/sir_search data-4e4671115a012ac9a2f8c46eeb3b39ad-58be5.webp 690w,\n/static/sir_search data-4e4671115a012ac9a2f8c46eeb3b39ad-59b8d.webp 1035w,\n/static/sir_search data-4e4671115a012ac9a2f8c46eeb3b39ad-4a474.webp 1380w,\n/static/sir_search data-4e4671115a012ac9a2f8c46eeb3b39ad-bc809.webp 2070w,\n/static/sir_search data-4e4671115a012ac9a2f8c46eeb3b39ad-6967c.webp 3517w\"\n          sizes=\"(max-width: 690px) 100vw, 690px\"\n          type=\"image/webp\"\n        />\n        <source\n          srcset=\"/static/sir_search data-4e4671115a012ac9a2f8c46eeb3b39ad-7e3fa.png 173w,\n/static/sir_search data-4e4671115a012ac9a2f8c46eeb3b39ad-7f1d4.png 345w,\n/static/sir_search data-4e4671115a012ac9a2f8c46eeb3b39ad-13856.png 690w,\n/static/sir_search data-4e4671115a012ac9a2f8c46eeb3b39ad-045bb.png 1035w,\n/static/sir_search data-4e4671115a012ac9a2f8c46eeb3b39ad-f46ab.png 1380w,\n/static/sir_search data-4e4671115a012ac9a2f8c46eeb3b39ad-ea5f6.png 2070w,\n/static/sir_search data-4e4671115a012ac9a2f8c46eeb3b39ad-222e2.png 3517w\"\n          sizes=\"(max-width: 690px) 100vw, 690px\"\n          type=\"image/png\"\n        />\n        <img\n          class=\"gatsby-resp-image-image\"\n          style=\"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;\"\n          src=\"/static/sir_search data-4e4671115a012ac9a2f8c46eeb3b39ad-13856.png\"\n          alt=\"sir search data\"\n          title=\"\"\n          src=\"/static/sir_search data-4e4671115a012ac9a2f8c46eeb3b39ad-13856.png\"\n        />\n      </picture>\n      </span>\n  </span>\n  </p>\n<p>What also become active once the model was setup, was the top right View selector. By default we are on the <strong>Variables</strong> view, showing the numeric outputs of the model. The other two views available are the <strong>Network</strong> and the <strong>Agents</strong>. <strong>Agents</strong> shows a tabular view of the agents within the model, which can be useful with small numbers of agents to check their exact properties. <strong>Network</strong> is useful to see the overall structure of the agents and their links. In this particular model, the agents are fully connected giving a uniformly distributed graph layout.</p>\n<p>\n  <span\n    class=\"gatsby-resp-image-wrapper\"\n    style=\"position: relative; display: block; padding: 20px; max-width: 690px; margin-left: auto; margin-right: auto;\"\n  >\n    <span\n      class=\"gatsby-resp-image-background-image\"\n      style=\"padding-bottom: 55.53034600113443%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAA7DAAAOwwHHb6hkAAACmUlEQVQoz2WTW08TURSF+2Q0XEqhM53pzHRKlBCNJsa7ENSCDSAtvWNiEdAYeFCCoMErijFGHzSByEUjoAF6hWoUgUIBbaEVQow/ablnCvXBh505yTnnO2utvUdj3j8Io1xJVYNi7jxKjBawQi1VPfTGepTw9bS+hAKmFnu0VvW7V2dFvr4OYqkDnMkGRmgALzeCFRugkczjkMqug5Gu0kYdDJKN4C7IZZfBm33g5Cbks26cPN6MvvZuvO65j+c376Kmqg15jIvu+WAw+cBKXiofAUsncazqPQ6fGsChox0oP9IGveBUD3Kyj2AuXLG3Izk2gM1wAMnQDLYiAWxOjuJOaycY0asCs+WFRpRHYBArUGwgu7yVbFpJulNVVsR7cPpEMzITA1gNzCIeWkJiZhWL4WXEp75ga/odXLU3VAe8nFWpEU0ElC5AZ7gILaNAq2nDRXabVEu3W7qQDk5iPphA8tsG1ue3kJz7hZXoMqmNYrD3EXS8O6dSBbLiORSx1VQK2JJTWGhw403PPWzPRrAY+YH17xlk4ttIL2SwEkvhZyiG4MsXEMzeXJYakzxKci3/AY2kcJ/eiScd3UgFgkiEF1VlGYIl5zbJ+ho2wlFM9D+lHD3/FBrFIQJV5IBKMQTkFYWcG5bKVqQ/jSAx/RnxcAKJWBJL0TUsTH3F7/A4NawDedQ4JUO1KUZhCIXMGQJZ1Ax3gcprHJWOGtPpv4X1j8NIR6JkcxYp6vSfyBhedfXSGRqXXJd9WaCWObsD3FFIY6PM1G4pWdpqrmH4wUOM9z/Dh77H8NMolQgeGjGvqkyxrRfcCvBtDqjAFJW87KCgPeAkB3gT5Sk7UcDaSa2d1g662EiP2Emdg/4WD+XtRmm5HwcOtuAvYhqmVQbow5wAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n    >\n      <picture>\n        <source\n          srcset=\"/static/sir_network-96a37c31a47ea0a13fe256839a4dfd9f-8e416.webp 173w,\n/static/sir_network-96a37c31a47ea0a13fe256839a4dfd9f-0b506.webp 345w,\n/static/sir_network-96a37c31a47ea0a13fe256839a4dfd9f-58be5.webp 690w,\n/static/sir_network-96a37c31a47ea0a13fe256839a4dfd9f-59b8d.webp 1035w,\n/static/sir_network-96a37c31a47ea0a13fe256839a4dfd9f-4a474.webp 1380w,\n/static/sir_network-96a37c31a47ea0a13fe256839a4dfd9f-bc809.webp 2070w,\n/static/sir_network-96a37c31a47ea0a13fe256839a4dfd9f-705c4.webp 3526w\"\n          sizes=\"(max-width: 690px) 100vw, 690px\"\n          type=\"image/webp\"\n        />\n        <source\n          srcset=\"/static/sir_network-96a37c31a47ea0a13fe256839a4dfd9f-7e3fa.png 173w,\n/static/sir_network-96a37c31a47ea0a13fe256839a4dfd9f-7f1d4.png 345w,\n/static/sir_network-96a37c31a47ea0a13fe256839a4dfd9f-13856.png 690w,\n/static/sir_network-96a37c31a47ea0a13fe256839a4dfd9f-045bb.png 1035w,\n/static/sir_network-96a37c31a47ea0a13fe256839a4dfd9f-f46ab.png 1380w,\n/static/sir_network-96a37c31a47ea0a13fe256839a4dfd9f-ea5f6.png 2070w,\n/static/sir_network-96a37c31a47ea0a13fe256839a4dfd9f-35589.png 3526w\"\n          sizes=\"(max-width: 690px) 100vw, 690px\"\n          type=\"image/png\"\n        />\n        <img\n          class=\"gatsby-resp-image-image\"\n          style=\"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;\"\n          src=\"/static/sir_network-96a37c31a47ea0a13fe256839a4dfd9f-13856.png\"\n          alt=\"sir network\"\n          title=\"\"\n          src=\"/static/sir_network-96a37c31a47ea0a13fe256839a4dfd9f-13856.png\"\n        />\n      </picture>\n      </span>\n  </span>\n  </p>\n<p>The top left menu allows to specify an attribute of each agent type to use as the scale factor for each node in the visualisation, and the top right allows to switch between different layout approaches.</p>\n<h1 id=\"summary\"><a href=\"#summary\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summary</h1>\n<p>Through this tutorial we have walked through the initial features to get started with, both on the console and in the definition of the models themselves. The next tutorial, based around building a model of mortgages issued by banks, goes much further into more advanced behaviours, as well as through the initial model building steps, when starting from scratch.</p>","headings":[{"value":"Overview","depth":2},{"value":"Project Structure","depth":2},{"value":"Project configuration and documentation","depth":3},{"value":"Model definition","depth":3},{"value":"Model","depth":1},{"value":"Initialisation","depth":2},{"value":"Model Fields","depth":3},{"value":"Globals","depth":3},{"value":"Accumulators","depth":3},{"value":"Type registration","depth":3},{"value":"Setup","depth":2},{"value":"Topology","depth":3},{"value":"Super","depth":3},{"value":"Step","depth":2},{"value":"Super","depth":3},{"value":"Run Sequences","depth":3},{"value":"Behaviours","depth":2},{"value":"SirAgent#step","depth":3},{"value":"SirAgent#exposed","depth":3},{"value":"Console","depth":2},{"value":"Summary","depth":1}],"frontmatter":{"title":"SIR Epidemiology Tutorial","toc":true,"experimental":null}},"site":{"siteMetadata":{"title":"Simudyne Docs","latestVersion":"2.6"}}},"pageContext":{"absolutePath":"/home/vsts/work/1/s/content/2.4/docs/tutorials/sir.md","versioned":true,"version":"2.4","kind":"docs","pagePath":"/tutorials/sir","chronology":{"prev":{"name":"Schelling Segregation Tutorial","path":"/tutorials/schelling"},"next":{"name":"Forest Fire Tutorial","path":"/tutorials/forestfire"}},"lastUpdated":"2026-04-21T13:56:54.849Z"}}