Week 11: A Closer Look at the Latest PR

Hi everyone,

This week’s update is a little delayed, but I’ll focus here on walking you through the details of my latest Pull Request. I’ll cover the other activities separately in the next blog. 

Refactoring LSODAContext

One of the first changes I made was updating the odesystem member variable in LSODAContext. Previously, it was an object of DESystem interface, but since DESystem itself implements FirstOrderDifferentialEquations interface and also brings in methods not directly needed by LSODA (specifically for storing the ode system purpose), I switched the type to FirstOrderDifferentialEquations.

This simplifies the workflow significantly: when using SBSCL with a direct ODE system, users now only need to implement computeDerivative() and getDimension(). Everything else is handled automatically, making the integration smoother and more intuitive.

Default Tolerance Values

I added sensible default tolerances in LSODAOptions:

  • Relative tolerance (relTol): 1e-6

  • Absolute tolerance (absTol): now dynamically adjusted using an absoluteToleranceAdjustmentFactor. By default, this factor is set to 1e-12, and the absolute tolerance scales according to the entries in the state vector.

I also implemented the setRelTol() and setAbsTol() methods from the AdaptiveStepsizeIntegrator interface, ensuring greater flexibility for users to configure solver behavior.

Documentation & Usability Improvements

To make adoption easier, I introduced a howToUse.md file. This document explains the different ways the LSODA-Integrator can be used within SBSCL, complete with examples and additional notes.

Additionally, I cleaned up the codebase by removing unnecessary files such as LSODAFunctions, LSODACommonContext, and LSODAIntegrator_F, which improves overall readability and maintainability.

Enhancing the Algorithm

The most important change in this PR is the updated implementation of the computeChange() method within LSODAIntegrator. In a previous blog, I have already explained the control flow of this algorithm.

SBML Test Suite Integration

To test solver accuracy and robustness, I:

  • Wrote a wrapper class: SBMLTestSuiteRunnerWrapper_LSODA

  • Linked it with a shell script so that it integrates seamlessly with the SBML Test Suite runner.

I also added SBMLTestSuiteRunnerWrapper under the test directory, which allows running SBML Test Suite models directly from the terminal with any SBSCL-supported ODE solver such as RosenbrockSolver and DormanPrince853Solver.

System Improvements & Fixes

  • Removed unnecessary logging messages in LSODAIntegratorTest.

  • Fixed a subtle bug in softFailure() within LSODAIntegrator.

  • Added extra checks in getResult() and checkOpt() to guard against edge cases.

New Overloaded Methods

To improve flexibility, I overloaded both the prepare and lsoda methods to handle different use cases.

prepare Methods:

prepare(FirstOrderDifferentialEquations system, int ixpr, int itask, int state)
prepare(FirstOrderDifferentialEquations system, int ixpr, int itask, int state, int mxstep)
prepare(FirstOrderDifferentialEquations system, double hmin, double hmax, int ixpr, int itask, int state)
prepare(FirstOrderDifferentialEquations system, double hmin, double hmax, int ixpr, int itask, int state, int mxstep)

lsoda driver function for Direct ODE Systems:

lsoda(double[] y, double[] t, double[] tout)

I also added a few more system tests in LSODASystemTest to verify the behavior of direct ODE systems with these new methods.


That wraps up the main highlights of this PR. It introduces significant usability improvements, stronger testing integration, and important refinements to solver accuracy. Now, I'm waiting for this PR to get merged. In my next blog, I’ll share the other ongoing activities, including documentation, wiki contributions, and discussions around future enhancements.


Comments

Popular posts from this blog

Week 7: Events, Exhaustion and Evaluations

My GSoC 2025 Journey Begins

Week 1: Coding Period Begins