Skip to main content
9 votes

Constraint programming using solver: how to state the time limit of search?

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 ...
G_B's user avatar
  • 1,857
7 votes

Integrating genetic algorithm (or other heuristic methods) with CPLEX

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. ...
PSLP's user avatar
  • 2,401
7 votes

Python to Excel

A great option is to use the pandas library, and specifically pandas.DataFrame.to_excel is what you need. I suggest you use one column per variable index, and one line per non zero variable. Here is ...
Kuifje's user avatar
  • 13.5k
6 votes

Constraint programming using solver: how to state the time limit of search?

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 ...
Nikos Kazazakis's user avatar
6 votes

Docplex : model is infeasible

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. ...
prubin's user avatar
  • 39.5k
6 votes
Accepted

Reformulate CPLEX optimization model of Warehouse Product Allocation

This is an instance of the quadratic assignment problem, which is known to be difficult. You have binary variable $x_{ic}$ to indicate whether article $i$ is assigned to aisle $c$ and binary variable $...
RobPratt's user avatar
  • 32.7k
5 votes

When using docplex.cp is it possible to get all feasible solutions?

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 ...
campioni's user avatar
  • 1,133
5 votes

DOCPLEX: tips to manipulate data input (binary parameter)

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 $...
EhsanK's user avatar
  • 5,864
5 votes
Accepted

Binary/integer variables get real values in docplex

All solution values will be floating-point numbers - independent of the variable types. In an optimal or feasible solution, they will simply be close to an integer value, depending on the specified ...
mattmilten's user avatar
  • 1,653
5 votes
Accepted

What is the default weight allocation in solving multi-objective on CPLEX?

Weights are defined by you to tell CPLEX how objectives with the same priorities are blended together. If you don't define weights, by default they are all assumed to be equal to 1. Let's assume in ...
EhsanK's user avatar
  • 5,864
4 votes
Accepted

Precedence constraints using binary variables - DOCPLEX

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 ...
campioni's user avatar
  • 1,133
4 votes
Accepted

Logical operation on an array in DOCplex

The first argument in logical_and is *args but it's not unpacked in the subroutines inside of ...
EhsanK's user avatar
  • 5,864
4 votes

DOCplex adding columns

let me a tiny example out of my zoo and buses story: ...
Alex Fleischer's user avatar
4 votes
Accepted

CPLEX MILP Report all solutions found

In Making optimization simple (Python) I gave 2 options: progress listener / MIP info callback get solutions one by one The models: ...
Alex Fleischer's user avatar
4 votes
Accepted

Constraint to handle the machine-configuration's change between initial position and its first occurrence in the process

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 ...
SimonT's user avatar
  • 701
4 votes
Accepted

LP solver CPLEX is 'optimal with unscaled infeasabilities'?

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 ...
prubin's user avatar
  • 39.5k
4 votes
Accepted

How to retrieve the variable's value in DOCplex

The key is a tuple of strings and not a tuple of numbers. ...
Alex Fleischer's user avatar
4 votes

opposite of no_overlap constraint in docplex for CP

You can use overlap_length ...
Alex Fleischer's user avatar
4 votes

Python to Excel

I have used openpyxl several times to create or alter excel files. It is quite easy if one is familiar with Python. With this module you can iterate through your variables and write its value to a ...
gmn's user avatar
  • 676
4 votes
Accepted

Sensitivity analysis for specific sets of constraints on DoCplex

You can filter the results you get from sensitivity.rhs : See small example out of the zoo example again: ...
Alex Fleischer's user avatar
3 votes

How to check infeasibility with conflict refiner (docplex mixed integer programming )?

As the docplex documentation says: Given an infeasible model, the conflict refiner can identify conflicting constraints and bounds within it. So, consider you ...
EhsanK's user avatar
  • 5,864
3 votes
Accepted

Rotated Second-Order Cone Constraints in docplex

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 ...
Oguz Toragay's user avatar
  • 8,667
3 votes
Accepted

Docplex Error: Model has non-convex objective

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 ...
Mark L. Stone's user avatar
3 votes

Docplex Error: Model has non-convex objective

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 ...
Philippe Couronne's user avatar
3 votes

CPLEX MILP Report all solutions found

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 ...
Joris Kinable's user avatar
3 votes

Constraint programming using solver: how to state the time limit of search?

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 ...
prubin's user avatar
  • 39.5k
3 votes
Accepted

How to display the range of coefficients in docplex log?

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 ...
Alex Fleischer's user avatar
3 votes

Could DOcplex.CP recognize that it solves the graph coloring minimization problem?

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. ...
Olivier Lhomme's user avatar
3 votes
Accepted

How to establish constraint between variables with multiple indexes using CPLEX in Python

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 ...
EhsanK's user avatar
  • 5,864
3 votes
Accepted

How to check infeasibility with conflict refiner (docplex mixed integer programming )?

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 ...
Joris Kinable's user avatar

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