Skip to content

Feat: set OptSolvX as default LP backend; add SBML-FBC→LP bridge#90

Open
xts-Michi wants to merge 30 commits intodraeger-lab:masterfrom
xts-Michi:feat/optsolvx-default
Open

Feat: set OptSolvX as default LP backend; add SBML-FBC→LP bridge#90
xts-Michi wants to merge 30 commits intodraeger-lab:masterfrom
xts-Michi:feat/optsolvx-default

Conversation

@xts-Michi
Copy link
Collaborator

@xts-Michi xts-Michi commented Aug 21, 2025

Status: Ready for review and merge - But PR #88 should be merged before

Summary

Switch FBA to OptSolvX by default, introduce an initial SBML-FBC→LP bridge, fix dependency/classpath issues for modern JDKs, remove the legacy SCPSolver/GLPK backend and enable configurable solver selection (Commons Math / ojAlgo) via OptSolvXConfig.

What changed since the last review

  • Removed NewGLPKSolver and SCPSolver test (SCPSolverIssue); no SCPSolver/GLPK deps remain in code or POM.
  • Added constraint-level tests for the bridge (BridgeConstraintTests) and minor perf tidy-ups in the bridge (cached SBML lists, pre-sized maps).
  • Restored getActiveObjective() in FBA for API/test compatibility.
  • Aligned dependencies to include Commons Math 2.2 alongside Math3 for legacy ODE API.
  • Backend selection / tests verifying selection
  • Added/updated bridge pipeline test to verify backend selection via -Doptsolvx.solver (ojAlgo vs commons-math).

Key changes

1) Default backend = OptSolvX

  • FBA uses OptSolvX by default via OptSolvXSolverAdapter.
  • Solver backend is resolved via OptSolvXConfig (system property -Doptsolvx.solver=..., per-model override, fallback to commons-math).
  • Supported backends: commons-math, ojalgo (aliases: cm, oj, …).

2) SBML-FBC → LP bridge (prototype)

  • FbaToOptSolvX maps:

    • variables = reactions (+ bounds from FBC v1/v2),
    • constraints = S·v = 0 with boundary species ignored,
    • objective = active FBC objective (v1/v2).
  • Small perf pass: cache SBML lists, pre-size maps.

3) Dependency / classpath

  • Add org.apache.commons:commons-math:2.2 for legacy ODE API (Math2) next to commons-math3:3.6.1.
  • Exclude legacy XML stack (xercesImpl, xml-apis, xalan) to avoid JAXP conflicts with modern JDKs (Log4j2 config now clean).
  • OptSolvX is resolved from the local Maven repository via the local-optsolvx profile until it is available on Maven Central.

4) Cleanup: remove SCPSolver/GLPK

  • Delete legacy GLPK/SCPSolver backend (code + test).
  • No more SCPSolver jars on the compile/test classpath.
  • Note: A shell helper under src/test/scripts/** still references old GLPK jars only for the historic wrapper; it’s inert for Maven builds and can be pruned later.

5) Tests & layout

  • Bridge objective: BridgeObjectiveTest.

  • New: BridgeConstraintTests checking S·v=0 at coefficient level:

    • counts per species,
    • sign/value for non-unit stoichiometry,
    • sum across reactions,
    • ignore boundary species,
    • ignore species with no participation,
    • multi-species (A,B) with different patterns.
    • Tests live under src/test/java/org/simulator/optsolvx.

6) Docs

  • README adds “Using OptSolvX (LP) in SBSCL)” snippet & JDK notes.
  • Ensured OptSolvX artifact remains Java 8 bytecode (major 52) for downstream users.

How to test

# E. coli core (unchanged public API)
mvn -q -Dtest=org.simulator.fba.FluxBalanceAnalysisTest#solveEColiCore test
mvn -q -Dtest=org.simulator.fba.FluxBalanceAnalysisTest#solveEColiCoreGZ test

# Bridge-focused (pipeline + backend selection)
mvn -Doptsolvx.solver=ojalgo -Dtest=org.simulator.optsolvx.BridgeObjectiveTest -Dsurefire.failIfNoSpecifiedTests=false test
mvn -Doptsolvx.solver=commons-math -Dtest=org.simulator.optsolvx.BridgeObjectiveTest -Dsurefire.failIfNoSpecifiedTests=false test

# Constraint-level bridge checks
mvn -Dtest=org.simulator.optsolvx.BridgeConstraintTests -Dsurefire.failIfNoSpecifiedTests=false test

Typical runtime (E. coli core):

INFO: FbaToOptSolvX: built LP (vars=95, cons=72, objectiveVars=1, dir=MAXIMIZE)
INFO: FBA: built OptSolvX model (vars=95, cons=72)
INFO: OptSolvXSolverAdapter: result feasible=true, objective≈0.874

Compatibility

  • No public API changes; only the default backend changed.
  • getActiveObjective() restored; tests depending on it pass.
  • Builds/runs on modern JDKs (tested with JDK 22); SBSCL remains Java 8; OptSolvX is consumed via the jdk8 classifier.

@xts-Michi xts-Michi changed the title Feat: set OptSolvX as default LP backend; add SBML-FBC→LP bridge prototype Feat: set OptSolvX as default LP backend; add SBML-FBC→LP bridge Jan 7, 2026
@xts-Michi xts-Michi self-assigned this Jan 7, 2026
Copy link
Collaborator

@matthiaskoenig matthiaskoenig left a comment

Choose a reason for hiding this comment

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

This looks very good. Can be merged from my side. Could you check if the FBC tests of the SBML test suite are running? If the tests pass this can be merged.

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

Labels

in progress Work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants