Fix issues #63 and #65: implement product-side include/exclude filtering and add species observable dirty-flag cache - #85
Merged
Conversation
…ing and add species observable dirty-flag cache Issue #63: Implement include_products/exclude_products BNGL rule modifiers - Add ProductFilter struct to TransformationSet - Add addExcludeProduct/addIncludeProduct/checkProductFilters methods - Parse ListOfExcludeProducts and ListOfIncludeProducts in NFinput.cpp (replaces hard-error abort with real parsing and enforcement) - Check product filters in ReactionClass::fire() after getListOfProducts to treat filter violations as null events Issue #65: Add per-complex species observable dirty-flag cache - Add _speciesObsCache, _speciesObsCacheSize, _speciesObsDirty to Complex - Cache is invalidated on complex modifications (mergeWithList, updateComplexMembership, molecule state changes, bond changes) - System::outputAllObservableCounts and recalculateAllObservables use the cache to avoid re-walking unchanged complexes for every observable - Significantly reduces O(C x O x M) cost for models with many histogram-style Species observables
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.
Summary
This PR fixes two open issues in NFsim:
Issue #63 — BNGL rule modifier
include_products/exclude_productsThe
include_products/exclude_productsmodifiers on BNGL reaction rules were previously unimplemented in NFsim, causing a hard abort at XML load time ("not yet enforced in NFsim"). This PR implements full parsing and enforcement of these modifiers, mirroring the existinginclude_reactants/exclude_reactantsimplementation.Changes:
ProductFilterstruct andaddExcludeProduct/addIncludeProduct/checkProductFiltersmethods toTransformationSetListOfExcludeProductsandListOfIncludeProductsin NFinput.cpp (replaces hard-error abort)ReactionClass::fire()aftergetListOfProducts, treating filter violations as null eventsIssue #65 — Species observable performance
SpeciesObservable::isObservable(Complex*)was invoked once per (complex, observable) pair per output sample, resulting in O(C x O x M) cost. For models with many histogram-style Species observables, this caused significant slowdowns. This PR adds a dirty-flag cache on Complex objects to avoid redundant recomputation.Changes:
_speciesObsCache,_speciesObsCacheSize,_speciesObsDirtyto theComplexclassSystem::outputAllObservableCountsandrecalculateAllObservablesuse the cache to avoid re-walking unchanged complexes for every observableTesting
Fixes #63, Fixes #65