Skip to content

Add XPRESS support to the MathOpt Python API#5271

Open
jaxor24 wants to merge 1 commit into
google:stablefrom
jaxor24:mathopt-python-xpress
Open

Add XPRESS support to the MathOpt Python API#5271
jaxor24 wants to merge 1 commit into
google:stablefrom
jaxor24:mathopt-python-xpress

Conversation

@jaxor24

@jaxor24 jaxor24 commented Jul 24, 2026

Copy link
Copy Markdown

What

Exposes the existing Xpress MathOpt backend through the MathOpt Python API.

The proto and C++ layers already support Xpress
(SOLVER_TYPE_XPRESS, XpressParametersProto, XpressParameters in
cpp/parameters.{h,cc}, and the SolveParametersProto.xpress field), and the
native backend ships in the wheel. Only the Python layer was missing the
corresponding surface, so mathopt.solve(model, SolverType.XPRESS) was not
usable from Python.

Changes

  • parameters.py
    • Add SolverType.XPRESS (maps to SOLVER_TYPE_XPRESS).
    • Add the XpressParameters wrapper (name/value controls), mirroring
      GurobiParameters and the C++ XpressParameters struct.
    • Add the SolveParameters.xpress field and serialize it in to_proto().
  • init_arguments.py
    • Add the StreamableXpressInitArguments placeholder and the corresponding
      StreamableSolverInitArguments.xpress field, for parity with the other
      solvers.
  • mathopt.py
    • Re-export XpressParameters and StreamableXpressInitArguments (required by
      the mathopt_test.py public-API check).
  • parameters_test.py
    • Add an XpressParameters.to_proto test and an xpress case in
      test_to_proto_with_specifics; test_solver_type_round_trip now covers the
      new enum member automatically.
  • BUILD.bazel
    • Add //ortools/math_opt/solvers:xpress_py_pb2 to the parameters library
      and parameters_test (the py_proto target already existed).

Testing

Validated against the published OR-Tools 9.15 wheel with Xpress 9.9:

  • parameters_test.py — 17/17 pass (includes the new Xpress coverage).
  • init_arguments_test.py — 5/5 pass.
  • End-to-end: a binary MIP solved through the public API with
    SolverType.XPRESS and XpressParameters(param_values={"PRESOLVE": "0"})
    returned TerminationReason.OPTIMAL with the expected solution; the native
    Xpress backend loaded and applied the solver-specific control.

No changes to the C++/proto layers.

The proto and C++ layers already support the Xpress MathOpt backend
(SOLVER_TYPE_XPRESS, XpressParametersProto, and the SolveParametersProto
xpress field), but the Python layer did not expose it.

- Add SolverType.XPRESS.
- Add the XpressParameters wrapper (name/value controls) and wire it into
  SolveParameters.to_proto().
- Add the StreamableXpressInitArguments placeholder for solver-instantiation
  parity with the other solvers.
- Re-export XpressParameters and StreamableXpressInitArguments from mathopt.
- Extend parameters_test.py coverage and add the xpress_py_pb2 build dep.
@google-cla

google-cla Bot commented Jul 24, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@jaxor24 jaxor24 closed this Jul 24, 2026
@jaxor24 jaxor24 reopened this Jul 25, 2026
@jaxor24

jaxor24 commented Jul 25, 2026

Copy link
Copy Markdown
Author

@googlebot I signed it!

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.

1 participant