[frames] | no frames]
 

IBM(R) ILOG CPLEX Python API Reference Manual

About this manual

This reference manual documents the IBM(R) ILOG CPLEX Python API. There are separate reference manuals for the C Callable Library, C++, Java, and .NET APIs of CPLEX.

To see the table of contents for this reference manual in your browser, click [frames].

What is the CPLEX Python API?

The CPLEX Python API is a Python package named cplex that allows the Callable Library to be accessed from the Python programming language. It is equally suitable for interactive use through the Python interpreter or for writing scripts or full-fledged applications.

For users of Python, CPLEX offers both a Python application programming interface (API) documented in this reference manual, as well as IBM(R) Decision Optimization CPLEX(R) Modeling for Python, also known as DOcplex. DOcplex is a library composed of two modules:

For more about DOcplex, see the DOcplex landing page.

What you need to know

This manual assumes that you are familiar with the Python programming language.

This manual also assumes that you are familiar with the operating system on which you are using CPLEX and have the appropriate version of Python installed on your system. For information about supported platforms, see Detailed System Requirements (DSR) on your IBM customer support site.

For interactive use, the tab completion functionality provided by the Python module rlcompleter is extremely useful as you browse the CPLEX Python API. GNU/Linux systems typically include this package by default. Mac users are advised to install the package readline for their system. Windows users are advised either to use IDLE, the Python IDE distributed with Python, or to install the package readline for their system.

Structure of the package cplex

The CPLEX Python API is an object-oriented API providing most of its functionality through the class Cplex defined in the top level of the package cplex. This class has a number of methods, such as Cplex.read and Cplex.solve for operating on optimization problems, but most of its functionality is provided through methods of data attributes such as Cplex.linear_constraints, Cplex.objective, and Cplex.solution. These objects provide methods for modifying and querying data associated with the corresponding parts of an optimization problem. These objects are instances of classes defined within the subpackage cplex._internal. As its name suggests, classes and other data defined in the package cplex._internal are not to be instantiated or otherwise accessed directly by the user, but rather should only be accessed as attributes of an instance of the object Cplex.