Hot answers tagged

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 ...
user avatar
  • 28.8k
18 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 (...
user avatar
  • 3,253
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): ...
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://...
user avatar
10 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: ...
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 ...
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 ...
user avatar
  • 1,384
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. ...
user avatar
  • 2,034
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 ...
user avatar
  • 28.8k
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 ...
user avatar
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 ...
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 ...
user avatar
  • 28.8k
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 ...
user avatar
  • 1,384
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.
user avatar
  • 1,493
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 ...
user avatar
  • 1,493
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: ...
user avatar
  • 1,384
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 ...
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: <...
user avatar
  • 1,129
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 <...
user avatar
  • 28.8k
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 ...
user avatar
  • 1,384
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].
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 ...
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....
user avatar
  • 2,609
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 ...
user avatar
3 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 ...
user avatar
3 votes
Accepted

How to get an extreme ray of an LP from Gurobi

In order to query the GRB_DoubleAttr_UnbdRay attribute, you need to optimize the problem with the InfUnbdInfo parameter set to 1.
user avatar
  • 3,034
3 votes

Solving multiple easy ILP instances

If I recall correctly, adding a constraint on the primal objective function causes degeneracy in the dual LPs, which could account for at least part of the speed decrease you noted. In addition to ...
user avatar
  • 28.8k
3 votes

GUROBI Re-optimize a model

The link that @EhsanK posted already covers the question pretty well. In such a case, Gurobi should choose the best suited algorithm on its own. Check out this little example, where I read and ...
user avatar
  • 1,493
3 votes

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

Have not used CPLEX, but I've done that in Gurobi. In the latter, you just retrieve the equivalent of dualFarkas() when the primal version of the Benders subproblem you are solving is infeasible.
user avatar
  • 31
3 votes
Accepted

Invalid solutions to Piecewise Mccormick Envelope Implementation

I agree that the e_z == 1 constraint belongs in the model. Your constraints ...
user avatar
  • 28.8k

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