Questions tagged [c++]

For questions about solving Operations Research problems using the C++ programming language.

Filter by
Sorted by
Tagged with
1 vote
0 answers
83 views

Trying to add lazy constraints to traveling salesman problem

For a simple traveling salesman problem, I am trying to add the "miller-tucker-zemlin subtour elimination constraints" by using ILOLAZYCONSTRAINTCALLBACK. ...
user avatar
3 votes
0 answers
82 views

Incorporating OR-Tools in a CMake Project

I'm trying to incorporate or-tools into my cmake project. I've tried some of the suggestions given by the project maintainers, who give a few different ways to integrate or-tools in the readme and in ...
user avatar
  • 431
6 votes
2 answers
2k views

Python vs C++ performance on Discrete Optimization

Are there any useful resources to compare the performance of python and c++ languages in algorithms dedicated to solving discrete optimization problems?
user avatar
  • 347
1 vote
1 answer
174 views

How to create Gurobi model using a matrix? (C++ API)

I have been working on the Gurobi (C++ API) using its reference manual for some time. I did not see any description in the manual regarding how to create the Gurobi model using a matrix and iterate ...
user avatar
  • 105
1 vote
2 answers
273 views

How to create A, b and c matrices from very large .lp file?

I am working on Scaling MIP. I use Gurobi within Clion. I need to extract the coefficient of Xs (A matrix), right-hand side (B matrix), and an objective function(c matrix) from the .lp file and ...
user avatar
  • 105
1 vote
2 answers
180 views

Gurobi with C++

This is not the right question to be posting here, but is anywhere a video tutorial/ written on how to link C++ header files with Gurobi?
user avatar
  • 101
0 votes
1 answer
169 views

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

I am working on the scaling of a MIP using C++. I use Gurobi within CLion. The Gurobi model I use now in Clion require me to enter everything manually (model.addVar, model.addConstr...). However, in a ...
user avatar
  • 105
6 votes
2 answers
188 views

What kind of data structure should be used to store labels when implementing a labeling algorithm?

The shortest path problem with resource constraints is a common subproblem when doing column generation. It is often solved with a labeling algorithm. The procedure is very well explained here and ...
user avatar
  • 389
2 votes
1 answer
184 views

The precision of the decimal number of the Cplex

I have faced a little weird problem when I use Cplex to solve my test problem. Basically, some of my data are float numbers up to three decimal numbers (For instance, 0.627). But, when I print out the ...
user avatar
  • 59
10 votes
1 answer
792 views

Linear Optimization Library for C++ with GPU Support

Does anyone know any linear optimization libraries for C++ supporting GPUs for parallelization? If multiple, which do you recommend? The GPU support is important to me since I am dealing with large ...
user avatar
2 votes
0 answers
103 views

Gurobi c++: Getting constraint matrix

I'm trying to get the constraint matrix from a Gurobi model in C++. In Python, one can get this by simply calling a method that will populate a scipy object (see this post). However, in a C++ fashion, ...
user avatar
0 votes
1 answer
146 views

Invalid solutions to Piecewise Mccormick Envelope Implementation

I am currently trying to implement a piecewise McCormick envelope in Drake (c++). The current issue I am having is that the solution produced by the optimization does not produce a valid $x$ and $y$ ...
user avatar
  • 11
4 votes
1 answer
115 views

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

I want to implement a (simple) branching heuristic through a CPLEX generic callback. There are multiple overloads of the makeBranch method in CPLEX's C++ API, see here: ...
user avatar
  • 1,129
3 votes
1 answer
443 views

Implementing benders decomposition using Lazy and User cuts callback of Cplex

I am trying to implement benders decomposition for a simple fixed charge transportation problem for the purpose of learning. I implemented the classic Benders decomposition successfully by adding ...
user avatar
  • 59
2 votes
0 answers
72 views

CPU time on Linux with Gurobi

I am solving a MILP model in C++ using Gurobi 10.1. I retrieve the CPU time of my C++ program under Linux via the following commands: ...
user avatar
  • 29
3 votes
2 answers
352 views

Calculated CPU time of C++ is different from actual time to solve MILP model via Gurobi

I am solving a MILP model in C++ using Gurobi 7.5.2. More specifically, I am determining the CPU time of my C++ program via the following commands: clock_t start_time; double elapsed_time; start_time=...
user avatar
3 votes
2 answers
419 views

How to get an extreme ray of an LP from Gurobi

