Getting started with docplex

To get started using the Mathematical Programming Modeling for Python feature of IBM® Decision Optimization CPLEX® Modeling for Python, you first need to verify that your system meets the requirements and install Python and DOcplex. As an alternative, you an choose to use `IBM Watson Studio Cloud<https://www.ibm.com/cloud/watson-studio/>`__ and not need to install anything on your computer.

Cloud: Solving Python models using IBM Watson Studio Cloud

The easiest way to start experimenting with DOcplex does not involve installing anything on your computer.

`IBM Watson Studio Cloud<https://www.ibm.com/cloud/watson-studio/>`__ 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.

Setting up a Python environment

System requirements

  • Python with version >= to 2.7.9, or version>= 3.6 (including 3.7) on 64-bit operating systems: Available from Python.org.
    • Python version lifespans: here
    • The Python version you choose must match the CPLEX one if you solve locally.
  • We currently support the following operating systems: Windows, Mac, Linux, AIX, plinux (linux-ppc64le), Linux on Z.
  • Your system must support SSL.

Get Python development tools

  • If you are new to Python, you might want a development studio with editors and debuggers. Both PyCharm and PyDev have free editions.
  • You can download Python from Python.org.
  • A good alternative is to use Anaconda, which includes a Python interpreter and over 195 of the most popular Python packages for science, math, engineering, and data analysis.
  • You can also turn a Visual Studio into a Python editor. See Python Tools for Visual Studio project from Microsoft.

Installing the CPLEX modeling library with pip

The IBM Decision Optimization CPLEX Modeling for Python (DOcplex) library can be installed via pip from PyPI.

Use pip to install the modeling library:

> pip install docplex

pip is the standard tool that is used to install Python packages and is included in Python 2.7.9 (and later), Python 3.5 (and later), and Python 3.6 (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.

Installing the CPLEX modeling library with conda install packager

The IBM Decision Optimization CPLEX Modeling for Python (DOcplex) 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 docplex

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 docplex

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

Managing environments

You might want to have a look at Virtual Environment and Conda Environment to help you manage your Python installation base and keep your global site-packages directory clean and manageable.