Search code examples
pythonlinear-programmingor-toolsmixed-integer-programmingxpress-optimizer

How to use XPRESS as solver in Google OR Tools?


Google OR Tools says that it supports FICO XPRESS. Using Python, calling help(pywraplp.Solver.CreateSolver) I see that it supports

      - XPRESS_LINEAR_PROGRAMMING or XPRESS_LP
      - XPRESS_MIXED_INTEGER_PROGRAMMING or XPRESS or XPRESS_MIP

I do have an XPRESS license and it's been made available to the OS.

import os
os.environ['XPRESS']='/Users/Me/XPRESS license/oem_xpauth.xpr'
import xpress as xp
xp.beginlicensing()

And this has been accepted by the XPRESS Python library. The real motivation is that I don't want to redefine this rather large model in XPRESS when Google OR Tools supports its usage.

I've come across the below documentation from Google:

To enable XPRESS support, configure with -DUSE_XPRESS=ON and -DXPRESS_ROOT=/absolute/path/to/XPRESS/root/dir, replacing /absolute/path/to/XPRESS/root/dir with the path to your XPRESS installation. XPRESS_ROOT can also be defined as an environment variable rather than an option at configure time.

Are these commands line issued? Or are these arguments to be passed to OR Tools via the Python library they've built? Also, is there any risk that this would break paths that the XPRESS library is expecting?

And also (from the same link)

OR-Tools can also optionally (disabled by default i.e. OFF) be compiled with support for the following third-party solvers:

GLPK (BUILD_GLPK), note: You must enable the support of GLPK solver by using -DUSE_GLPK=ON (OFF by default). CPLEX (USE_CPLEX), XPRESS (USE_XPRESS)

But I'm unclear on where to pass USE_XPRESS


Solution

  • Xpress is not supported by the default builds of ortools that you get for example by pip install ortools.

    You have to build google OR tools with Xpress support yourself. In order to do that:

    1. Follow the general instructions from ortools here (see the "build from source" sections).
    2. For install via make create a Makefile.local with content UNIX_XPRESS_DIR = /path/to/Xpress/installation and always specify USE_XPRESS=ON XPRESS_ROOT=/path/to/Xpress/installation when issuing make commands.

    I guess that things for installing via cmake or bazel are similar, but I never tried them.