Skip to main content
20 votes
Accepted

Linear Optimization Library for C++ with GPU Support

For context: most (if not all) major LP solvers are built on 2 algorithms: the simplex method, and the interior-point method. The simplex method is intrinsically sequential: you're doing a lot of (...
mtanneau's user avatar
  • 4,173
19 votes

Python vs C++ performance on Discrete Optimization

If you are using a solver (open-source or commercial) to solve a discrete optimization problem, and if the problem is not trivial or extremely easy, chances are very high that the bulk of the ...
prubin's user avatar
  • 39.3k
16 votes
Accepted

Python vs. compiled languages in OR research using metaheuristics

Speaking as an occasional reviewer for journals, when I read a paper proposing a new heuristic or metaheuristic my first question is "does it work?", which is independent of the programming ...
prubin's user avatar
  • 39.3k
13 votes
Accepted

How to implement a custom global constraint in IBM's ILOG CP optimizer

The Graph Coloring example shipped with CP optimizer (file: color.cpp in the examples directory): ...
Joris Kinable's user avatar
12 votes

CPLEX exceeds time limit issue

It could be that you faced the issue described in this bug report. RS03137: CPLEX MAY IGNORE TIME LIMITS ON HIGHLY SYMMETRIC MODELS ON WHICH A NEW INCUMBENT IS FOUND CLOSE TO THE TIME LIMIT. http://...
Xavier Nodet's user avatar
12 votes
Accepted

How can I implement a user-written lazy constraint callback in concert CPLEX with C++?

You have it almost all right, with a few caveats. Let's say I want to implement a Foo Lazy Constraint: ...
Alberto Santini's user avatar
9 votes

Solving multiple easy ILP instances

in order to increase the throughput you could Not only rely on add and remove in "modifying problems" options but on smaller changes. Try to run the instances in parallel Instead of adding a ...
Alex Fleischer's user avatar
8 votes
Accepted

Precedence Constraint in OR-Tools

