Network-free simulation of energy-based (eBNGL) models via load-time rule expansion#58
Merged
jrfaeder merged 2 commits intoRuleWorld:masterfrom Apr 6, 2026
Merged
Conversation
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
Implements network-free simulation of energy-based rule-based models (eBNGL) in NFsim. Energy rules using the
Arrheniusrate law are automatically expanded at model-load time into conventionalBasicRxnClassrules with pre-computed rate constants, following the algorithm in Sekar (2015, Chapter 3). This eliminates any runtime energy computation or rejection sampling overhead while maintaining exact thermodynamic consistency (detailed balance).This is, to our knowledge, the first implementation of network-free energy-based simulation in any rule-based modeling framework.
Background
Energy-based BioNetGen (eBNGL) allows modelers to specify cooperative interactions via energy patterns and Arrhenius rate laws, with free energy computed from pattern matches. Previously, eBNGL models could only be simulated after full network generation (ODE/SSA in BNG2), because computing reaction rates requires knowledge of both reactants and products — information unavailable in a network-free simulator until after the reaction fires.
Sekar (2015) proved that only energy pattern embeddings overlapping the reaction center contribute to ΔG (Corollary 3.3-43), enabling each energy rule to be expanded into a finite set of conventional rules with analytically pre-computed rates. This PR implements that algorithm directly in NFsim's C++ input pipeline.
Reference
Implementation
New files
Thermodynamic consistency verified: k_fwd/k_rev = exp(-ΔG/RT) for all variants, confirming detailed balance is exactly preserved.
Known limitations
writeXML()does not yet emit<ListOfEnergyPatterns>ortype="Arrhenius"rate laws — requires corresponding BNG2 patchnumberPerQuantityUnit/ volume convention); does not affect thermodynamic ratiosblockSameComplexBindingfor expanded rules: Intra-complex binding blocking not yet wired for Arrhenius rulesHow to test
Verify that 4 expanded rules are created (2 forward + 2 reverse) and the reported rates match the analytical predictions above.