Questions tagged [docplex]
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.
258
questions
0
votes
1
answer
35
views
CPLEX Python for Scheduling Case: How to define the continuous variable and constraint (for loop)?
I have defined the variables and constraints for a scheduling case with CPLEX by using python. I would like to define two continuous variables and add constraints with for loop function. However the ...
0
votes
0
answers
32
views
How can I define the relation between two decision variables with different keys? TypeError: Cannot convert linear constraint to a boolean value
I am solving an optimisation problem formulated as an MILP using docplex library in Python.
I have a decision variable indexed by activity a as the key : avail_car[a]
And another decision variable ...
1
vote
1
answer
27
views
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. ...
0
votes
0
answers
18
views
Complex Assigning/Scheduling with CP Optimizer
I've been trying to tackle a problem with CP optimizer, but I'm a little stuck:
I have projects with 200-300+ individual tasks with individual upstream and downstream dependencies. The tasks follow a ...
0
votes
1
answer
27
views
May be a bug? Where can I find the meaning of parameter in docplex?
when I want to search the meaning of parameter value in docplex, it seems to go wrong. The following is the code:
from docplex.mp.model import Model
import cplex
model_do = Model()
# the following ...
-1
votes
0
answers
11
views
writing down an objective function with three sums in cplex python
How can I write down the below objective function in CPLEX Python API? |p| is just the length of parameter p(the length of a path in a network in my context).
1
vote
1
answer
39
views
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....
0
votes
1
answer
14
views
reseting a model in cplex python API
I am using Cplex python API for my optimization problem. I want to run many instances of the problem and each time I want to create a new model with a different set of variables. The problem is that I ...
0
votes
1
answer
27
views
Number of variables: Assignment Problem (OR with Python and Cplex)
I have to assign a given number of machines (i=8) to a given number of tasks (j=14). Therefore I wrote a code in python with docplex. The Problem is if I think I should have 8*14=112 decision ...
1
vote
1
answer
26
views
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 ...
-1
votes
0
answers
25
views
TypeError: Cannot convert linear constraint to a boolean value:
I would like to know which operator in cplex docplex in python api is "or".
I need to compare two linear constraints and when I do this comparison p generates this error.
enter image ...
0
votes
0
answers
50
views
CPLEX DOcplexException on Mac big sur(M1)
from docplex.mp.model import Model
opt_model = Model(name = 'Linear Program')
x = opt_model.continuous_var(name = 'x', lb = 0)
y = opt_model.continuous_var(name = 'y', lb = 0)
c1 = opt_model....
1
vote
1
answer
66
views
"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 ...
-1
votes
1
answer
33
views
Cplex Python Gaps
How can I print the gaps(each iteration) like OPL's engine in Python? I want to keep the gaps like this:
Nodes Cuts/
Node Left Objective IInf ...
0
votes
0
answers
31
views
Why docplex optimization gives no answer
I am working on an optimizatiom model which is set to maximize NPV. I am getting some results, however my cap_ele should represent the max value in the el_to_ele_t series. However after running the ...
0
votes
2
answers
72
views
Python Cplex Ceil() Function
ceil() in the constraint
Hello, I am studying a published paper. One of the constraints from this paper(which can be shown in the link) requires the ceil() function. We can use the ceil() function at ...
0
votes
0
answers
25
views
How to minimize and then maxmize one function sequentially with DOcplex in python?
I want to solve a problem like this:
maxy∈Y{minx∈X(y) cTx}
which is to firstly minimize cTx with x in X(y), and we get the result with y still uncertain, and then we maximize the what we got with y ...
-1
votes
1
answer
39
views
Why do i get no attribute in docplex?
I am running an optimization code in docplex but for some reason I get an error:
AttributeError: 'NoneType' object has no attribute 'get_value_dict'
This error refers to the line:
prod_hpp_grid_ts = ...
0
votes
0
answers
39
views
APPSI Needscompiledextension
I've been running an iterative optimization problem using pyomo, and was pointed to using their appsi solvers to reduce read/write time between iterations.
When I attempt to run the solver, I receive ...
0
votes
0
answers
31
views
Mixed Integer Linear Modeling in CPLEX
I have some information about the voyage of a ship:
the total distance between Port A and Port B,
the amount of Fuel the ship can consume for the voyage,
the ETA to port B from port A.
Based on this ...
0
votes
0
answers
31
views
DOcplexException: Multiply expects variable, expr or number, True was passed
I have a model that function with cplex 12 but in cplex 21 show me this error:
DOcplexException: Multiply expects variable, expr or number, True was passed (type is <class 'bool'>)
0
votes
1
answer
51
views
getting DOcplexException: cannot convert to expression: <generator object <genexpr> at 0x7f59feda16d0>
Im trying this code
m.minimize(30sum(x["Product A",j])+28sum(I["Product B",j])+0.9sum(I["Product A",j])+0.75sum(I["Product B",j])for i in Products)
and it keeps ...
0
votes
1
answer
64
views
CPLEX Binary Variable in Python
I am trying to set up a binary variable for my optimization problem in Python by using the IBM CPLEX. In my objective function, I set up a line which turns on and off depending on the market price in ...
0
votes
0
answers
40
views
Adding constraints in DOCPLEX with Python
I am using docplex in Python to solve an ILP.
I would like to add the following constraints to the model.
.......
I tried this code but it did not work
mdl.add_constraints(mdl.sum(y[i,j] for j in ...
0
votes
1
answer
20
views
How can I use docplex in cplex 221? ModuleNotFoundError: No module named 'docplex.mp';
I recently install IBM Ilog Cplex 221. I install cplex running "python setup.py install" in my corresponding python version folder. I have intstalled docplex, but when I excute the code ...
0
votes
1
answer
55
views
Is it possible to view the constraints while using docplex?
I have a quadratic model which I wrote using docplex and when solving it says it is infeasible. When I checked to see if there are any conflicts it returned 0 so I assume there are none but I have no ...
0
votes
1
answer
68
views
Relative MIP gap tolerance in docplex module
I solve a multiobjective MIP with the docplex module in Python. As the problem is rather large, I would like to set a relative MIP gap tolerance: parameters.mip.tolerances.mipgap (https://www.ibm.com/...
0
votes
1
answer
97
views
Unable to find the same solution on CPLEX and MATLAB for a quadratic program
I'm trying to solve the following quadratic problem with MATLAB (using quadprog function) and CPLEX. The problem is that MATLAB and CPLEX provided feasible solutions but both solutions didn't match. ...
0
votes
1
answer
24
views
How to express exponential of a variable in docplex?
I need to define a constraint as follows:
mdl.add_constraints(p_pg[plan, segment] == np.exp(u_pg[plan, segment] for plan in range(1, p+1) for segment in range(1, g+1))
In this constraint both p_pg and ...
0
votes
1
answer
96
views
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
...
0
votes
0
answers
31
views
How do I Implement a Utility Function from a Preference Table
I'm working with a facility location/resource allocation problem with a dataset that looks like this:
Agents_df
Agent
First Preference
Second Preference
Third Preference
1
Office A
Office B
Office C
...
1
vote
0
answers
28
views
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 ...
0
votes
1
answer
60
views
DocPlex giving CpoSolverException when using search phases
I am running a constraint programming model in docplex. When I add the following search phase I get an error in docplex:
model.set_parameters({'SearchType': 'DepthFirst', 'Workers': 2, "...
0
votes
0
answers
49
views
Mathematical model to CPLEX
I am trying to convert this mathematical model to CPLEX code. But it is not working.
tuple Sortie {
int launch;
int deliver;
int rendez; }
{Sortie} ...
0
votes
2
answers
116
views
docplex.mp.utils.DOcplexException: Expecting sequence of linear constraints, got: docplex.mp.QuadraticConstraint[]
Please pardon my ignorance. I was trying my understanding on Docplex. I produce this code to model optimization equations as shown in the picture below. My main concentration is constraint 2c, I can't ...
0
votes
1
answer
22
views
Developing desktop app by python with cplex packages
I want to develop an app for my linear programming script in python, and when I installed python cplex API, and docplex that needed cplex optimisation studio to be installed in my computer.
my ...
-1
votes
1
answer
63
views
How can I take the solution values from first calculation and use it in another calculation in python using docplex
I calculated a machine scheduling problem using docplex in python. I obtained one of the decision variable as:
yib
solution
y_0_1
1
y_1_2
1
y_2_1
1
y_3_1
1
y_4_1
1
Since I wanted to use this ...
0
votes
1
answer
158
views
How to use nested IF-THEN constraints in DOCPLEX (Python)?
I am modeling the situation I want using python cplex.
While using it, a few questions arose, and these are:
Can I use nested IF-THEN constraints in CPLEX?
First, I could find below how to use the ...
0
votes
0
answers
60
views
How to write a CPLEX conditional constraint in python(docplex)?
I have a CPLEX model that has several constratints. This model is to solve the order batching and sequencing problem. Among them, the two constraints are as follows.
forall( o in O ) // ...
2
votes
1
answer
58
views
Optimization integer programming with covariance matrix
I am trying to do a optimization problem which requires the calculation of a new covariance matrix affected by the variable within the implementation.
I am able to do so with scipy optimization ...
0
votes
0
answers
85
views
CPLEX returns no solution with deterministic time limit
I'm working with CPLEX using the python API (Docplex).
If I set the time limit in seconds with model.set_time_limit(60) the solver returns the best integer feasible solution notifying that the time is ...
0
votes
1
answer
61
views
'Maximum polynomial degree is 2' docplex's error
I am using docplex (docplex.md.model) for a minimization problem, and my objective function has a product of three variables (one continuous and two binaries), when running the code I got this error:
...
0
votes
1
answer
63
views
CpoException: Executable file should be given in 'execfile' context attribute
the line in question that is giving me problems is the following:
msol = mdl.solve(TimeLimit=20, trace_log=False, execfile='\Applications\CPLEX_Studio_Community201\cpoptimizer\bin\x86-64_osx\...
1
vote
1
answer
46
views
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 ...
0
votes
1
answer
73
views
Translation of a mathematical summation into code
I'm playing with docplex on Python and I'm facing some difficulties.
I wanto to code the Mathematical expressions
attached in the image as constraints, but it is quite hard for me. I know that t and T ...
1
vote
1
answer
101
views
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 ...
1
vote
1
answer
116
views
docplex "Error: Model has non-convex objective:"
I would like to solve a mix-integer nonlinear programming problem in phyton. I use the codes you see in below. I'm taking this error:
Error: Model has non-convex objective: x_1_2 * ...
0
votes
1
answer
207
views
CPLEX with student edition on google colab
I have google colab but I get the warning for using CPLEX and Docplex :
9 frames
CplexSolverError: CPLEX Error 1016: Community Edition. Problem size limits exceeded. Purchase at http://ibm.biz/...
0
votes
1
answer
169
views
[docplex error]-docplex.mp.utils.DOcplexLimitsExceeded: **** Promotional version. Problem size limits (1000 vars, 1000 consts) exceeded
I want to use docplex module in python and I have installed CPLEX version 20.10 and installed python 3.7.9.
When I tried to run the code, I got the error:
docplex.mp.utils.DOcplexLimitsExceeded: **** ...
0
votes
0
answers
90
views
How can I optimize the search in a CSP problem using docplex (CpoModel)
I am using docplex (CpoModel) with Python to solve a CSP and I have the following problem: when I test it with a very simple infeasible problem, it does not return that the problem is infeasible in a ...