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
0
votes
1 answer
How to install CP Optimizer 20.1 with docplex?
I am installing docplex using pip install docplex and it shows:
Successfully installed docplex-2.22.213
When I run the code it says:
- CP Optimizer 12.10.0.0 -
But since the latest ILOG CPLEX Optimization Studio is 20.1 I would expect to see CP…

S.Perera
- 874
- 3
- 9
- 24
0
votes
1 answer
DOcplexException: Expecting iterable Error
I am dealing with a vehicle routing problem with multiple working days. I want to add constraints that if a working day is 6 or its multipliers, a worker must work only 240 minutes. Therefore, I put two loops for working days (k) and workers (w) and…

Mustafa
- 1
- 3
0
votes
1 answer
An Linear Programming problem cvxpy solves but IBM ILOG CPLEX is 'optimal with unscaled infeasabilities'?
The problem being solved is finding the truss with the least weight, exactly done as on this website: https://www.layopt.com/truss/. This method is also called the ground structure method. I am aiming to add some functionallity to the method through…

Bart
- 442
- 1
- 3
- 9
0
votes
0 answers
Docplex objective function without variables
My problem doesn't require the variables to be directly in the objetive function, only the related data. So if I don't put the variables in there, the objective function has no link to the variables and the model doesn't work properly, but if I do…
0
votes
1 answer
Subtour constraint causes warnings in docplex
mdl = Model('CVRP')
x = mdl.binary_var_dict(A, name='x')
u = mdl.continuous_var_dict(N, name='u')
mdl.minimize(mdl.sum(distanceList[i][j]*x[i, j] for i, j in A))
mdl.add_constraints(mdl.sum(x[i, j] for j in V if j != i) == 1 for i in…

Mustafa
- 1
- 3
0
votes
1 answer
Can an optimization constraint be implemented with 2 variable that declared with different feature?
My goal is to write the following constraint with the doxplex.mp.model with Python API:
P[t,j] >= s[t-j+1] - sum(s[k=t-j+2] from k to t) for t = 1,....,N, j = 1,...,t
my code.
from docplex.mp.model import Model
clsp = Model(name = 'capacitated lot…

DasPlaies
- 5
- 1
0
votes
1 answer
Error while writing optimization constraint in cplex python api
My goal is to write the following model using docplex.mp.model in python. which ptj takes binary variable {0,1}.
[summation from of Ptj from j=1 to t][t = 1,.....,8]
here is the code I wrote:
N = 8
(period_list = [t for t in range(1,…

DasPlaies
- 5
- 1
0
votes
1 answer
docplex: Find the binary decision variables with value 1
I have an MIP model, which includes some sets of binary variables, e.g., y_{rnt}. Instead of having a loop over each index (like below), I would like to only print (an store) variables such that y_{rnt}=1. Does the docplex offer any function in…

mdslt
- 155
- 1
- 10
0
votes
1 answer
Linear Programming: List of all solutions generated using DocPlex in PYTHON (failing with the cplex solution pool)?
I am actually facing an issue in the resolution of a problem. My problem is a Liner Programing problem with optimization of the food diet and minimization of the cost. As the problem is similar to this one…
0
votes
2 answers
How to code subtour constraint in cplex python
I am quite new in python cplex. I tried to model VRP and needed to eliminate subtours for feasible solution, but I cannot do that with the following code:
from docplex.mp.model import Model
import numpy as np
n = 10
Q = 20
N = [i for i in range(1,…

Mustafa
- 1
- 3
0
votes
1 answer
docplex.cp.model out-of-memory running on a cluster
I am trying to run the following docplex.cp.model with a large dataset. This is with some sample data:
import numpy as np
from docplex.cp.model import CpoModel
N = 180000
S = 10
k = 2
u_i = np.random.rand(N)[:,np.newaxis]
u_ij =…

S.Perera
- 874
- 3
- 9
- 24
0
votes
1 answer
Optimality gap in DoCplex
I've created a model in Python, DoCplex. After solving the model, I got a feasible solution. I'd like to get a relative and absolute optimality gaps in DoCplex. Is there a way to obtain these gaps in Docplex?

Nari90
- 23
- 2
0
votes
1 answer
Docplex: use variables in a cloned model
I do not understand how cloned models in docplex can be modified.
from docplex.mp.model import Model
mdl_1 = Model('Model 1')
x = mdl_1.integer_var(0, 10, 'x')
mdl_1.add_constraint( x <= 10)
mdl_1.maximize(x)
mdl_1.solve()
#now clone
mdl_2 =…

Finn
- 2,333
- 1
- 10
- 21
0
votes
1 answer
LP Relaxation with Cplex (Python)
I am developing a lp model with docplex on python and I need to get solution variables of the relaxed one but do not know how to ask python to give me the relaxed solution variables of the model. I can see them as an output but when I print it, it…

alasskaa
- 1
- 1
0
votes
1 answer
Docplex objective funtion: Minimize a maximum value
I need to minimze the maximum value of a dictionary. How can I phrase the objective function?
example input: A = {1: 1.0, 2: 2.0, 3: 2.0, 4: 1.0, 5: 7.0, 6: 1.0, 7: 4.0}
So far I´ve tried:
Count == max(A.values())
Count == max(A.items(),…

Mado_xx
- 1
- 2