simmer 3.6.4

The fourth update of the 3.6.x release of simmer, the Discrete-Event Simulator for R, is on CRAN. This release patches several bugs regarding resource priority and preemption management when seized amounts greater than one were involved. Check the examples available in the corresponding issues on GitHub (#114#115#116) to know if you are affected.

It can be noted that we already broke the intended bi-monthly release cycle, but it is for a good reason, since we are preparing a journal publication. Further details to come.

Minor changes and fixes:

  • Fix preemption in non-saturated multi-server resources when seizing amounts > 1 (#114).
  • Fix queue priority in non-saturated finite-queue resources when seizing amounts > 1 (#115).
  • Fix resource seizing: avoid jumping the queue when there is room in the server but other arrivals are waiting (#116).

La importancia de la divulgación

(Esta anotación se publica simultáneamente en Naukas)

¿Para qué sirve la divulgación? ¿Es efectiva? ¿Cómo debe hacerse? Son las preguntas que alimentan el eterno debate instalado en el seno de foros de divulgación como este, Naukas, que persiguen el fomento de la ciencia y la racionalidad frente a la superchería y el pensamiento mágico. Un debate sempiterno que resurge periódicamente cada vez que la irracionalidad se hace notar a través de una noticia triste, una acción política desafortunada… Pero es lo que tienen las carreras de fondo, que carecen de referencias a corto plazo a las que agarrarse. Y aunque algunos puedan estar hastiados, es importante darse cuenta de que el debate es necesario, porque el andamiaje metodológico que se construye a partir de la duda sistemática es el único mecanismo de revisión y control que tenemos, imprescindible para seguir mejorando y avanzando.

Se hace camino al andar, decía el poema, y a veces es importante pararse y darse la vuelta a contemplar lo andado. Creo que nadie a día de hoy cuestionaría que la educación es efectiva, a pesar de las evidencias en contra que constantemente salpican la realidad cotidiana. No en vano, la educación ha traído el progreso científico y tecnológico, y estos a su vez hasta donde estamos. Para mí, la divulgación es un complemento que llena aquellos huecos adonde la educación no puede llegar. Y como la educación, la divulgación es un proceso lento, pero inexorable, de transformación de la sociedad.

Hay muchas formas de divulgar, como hay muchas formas de comunicar en general, mejores y peores, más o menos adecuadas a según qué formatos y audiencias. A menudo, se habla del papel del humor en la divulgación: si haces reír, el mensaje entra mejor, se suele decir, pero mi opinión es que el humor está un paso más allá. El humor es un mecanismo de cohesión social que refuerza la estructura de grupo a través de sobreentendidos. Esto es muy importante: no se puede hacer humor, un grupo de personas no puede reír con una broma, si no existe un sobreentendido previo, un conocimiento compartido, un poso común. Y cerramos el círculo: para esto sirve la divulgación, para dejar ese poso que después el humor es capaz de amalgamar y compactar como ninguna otra herramienta humana.

La educación hace el camino, la divulgación lo asfalta y el humor lo apisona para que todos avancemos más libres como sociedad. Y he aquí a continuación uno de estos maestros de la apisonadora, caminando a hombros de gigantes. Seguid divulgando.

#Naukas17: El sonido del viento

Ya estamos de vuelta de #Naukas17, la séptima edición —que se dice pronto— de Naukas Bilbao. Un nuevo año, un nuevo reto repleto de nuevas incorporaciones, ausencias notables y 2000 localidades por llenar con la receta de siempre: ciencia, escepticismo y humor. Este fue el resultado:

Imagen de Xurxo Mariño.

Además, Almudena, que ha divulgado ciencia no solo en este blog, en Naukas y dando charlas en muchos otros eventos, sino también desde la Expedición Malaspina, el Ártico y Radio Clásica, recibió el Premio Tesla 2017 a la divulgación, junto con Jose Cervera y Daniel Torregrosa.

Imagen de Xurxo Mariño.

Finalmente, esta fue nuestra contribución: El sonido del viento:

simmer 3.6.3

The third update of the 3.6.x release of simmer, the Discrete-Event Simulator for R, is on CRAN. First of all and once again, I must thank Duncan Garmonsway (@nacnudus) for writing a new vignette: “The Bank Tutorial: Part II”.

Among various fixes and performance improvements, this release provides a way of knowing the progress of a simulation. This feature is embed into the run() function as a parameter called progress, which accepts a function with a single argument and will be called for each one of the steps (10 by default) with the current progress ratio (a number between 0 and 1). A very naive example using a simple print():

library(simmer)

wait_and_go <- trajectory() %>%
  timeout(1)

simmer() %>%
  add_generator("dummy", wait_and_go, function() 1) %>%
  run(until=10, progress=print, steps=5)
## [1] 0
## [1] 0.2
## [1] 0.4
## [1] 0.6
## [1] 0.8
## [1] 1
## simmer environment: anonymous | now: 10 | next: 10
## { Generator: dummy | monitored: 1 | n_generated: 10 }

Or we can get a nice progress bar with the assistance of the progress package:

simmer() %>%
  add_generator("dummy", wait_and_go, function() 1) %>%
  run(until=1e5, progress=progress::progress_bar$new()$update)
#> [==============---------------------------------------------------------]  20%

But more importantly, this release implements a new way of retrieving attributes (thus deprecating the old approach, which will be still available throughout the 3.6.x series and will be removed in version 3.7). Since v3.1.x, arrival attributes were retrieved by providing a function with one argument. A very simple example:

trajectory() %>%
  set_attribute("delay", 3) %>%
  timeout(function(attr) attr["delay"])
## Warning: Attribute retrieval through function arguments is deprecated.
## Use 'get_attribute' instead.
## trajectory: anonymous, 2 activities
## { Activity: SetAttribute | key: delay, value: 3, global: 0 }
## { Activity: Timeout      | delay: 0x5569098b9228 }

Later on, v3.5.1 added support for global attributes, making it necessary to add a second argument to retrieve this new set of attributes:

trajectory() %>%
  set_attribute("delay", 3, global=TRUE) %>%
  timeout(function(attr, glb) glb["delay"])
## Warning: Attribute retrieval through function arguments is deprecated.
## Use 'get_attribute' instead.
## trajectory: anonymous, 2 activities
## { Activity: SetAttribute | key: delay, value: 3, global: 1 }
## { Activity: Timeout      | delay: 0x556908730320 }

This method is a kind of rarity in simmer. It’s clunky, as it is not easy to document (and therefore to discover and learn), and non-scalable, because new features would require more and more additional arguments. Thus, it is now deprecated, and the get_attribute() function becomes the new method for retrieving attributes. It works in the same way as now() for the simulation time:

env <- simmer()

trajectory() %>%
  set_attribute("delay_1", 3) %>%
  # shortcut equivalent to set_attribute(..., global=TRUE)
  set_global("delay_2", 2) %>% 
  timeout(function() get_attribute(env, "delay_1")) %>%
  # shortcut equivalent to get_attribute(..., global=TRUE)
  timeout(function() get_global(env, "delay_2"))
## trajectory: anonymous, 4 activities
## { Activity: SetAttribute | key: delay_1, value: 3, global: 0 }
## { Activity: SetAttribute | key: delay_2, value: 2, global: 1 }
## { Activity: Timeout      | delay: 0x55690829f550 }
## { Activity: Timeout      | delay: 0x55690830c310 }

This is a little bit more verbose, but I believe it is more consistent and intuitive. Moreover, it allows us to easily implement new features for extracting arrival information. In fact, get_attribute() will come hand in hand with two more verbs: get_name() and get_prioritization(), to retrieve the arrival name and prioritization values respectively.

New features:

  • Show simulation progress via an optional progress callback in run() (#103).
  • New “The Bank Tutorial: Part II” vignette, by Duncan Garmonsway @nacnudus (#106).
  • New getters for running arrivals (#109), meant to be used inside trajectories:
    • get_name() retrieves the arrival name.
    • get_attribute() retrieves an attribute by name. The old method of retrieving them by providing a function with one argument is deprecated in favour of get_attribute(), and will be removed in version 3.7.x.
    • get_prioritization() retrieves the three prioritization values (prioritypreemptiblerestart) of the active arrival.
  • New shortcuts for global attributes (#110): set_global() and get_global(), equivalent to set_attribute(global=TRUE) and get_attribute(global=TRUE) respectively.

Minor changes and fixes:

  • Some code refactoring and performance improvements (2f4b484, ffafe1e, f16912a, fb7941b, 2783cd8).
  • Use Rcpp::DataFrame instead of Rcpp::List (#104).
  • Improve argument parsing and error messages (#107).
  • Improve internal function make_resetable() (c596f73).

Agente Smith forever

No sé si lo han leído, pero dice Chema, AKA Rinzewind, que Las penas del Agente Smith ya no se llama Las penas del Agente Smith. Algo así como que se le salió la sopa por la nariz y las letritas formaron un nombre de mierda (lo dice alguien cuyo blog se llama Enchufa2, con un dos: sé de lo que hablo) que le hizo gracia; no sé, no me he parado en los detalles.

Me da igual: para mí seguirá siendo Las penas del Agente Smith. Podrá cambiarlo en el HTML, pero no en nuestros corazones. De hecho, lo primero tiene arreglo: he aquí una extensión de Chrome para que su blog aparezca con el nombre correcto. Descomprimir, instalar y a disfrutar.