Supported Solvers

Supported solvers in Mixed Integer Programming (MIP)

A how-to guide for working with different solvers.

These are the supported solvers for Mixed Integer Programming (MIP):

ProviderDescriptionUse with
HiGHSOpen-source solver.Nextmv platform & SDK
FICO XpressCommercial solver.Nextmv platform & SDK
OR-ToolsOpen-source solver.Nextmv platform & Python

When working locally with the Nextmv Platform make sure all necessary assets are up to date by running the following command:

nextmv sdk install
Copy

HiGHS

HiGHS

HiGHS is an open-source solver. It is a high performance serial and parallel software for solving large-scale sparse linear programming (LP), mixed-integer programming (MIP) and quadratic programming (QP) models.

  • When running locally, this solver is supported natively using Nextmv's Go SDK.
  • To use this solver, follow the instructions in the getting started tutorial.
  • Does not require additional licensing or setup, for running locally or in the cloud.

HiGHS is the default SolverProvider used in the mip template, as shown in the getting started tutorial. The SolverProvider is passed as an argument to the NewSolver function.

// Create a solver using a provider. Please see the documentation on
// [mip.SolverProvider] for more information on the available providers.
solver, err := mip.NewSolver(mip.Highs, model)
if err != nil {
	return schema.Output{}, err
}
Copy

When using HiGHS as the SolverProvider, it shows up as the value to the provider key in the output, under the statistics section:

"statistics": {
  "result": {
    "custom": {
      "constraints": 1,
      "provider": "highs",
      "status": "optimal",
      "variables": 11
    },
    "duration": 0.000501042,
    "value": 444
  },
  "run": {
    "duration": 0.000501042
  },
  "schema": "v1"
},
"version": {
  "sdk": "VERSION"
}
Copy

FICO Xpress

FICO Xpress

FICO Xpress is a commercial solver. Use it to solve for large-scale linear and mixed integer problems, as well as non-linear problems: LP, NLP, MIP, MINLP, QP, QCQP, SOCP, MIQP, MIQCQP, MISOCP, MINLP, and CP.

  • When running locally, this solver is supported natively using Nextmv's Go SDK.
  • To use this solver, follow the instructions in the getting started tutorial.
  • Running locally with the Nextmv CLI and SDK is supported out of the box using the community license.
  • To deploy an app to Nextmv Cloud please contact support.

When using FICO Xpress as the SolverProvider, change how the NewSolver function is declared.

// Create a solver using a provider. Please see the documentation on
// [mip.SolverProvider] for more information on the available providers.
solver, err := mip.NewSolver(mip.Xpress, model)
if err != nil {
	return schema.Output{}, err
}
Copy

The getting started tutorial shows how to get up and running with the mip template, which uses HiGHS. When using FICO Xpress, you also need to change the app.yaml manifest that comes with the app.

# This manifest holds the information the app needs to run on the Nextmv Cloud.
type: sdk
features:
  - sdk
  - mip-xpress # Replace if using a different solver provider in your app.
Copy

As shown with HiGHS, the provider key in the statistics section of the output indicates the SolverProvider that was used. When using FICO Xpress, you can expect the value of provider to be "xpress".

OR-Tools

OR-Tools

OR-Tools is an open-source solver. It is a software suite for optimization, tuned for tackling the world's toughest problems in vehicle routing, flows, integer and linear programming, and constraint programming.

  • This solver is supported using Python.
  • When running locally, this solver is not supported natively using Nextmv's SDK and you need to run with the Python command directly.
  • Does not require additional licensing or setup, for running locally or in the cloud.

Get started by initializing the ortools template. The template contains a solution to the same knapsack problem described in the getting started tutorial.

nextmv sdk init -t ortools
Copy

Change directories into the ortools folder.

You should see the input.json and main.py files, similar to these ones:

{
  "items": [
    {
      "item_id": "cat",
      "value": 100,
      "weight": 20
    },
    {
      "item_id": "dog",
      "value": 20,
      "weight": 45
    },
    {
      "item_id": "water",
      "value": 40,
      "weight": 2
    },
    {
      "item_id": "phone",
      "value": 6,
      "weight": 1
    },
    {
      "item_id": "book",
      "value": 63,
      "weight": 10
    },
    {
      "item_id": "rx",
      "value": 81,
      "weight": 1
    },
    {
      "item_id": "tablet",
      "value": 28,
      "weight": 8
    },
    {
      "item_id": "coat",
      "value": 44,
      "weight": 9
    },
    {
      "item_id": "laptop",
      "value": 51,
      "weight": 13
    },
    {
      "item_id": "keys",
      "value": 92,
      "weight": 1
    },
    {
      "item_id": "nuts",
      "value": 18,
      "weight": 4
    }
  ],
  "weight_capacity": 50
}
Copy

Please note that the input.json is the same one used in the mip template.

Because this is a Python template, make sure that the requirements described in the requirements.txt file are installed.

pip3 install -r requirements.txt
Copy

Run the code, specifying the file to be used as input.

python3 main.py -input input.json -duration 10
Copy

After running, the output should have been printed to stdout, similar to this one:

{
  "solutions": [
    {
      "items": [
        {
          "item_id": "cat",
          "value": 100,
          "weight": 20
        },
        {
          "item_id": "water",
          "value": 40,
          "weight": 2
        },
        {
          "item_id": "phone",
          "value": 6,
          "weight": 1
        },
        {
          "item_id": "book",
          "value": 63,
          "weight": 10
        },
        {
          "item_id": "rx",
          "value": 81,
          "weight": 1
        },
        {
          "item_id": "coat",
          "value": 44,
          "weight": 9
        },
        {
          "item_id": "keys",
          "value": 92,
          "weight": 1
        },
        {
          "item_id": "nuts",
          "value": 18,
          "weight": 4
        }
      ]
    }
  ],
  "statistics": {
    "result": {
      "custom": {
        "constraints": 1,
        "provider": "SCIP",
        "status": 0,
        "variables": 11
      },
      "duration": 0.12345,
      "value": 444.0
    },
    "run": {
      "duration": 0.12345
    },
    "schema": "v1"
  }
}
Copy

The template contains an app.yaml manifest that specifies how to execute the app in the cloud.

# This manifest holds the information the app needs to run on the Nextmv Cloud.
type: python
runtime: ghcr.io/nextmv-io/runtime/ortools:latest
# List all files/directories that should be included in the app. Globbing
# (e.g.: configs/*.json) is supported.
files:
  - main.py
Copy
  • type (do not modify this value): specifies that the app uses Python instead of the Nextmv SDK.
  • runtime (do not modify this value): specifies the docker runtime where the app is run. This value must not be modified because the runtime is specific for OR-Tools.
  • files: a list of all the files that should be included in the app. Globbing is supported, so you may specify individual files or whole directories. In the simple template, just the main.py needs to be included.

The OR-Tools runtime has no access to network calls. This means that importing other packages or performing HTTP requests is not yet available. If you would like more Python packages to be supported in the runtime, please contact support.

After running locally, and making sure your app manifest is correctly set up, you may follow the steps for deploying a custom app.

Page last updated

Go to on-page nav menu