Tag Info

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 ...

6

Short answer: The model is wrong. :-) Longer answer: After attempting to solve the model and being told it is infeasible, run the conflict refiner to get an set of mutually inconsistent constraints. Plug your heuristic solution into each of those constraints, and see which are violated. Assuming your heuristic solution really is feasible, those constraints ...

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 ...

4

When you turn CPLEX loose on a model, it runs a presolver that does assorted magic tricks that end up with a modified model. It then solves the modified model and, assuming it finds a solution to the modified model, transforms that solution back to the original model. I believe that the "unscaled infeasibilities" message means that CPLEX found what ...

4

In Making optimization simple (Python) I gave 2 options: progress listener / MIP info callback get solutions one by one The models: from docplex.mp.model import Model from docplex.mp.progress import * mdl = Model(name='buses') nbbus40 = mdl.integer_var(name='nbBus40') nbbus30 = mdl.integer_var(name='nbBus30') mdl.add_constraint(nbbus40*40 + nbbus30*30 >...

3

One solution is to add an Incumbent callback (not sure whether DOCPLEX support this yet, but certainly Java/C++), and log the solution + time stamp within the the callback. Another solution which, if my memory service me well, is the following: Set the MIP integer solution limit to 1 (IntSolLim parameter in Cplex <=12.6). Invoke solve(). Cplex will ...

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

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

ILOG Cplex 20.1 installation comes with a directory with examples. To use the conflict refiner, you want to consult the manual which includes a list of files that contain examples on how to use the conflict refiner. Of particular interest are the following files: ./examples/src/java/ConflictEx1.java ./examples/src/cpp/iloconflictex1.cpp ./examples/src/python/...

3

As the docplex documentation says: Given an infeasible model, the conflict refiner can identify conflicting constraints and bounds within it. So, consider you have an infeasible model (I'll call my instance model). This is one way to use the conflict refiner. import docplex.mp.conflict_refiner as cr import docplex.mp.model as cpx model = cpx.Model(name='...

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 ...

3

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 ...

3

Once you solve a docplex model, it creates an internal SolveDetails object that contains the best bound you're looking for. You can access it in two ways: Assuming you've defined your docplex model as model (an instance of the class docplex.mp.model.Model) print(model.get_solve_details().best_bound) Assuming you've stored your model's solution in sol (an ...

3

kpi syntax example in docplex from docplex.mp.model import Model mdl = Model(name='buses') nbbus40 = mdl.integer_var(name='nbBus40') nbbus30 = mdl.integer_var(name='nbBus30') nbbus=nbbus30+nbbus40 mdl.add_kpi(nbbus,"nbbus") mdl.add_constraint(nbbus40*40 + nbbus30*30 >= 300, 'kids') mdl.minimize(nbbus40*500 + nbbus30*400) mdl.solve(log_output=...

3

The key is a tuple of strings and not a tuple of numbers. from docplex.mp.model import Model # Set and parameters I = ["i1"]; J = ["j1"]; #Parameters form = {("i1", "j1"): number} # model mdl = Model(name='name') # Declare variables idx_x = [(i,j) for i in I for j in J] x = mdl.binary_var_dict(idx_x, name="x&...

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

I am fairly certain that you cannot resume solution from the previous final state after altering the model. This is a known fact with CPLEX, presumably the same with CPOptimizer for essentially the same reason: the final state of the previous solve may not be valid for the modified problem. For instance, if you were to drop constraints and resume, the true ...

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("...

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