<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/simmer-4-1-0/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://www.enchufa2.es/archives/simmer-4-1-0.html"> R – Enchufa2</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>The 4.1.0 release of <a rel="nofollow" href="http://r-simmer.org/" target="_blank">simmer</a>, the Discrete-Event Simulator for R, is on CRAN. As per request in the mailing list, now <code>get_global()</code> is able to work inside a generator function. Moreover, the new <code>add_global()</code> method attaches a global attribute to a simulator.</p>
<pre><code><span>library</span>(simmer)

env &lt;- simmer()

hello_sayer &lt;- trajectory() %>%
  log_(<span>&quot;hello world!&quot;</span>) %>%
  set_global(<span>&quot;interarrival&quot;</span>, <span>1</span>, mod=<span>&quot;+&quot;</span>)

generator &lt;- <span>function</span>() get_global(env, <span>&quot;interarrival&quot;</span>)

env %>%
  add_global(<span>&quot;interarrival&quot;</span>, <span>1</span>) %>%
  add_generator(<span>&quot;dummy&quot;</span>, hello_sayer, generator) %>%
  run(<span>7</span>) %>%
  get_global(<span>&quot;interarrival&quot;</span>)</code></pre>
<pre><code>## 1: dummy0: hello world!
## 3: dummy1: hello world!
## 6: dummy2: hello world!</code></pre>
<pre><code>## [1] 4</code></pre>
<p>Compared to plain global variables, these ones are automatically managed and thus reinitialised if the environment is reset.</p>
<pre><code>env %>%
  reset() %>%
  get_global(<span>&quot;interarrival&quot;</span>)</code></pre>
<pre><code>## [1] 1</code></pre>
<pre><code>env %>%
  run(<span>7</span>) %>%
  get_global(<span>&quot;interarrival&quot;</span>)</code></pre>
<pre><code>## 1: dummy0: hello world!
## 3: dummy1: hello world!
## 6: dummy2: hello world!</code></pre>
<pre><code>## [1] 4</code></pre>
<p>There has been a small refactoring of some parts of the C++ core, which motivates the minor version bump, but this shouldn’t be noticeable to the users. Finally, several bug fixes and improvements complete this release. See below for a complete list.</p>
<div>
<h3>New features:</h3>
<ul>
<li>New getter <code>get_selected()</code> retrieves names of selected resources via the <code>select()</code> activity (#172 addressing #171).</li>
<li>Source and resource getters have been vectorised to retrieve parameters from multiple entities (as part of #172).</li>
<li>Simplify C++ <code>Simulator</code> interface for adding processes and resources (#162). The responsibility of building the objects has been moved to the caller.</li>
<li>New <code>add_global()</code> method to attach global attributes to a simulation environment (#174 addressing #158).</li>
</ul>
</div>
<div>
<h3>Minor changes and fixes:</h3>
<ul>
<li>Remove 3.8.0 and 4.0.1 deprecations (#170 addressing #165).</li>
<li>Fix <code>get_global()</code> to work outside trajectories (#170 addressing #165).</li>
<li>Fix <code>rollback()</code> with an infinite amount (#173).</li>
<li>Fix and improve schedules and managers (as part of #174).</li>
<li>Fix <code>reset()</code> to avoid overwriting the simulation environment (#175).</li>
</ul>
</div>
<p><em>Article originally published in Enchufa2.es: <a rel="nofollow" href="https://www.enchufa2.es/archives/simmer-4-1-0.html" target="_blank">simmer 4.1.0</a></em>.</p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://www.enchufa2.es/archives/simmer-4-1-0.html"> R – Enchufa2</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/4GMsNGoEsww" height="1"></a></div>