OptSolvX is a flexible Java library for solving linear programming (LP) problems with multiple interchangeable solver
backends.
It provides a clean, test-driven API for building, comparing and extending LP solvers.
OptSolvX is intended for applications in mathematics, research, and systems biology.
- Solver-agnostic LP core:
AbstractLPModel,Variable,Constraint,OptimizationDirection,LPSolution - Unified solver adapter interface:
LPSolverAdapter - Pluggable backends:
CommonsMathSolver,OjAlgoSolver(GLPK, CBC, SCIP, CPLEX, Gurobi planned) - Test-driven development with JUnit 5
- Clean logging & validation (build checks, bounds, relations)
- Easy to extend with custom backends; demo included
- LP modeling & solving: maximize/minimize, EQ/LEQ/GEQ constraints, variable bounds, build() workflow
- Backends: Commons Math and ojAlgo adapters ready (
CommonsMathSolver,OjAlgoSolver) - Builds: Java 22 by default; optional Java 8 bytecode via compat8 profile (classifier jdk8)
Requirements: Maven ≥ 3.9, Java 22 or newer (for building).
Optional: build an additional Java 8 bytecode artifact via profile compat8.
git clone https://github.com/draeger-lab/OptSolvX.git
cd OptSolvXDefault (Java 22) - installs to local Maven repo
mvn clean installOptional: Java 8 bytecode JAR (classifier jdk8)
mvn -P compat8 -DskipTests clean packageArtifacts
- target/optsolvx-.jar - Java 22 (default)
- target/optsolvx--jdk8.jar - Java 8 bytecode (compatibility)
OptSolvX requires Java 22 or newer to build the library.
The build enforces this via the Maven Enforcer plugin.
If a different JDK is active, the build will fail early with a clear message.
Optional: use the compat8 profile to produce a Java 8 bytecode JAR for downstream projects.
All mathematical LP tests are found in src/test/java/org/optsolvx/tests/lp.
Biological and advanced tests (e.g., with SBML) will be added in the future under src/test/java/org/optsolvx/bio.
Run all tests with:
mvn testRun the built-in demo (max x + y with two constraints) using the OptSolvX backend-selection mechanism.
From IDE: run org.optsolvx.backend.demo.SolverDemo.
From Maven (CLI):
mvn -q exec:java
# If needed:
# mvn -q -DskipTests exec:java -Dexec.mainClass=org.optsolvx.backend.demo.SolverDemoBy default, the solver is chosen via OptSolvXConfig using:
- CLI override (first argument)
- Per-model preference (
model.setPreferredSolver(...)) - User config (
~/.optsolvx/config.properties) - Environment variable
OPTSOLVX_SOLVER - Built-in default (
commons-math)
You can explicitly select a backend like this:
mvn -q exec:java -Dexec.args="ojalgo"Expected Output for the demo problem:
Variable values: {x=3.0, y=0.5}
Objective: 3.5
Feasible: true
Optional debug: enable verbose model logging in the demo:
model.setDebug(true); // call before model.build()Contributions and feedback are welcome! Please open issues or pull requests on this Repository.