{"data":{"markdownRemark":{"html":"<h2 id=\"basic-concepts\"><a href=\"#basic-concepts\" 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>Basic Concepts</h2>\n<p>Time series variables are data pieces inside an agent that keep track of that agent's previous values. Since they must hold multiple values in a series, these variables are windowed values, storing data for a specific number of time steps. Modellers can specify how many time steps a time series variable should hold.</p>\n<p>Once created, a time series variable will hold values of one specific agent attribute for a specific number of time steps. The default value of each tick in the time series variable is 0. Modellers can use the <code class=\"language-text\">offset</code> parameter of the time series variable creation methods to determine how many historical values should be kept at the same time. The variable will only store the latest <code class=\"language-text\">offset</code> ticks.</p>\n<p>For example, suppose a model saves historical values corresponding to the number of ticks that have been run so far. Assume further that this model contains a time series variable with an offset of 3, and the model has run for 2 ticks. At this point, since the model has run for 2 ticks, the values in the time series variable will be 0,1,2. The 0 represents an uninitialized variable, while the 2 represents the most recent tick. If the model runs for another tick, the time series variable will now contain the values 1,2,3. The uninitialized value has been replaced with the next most recent value of 1, while the new value of 3 has been added into the variable.</p>\n<h2 id=\"examples\"><a href=\"#examples\" 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>Examples</h2>\n<p>The Simudyne SDK allows modellers to create time series variables with the <code class=\"language-text\">WindowedDouble</code> and <code class=\"language-text\">WindowedLong</code> classes.</p>\n<div class=\"gatsby-highlight\" data-language=\"java\"><pre class=\"language-java\"><code class=\"language-java\"><span class=\"token comment\">// Create new windowed value, storing 10 ticks of data.</span>\nWindowedDouble mortgages <span class=\"token operator\">=</span> <span class=\"token function\">createWindowedDouble</span><span class=\"token punctuation\">(</span><span class=\"token number\">10</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\nWindowedLong balances <span class=\"token operator\">=</span> <span class=\"token function\">createWindowedLong</span><span class=\"token punctuation\">(</span><span class=\"token number\">10</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p>The time series variable objects allow modellers to access specific ticks.</p>\n<div class=\"gatsby-highlight\" data-language=\"java\"><pre class=\"language-java\"><code class=\"language-java\">WindowedLong balance <span class=\"token operator\">=</span> <span class=\"token function\">createWindowedLong</span><span class=\"token punctuation\">(</span><span class=\"token number\">10</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token comment\">// Retrieves the value of balance from 2 ticks ago.</span>\nbalance<span class=\"token punctuation\">.</span><span class=\"token function\">offset</span><span class=\"token punctuation\">(</span><span class=\"token number\">2</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token comment\">// Both of these calls retrieve the current value of the balance.</span>\nbalance<span class=\"token punctuation\">.</span><span class=\"token function\">offset</span><span class=\"token punctuation\">(</span><span class=\"token number\">0</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\nbalance<span class=\"token punctuation\">.</span><span class=\"token function\">get</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token comment\">// Throws an exception because it is larger than the number of held values.</span>\nbalance<span class=\"token punctuation\">.</span><span class=\"token function\">offset</span><span class=\"token punctuation\">(</span><span class=\"token number\">11</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div>","headings":[{"value":"Basic Concepts","depth":2},{"value":"Examples","depth":2}],"frontmatter":{"title":"Time Series Variables","toc":null,"experimental":null}},"site":{"siteMetadata":{"title":"Simudyne Docs","latestVersion":"2.6"}}},"pageContext":{"absolutePath":"/home/vsts/work/1/s/content/2.5/reference/data_management/time_series.md","versioned":true,"version":"2.5","kind":"reference","pagePath":"/reference/data_management/time_series","chronology":{"prev":{"name":"Outputting Data","path":"/reference/data_management/outputting_data"},"next":{"name":"Output Channels","path":"/reference/data_management/channels"}},"lastUpdated":"2026-04-21T13:56:54.861Z"}}