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 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>= 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.
- We currently support the following operating systems: Windows, Mac, Linux, AIX, plinux (linux-ppc64le), Linux on Z. * The platform version you choose must match the CPLEX one. Depending on the CPLEX version, a platform may be supported or not.
- 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 3.x. 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.
Installing examples¶
After the library is installed, you can optionally download and extract samples from GitHub. We provide samples for Mathematical Programming and samples for Constraint Programming.
More resources on Python¶
- Free online trainings
- 5-course series, the Python for Everybody: develop programs to gather, clean, analyze, and visualize data, by the Michigan University
- An Introduction to Interactive Programming in Python - Part 1 from Rice University
- An Introduction to Interactive Programming in Python - Part 2 from Rice University
- Introduction to Python for Data Science
- Big Data University
- Books
- Learn Python the Hard Way -
- Introducing Python: Modern Computing in Simple Packages - Bill Lubanovic
- Learning Python, 5th Edition - Mark Lutz
- High Performance Python: Practical Performant Programming for Humans - Micha Gorelick
- The Python Standard Library by Example - Doug Hellmann
- Python Cookbook - David Beazley & Brian K. Jones
- Python Essential Reference - David M. Beazley
- Python in a Nutshell - Alex Martelli
- Scientific Python Conferences