{"data":{"markdownRemark":{"html":"<p>You can start using the Simudyne SDK without defining any configuration, since sensible default values are provided. Later on you might need to amend the settings to change the default behavior. Typical examples of settings that you might amend:</p>\n<ul>\n<li>distribution of model</li>\n<li>log level</li>\n<li>serialization level</li>\n<li>port and hostname for the server to run on</li>\n</ul>\n<h2 id=\"where-configuration-is-read-from\"><a href=\"#where-configuration-is-read-from\" 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>Where configuration is read from</h2>\n<p>The Simudyne SDK reads the config from a <code class=\"language-text\">simudyneSDK.properties</code> file in the root directory of a project. If this file cannot be found, default values are set for all config.</p>\n<p>All config properties can also be overwritten dynamically in the model code. Use <code class=\"language-text\">getConfig()</code> to get the config for a specific model, and <code class=\"language-text\">setString()</code>, <code class=\"language-text\">setBoolean()</code>, <code class=\"language-text\">setLong()</code> or <code class=\"language-text\">setInt()</code> to set config of a specific type.</p>\n <p class=\"code-header\">ModelConfig.java</p>\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\">Housing</span> <span class=\"token keyword\">implements</span> <span class=\"token class-name\">Model</span> <span class=\"token punctuation\">{</span>\n\t<span class=\"token annotation punctuation\">@Constant</span> <span class=\"token keyword\">public</span> <span class=\"token keyword\">boolean</span> distributed <span class=\"token operator\">=</span> <span class=\"token boolean\">false</span><span class=\"token punctuation\">;</span>\n\n  <span class=\"token keyword\">public</span> <span class=\"token keyword\">void</span> <span class=\"token function\">setup</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">{</span>\n    <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>distributed<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n    \t<span class=\"token function\">getConfig</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span><span class=\"token function\">setString</span><span class=\"token punctuation\">(</span>\n        <span class=\"token string\">\"core-abm.backend-implementation\"</span><span class=\"token punctuation\">,</span>\n        <span class=\"token string\">\"simudyne.core.graph.spark.SparkGraphBackend\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n    <span class=\"token punctuation\">}</span>  \n  <span class=\"token punctuation\">}</span>  \n<span class=\"token punctuation\">}</span></code></pre></div>\n<div class=\"ui segment info message\">\n  <h4>Best practice</h4>\n  Put all config in the properties file, and only override config in the code for values that change based on user input. (An example of this might be overriding if the model should run distributed based on a toggle input). This is so that the model can be compiled and the config changed without having to recompile.\n</div>\n<h2 id=\"custom-simudynesdkproperties\"><a href=\"#custom-simudynesdkproperties\" 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>Custom simudyneSDK.properties</h2>\n<p>A custom <code class=\"language-text\">simudyneSDK.properties</code> might look like this</p>\n<ul>\n<li>core-abm.max-messaging-phases - This is the max number of phases we will keep sending messages in a single step/tick. Setting a max number will prevent you from accidentally creating an infinite loop of messages being sent and received.</li>\n<li>core-abm.serialize.agents - When the <code class=\"language-text\">AgentSystem</code> is marked as <code class=\"language-text\">@Variable</code>, should the agents be reported <a href=\":version/reference/agents/reporting#agent-fields\">Read More</a>.</li>\n<li>core-abm.serialize.accumulators - When the <code class=\"language-text\">AgentSystem</code> is marked as <code class=\"language-text\">@Variable</code>, should the accumulators be reported <a href=\":version/reference/agents/reporting#agent-statistics\">Read More</a>.</li>\n<li>core-abm.local-parallelism - If not set, will default to number of processors available to the JVM.</li>\n<li>core.prng-seed - The seed to use for generating random numbers.</li>\n</ul>\n <p class=\"code-header\">simudyneSDK.properties</p>\n<div class=\"gatsby-highlight\" data-language=\"yaml\"><pre class=\"language-yaml\"><code class=\"language-yaml\"><span class=\"token comment\">### SimudyneSDK Configuration file</span>\n\n<span class=\"token comment\">### NEXUS-SERVER ###</span>\n\nnexus<span class=\"token punctuation\">-</span>server.port = 8080\nnexus<span class=\"token punctuation\">-</span>server.hostname = 127.0.0.1\n\n<span class=\"token comment\">### CORE ###</span>\n\n<span class=\"token comment\"># core.prng-seed = 1640702558671097951</span>\n\n<span class=\"token comment\">### CORE-ABM ###</span>\ncore<span class=\"token punctuation\">-</span>abm.max<span class=\"token punctuation\">-</span>messaging<span class=\"token punctuation\">-</span>phases = 50\n\n<span class=\"token comment\"># For serialization-level, choose between : {NONE,CHECKED}</span>\ncore<span class=\"token punctuation\">-</span>abm.serialization<span class=\"token punctuation\">-</span>level=NONE\ncore<span class=\"token punctuation\">-</span>abm.serialize.agents=true\ncore<span class=\"token punctuation\">-</span>abm.serialize.links=true\ncore<span class=\"token punctuation\">-</span>abm.serialize.accumulators=true\ncore<span class=\"token punctuation\">-</span>abm.local<span class=\"token punctuation\">-</span>parallelism=8</code></pre></div>\n<div class=\"ui segment info message\">\nThe above hostname will make sure that the server and console are ONLY available locally. If you wish to deploy to a server you should change the hostname either to the IP address, or more commonly 0.0.0.0\n</div>\n<h2 id=\"configuring-distributed-abms-with-spark\"><a href=\"#configuring-distributed-abms-with-spark\" 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>Configuring Distributed ABMs (with Spark)</h2>\n<p>If the model is to be run as a distributed model using Spark, the <code class=\"language-text\">core-abm.backend-implementation</code> needs to be set in the config, and the following Spark settings.</p>\n <p class=\"code-header\">simudyneSDK.properties</p>\n<div class=\"gatsby-highlight\" data-language=\"yaml\"><pre class=\"language-yaml\"><code class=\"language-yaml\">core<span class=\"token punctuation\">-</span>abm.backend<span class=\"token punctuation\">-</span>implementation=simudyne.core.graph.spark.SparkGraphBackend\n\n<span class=\"token comment\"># Default Spark settings. Comment these lines if you will be providing the configuration</span>\n<span class=\"token comment\"># via spark-submit or similar, otherwise these settings are required.</span>\n\n<span class=\"token comment\"># For log-level, choose between : {OFF, FATAL, ERROR, WARN, INFO, DEBUG, TRACE, ALL}</span>\n\ncore<span class=\"token punctuation\">-</span>abm<span class=\"token punctuation\">-</span>spark.master<span class=\"token punctuation\">-</span>url = local<span class=\"token punctuation\">[</span>*<span class=\"token punctuation\">]</span>\ncore<span class=\"token punctuation\">-</span>abm<span class=\"token punctuation\">-</span>spark.spark.executor.memory = 2g\ncore<span class=\"token punctuation\">-</span>abm<span class=\"token punctuation\">-</span>spark.spark.sql.shuffle.partitions = 24\ncore<span class=\"token punctuation\">-</span>abm<span class=\"token punctuation\">-</span>spark.checkpoint<span class=\"token punctuation\">-</span>directory = /var/tmp\ncore<span class=\"token punctuation\">-</span>abm<span class=\"token punctuation\">-</span>spark.log<span class=\"token punctuation\">-</span>level = WARN</code></pre></div>\n<h2 id=\"configuring-distributed-multiruns-with-spark\"><a href=\"#configuring-distributed-multiruns-with-spark\" 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>Configuring Distributed Multiruns (with Spark)</h2>\n<p>If the model is to be run as a distributed model using Spark when running as multirun, the <code class=\"language-text\">core-runner.runner-backend</code> needs to be set in the config, and the following Spark settings.</p>\n<div class=\"gatsby-highlight\" data-language=\"yaml\"><pre class=\"language-yaml\"><code class=\"language-yaml\">core<span class=\"token punctuation\">-</span>runner.runner<span class=\"token punctuation\">-</span>backend = simudyne.core.runner.spark.SparkRunnerBackend\n\n<span class=\"token comment\"># Default Spark settings. Comment these lines if you will be providing the configuration</span>\n<span class=\"token comment\"># via spark-submit or similar, otherwise these settings are required.</span>\n\n<span class=\"token comment\"># For log-level, choose between : {OFF, FATAL, ERROR, WARN, INFO, DEBUG, TRACE, ALL}</span>\n\ncore<span class=\"token punctuation\">-</span>runner<span class=\"token punctuation\">-</span>spark.master<span class=\"token punctuation\">-</span>url = local<span class=\"token punctuation\">[</span>*<span class=\"token punctuation\">]</span>\ncore<span class=\"token punctuation\">-</span>runner<span class=\"token punctuation\">-</span>spark.spark.executor.memory = 2g\ncore<span class=\"token punctuation\">-</span>runner<span class=\"token punctuation\">-</span>spark.spark.sql.shuffle.partitions = 24\ncore<span class=\"token punctuation\">-</span>runner<span class=\"token punctuation\">-</span>spark.log<span class=\"token punctuation\">-</span>level = WARN\ncore<span class=\"token punctuation\">-</span>runner<span class=\"token punctuation\">-</span>spark.task.cpus = 1</code></pre></div>","headings":[{"value":"Where configuration is read from","depth":2},{"value":"Custom simudyneSDK.properties","depth":2},{"value":"Configuring Distributed ABMs (with Spark)","depth":2},{"value":"Configuring Distributed Multiruns (with Spark)","depth":2}],"frontmatter":{"title":"Model Configuration","toc":false,"experimental":null}},"site":{"siteMetadata":{"title":"Simudyne Docs","latestVersion":"2.6"}}},"pageContext":{"absolutePath":"/home/vsts/work/1/s/content/2.0/reference/models/model-configuration.md","versioned":true,"version":"2.0","kind":"reference","pagePath":"/reference/models/model-configuration","chronology":{"prev":{"name":"Annotations","path":"/reference/models/annotations"},"next":{"name":"Agents","path":"/reference/agents"}},"lastUpdated":"2026-04-21T13:56:54.827Z"}}