Questions tagged [c++]
For questions about solving Operations Research problems using the C++ programming language.
51
questions
0
votes
1
answer
71
views
Is an insanely high number of feasibility cuts normal while solving a VRP with Benders?
I am in the process of trying to solve a VRP with synchronization constraints with Benders Decomposition. I am programming in C++ and my approach seems to be really slow for the following reason:
My ...
1
vote
2
answers
72
views
Tips for implementing Benders Decomposition in C++?
currently I am working on implementing Benders Decomposition for a large-scale stochastic MIP in C++ using the CPLEX Solver. I've been spending the last couple of months learning the programming ...
0
votes
1
answer
32
views
Graphs arcs on AMPL C++ API
I am trying to model a routing instance in AMPL C++ API. The AMPL Book presents a strategy for modeling routing instances via AMPL (Figures 6-2a and 6-2b, Page 95, Chapter 6), as it is presented below:...
2
votes
2
answers
89
views
Which data type is best used when programming an optimization problem in C++?
Switching over from CPLEX Optimization Studio, now I want to solve problems in C++ using the CPLEX API.
Being used to the CPLEX data types, I was wondering how they best translate to C++.
For example, ...
0
votes
1
answer
74
views
Are there any hidden differences in OR-Tools' default parameters for a MIP model in Python vs C++?
or-tools-discuss cross post here.
As a disclaimer -- I am very aware that OR-Tools' Python code are just wrappers around their C++ source code. I'm just getting an odd discrepancy between a model ...
2
votes
0
answers
57
views
Automated Benders Using Annotations
I'm trying to solve an optimization model using Automated Benders with annotations using CPLEX library in C++. I've defined a master problem and N (number of supply nodes in my model's network) ...
2
votes
1
answer
100
views
How should I implement Benders Decomposition with annotations in C++ using CPLEX library
I'm a beginner in C++ and want to implement Benders decomposition in C++ using CPLEX. I'm gonna use it for a special case study, so I need to customize the cuts to minimize the optimality gap. However,...
7
votes
2
answers
464
views
Implementing Heuristic Callback in CPLEX C++ API for MILP
I am trying to implement a heuristic callback to a MILP with BOTH integer variables and continuous variables. After finding a feasible solution, I tried to use setSolution() to send the solution to ...
3
votes
2
answers
907
views
Is solving a quadratic programming optimization problem using python slower than C++?
I am using the cvxpy library in python to solve a quadratic programming problem and the solver used is scip. I found that when the amount of data becomes large, the solution process will be ...
7
votes
1
answer
164
views
Name of graph algorithm arising while using the Ryan Foster Branching
I'm using the Ryan-Foster branching in my Branch and Price algorithm for a pickup and delivery problem, but I'm having trouble keeping track of all the pairs as I go down the search tree.
Let's say ...
-3
votes
1
answer
87
views
Testing Varying Parameters With the Same Script [closed]
As the title suggests, I would like to test different values of parameters with the same code in C++.
For example, one of the parameters is: #define α 0.5. I would ...
7
votes
4
answers
3k
views
Python vs. compiled languages in OR research using metaheuristics
In many articles that use metaheuristics to solve optimization problems, the programming language of choice is C++. For example, the following two articles present state-of-the-art metaheuristics to ...
2
votes
1
answer
158
views
Gurobi C++-how to set the NonConvex parameter to 2
When I solve the model, it happen "Error 10020: Objective Q not PSD" in the end.
The gurobi website said, to resolve this issue, set the NonConvex parameter to 2.
I type "model.set(...
0
votes
1
answer
117
views
Gurobi C++ - how to divide variables
How do I divide a variable by another variable?
For example, if I have a variable max, and a variable $\sum\sum X_{ij}$, what I want to do is max divided by $\sum\sum X_{ij}$.
But the question is that ...
2
votes
0
answers
180
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.
...
3
votes
0
answers
450
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 ...
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?
1
vote
1
answer
382
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 ...
1
vote
2
answers
392
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 ...
1
vote
2
answers
480
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?
0
votes
1
answer
233
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 ...
6
votes
2
answers
457
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 ...
2
votes
1
answer
426
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 ...
10
votes
1
answer
1k
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 ...
2
votes
0
answers
164
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, ...
0
votes
1
answer
193
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$ ...
4
votes
1
answer
147
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:
...
3
votes
1
answer
782
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 ...
2
votes
0
answers
86
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:
...
3
votes
2
answers
797
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=...
3
votes
2
answers
878
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\...
2
votes
1
answer
386
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 ...
3
votes
1
answer
440
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:
...
7
votes
3
answers
1k
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 ...
4
votes
1
answer
1k
views
How exactly does OptionalIntervalVar work in OR-Tools?
I created OptionalIntervals for a number of tasks:
...
5
votes
1
answer
2k
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 ...
6
votes
0
answers
203
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 ...
9
votes
1
answer
882
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 ...
6
votes
0
answers
156
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 ...
3
votes
1
answer
186
views
ValidateModel or tools in c++ and proto problems
I'm trying to validate my model, this is the relevant part of my code:
...
8
votes
2
answers
549
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 ...
4
votes
0
answers
101
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+...
5
votes
1
answer
2k
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 ...
8
votes
1
answer
445
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 ...
6
votes
1
answer
568
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 ...
10
votes
2
answers
923
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 ...
10
votes
1
answer
314
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 ...
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, ...
10
votes
2
answers
256
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 ...
13
votes
2
answers
2k
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 ...