Skip to content
Skills Library
Science & research · Building & coding

dcp-docplex

/dcp-docplex

DOcplex (docplex.mp), the Python modelling API of IBM CPLEX, for mixed-integer linear models with integer, binary and continuous variables, linear, indicator and logical constraints, optimisation and enumeration of solutions. Use when writing, debugging or explaining a model with docplex or CPLEX in Python, or when a problem such as assignment, scheduling, packing or selection should be modelled with docplex.

Repository
DCP-Skills ↗
Licence
Apache-2.0
Last repository change
11.11.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
21
Scripts
7
HTML comments
0
URLs in SKILL.md
4
Deprecation

No signals detected. Repository changed on 11.11.2026, without references to retired models or APIs.

Licence

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

What to check before installing
  • 7 scripts in this package. Review them before installing, as Claude may execute them.

Scripts: assets/python/assignment-all-optimal/model.py, assets/python/infeasible-staffing/model.py, assets/python/magic-square/model.py, assets/python/one-machine-schedule/model.py, assets/python/product-mix/model.py, assets/python/set-cover/model.py, assets/python/subset-sum-all/model.py

What it does and when to use it

DOcplex (docplex.mp), the Python modelling API of IBM CPLEX, for mixed-integer linear models with integer, binary and continuous variables, linear, indicator and logical constraints, optimisation and enumeration of solutions. Use when writing, debugging or explaining a model with docplex or CPLEX in Python, or when a problem such as assignment, scheduling, packing or selection should be modelled with docplex.

Original author description

DOcplex (docplex.mp), the Python modelling API of IBM CPLEX, for mixed-integer linear models with integer, binary and continuous variables, linear, indicator and logical constraints, optimisation and enumeration of solutions. Use when writing, debugging or explaining a model with docplex or CPLEX in Python, or when a problem such as assignment, scheduling, packing or selection should be modelled with docplex.

How it works

  1. Pick an interface
  2. Contents
  3. Modelling
  4. Solving
  5. All solutions
  6. Common issues
  7. Further reading
Original SKILL.md headings · 78 lines, 546 words
SKILL.md preview
---
name: dcp-docplex
description: DOcplex (docplex.mp), the Python modelling API of IBM CPLEX, for mixed-integer linear models with integer, binary and continuous variables, linear, indicator and logical constraints, optimisation and enumeration of solutions. Use when writing, debugging or explaining a model with docplex or CPLEX in Python, or when a problem such as assignment, scheduling, packing or selection should be modelled with docplex.
license: Apache-2.0
compatibility: Python 3 with the docplex and cplex packages (tested with docplex 2.32.264, cplex 22.2.0.1, Python 3.12). The pip cplex package is the CPLEX Community Edition, limited to 1000 variables and 1000 constraints per model; no key or network is needed
metadata:
  domain: constraint-programming
  solver: CPLEX
  paradigm: mip
  interfaces: "python"
---

# DOcplex (CPLEX)

DOcplex is the modelling API of IBM CPLEX. You build a `docplex.mp` `Model` from
variables and constraints, then `solve()` hands it to CPLEX, which proves optimality for
mixed-integer programs. The one idea to keep: the model must be **linear**. A product of two
variables, a division or a remainder of a variable is refused by CPLEX or by Python, and
[encodings](references/python/encodings.md) show the linear forms that do the same job.

This skill covers the `docplex.mp` modelling API. It does not cover the native `cplex` Python
API, the C++ or Java APIs, or CP Optimizer (`docplex.cp`).

## Pick an interface

| | Python |
|---|---|
| Read | [interfaces/python/README.md](interfaces/python/README.md) |
| Package | `docplex` with the `cplex` wheel (Community Edition) |

Other bindings (the native `cplex` API, C++, Java) are not covered yet.

