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
CPLEX solving models and detecting infeasibility
I would like to solve a given problem using CPLEX. If the problem is infeasible I would like to detect it as soon as possible and use that information to solve some other problem. I wrote the following code, but I am not sure if it is the best way…

diabolik
- 55
- 6
0
votes
1 answer
Using logarithmic in the objective function in IBM CPLEX
My objective function in IBM CPLEX is as follows:
objective = opt_model.sum(math.log(r_vars[0,0]*(3*w_vars[0]-1))+math.log(r_vars[1,0]*(3*w_vars[0]-1)))
opt_model.maximize(objective)
The variable w_vars can get a value in the range [0,1] and the…

Shahrooz Pooryousef
- 107
- 11
0
votes
2 answers
Updating constraint set rhs in docplex
I am trying to update the rhs of a constraint iteratively under a while loop in docplex, however, it does not work properly. As I analyze the output text file, while some constraints are updated as I want, others are not.
z_bar is a list consists of…

diabolik
- 55
- 6
0
votes
1 answer
External calculation within opl
I'm implementing a CP model with cplex but within the steps I want some data to be calculated in a function or some similar form then resolve the model using the result.
What I need to calculate is the angle between two points with a third one as…
0
votes
1 answer
CPLEX CP Scheduling problems: Float Times in Interval Variables
I have been carrying out experiments with CPLEX ILOC CP Optimizer using **docplex for Python ** in the field of scheduling. However, as far as CPLEX doc states, interval variables must be defined by integer values (start, duration, end).
Thus, my…

Javi Pernas
- 5
- 2
0
votes
0 answers
docplex maximize problem with multiple knapsack problem
import numpy as np
from docplex.mp.model import Model
rnd = np.random
rnd.seed(1995)
#Number of Objects
N = 12
M = 3
#Gnerate the list of objects indices
Obj = [j for j in range(0, N)]
Knap = [i for i in range(0,…

Abdullah
- 11
- 3
0
votes
0 answers
How to create range variable in DoCPLEX the way I prefer?
Suppose we have two variable x and y, and I want x-y between 0 and 1. So I did this
x = mdl.continuous_var(0, 1, 'x')
y = mdl.continuous_var(0, 1, 'y')
mdl.add_range(0.0, x - y, 1.0, f'_range_experiment')
In the LP file, I can see that this is…

qqzj
- 21
- 1
- 6
0
votes
0 answers
Define a decision variable of M0 in CPLEX
Good day to you.
From a previous model with cplex (MIP 1), I use M0 as a parameter.
Total_P = 8
M0 = np.array([[0,1,0,1,0,0,0,2]]).reshape(Total_P,1)
Then, I tried to develop a different model (MIP 2) with adjusted objectives and constraints from…

Nicholas Nicholas
- 83
- 7
0
votes
1 answer
docplex does not support square root np.sqrt(x), please suggest an alternative solution
I have implemented docplex model with python, everything goes well: problem formulation, variables, constraints and objective function.
The problem raised when I tried to compute Euclidian distance Between two centers of circles, simply numpy can do…

Rashad Moqa
- 18
- 2
0
votes
0 answers
Academic edition CPLEX and docplex
I have two questions. First, even I upgrade my CPLEX from trial to academic version still in my IBM page it is shown as trial edition. Second, related to this (I guess) I am getting error while trying to solve my model with Python. Can someone give…

bihatunkisi
- 3
- 2
0
votes
1 answer
Read variables from text file python (OPL Data file)
I've got many text (.txt) files that looks like this:
#camiones disponibles
set K:= 1 2 3;
#capacidades de camiones
param Q:=
1 20000
2 15000
3 10000
;
#demanda por tipo de leche
param D:=
26800
11700
2500
;
#costos de transporte
param c[*,*]
:…

Gonzalo Luarte
- 21
- 4
0
votes
0 answers
Manual Benders Algorithm with CPLEX in python
I have written a manual benders algorithm on python. I utilize CPLEX to solve both master and subproblems.
My problem is, the algorithm never ends. I debugged and found out that even though it adds a new constraint (I do not know how to see the…

diabolik
- 55
- 6
0
votes
0 answers
Unable to solve a LP Problem in python using docplex
from docplex.mp.model import Model
m = Model(name="LP_Problem")
x1 = m.continuous_var(name="x1")
x2 = m.continuous_var(name="x2")
c11 = m.add_constraint( x1 + x2 <= 722)
c12 = m.add_constraint( 25 * x1 + x2 <= 685)
c13 = m.add_constraint( 48 * x1…

Anil
- 1
0
votes
2 answers
Running Docplex package in Python "docplex.mp.utils.DOcplexException: Cannot solve model: no CPLEX runtime found"
I wanted to solve my Oprimization model in Python by Cplex so I installed Cplex in my system (Windows 11) and based on Cplex help insttall setup.py with this command:
python C:\Program Files\IBM\ILOG\CPLEX_Studio221\python\setup.py install
There are…

Paria fakhrzad
- 1
- 1
0
votes
1 answer
Not showing any solution in cplex
CPLEX is not showing any solution after I have integrated the equations of pevch[i][j] and pevdis[i][j]
int t=24;
int n=10;
int j=0;
range number =1..n;
range tavail=1..t;
float soc[number][tavail]=...;
//forcasted load at 0..4
float…

Haripriya M R
- 11
- 3