docplex (a.k.a. IBM® Decision Optimization CPLEX® Modeling for Python) is a Python modeling API that provides modules for mathematical programming via CPLEX and constraint programming via CP Optimizer.
Questions tagged [docplex]
316 questions
2
votes
2 answers
How to add quadratic constraints to the model by using DOcplex (python)?
Take this quadratic constraint as example:
(-x1^2 + x2^2 + x3^2 <= 0)
Note that in the CPLEX Python API, the above constraint is formalated as follows:
m.quadratic_constraints.add(
quad_expr=[["x1", "x2", "x3"], ["x1", "x2", "x3"], [-1, 1, …

aniuniu
- 23
- 3
2
votes
1 answer
How to use Continuous Variables for IF-THEN constraints on DOCPLEX (Python)?
I'm using DOCPLEX to build up a Mixed Integer Linear Programming (MILP) problem which is then solved via CPLEX on Python. However, upon trying to solve the MILP problem using IF-THEN constraints, I receive the following error:
DOcplexException:…

Muhammad Ali
- 277
- 3
- 11
2
votes
2 answers
How to implement refining conflict in constraint programming
I use Docplex with python 3.7 to implement constraints programming. when it was infeasible, how can i proceed to list constraints those was to source of the conflict?
mdl.export_as_cpo(out="/home/..../MCP3.lp")
msol = mdl.solve(FailLimit=700000,…

Issouf
- 140
- 12
2
votes
1 answer
Get values of a binary variables
I have a MILP that I solved using docplex. Now I want to get the value of my binary variables ( binary_var_dict) after the resolution. Can anyone tell me how should I proceed ? Thanks in advance

Death_Note
- 31
- 4
2
votes
2 answers
model.solve() method is not working ("CPLEX DLL not found") for DOcplex for Python
I build my mathematical model using DOcplex IBM package for Python. I am sure that the other part of the modeling is correct, however when the call to Model.solve() is executed, and I get the following error:
"CPLEX DLL not found: please provide…

Faraz Ramtin
- 345
- 3
- 11
1
vote
2 answers
Docplex (cplex) fails solve a simple quadratic optimization problem
I'm trying to solve the following problem using the docplex:
min (x+10)**2
its obvious answer is x = -10. I used the following code to solve it in docplex:
===============================================
from docplex.mp.model import Model
model =…

Ehsan Rezaei
- 11
- 1
1
vote
1 answer
docplex.mp.utils.DOcplexException: Model.if_then()
This is the Docplex code
from docplex.mp.model import Model
car=[1, 2, 3]
myorder=[391, 392, 393, 448, 449, 450]
mdl = Model(name='planning')
Assignment = mdl.binary_var_matrix(myorder, car, name='Assignment')
CarLoaded =…

william007
- 17,375
- 25
- 118
- 194
1
vote
1 answer
Docplex return first feasible solution found
I'm trying to solve a NP-Hard problem using docplex and cplex and I need that docplex return the first factible solution founded and stop the search. In general, stop when find the nth best solution. Something like that:
set limits solutions n

Sebastian Jose
- 301
- 2
- 9
1
vote
1 answer
Is there any grammar/ guidance for writing CPLEX Module by Python?
I am trying to use CPLEX module via python for the scheduling case.
However there is an error as follows.
model = Model(name='scheduling')
# --- decision variables ---
numbers = range(1, math.factorial(6))
K = [number for number in range(1,…

Nicholas TI
- 23
- 2
1
vote
1 answer
Object based Variables for Optimization in docplex
I have an implementation where I need to optimize over object variables. I am using the mathematical programming package of docplex. The problem is that all (both) object variables are being considered the same.
from docplex.mp.model import…

Aditya Paul
- 61
- 8
1
vote
1 answer
"from cplex import *" command get an Error in VScode saying "... mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')"
Thank you in advance for your kind support
I installed the CPLEX academic version to solve a MIP model using Docplex in the VScode editor (using Python 3.10.4 64-bit).
However, can't run it and getting the following error for this line: "from cplex…

Masoud Golalikhani
- 21
- 1
1
vote
1 answer
Why doesn't my CPLEX API solve the problem?
I have written my quadratic program in the CPLEX API but when I try to solve it the model doesn't do anything. The following is the code:
import numpy as np
from docplex.mp.model import Model
# Model Design
COVID_19_QP_CPLEX_MODEL = Model()…

Anas
- 29
- 3
1
vote
0 answers
docplex Model has not been solved yet Error
Hello everyone and thank you in advance for your attention,
I am trying to model and solve a Mixed-integer model in which the objective function and all constraints are linear and I only have one nonlinear constraint.
The relevant variables related…

Masoud Golalikhani
- 21
- 1
1
vote
1 answer
How can I add multiple constraint groups to a diet model?
I struggle a bit to understand the different steps that are used in this example: diet.py, I've added the same code below. Also not an expert in modelling. As I understand it:
the first part makes tuples of the three lists for the model to search…

Caroline Gebara
- 45
- 1
- 5
1
vote
1 answer
How can obtain the range of all solutions with CPLEX optimizer?
I am working on defining a diet model, to extract all possible solutions of diets with both environmental and nutritional constraints. I have used the same setup as in this docplex-example at GitHub to do the optimization and included environmental…

Caroline Gebara
- 45
- 1
- 5