Skip to content

Conversation

@xts-Michi
Copy link
Collaborator

@xts-Michi xts-Michi commented Jul 20, 2025

Add CommonsMathSolver Adapter for AbstractLPModel

This PR introduces the first solver integration into the abstract interface.

Key Changes

CommonsMathSolver Integration

  • Added CommonsMathSolver:

    • Accepts a finalized (build()-ed) AbstractLPModel and solves the linear program using Apache Commons Math's SimplexSolver
    • Extracts variables, bounds, constraints, and objective function directly from the model (no redundant mapping required)
    • Fully supports both maximization and minimization via the OptimizationDirection enum
  • Standardized Result Handling:

    • Introduces or updates LPSolution as a single, extensible container for all solver results: variable assignments, objective value, and feasibility flag
    • Ensures results are accessible via variable names (Map<String, Double>)

Tests

  • Added generic unit tests for the solver interface and adapter:
    • Abstract base tests (BaseLPSolverTest) ensure consistent behavior for any solver integration
    • Concrete test class (CommonsMathSolverTest) runs all standard LP tests against the new CommonsMathSolver
  • The existing demo (SolverDemo) remains for manual/interactive exploration
  • Test coverage includes:
    • Adding variables and constraints
    • Model build/finalization logic
    • Duplicate name handling
    • Enum-based maximize/minimize direction
    • Model mutability and debug flag

@xts-Michi xts-Michi self-assigned this Jul 20, 2025
@xts-Michi xts-Michi requested a review from matthiaskoenig July 21, 2025 19:04
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.

minor comments, ready to merge

@xts-Michi xts-Michi merged commit 355e0d5 into main Jul 23, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants