| Listeners | R Documentation |
Create a class of listener. A listener monitors the trial while checking condition of pre-defined milestones. Actions are triggered and executed automatically.
Public methods in this R6 class are used in developing this package. Thus, we have to export the whole R6 class which exposures all public methods. However, only the public methods in the list below are useful to end users.
$add_milestones() register milestone(s) with the listener.
$get_milestone_names() return names of registered milestones.
Internal machinery. The remaining public methods
($monitor(), $mute() and $reset()) are public only
because they are invoked on a listener object by other components of the
package (controllers), which R6 cannot grant through private members.
Users should not call them directly.
an R6Class generator object; use listener() to create a listener.
new()initialize a listener
Listeners$new(silent = FALSE)
silentlogical. TRUE to mute messages.
add_milestones()register milestones with listener. Order in ... matter
as they are scanned and triggered in that order. It is users'
responsibility to use reasonable order when calling this function,
otherwise, the result of Listeners$monitor() can be problematic.
Listeners$add_milestones(...)
...one or more objects returned from milestone().
listener <- listener()
interim <- milestone(name = 'interim',
when = eventNumber('endpoint', n = 100)
)
final <- milestone(name = 'final',
when = calendarTime(time = 24)
)
listener$add_milestones(interim, final)
get_milestone_names()return names of registered milestones
Listeners$get_milestone_names()
monitor()INTERNAL MACHINERY: DO NOT CALL THIS METHOD DIRECTLY.
scan, check, and trigger registered milestones.
Milestones are triggered in the order when calling
Listener$add_milestones.
Listeners$monitor(trial)
triala Trial object.
mute()INTERNAL MACHINERY: DO NOT CALL THIS METHOD DIRECTLY.
mute all messages (not including warnings)
Listeners$mute(silent)
silentlogical.
reset()INTERNAL MACHINERY: DO NOT CALL THIS METHOD DIRECTLY.
reset all milestones registered to the listener. Usually, this is called before a controller can run additional replicates of simulation.
Listeners$reset()
clone()The objects of this class are cloneable with this method.
Listeners$clone(deep = FALSE)
deepWhether to make a deep clone.
##
## ------------------------------------------------
## Method `Listeners$add_milestones`
## ------------------------------------------------
listener <- listener()
interim <- milestone(name = 'interim',
when = eventNumber('endpoint', n = 100)
)
final <- milestone(name = 'final',
when = calendarTime(time = 24)
)
listener$add_milestones(interim, final)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.