What you want is: AddLessOrEqual(LinearExpr(starts[j]).AddConstant(durations[j]), starts[succ[j][s]]) You might also want to take a look at the examples (ending ...
Stradivari's user avatar
  • 1,414
8 votes

CPLEX exceeds time limit issue

That may be related to the "presolve" phase of the optimization procedure. In large instances, the time for "presolve" may be too large, that makes the total time larger than the specified time-limit. ...
Mostafa's user avatar
  • 2,104
7 votes
Accepted

Specify the sense of a constraint in CPLEX

For specifying constraint direction, look to the various IloRange constructors. You can specify both a lower and upper bound (for constraints of the form $b_0 \le a'x \le b_1$, or use a constructor ...
prubin's user avatar
  • 39.3k
7 votes
Accepted

Correct way to get a dual extreme ray for an infeasible LP in CPLEX / C++

Can you elaborate a bit on what you mean when you say you are getting "Strange values"? One possible explanation is that if you call getDuals() on a model that ...
Ed Klotz's user avatar
  • 161
7 votes
Accepted

Cumulative Constraint OR-Tools

If you look at OR-Tools: CumulativeConstraint, AddCumulative takes a variable as argument, so if it is constant, create a variable with a fixed domain. It returns ...
Laurent Perron's user avatar
7 votes

Python vs. compiled languages in OR research using metaheuristics

I think this is a false dichotomy. Surely, C++ is the classical language for fast programs (besides FORTRAN, maybe). But nowadays, Java is very fast as well. Julia is also an option, fast and aimed ...
J Fabian Meier's user avatar
6 votes
Accepted

Check which constraints are violated (Concert - Cplex Studio 12.10 - C++)

You don't actually need to use the MIP start approach. Fix the upper and lower bounds for all your discrete variables to their values in the heuristic solution, then try to solve the model. Assuming ...
prubin's user avatar
  • 39.3k
6 votes

How exactly does OptionalIntervalVar work in OR-Tools?

In the Python API there is a pretty good docstring of what an OptionalIntervalVar is: An optional interval variable is a constraint, that is itself used in other constraints like NoOverlap. This ...
Stradivari's user avatar
  • 1,414
6 votes

Gurobi with C++

There is a dedicated section about C++ programming with Gurobi in the official documentation. There is also a CMake example in the Gurobi Knowledge Base.
mattmilten's user avatar
  • 1,653
6 votes

Implementing Heuristic Callback in CPLEX C++ API for MILP

Disclaimer: It's been a while since I used Cplex' C++ API. According to your question, you probably rather want to use a generic callback and inject a feasible (heuristic) solution through ...
joni's user avatar
  • 1,572
5 votes
Accepted

Gurobi C++: adding variables with vector

You can use addTerms() to construct a linear expression in one call. According to the documentation this is the most efficient way: You should avoid using expr = expr + x in a loop. It will lead ...
mattmilten's user avatar
  • 1,653
5 votes
Accepted

assigning values to IntVar if and only if BoolVar, else zero [or-tools]

To create an intermediate boolean that is true iff s[j] == t you just have to create 2 constraints: ...
Stradivari's user avatar
  • 1,414
5 votes

Parallelization of an existing Adaptive Large Neighbourhood Search Heuristic

Another paradigm to parallelize search heuristics is the Backbone strategy. See for example this paper. The main idea is to run multiple instances of an arbitrary heuristic in parallel, and then ...
Michael Feldmeier's user avatar
5 votes
Accepted

Gurobi with C++

On macOS, you can find a Makefile inside /Library/gurobi950/macos_universal2/examples/build to compile all examples. Open the Terminal.app and enter the following: <...
joni's user avatar
  • 1,572
5 votes
Accepted

Implementing Heuristic Callback in CPLEX C++ API for MILP

As @Joni notes, there is a parameter that controls how much (if any) effort CPLEX spends checking solutions you supply. You can freely mix integer and continuous variables in the call to setSolution, ...
prubin's user avatar
  • 39.3k
4 votes

How can I implement a user-written lazy constraint callback in concert CPLEX with C++?

I don't have any C++ code using a lazy constraint callback, although I could show you a Java example if you can't find anything better. The basic approach, IIRC, is to create an instance of class <...
prubin's user avatar
  • 39.3k
4 votes

ValidateModel or tools in c++ and proto problems

CpModelProto is a protobuf representation of your model in ortools. You create it by using the CpModelBuilder class (your ...
Stradivari's user avatar
  • 1,414
4 votes

C++ code for branch and price

Out of the multiple options, the open-source option is Coin-OR's BCP (Branch-Cut-Price) [github]. SCIP also offers branch-and-price via its GCG (generic branch-cut-and-price) solver [link].
Divyam Aggarwal's user avatar
4 votes
Accepted

No solution found from n MIP starts

After hours of internet research and coding debugging, I could finally solve the problem. The problem was on the way that I passed the solution to the Cplex MIP Start. Below follows an example of how ...
Matheus Diógenes Andrade's user avatar
4 votes
Accepted

How to make CLion read .lp file and make Gurobi solve that file within CLion?

I'm assuming you have the .lp file. Check the example in the Gurobi webpage lp_c++.cpp, where they show how to create a model based on a .lp file, and optimize it (respectively, lines 23 and 25 in the ...
Nara Begnini's user avatar
3 votes
Accepted

How does CPLEX handle objective estimates passed to the makeBranch method?

The answer is basically no. You will find interesting information here related to node evaluation and here related to node selection in the CPLEX B&B. In particular, by setting the parameter Cplex....
Hexaly's user avatar
  • 2,976
3 votes

Implementing benders decomposition using Lazy and User cuts callback of Cplex

First, I don't understand why you extract the master model, set parameters and add the callback repeatedly inside a loop. When using a callback, the plan is to solve the master problem once, adding ...
prubin's user avatar
  • 39.3k
3 votes

No solution found from n MIP starts

Assuming that your solution is indeed feasible and that your lazy constraints are correctly coded, the most likely explanation is that the order of your variables is inconsistent between your ...
Nikos Kazazakis's user avatar

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