Skip to main content

Questions tagged [c++]

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

Filter by
Sorted by
Tagged with
0 votes
0 answers
78 views

How to correctly use legacy callbacks in CPLEX with C++ to generate Benders' cuts?

I've been working on implementing Branch-and-Benders Cut using CPLEX version 20.1 with the C++ API, but I'm encountering some difficulties. I've followed the example provided by CPLEX, specifically ...
2 votes
0 answers
120 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
73 views

How to deal with performance bottlenecks in Stochastic Vehicle Routing Problem with Benders' decomposition?

I've been working on solving a stochastic vehicle routing problem using Benders' decomposition with CPLEX in C++. Initially, my implementation struggled with larger instances, but I've made ...
1 vote
1 answer
134 views

How do I check convergence in stochastic Benders?

So in the deterministic version of Benders, the main process works like this: I initialize my x-vector (Integer variables from the master problem) and solve the dual subproblem (SP). I add an ...
1 vote
1 answer
66 views

custom branch and bound on cplex or GAMS

Does anyone have an idea how to create a custom B&B on CPLEX or GAMS? In my work, I need to add custom cuts on integer solutions in certain conditions by adding only one branch. Also, I need to ...
0 votes
1 answer
84 views

Using CPLEX in C++, how can I efficiently alter the objective function and then resolve the problem?

I want to solve an optimization problem using the CPLEX API in C++. After solving the model, I then want to resolve it using a different objective function. For that purpose, I learned the functions <...
11 votes
2 answers
2k 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 ...
6 votes
0 answers
167 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
211 views

ValidateModel or tools in c++ and proto problems

I'm trying to validate my model, this is the relevant part of my code: ...
4 votes
0 answers
109 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+...
0 votes
1 answer
123 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 ...
0 votes
1 answer
39 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:...
0 votes
2 answers
192 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 ...
2 votes
2 answers
148 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, ...
1 vote
1 answer
394 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
1 answer
143 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
1 answer
199 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 ...
7 votes
2 answers
607 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
1k 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 ...
10 votes
2 answers
1k 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 ...
7 votes
3 answers
2k 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 ...
-3 votes
1 answer
91 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
190 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
166 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
242 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
715 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
469 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
449 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
754 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
255 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
664 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 ...
4 votes
1 answer
2k views

How exactly does OptionalIntervalVar work in OR-Tools?

I created OptionalIntervals for a number of tasks: ...
6 votes
0 answers
234 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 ...
2 votes
1 answer
612 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 ...
14 votes
2 answers
612 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 ...
4 votes
1 answer
1k 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
196 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
225 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
160 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: ...
2 votes
0 answers
103 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
1k 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
1k 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
480 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
517 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: ...
6 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 ...
9 votes
1 answer
1k 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
1 answer
759 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 ...
8 votes
2 answers
607 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 ...