Skip to content

Refactor: Integrate FERN with native SBSCL SBMLinterpreter (Resolves #55) - #109

Open
dyrpsf wants to merge 1 commit into
draeger-lab:masterfrom
dyrpsf:feature-issue-55-fern-refactor
Open

Refactor: Integrate FERN with native SBSCL SBMLinterpreter (Resolves #55)#109
dyrpsf wants to merge 1 commit into
draeger-lab:masterfrom
dyrpsf:feature-issue-55-fern-refactor

Conversation

@dyrpsf

@dyrpsf dyrpsf commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

Overview

This PR resolves Issue #55 by deeply integrating FERN's stochastic propensity calculations with the native, highly-optimized SBSCL SBMLinterpreter.

Previously, FERN relied on a custom MathTree class that manually copied the Abstract Syntax Tree (AST) and created a new instance of the interpreter for every single reaction calculation. This created a massive memory and performance bottleneck during stochastic simulations.

Changes Made

  • Refactored SBMLPropensityCalculator.java: The calculator no longer duplicates the interpreter state. It now updates the existing SBMLinterpreter state and natively calculates velocities using interpreter.compileReaction(reactionIndex).
  • Deleted MathTree.java: Completely removed this class to prevent slow AST copying and manual Depth-First Search (DFS) tree traversals for species dependencies. Dependency resolution is now handled efficiently by querying the Reaction object directly via JSBML.
  • Updated SBMLEventHandlerObserver.java: Rewired event, trigger, and delay evaluations to use native ASTNode and ASTNodeValue evaluation from SBSCL instead of MathTree.
  • Cleaned NetworkTools.java: Removed obsolete helper methods that relied on the deleted MathTree class.

Impact

This architectural shift significantly reduces the memory overhead and computational bottleneck of the Gillespie algorithm in SBSCL. By relying on the native engine, the mathematical structure of the model is no longer being duplicated in memory for every propensity calculation.

Resolves #55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor FERN classes to use SBSCL classes

2 participants