Release 1.1.2 #92
Julian-Patzner
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
This patch adds an optional firing condition to tick triggers and reworks intervention follow-up handling and the event queue to be type-stable and allocation-optimized.
Conditional Tick Triggers
ITickTriggerandSTickTriggernow accept an optionalconditionpredicate on theSimulation, evaluated alongsideswitch_tick/intervalto decide whether the trigger fires at all.conditionkeyword: Passcondition = sim -> ...(defaultsim -> true) to suppress a trigger based on simulation-wide state, independently of its schedule. This is separate from the per-individual/per-setting condition on the trigger'sstrategy. The predicate is wrapped in aFunctionWrapperfor type-stable evaluation, and a non-boolean return raises a clear error, matching how strategy conditions behave.is_disease_active(sim): A new exported helper returningtruewhile any individuals are exposed or infectious. Its purpose is to be used as a tick-triggercondition: a recurring trigger otherwise keeps the simulation permanently awake, but gating it onis_disease_activelets the trigger stop firing once the disease dies out, sois_dormantcan fast-forward the simulation again.should_fire(trigger, sim): A new method that consults the schedule and the trigger-level condition together;step!andis_dormantnow use it.This is additive and backward-compatible — the default condition preserves the previous always-fire behavior.
Direct Follow-Up Triggering
Built-in measures no longer return a
Handoverfor the event queue to act on later. Each now triggers its follow-up strategy directly and returnsnothing.apply_followup!: A new helper that triggers a follow-up strategy for a single focal object (Individual/Setting) or a vector of them, dispatched on the concrete focal/strategy type, and a no-op when the follow-up isnothing. All built-in measures (Test,PoolTest,TestAll,FindSetting,FindSettingMembers,IsOpen,Vaccinate,TraceInfectiousContacts) now call it instead of constructing aHandover.FindMembers/ member-resolving measures:FindSettingMembers,FindMembers, andTraceInfectiousContactsnow trigger the follow-up per member inline rather than collecting members into aHandover.FindMembersreuses internalfilter_buffer/sample_bufferbuffers and a new in-placesample_individuals!, avoiding a fresh member-list allocation on each run.Handoveris unchanged for custom measures.process_eventstill checks for a returnedHandoverand applies its follow-up, so user-defined measures that return aHandovercontinue to work exactly as before. Only the built-in measures changed.Event Queue Optimization
The
EventQueuenow keeps individual and setting events in separate, concretely-typed buckets so that draining and processing stay statically dispatched. It now also utilizes free lists to reduce memory allocations.IMeasureEvents andSMeasureEvents are stored in their own bucket and staging vectors (i_buckets/s_buckets,i_staging/s_staging) rather than a sharedVector{Event}.enqueue!,stage!, and_insert!dispatch on the concrete event type.process_due!: A new draining path used byprocess_events!that processes every event due for a tick directly from the typed buckets, keepingprocess_eventstatically dispatched and avoiding boxing each event into aUnion{IMeasureEvent, SMeasureEvent}.i_free/s_free) and reused for future tick slots, so growing the queue reuses existing capacity rather than repeatedly reallocating.Reproducibility Notes
TraceInfectiousContactsnow draws one random value per traced infectee in sequence rather than drawing them all at once and filtering. The selection logic is unchanged, but the draw pattern differs, so seeded runs that use contact tracing will produce different (but equally valid) results than 1.1.1. Runs without contact tracing are unaffected.Xoshiroconstructed once (in bothSimulationconstruction andreset!), rather than re-seeding a freshXoshirowith the same seed per thread.This discussion was created from the release Release 1.1.2.
All reactions