I am working on a problem of form \begin{equation} \begin{array}{l @{\quad} l} \mathrm{max}_{x, u} & p^{\top} u \\ \text{st.} & A u + a x \leq 0 \\ & x \in \{0, 1\...
user avatar
2 votes
1 answer
238 views

C++ code for branch and price

I looking to learn to use bpcolumn generation techniques in c++. Does any body know of GitHub repository or any other site where I can find some code And learn about it... The application can be ...
user avatar
3 votes
1 answer
297 views

Gurobi C++: adding variables with vector

I am solving an LP by using GUROBI - C++ combo. Assume I have a variable $p \in \mathbb{R}^n$. I am adding this as a vector: ...
user avatar
6 votes
3 answers
896 views

No solution found from n MIP starts

Currently, I am working on the implementation of a MILP formulation with lazy constraints for an optimization problem, and I am using the MIP Start strategy. I am generating the integer feasible ...
user avatar
4 votes
1 answer
484 views

How exactly does OptionalIntervalVar work in OR-Tools?

I created OptionalIntervals for a number of tasks: ...
user avatar
5 votes
1 answer
990 views

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

If I have an IntVar s[j] stored in a vector s, is it possible to iterate for (a period of ...
user avatar
6 votes
0 answers
162 views

OptionalIntervalVar enforced but not working OR-TOOLS

I'm using OptionalIntervalVar and then maximizing the starts. The optimal solution is not affecting the other variables that creates the ...
user avatar
9 votes
1 answer
650 views

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

Currently, I am working on the implementation of a formulation for an optimization problem, at the moment I already have the MIP formulation implemented in C++ using Cplex studio 12.10 with the ...
user avatar
6 votes
0 answers
133 views

Modelling issue with precedence constraint in OR-Tools

I'm trying to solve an RCPSPDc model It is infeasible, although Ilog Cplex solves it, so I think I have a modelling issue. I have more constraints but the precedence is the one that makes it ...
user avatar
3 votes
1 answer
173 views

ValidateModel or tools in c++ and proto problems

I'm trying to validate my model, this is the relevant part of my code: ...
user avatar
8 votes
2 answers
476 views

Solving multiple easy ILP instances

I have an application where I am solving millions of ILP instances that differ from each other only on one constraint. The instances, of course, are relatively easy to solve or otherwise this would be ...
user avatar
  • 189
4 votes
0 answers
97 views

Modelling issue with rcpsp and boolean expressions

I'm trying to solve an RCPSPDc problem in OR-Tools with CP-SAT solver. In my RCPSPDc model (with discount rate) i want to set this objective: $$\max_{s}\sum_{j\in J}\text{profit}_{j}\cdot \frac{1}{(1+...
user avatar
5 votes
1 answer
1k views

Cumulative Constraint OR-Tools

I'm trying to solve an rcpsp model. I can't find documentation for the AddCumulative function of OR-Tools. How should this function be used? I want to write this ...
user avatar
8 votes
1 answer
313 views

Precedence Constraint in OR-Tools

I'm trying to write this constraint in C++ and add it to my model (addLessOrEqual): $$\text{start}_{i}+\text{duration}_{i}\le\text{start}_{j}$$ for an $(i,j)$ arc ...
user avatar
6 votes
1 answer
312 views

GUROBI Re-optimize a model

(For Linear Programming) I am aware of CPLEX's reoptimize methods. If I am not wrong, if you solve a problem and after that you add a new constraint, then you can call the reoptimize method for not to ...
user avatar
7 votes
2 answers
683 views

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

I am trying to implement a user-written lazy constraint callback in concert CPLEX with C++. Although I know there exists a way to implement callbacks in concert CPLEX with C++ via macros, I am looking ...
user avatar
10 votes
1 answer
226 views

Specify the sense of a constraint in CPLEX

I am writing a small wrapper around Gurobi and Cplex so that the models I write are solver independent. I'm very familiar with Gurobi but I'm very new to Cplex and I'm having trouble replicating ...
user avatar
  • 431
8 votes
2 answers
1k views

CPLEX exceeds time limit issue

I am solving a MILP model using CPLEX 12.8.0, but CPLEX exceeds the time limit on some test instances. More specifically, I set the time limit for 30 minutes using the cplex.setParam(IloCplex::TiLim, ...
user avatar
  • 89
10 votes
2 answers
231 views

Parallelization of an existing Adaptive Large Neighbourhood Search Heuristic

I am solving (or say, trying to find good solutions for) an arbitrary combinatorial optimization problem, think of it as a Vehicle Routing Problem with a bunch of side constraints that are not ...
user avatar
13 votes
2 answers
1k views

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

We are coding a Benders decomposition using CPLEX/Concert (C++) and we are having some troubles to generate a feasibility cut because we are not sure how to get an extreme ray of the dual for a primal ...
user avatar
  • 801
14 votes
2 answers
374 views

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

How do you implement a custom, global constraint in CP Optimizer? This is not a trivial thing to do, as CP Optimizer does not ship any examples of a custom constraint, and the documentation is very ...
user avatar