Conversation
) When a rule with DiscreteHazard fires and the match persists (common with attribute-containing schemas), the incremental hom-set's addition! phase creates a phantom match in a new component with a different key. The re-enable loop then also re-enables the original fired key, producing two sampler entries for the same logical match. With Dirac distributions, both schedule at the exact same time, causing exponential blowup (1,2,4,8,... events per timestep). Fix: track which (rule, key) pairs are enabled during the update phase. In the add_new loop, check if a newly-discovered match duplicates one already enabled. In the re-enable loop, check if an equivalent match was already scheduled by the update phase before re-enabling. (cherry picked from commit 2fb09aa)
Collaborator
|
Thank you for catching this! Can you add some tests that reproduce the problem? |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Author
|
Added a regression test for the reported failure mode. The new test builds a one-object attributed model with a That is the behavior that was previously violated by the duplicate scheduling bug. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
DiscreteHazardrules can be scheduled more than once in the same timestep when a fired match persists after the rewrite. This shows up most readily with attribute-containing schemas.The failure mode is that the incremental hom-set update can discover the same logical match under a new key during the addition phase, and then the later re-enable step can also re-enable the original fired key. That leaves two sampler entries for one logical match. With Dirac-style discrete hazards, both entries fire at the same time, so the number of events can grow explosively across timesteps (
1, 2, 4, 8, ...).Fix
This patch tracks which
(rule, key)entries have already been re-enabled during the update pass.When
add_newdiscovers a match, the code now checks whether an equivalent match was already enabled for that rule and skips the duplicate if so. Likewise, when previously fired matches are re-enabled at the end of the simultaneous-event update, the code checks whether an equivalent match was already scheduled during the update pass and avoids scheduling it twice.In other words, the sampler keeps one entry per logical match, even if the incremental hom-set temporarily represents that match with multiple keys.
Testing
#32julia --project -e 'using Pkg; Pkg.instantiate(); include("test/ABMs.jl")'Closes #32.