Tag Info

Hot answers tagged docplex

9

What Nikaza said, and also: problems of this kind often have a large number of solutions that differ only by trivial permutations/relabellings/reorderings. For example, if one worker is assigned 10 tasks that can be done in any order with no change to the objective, then there are 10! = 3628800 solutions that will have exactly the same OF. If another worker ...

7

I am aware of two ways of combining a (meta-)heuristic with a solver (like cplex). 1) Warm start: use a heuristic to quickly find a good solution and give it to the solver as a starting solution. This can help pruning the branch and bound tree considerably. (e.g. "Designing sustainable energy regions using genetic algorithms and location-allocation ...

6

CPLEX is probably spending 15 hours trying to reduce the optimality gap. This is very common issue in MILP problems. The way MILPs are solved is commonly to make all integers continuous and solve the resulting LP. That is called the linear relaxation, and its solution provides a valid lower bound (if we are minimising) on the objective function. The ...

4

I think you do need some variable that keeps track of the configuration a machine is in at a given process plan position. This could be a variable $C_{wcj}$ that is $1$ if machine $w$ is in configuration $c$ at process plan position $j$. Then the following three constraints give you that: Each machine is in exactly one configuration at each process plan ...

4

The first argument in logical_and is *args but it's not unpacked in the subroutines inside of logical_and. Your error will be gone if you change the following line from m.add_constraint(m.logical_and(w[k] for k in range(10)) == c) to m.add_constraint(m.logical_and(*(w[k] for k in range(10))) == c)

4

let me a tiny example out of my zoo and buses story: from docplex.mp.model import Model # original model mdl = Model(name='buses') nbbus40 = mdl.integer_var(name='nbBus40') nbbus30 = mdl.integer_var(name='nbBus30') ctKids=mdl.add_constraint(nbbus40*40 + nbbus30*30 >= 300, 'kids') mdl.minimize(nbbus40*500 + nbbus30*400) mdl.solve() for v in mdl....

4

After a while, I finally found a way to establish a precedence constraint using binary variables. It was hard to find examples of precedence constraints that do not use time as a parameter in both theoretical models and also code implementation tutorials. Anyway, I am sharing here the code I used in DOCPLEX to establish the precedence constraint with ...

4

I am answering my own question because it may help other people. I could not find a function in docplex able to get all feasible solutions for a ILP problem. For my best knowledge, docplex only has this kind of function for MIP problems. If you are dealing with MIP, you can check additional information here: https://www.ibm.com/support/knowledgecenter/...

4

One thing I would personally do is stick to dictionaries as accessing each key is easier and faster (Its complexity is $O(1)$). If you have three collections for your keys, namely your $H$, $C$, and $V$, then, as you probably know, you can use binary_var_cube where you can see, from the documentation linked: Creates a dictionary of binary decision ...

3

For your first question: DOCplex instead is an object-oriented modeling API. It builds either on the CPLEX Python API (for local solves) or on the DOcplexcloud service, for remote solves. It provides object-oriented modeling which is more convenient for some people. This library is composed of 2 modules: Mathematical Programming Modeling for Python using ...

3

The automatic search of CP Optimizer does not try to recognize a graph colouring problem. As you notice, fixing the colour of one variable to get rid of some symmetries in the model may help. Extending this idea and fixing the colours of one clique may further help. Such dominance rules are not automatically inferred in CP Optimizer but are let to the user ...

3

Based on a clarification in the comment, you have KeyError and more or less, this is what's happening: You're looking at an index or key (in your dictionary) that doesn't exist and those are keys related to indices j-1 and p-1. What you need to do is not to loop over all set_J and set_OP. So, for example, assuming set_J = {1,2,3}, you can't have an index of ...

3

CP Optimizer is doing a search for progressively better solutions. Each time it finds a feasible solution, it restricts the remainder of the search to solutions with better objective values than what it just found. So you should get a sequence of progressively better solutions. Given enough time and memory, it will exhaust the search space, and the last ...

3

The comment by @prubin is spot on. The V matrix is probably being numerically evaluated as not positive semidefinite by CPLEX. That can easily happen when one ore more eigenvalues are what you call null, i.e., theoretically equal to zero, i.e., zero in exact arithmetic. But CPLEX is using double precision floating point arithmetic, not exact arithmetic, so ...

2

Cplex can minimize convex quadratic objectives, or maximize concave ones. For example, minimizing $x^2+y^2$ is OK, but minimizing $x^2 -y^2$ is not. See this page for more details: As mentioned in the page, you can set the parameter optimalitytarget to 2 to proceed and accept the risk of finding a local optimum. If so, Cplex will not stop and look for an ...

2

even from docplex you can get access to the cplex python API. See example in SO for sensitivity analysis at https://stackoverflow.com/questions/62475139/sensitivity-analysis-in-docplex Plus before the solve see https://www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.cplex.help/CPLEX/Parameters/topics/DataCheck.html « When the value of this ...

2

According to you mentioned, it sounds like the Resource‐Constrained Project Scheduling Problem (RCPS). To execute such a problem with CPLEX, you have two different options. First, develop a mixed-integer programming model and solve it using CPLEX solver. Second, using constraint programming with CPLEX/CPO. For the first option, some examples could be ...

2

I believe there is a problem in the indices that you used in the construction of constraints. For example, you defined $T_w{_{w'}}_{,jj+1}$ which should have had 4 indices in your constraint while you put 5 of them. T_var[w, c, c1, j-1, j] I am not an expert in DOcplex but I am familiar with Pyomo in which you can first define a "ConstraintList()" and ...

2

within 4s with your data set CPLEX both MIP and Constraint Programming prove optimality In OPL int n1=164; int n2=2; range r1=1..n1; range r2=1..n2; int values[i in r1][j in r2]=0; execute { // Read in file the 2D array values with seperator sep and ranges range1 and range2 function read2D(file,range1,range2,values,sep) ...

2

I guess your model is not feasible. Let me use the tiny zoo example: from docplex.mp.model import Model mdl = Model(name='buses') nbbus40 = mdl.integer_var(name='nbBus40') nbbus30 = mdl.integer_var(name='nbBus30') mdl.add_constraint(nbbus40*40 + nbbus30*30 >= 300, 'kids') mdl.minimize(nbbus40*500 + nbbus30*400) mdl.solve(log_output=True,) print("...

2

Assuming you are fine with turning the warnings off, you can change the verbosity level of the data consistency checks that you get from docplex by changing the value of datacheck parameter. You can read more about it in the IBM doc on data consistency. from docplex.mp.model import Model mdl = Model(name='my_model') ... mdl.parameters.read.datacheck = 0 # ...

1

If you really want to ignore them then you can often set the warning output to null (or similar) https://www.ibm.com/docs/en/icos/20.1.0?topic=cm-warning-method-1 From where/how are you calling cplex?

1

Please read the relevant manuals. I am not aware of any such functionality and a search of named parameters in the documentation yields no results either. However this page goes into details how to get the information you want and also documents in an example how to stop it from this callback based on this information using the C Interface.

1

Let binary variable $Z_w$ indicate whether the first occurrence of machine $w$ is different than its initial configuration. Here's a derivation of linear constraints via conjunctive normal form, without introducing any additional variables:  \bigvee_{c \not= c_0} \bigvee_j \left(\bigvee_p X_{p,w,c,j} \land \bigwedge_{k<j} \bigwedge_q \bigwedge_d \lnot ...

1

For future reference, I solved this issue by using Pyomo modeling tool. In the end, I could solve the problem using Cplex, Gurobi, and ipopt by only stating the name of the solver.

Only top voted, non community-wiki answers of a minimum length are eligible