MiniEvents
MiniEvents.kill! — Method
kill!(agents, sim)
Remove all agent events (rates as well as scheduled). Generic version for iterables of agents.
MiniEvents.next_event! — Function
next_event(sim)Find and execute the next event in sim.
MiniEvents.now — Method
now(sim)
Current time in simulation sim.
MiniEvents.refresh! — Method
refresh!(agents, sim)
Recalculate event rates for agents. Generic version for iterables of agents.
MiniEvents.schedule! — Method
schedule!(fun, obj, at, sim)
Schedule fun(obj) to be triggered at time at.
MiniEvents.schedule_dt! — Method
schedule_dt!(fun, obj, dt, sim)
Schedule fun(obj) to be triggered at now(sim) + dt.
MiniEvents.spawn! — Method
spawn!(a, s)
Activate agent by adding its events to the scheduler.
MiniEvents.spawn_pop! — Method
spawn_pop!(agents, s)
Spawn an entire population of agents.
MiniEvents.step_dt! — Method
step_dt!(sim, dt)
Process events until time has increased by dt.
MiniEvents.step_until! — Method
step_until!(sim, t)
Process events until now(sim) >= t.
MiniEvents.@events — Macro
@events(decl_agent, block)Parse block to generate event code using agent declaration decl_agent (where decl_agent has the format <name> :: <type>).
block has to consist of a list of event declaration and directives (in no particular order).
Directives
@debug
Emits code that compares the current value of an object's rates with the stored values. This is especially useful to catch cases where a required refresh (see below) was emitted.
Event declarations
MiniEvents provides basic support for deterministic scheduling with @repeat and @at. Note that only one of these event types can occur per event declaration. In addition any number of stochastic events can be declared using @rate or @ratesfor.
@repeat
@repeat(interval) => actionRepeat action every interval time units. @repeat(interval, start) => action Repeat action every interval time units, starting at start.
@at
@at(start) => actionRun action exactly once at start. Note that future actions have to be scheduled manually.
@rate
@rate(rate) ~ condition => actionIf condition is met perform action at rate rate. Note that rates and conditions are evaluated at the point of scheduling and need to be refreshed manually if the agent object's state changes (see below).
@ratesfor
@ratesfor(function, iterator) ~ condition => actionThis allows for the efficient scheduling of an event whose rate is the sum of a number of individual rates when it is important to know which particular individual rate was triggered. For example infection rate of an individual could depend on the number of its contacts, but in some cases we want to know which contact was the source of infection.
Scheduling
The following pseudo macros are used to control scheduling. They generally take one or several arguments (each of which can be an iterable). They can only be used in action blocks.
@r
Refresh an object. This updates the rate and condition. Objects without a rate event can't be refreshed.
@kill
Remove an object from scheduling.
@spawn
Add a new object to scheduling.
Information
These macros provide access to some internal state of the scheduler and take no arguments. They can only be used in action blocks.
@sim
Access the sim object.
@selected
The selected item in @ratesfor.
MiniEvents.@simulation — Macro
@simulation(name, args...)Generate a simulation type named name. args is a list of agent types that can be subject to events (as declared with @events). As an optional last parameter a declaration block can be provided. This block will be included verbatim in the declaration of struct <name> and be used to store global information that needs to be accessible from inside of event code (via the @sim pseudo macro), such as for example parameters or global system state.
Index
MiniEvents.EventLists.AgentEventsMiniEvents.EventLists.EventListMiniEvents.EventLists.EventListMiniEvents.Scheduler.PQSchedulerMiniEvents.Scheduler.PQSchedulerBase.isemptyMiniEvents.EventLists.add_agent!MiniEvents.EventLists.change_rates!MiniEvents.EventLists.remove_agent!MiniEvents.EventLists.sum_ratesMiniEvents.EventLists.sum_ratesMiniEvents.Scheduler.advance!MiniEvents.Scheduler.next!MiniEvents.Scheduler.reset!MiniEvents.Scheduler.schedule_at!MiniEvents.Scheduler.schedule_in!MiniEvents.Scheduler.time_nextMiniEvents.Scheduler.time_nowMiniEvents.Scheduler.unschedule!MiniEvents.Scheduler.upto!MiniEvents.kill!MiniEvents.next_event!MiniEvents.nowMiniEvents.refresh!MiniEvents.schedule!MiniEvents.schedule_dt!MiniEvents.spawn!MiniEvents.spawn_pop!MiniEvents.step_dt!MiniEvents.step_until!MiniEvents.@eventsMiniEvents.@simulation