Setting up an optimization engine

Get IBM® optimizers

  • Mathematical programming (MP) and Constraint programming (CP) models must be solved with a local CPLEX installation (CPLEX Optimization Studio V12.8.0 or higher). Additionally, you can use docplex in IBM Watson Studio Cloud.
  • You can get the solving capability you need here:
    • IBM ILOG® CPLEX Optimization Studio Development or Deployment edition for solving with no engine limit or the Community Edition with engine limits. You can download the full CPLEX Community Edition here or you can download and install it from AnacondaCloud here.
    • IBM Academic Initiative for faculty members, research professionals: IBM Academic Initiative (AI) is a global program that faculty members, research professionals at accredited institutions, and qualifying members of standards organizations can join. Members can get full versions of a large selection of IBM software, including CPLEX at no charge. More information about IBM ILOG Optimization products in the IBM Academic Initiative can be found here.
    • Using IBM Decision Optimization for Watson Studio, you can create models with Watson Studio and deploy models on Watson Machine Learning.
    • IBM Watson Studio Cloud is an IBM service that provides a hosted notebook service in the cloud. Sign up for a free IBM Cloud account and you’ll find many Decision Optimization Notebooks already available in Watson Studio Cloud.

Engine setup

Before you run the examples, you need to set up an optimization engine. The examples are written so that they use the IBM ILOG CPLEX Optimization Studio on your computer if the product is installed.

If you do not have CPLEX Studio on your computer, you can install IBM ILOG CPLEX Community edition library for free.

Ultimately, you can use the IBM Decision Optimization for Watson Studio to solve your models.

Using IBM ILOG CPLEX Optimization Studio on your computer

Starting from docplex 2.16, docplex will use by default the CPLEX and CPO engines by searching your system, in the following order:

  • if cplex was installed using pip install cplex, docplex will use the engines installed this way.
  • docplex looks for the latest version of CPLEX Optimization Studio installed on your machine, by inspecting the CPLEX_STUDIO_DIRXXX variables, where XXX is the version of Cplex Optimization Studio

You can override this behaviour by changing your solver configuration.

Installing IBM ILOG CPLEX Optimization CE

IBM ILOG CPLEX Optimization is available as a free Community Edition. You can install the python runtimes using pip or with conda. The Community Edition allows you to experiment with the optimization engine with limits on size of models to 1000 variables or 1000 constraints.

Installing IBM ILOG CPLEX Optimization library with pip

The IBM ILOG CPLEX Optimization library can be installed via pip from PyPI.

Use pip to install the library:

> pip install cplex

pip is the standard tool that is used to install Python packages and is included in Python 2.7.9 (and later), Python 3.6 (and later), and Python 3.7 (and later). See pip for more details. Refer to the pip documentation for easy access to the upgrade, uninstall, and version checking commands.

See README.md for a detailed list of dependencies that are automatically downloaded and installed.

  • The Pypi distribution of CPLEX CE is available on the following platforms:

    • Windows
    • Linux (x86-64)
    • OSX

Installing the IBM ILOG CPLEX Optimization library with conda install packager

The IBM ILOG CPLEX Optimization library can be installed via conda from the CPLEX conda home.

First install Anaconda, then use conda to install the modeling library:

> conda install -c ibmdecisionoptimization cplex

conda is the package installer that is used to install Python packages and is included in Continuum Anaconda distributions. Refer to the anaconda documentation for easy access to the upgrade, uninstall, and version checking commands.

When using conda commands, you need to specify the ibmdecisionoptimization channel. For instance, to update your already existing installation of docplex using conda:

> conda update -c ibmdecisionoptimization cplex
  • The conda distribution of CPLEX CE available on the following the platforms:

    • Windows
    • Linux (x86-64)
    • OSX
    • Linux (linux-ppc64le)