## Contents
- [Modelling](#modelling)
- [Solving](#solving)
- [All solutions](#all-solutions)
- [Common issues](#common-issues)
- [Further reading](#further-reading)
- Per language: [Python](interfaces/python/README.md); sources in [sources.md](sources.md)

## Modelling

Variables are integer, binary or continuous; constraints are linear (in)equalities, plus
indicator, equivalence, if-then and logical helpers that CPLEX linearises, and an objective to
minimise or maximise. The calls are in the interface file; patterns a table does not show
(all-different, element, counting, binary times integer, division, disjunctions) are in
[encodings](references/python/encodings.md). Each helper adds variables and constraints of its
own, which count against the Community Edition limit ([cost table](interfaces/python/speed.md)).

## Solving

| Outcome | Meaning |
|---|---|
| proven optimal | also reported for a feasible model with no objective |
| optimal within the gap | stopped at the relative gap (default 1e-4): not exact; set the gap to 0 |
| time limit, with a solution | not proven optimal |
| time limit, no solution | nothing found |
| infeasible | proven: no solution |
| unbounded | the objective is unbounded |
| infeasible or unbounded | presolve could not tell which; turn presolve off and solve again |

Accept a result as an answer only when it is proven optimal; any other outcome may be a guess.
The exact status strings, codes and parameter names are in the interface file.

## All solutions

CPLEX has no call that lists every solution, but a solution pool can be filled, and a loop of
no-good cuts (solve, forbid that assignment, repeat) works without any pool settings. Both
are complete for integer and binary decision variables. Auxiliary variables multiply solutions:
enumerate over decision variables and drop duplicates. For all optimal solutions, solve for the
optimum, fix the objective to it, then enumerate. The loop is slow for many solutions, so
prefer the pool for more than a few dozen. Calls: [interface file](interfaces/python/README.md#all-solutions).

## Common issues

| Symptom | Likely cause | Fix |
|---|---|---|
| refusal citing a non-convex quadratic constraint | product of two variables | a binary times a bounded integer has a linear form in [encodings](references/python/encodings.md) |
| limit error, `CPLEX code=1016` | Community Edition limit of 1000 variables or constraints | reduce the formulation; enumeration adds rows of its own |

More, by symptom, in [the interface file](interfaces/python/README.md#common-issues).

## Further reading

- Documentation for agents: no `llms.txt` is published (checked: 404); start from the API reference.
- API reference: [`Model`](https://ibmdecisionoptimization.github.io/docplex-doc/mp/docplex.mp.model.html), [`Solution`](https://ibmdecisionoptimization.github.io/docplex-doc/mp/docplex.mp.solution.html)
- Modelling guide: [docplex.mp index](https://ibmdecisionoptimization.github.io/docplex-doc/mp/index.html)
- Examples: [docplex-examples `examples/mp`](https://github.com/IBMDecisionOptimization/docplex-examples/tree/master/examples/mp)
Files in this package (21)
  • SKILL.md 5 KB
  • sources.md 7 KB
  • assets/python/assignment-all-optimal/README.md 1 KB
  • assets/python/assignment-all-optimal/model.py 2 KB
  • assets/python/infeasible-staffing/README.md 1 KB
  • assets/python/infeasible-staffing/model.py 1 KB
  • assets/python/magic-square/README.md 1 KB
  • assets/python/magic-square/model.py 1 KB
  • assets/python/one-machine-schedule/README.md 1 KB
  • assets/python/one-machine-schedule/model.py 2 KB
  • assets/python/product-mix/README.md 1 KB
  • assets/python/product-mix/model.py 1 KB
  • assets/python/set-cover/README.md 1 KB
  • assets/python/set-cover/model.py 1 KB
  • assets/python/subset-sum-all/README.md 1 KB
  • assets/python/subset-sum-all/model.py 1 KB
  • evals/evals.json 4 KB
  • interfaces/python/README.md 17 KB
  • interfaces/python/program-shape.md 2 KB
  • interfaces/python/speed.md 2 KB
  • references/python/encodings.md 5 KB

Versions

The database has no other skills named dcp-docplex.

Database snapshot: 13.11.2026 · package version 0932e1d836c5 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100dcp-maxicp
    MaxiCP, a constraint programming solver from UCLouvain with integer and Boolean variables, global constraints, interval variables for scheduling, depth-first search, optimisation and solution enumeration, used from Java (org.maxicp:maxicp) through its raw API. Use when writing,…
  • 100dcp-gurobi
    Gurobi, a solver for linear, mixed-integer and indicator-constrained optimisation models (branch-and-cut), used from Python (gurobipy). Covers install, variables, linear and indicator constraints, minimise or maximise, solution status, and enumerating all or all optimal…
  • 91optimization-modeling
    When the user wants to build optimization models, solve mathematical programming problems, or find optimal solutions. Also use when the user mentions "linear programming," "integer programming," "mixed-integer programming," "constraint optimization," "mathematical optimization,"…
  • 95milp-modeling-gurobi
    When the user wants to build, solve, and debug mixed-integer linear programs in Python with Gurobi — creating variables, writing constraint-builder functions, setting objectives and parameters, handling solver status, and extracting solutions safely. Also use when the user…
  • 100operations-research-analyst
    Use when a task needs the judgment of an Operations Research Analyst — formulating a linear or mixed-integer optimization model for allocation/scheduling/blending, sizing safety stock or staffing under a target service level, deciding whether to re-optimize a disrupted schedule…
  • 100integer-programming
    Integer Programming for MCM/ICM competitions. Use when decision variables must be integers (0/1 decisions, discrete quantities) - knapsack, assignment, scheduling, facility location. Extends linear programming with integrality constraints.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.