Registry / data / docplex

docplex

JSON →
library2.32.264pypypi✓ verified 85d ago

DOcplex is a modeling library for mathematical optimization, providing a Python API to IBM ILOG CPLEX and CP Optimizer solvers. Current version 2.32.264 supports linear, mixed-integer, and constraint programming. Release cadence is quarterly.

pip install docplex
INSTALL
IMPORT
SIG · DOCPLEX
D
docplex
datapythonv2.32.264
Install
3.9s avg
Import
139ms
Disk
23MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.32.264 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.144s · 24MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.9s · import 0.134s · 25MB
23MB installed
● package 23MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Model
from docplex.mp.model import Model
from docplex import Model
Model is not directly in the docplex namespace; import from docplex.mp.model.
CpoModel
from docplex.cp.model import CpoModel
from docplex import CpoModel
CpoModel is not directly in the docplex namespace; import from docplex.cp.model.

Create a simple mixed-integer programming model, add variables and constraints, maximize objective, and solve.

from docplex.mp.model import Model mdl = Model(name='example') x = mdl.integer_var(name='x') y = mdl.integer_var(name='y') mdl.add_constraint(x + y <= 10) mdl.maximize(x + 2*y) solution = mdl.solve() if solution: print(f'x = {x.solution_value}, y = {y.solution_value}')
Debug
Known issues
breakingIn DOcplex 2.10+, the `CpoModel.solve()` returns a `CpoSolveResult` instead of a tuple. Code relying on tuple unpacking will break.
fix
Access result attributes directly (e.g., `sol.get_objective_value()`) rather than unpacking.
affects: >=2.10
deprecated`docplex.mp.vartype` (e.g., `IntegerVarType`) is deprecated in favor of using `docplex.mp.model.Model.integer_var()` directly.
fix
Use model methods like `model.integer_var()`, `model.binary_var()`, and `model.continuous_var()` instead.
affects: >=2.20
gotchaDOcplex requires a CPLEX license to solve locally (free for academic users with IBM Academic Initiative). Without a local CPLEX installation or cloud subscription, `solve()` will raise a `DOcplexException`.
fix
Install CPLEX (e.g., `pip install cplex`) and set up license, or use IBM Decision Optimization on Cloud (set `url` and `key` in `Model.solve()`).
affects: all
Errors
Common errors & fixes
docplex.util.environment.DOcplexException: Model has no solution
Solver failed to find a feasible solution or model is infeasible.
fix
Check model constraints for conflicts or use `mdl.refine_conflict()` to diagnose infeasibility.
ImportError: cannot import name 'Model' from 'docplex'
Incorrect import path; Model is in `docplex.mp.model`.
fix
Use `from docplex.mp.model import Model` instead of `from docplex import Model`.
NameError: name 'IntegerVarType' is not defined
Deprecated import removed in newer versions.
fix
Use `model.integer_var()` or `model.binary_var()` directly, not `IntegerVarType`.
Upgrade
Version history
2.32.264latest on PyPI · released Apr 1, 2026
Audit
Dependencies
cplexoptionalOptional: required to solve models locally, otherwise DOcplex can connect to IBM Decision Optimization on Cloud
Agent activity
17 hits · last 30 days
node
14
Amazon
1
OpenAI (training)
1
Resources
docplex — pip install docplex · libregistry