skillfed

docplex

The IBM Decision Optimization CPLEX Modeling for Python

docplex v2.32.264 78.4K downloads/30d#14,442 on PyPI
Permissive license Apache 2.0 Active released

What it is and what it does

Docplex is IBM's Python modeling library for building optimization problems that can be solved by IBM ILOG CPLEX Optimization Studio. It provides two main modules: docplex.mp for linear and quadratic programming, and docplex.cp for constraint programming. The library lets you define decision variables, constraints, and objectives in Python, then submit them to a CPLEX solver for execution.

The package is designed for developers who need to add optimization capabilities to applications—scheduling, resource allocation, planning, or other decision-making problems. It requires only six as a runtime dependency but mandates that CPLEX Optimization Studio be installed separately on your system to actually solve models. Recent versions add support for running OPL models directly from Python and work with modern Python versions including 3.13 and 3.14.

Use it for:

  • Build linear and quadratic programming models in Python and solve them with CPLEX without writing solver-specific syntax
  • Embed constraint programming problems into Python applications for scheduling, sequencing, or resource optimization tasks
  • Run OPL (Optimization Programming Language) models from Python using native integration instead of external .dat files
  • Extract and process optimization results (variables, objectives, solution pools) in Python-friendly formats like dictionaries and pandas DataFrames
  • Develop end-to-end optimization pipelines that combine data preparation, model building, solving, and result analysis in a single Python workflow

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Modeling library for building and solving mathematical optimization problems using IBM CPLEX and CP Optimizer solvers, with two namespaces for linear/quadratic and constraint programming respectively.

Yes, with conditions. Install docplex if you have IBM ILOG CPLEX Optimization Studio already deployed or can obtain it, and you need to model optimization problems in Python. The library is actively maintained, permissively licensed, and well-integrated with Python data tools. Without CPLEX Studio installed separately, the package alone cannot solve models—it is a modeling layer only. The high install friction reflects this external dependency, not the package quality.

Install

docplex on PyPI

pip

pip install docplex

uv

uv add docplex

poetry

poetry add docplex

Installing docplex

Before you install

High install friction: the package itself is straightforward, but solving models requires IBM ILOG CPLEX Optimization Studio V12.8 or later to be installed separately on your machine. Maintenance is active with recent releases.

License in practice

Apache 2.0 permissive license allows commercial and private use with minimal restrictions, making it suitable for most projects that can meet the external CPLEX solver dependency.

Quickstart

pip install docplex

from docplex.mp.model import Model

mdl = Model(name='example')
x = mdl.continuous_var(name='x')
y = mdl.continuous_var(name='y')
mdl.maximize(x + y)
mdl.add_constraint(x + y <= 10)
solution = mdl.solve()

IBM ILOG CPLEX Optimization Studio V12.8 or later must be installed on your machine to solve models; the package alone only provides modeling capabilities.

Verify before relying

  • Whether numpy 2.0 compatibility mentioned in changelog applies to current version 2.32.264
  • Specific Python version support (requires_python is unspecified in metadata)
  • Whether OPL model support in 2.32.264 requires additional CPLEX Studio features or configuration

Package facts

License Apache 2.0 (permissive)
Python support not specified
Install friction high — source build required
Runtime dependencies 1 — six
Maintenance actively maintained — 135 days since the last release
First released
Downloads 78,447/month — #14,442 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: docplex-2.32.264.tar.gz

Keywords: optimization, cplex, cpo

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: Information TechnologyIntended Audience :: Science/ResearchLicense :: OSI Approved :: Apache Software LicenseOperating System :: MacOSOperating System :: MicrosoftOperating System :: OS IndependentOperating System :: UnixProgramming Language :: Python :: 3Topic :: Other/Nonlisted TopicTopic :: Scientific/EngineeringTopic :: Scientific/Engineering :: MathematicsTopic :: Software Development :: LibrariesTopic :: System

Tags

mathematical optimization modelingcplex python interfaceconstraint programming solverlinear programming libraryibm decision optimizationquadratic optimization pythoncp optimizer modeling
optimization-modelingibm-cplexconstraint-programming

More Libraries packages