Skip to content

Fix #39: Resolve 25-minute stochastic test hang using deterministic Random seeding - #108

Open
dyrpsf wants to merge 1 commit into
draeger-lab:masterfrom
dyrpsf:fix-issue-39-stochastic-test
Open

Fix #39: Resolve 25-minute stochastic test hang using deterministic Random seeding#108
dyrpsf wants to merge 1 commit into
draeger-lab:masterfrom
dyrpsf:fix-issue-39-stochastic-test

Conversation

@dyrpsf

@dyrpsf dyrpsf commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Overview

This PR addresses Issue #39, where the SBML test suite (specifically stochastic models like 01592) would hang for 25+ minutes due to non-deterministic event picking and subsequent retry loops.

Changes

  • Deterministic Randomness: Modified EquationSystem.java to replace ThreadLocalRandom.current() with a deterministically seeded java.util.Random(12345L). This ensures that the simulation chooses the same sequence of events every time, preventing the "random walk" that caused tests to exceed their stochastic bounds and trigger long retries.
  • Enabled Test 01592: Un-skipped test case 01592 in SBMLTestSuiteTest.java as it now runs successfully and quickly with the new seeding strategy.
  • Test Suite Discovery: Added missing @RunWith(Parameterized.class) and @Test annotations to SBMLTestSuiteTest.java to ensure the parameterized suite is correctly recognized and executed by JUnit/Maven.

Validation

  • Successfully ran mvn clean test-compile to verify syntax and annotations.
  • Executed the core test suite (mvn test), which resulted in a BUILD SUCCESS with 148 tests passing.
  • Verified that the code structure is stable and does not introduce regressions in the LSODA or Runge-Kutta solvers.

Closes #39

@draeger draeger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this effort! While I am conviced this is useful, I remember @hemilpanchiwala had already used a fixed seed to reduce computation time when running test cases. Did you come across this existing approach yet?

@dyrpsf

dyrpsf commented Mar 28, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for this effort! While I am conviced this is useful, I remember @hemilpanchiwala had already used a fixed seed to reduce computation time when running test cases. Did you come across this existing approach yet?

Thank you for the feedback, @draeger !

Yes, I am aware of the random_seed variable and the RNG class mentioned by @hemilpanchiwala . However, during my investigation of Issue #39, I discovered that EquationSystem.java was still using ThreadLocalRandom.current().nextInt() within the pickRandomEvent method.

Since ThreadLocalRandom is non-deterministic and does not respect external seeds, it was effectively bypassing the existing seeding approach during the actual ODE simulations. This PR specifically addresses that by:

  1. Switching EquationSystem to use a dedicated java.util.Random instance.
  2. Initializing it with a fixed seed (12345L) to ensure that the stochastic event-picking process becomes deterministic and repeatable.

This change is what allowed test 01592 to finally pass within seconds in my local environment, as the simulation no longer falls into the 25-minute "random walk" retry loop.

@draeger
draeger requested a review from matthiaskoenig April 24, 2026 20:21
@draeger
draeger self-requested a review April 24, 2026 21:04
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.

SBML TestSuite semantic/01592 takes 15-25 minutes to run

2 participants