Introduction
The Xpress Python interface allows for creating and solving optimization problems using the Python programming language and the FICO Xpress Optimizer library. This manual describes how to use the Xpress Python interface.
Outline
The following chapters cover:
- Creating, handling, solving, and querying optimization problems (Chapter Modeling an optimization problem);
- Using Python numerical libraries such as NumPy to create optimization problems (Chapter Using Python numerical libraries);
- Setting and getting the value of parameters (controls and attributes) of a problem (Chapter Controls and Attributes);
- Using Python functions as callbacks for the Xpress Optimizer and the Xpress Nonlinear solver (Chapter Using Callbacks);
- Several examples of usage of the Xpress Python interface (Chapter Examples of use);
- A reference with all functions and parameters in the Python interface (Chapter Reference Manual).
It is assumed here that the reader has basic understanding of the Python programming language. Ample documentation on Python is available at http://docs.python.org, including a tutorial and a reference manual. Unless specified otherwise, Python 3 is used in all of the examples and code samples throughout this manual. The current version of the Xpress Python interface works on Python 2.7, Python 3.4, and subsequent versions.
Installing the Python Xpress module
Installation from the Python Package Index (PyPI)
The Xpress Python interface is available on the PyPI server and can be installed with the following command:
pip install xpress
Packages for Python 2.7 and 3.4 and subsequent versions are available, for Windows, Linux, and MacOS. The package contains the Python interface module and its documentation in PDF format, the Xpress Optimizer's libraries, and a copy of the community license (see http://subscribe.fico.com/xpress-optimization-community-license). Online documentation can be viewed at the FICO Xpress Optimization Help page.
Installation from Conda
A Conda package is available for download with the following command:
conda install -c fico-xpress xpress
As for the PyPI package, Conda packages for Python 2.7 and 3.4 and subsequent versions are available, for Windows, Linux, and MacOS. The Conda package contains the Python interface module and its documentation in PDF format, the Xpress Optimizer's libraries, and a copy of the community license.
Troubleshooting the installation
Whether the Xpress Python module is downloaded from PyPI or from the Conda server, there are a few remarks that might help ensure that the installation works right away. The advice below is independent of the Python platform (PyCharm, Spyder, etc.) that may be in use.
The Xpress Python interface uses the Python package NumPy for some operation, hence NumPy must be installed. It is usually installed if a Conda installation is used, nevertheless ensure that version 1.13 or later is installed for Python versions 2.7, 3.5, and 3.6, and version 1.11 is installed for Python 3.4.
For MacOS users, it might be useful to alter the linking settings of the Python modules. All such modules (named xpress.*.so) depend on libxprs.dylib, and the modules are given the correct absolute path of the installation directory containing libxprs.dylib. Should the location of this library change, the dependency has to be updated on the modules as well with the command
install_name_tool -change libxprs.dylib /path/to/libxprs.dylib xpress.so