# The MathOpt Service

MathOpt is an API for modeling and solving optimization problems from C++ and
Python. The MathOpt *service* is an experimental set of methods within the OR
API that lets you to solve mathematical optimization problems *remotely* using
the endpoint:

- `https://optimization.googleapis.com/v1/mathopt:solveMathOptModel`

## MathOpt Features

MathOpt models can contain:

- Integer or continuous variables
- Linear or quadratic constraints
- Linear or quadratic objectives

Models are defined independently of any solver and solvers can be swapped
interchangeably. The following solvers are supported in the `SolveMathOptModel`:

- [GLOP](https://developers.google.com/optimization/lp/lp_advanced)
- [PDLP](https://developers.google.com/optimization/lp/pdlp_math)
- [CP-SAT](https://developers.google.com/optimization/cp/cp_solver)
- [SCIP](https://www.scipopt.org/)
- [GLPK](https://www.gnu.org/software/glpk/)
- [OSQP](https://osqp.org/)
- [HiGHS](https://highs.dev/)

The MathOpt service supports most the features of MathOpt when solving a model,
including:

- Duality
- Primal and dual rays
- Suboptimal primal and dual solutions
- Warm starts (by solution or basis)
- Detailed termination reason
- Branching priority
- Many solver independent parameters

Callbacks, incrementalism, and interruption are not yet supported. The MathOpt
service will support these features in the future using a richer communication
protocol.

## Setup and Installation

To use MathOpt's remote solve capabilities, you need an API key that can be
obtained following the [setup guide](https://developers.google.com/optimization/service/setup). MathOpt provides client libraries in
C++ and Python, which are available as part of [OR-Tools since release 9.9](https://github.com/google/or-tools/releases/tag/v9.9).

You can reach out to [or-mathopt-service+support@google.com](mailto:or-mathopt-service+support@google.com) should you have
questions related to the MathOpt service.