Questions tagged [gurobi]

Questions related to the commercial solver Gurobi Optimizer.

Filter by
Sorted by
Tagged with
1 vote
1 answer
95 views

Conditional Statements in an LP model

I am currently working on a large workforce/manpower planning model for an aviation company. This model should decide whether to hire a new pilot or to let pilots fly overtime. It has two skillsets. ...
Adri's user avatar
  • 11
4 votes
1 answer
200 views

MIP Model with relaxed integer constraints takes longer to solve than normal model, why?

I am currently working on my undergrad thesis which is a mathematical optimization problem of the territory design family of problems. I am using the mathematical formulation of the problem to solve ...
EduardoSalazarT's user avatar
1 vote
2 answers
113 views

Is there a way to obtain coefficient matrix A and RHS b of constraints equation from cplex or guribi in python?

I have a non-linear program, minimizing sum of concave functions subject to linear constraints. Hence I'm using a different solver(in Julia). However, that solver assumes we have constraints in $Ax \...
Meet Saiya's user avatar
2 votes
2 answers
78 views

Small negative decision variable returned in Gurobipy model

I have a multi-period model in gurobipy with 7 types continuous decision variables and 1 type of binary (Thousands indexed total). The model solves properly and the solution has passed many validation ...
TroyE219's user avatar
  • 105
1 vote
1 answer
70 views

Smallest graph coloring in Gurobi

I am trying to design an algorithm to label a graph’s nodes with as few colors as possible such that all pairs of nodes joined by an edge do not have the same color. This is the code I have written so ...
Andrew's user avatar
  • 133
1 vote
4 answers
155 views

Multi-period Inventory Balance in Gurobipy

I would like to get the inventory balance in the oponed facility $\text{C}$ such that, the Inventory at time $t$ is equal to the previous one, plus the inflow minus the outflow. I have tried to create ...
Abde's user avatar
  • 81
-1 votes
2 answers
56 views

How to implement tiered pricing based on weight or cube volume or order amount total into objective function with Guro i py

I am working on an optimization project here and my objective is to come out with the optimal amount of each item to buy at certain vendors that can minimize the cost while meeting the demand(already ...
DJ-coding's user avatar
3 votes
2 answers
179 views

Reformulate bilinear binary constraint

I'm a solving a model that has the following constraint: $$ c_{p,n} = \sum_{s\in S}\sum_{i \in \{1,2,3\} } x_{p,s,i-1} x_{n,s,i}, \forall (p,n) \in C $$ where both the $c$ and $x$ variables are binary,...
cholo14's user avatar
  • 183
0 votes
1 answer
67 views

How to add conditions in objective functions?

I want to implement some conditions in my objective function. I know adding conditions to constraints is possible through addGenConstrIndicator() but I don't know how I can add conditions in the ...
Saeid Ghafouri's user avatar
0 votes
0 answers
55 views

Gurobi-Python, unmet demand of customers

I would like to capture the unmet demand by modeling the following constraint with two decision variables. where $QU_{wc}$ is the unmet demand and $QW_{wc}$ the shipped amount of products. I model the ...
Abde's user avatar
  • 81
0 votes
1 answer
38 views

How to check conditional constraints added to the model?

I want to know how I can check constraints like https://www.gurobi.com/documentation/current/refman/py_model_agc_indicator.html in my model using something like ...
Saeid Ghafouri's user avatar
0 votes
2 answers
105 views

Modelling with Gurobi-Python a Supply Chain Problem

I would like to write the following simple model in GurobiPy, which is part of many terms that's belongs to the objective function, I assumed that I have three suppliers are selected and three ...
Abde's user avatar
  • 81
2 votes
2 answers
234 views

Using indicator constraint with two variables

I want to use the sum of two binary decision variables (when their sum equals to one) as the condition of Model.AddGenConstrIndicator https://www.gurobi.com/documentation/current/refman/...
Saeid Ghafouri's user avatar
0 votes
1 answer
111 views

How to use Gurobi variables as a dictionary index in Gurobipy

I want to model a problem that one of my variables needs to be used as an index of a dictionary in my constraints. Here is a minimal code that shows an example situation: ...
Saeid Ghafouri's user avatar
0 votes
0 answers
52 views

Multi-Scenario Gurobi Python Output

I have an lp and am trying to solve multiple scenarios at once. One of my scenarios is infeasible though this is not the issue. For some reason, when I print m.status, both solutions have a status of ...
TroyE219's user avatar
  • 105
2 votes
3 answers
328 views

"Re-optimize" feature in Commercial Optimization

How does the "re-optimize" feature work in commercial optimization solvers such as IBM CPLEX and Gurobi? I recently experienced a considerable performance boost by re-solving a model with ...
Pia MiA's user avatar
  • 392
-1 votes
1 answer
92 views

GurobiPy Tutorials and hands on from beginner to advanced

What is the best way to start modelling with GurobiPy, in order to utilize it, for research purpose (i.e. more complicated problems)?
Abde's user avatar
  • 81
2 votes
0 answers
54 views

Branching the product of binary and continuous variable in Gurobi

I have a binary variable (X) multiplying a continuous variable (Y). I know I can linearize by adding an auxiliary variable (I have that model working), but I now want to do my own branching in the ...
orpanter's user avatar
  • 423
2 votes
3 answers
274 views

Robust Optimization in Gurobi

I have a research problem where my Mixed Integer Linear Program has data that follow probability distributions. I am approaching this by creating some m instances through realizations of these random ...
arvind rathore's user avatar
3 votes
2 answers
299 views

Does solver take advantage of the problem structure?

Does Guroib take advantage of the problem structure? I am working on a large optimization problem with more than 40,000 binary variables and huge number of constraints. below is only one of the ...
Hussein Sharadga's user avatar
1 vote
2 answers
188 views

Capacitated Maximum Coverage Location Problem, Python and Gurobi

I am trying to solve a capacitated MCLP problem with two additional constraints. Non-overlapping circles Minimum and Maximum value for the capacity for a circle. for 2nd constraint, I am able to add ...
Nandy's user avatar
  • 13
1 vote
1 answer
162 views

How to write this logical expression with Gurobi + Java, or express it as a big-m formulation

I am trying to write the following expression in Gurobi+Java or Gurobi+python, if it is more practical It could be expressed as a big-M formulation. \begin{equation} \label{const4} \text{D}_{uv} = ...
Hernan19's user avatar
1 vote
0 answers
57 views

min matrix norm with gurobi v10+

I was trying to use Gurobi for a minimization problem like so: $$ \min\|M-TX\|_1 $$ where all three terms are matrices. $X$ is the nonnegative decision variable(s) of compatible size. $M$ and $T$ are ...
Brannon's user avatar
  • 762
3 votes
1 answer
129 views

How do I pass an objective bound to Gurobi?

I have a non-convex Quadratic Programming over unite simplex set. I have a valid lower bound on the objective function (goal is minimization problem). If I add a constraint like $$f(x)\geq lower~bound,...
Abbas Khademi's user avatar
2 votes
1 answer
136 views

Should I replace sin(theta) by piecewise linear and solve the linear problem using gurobipy or use ipopt to solve the nonlinear probelm?

I have a large nonlinear and nonconvex problem. It also has sin (theta) and cos(theta). While gurobipy accepts sin or cos using the general constraint. gurobipy uses piecewise linear approximation, ...
Hussein Sharadga's user avatar
1 vote
2 answers
128 views

How do I convert existing MILP problem into heuristics? or Shall I add heuristics to my existing MILP problem?

I have formulated a MILP problem & solved it using Gurobi. Below is the link to the description of MILP problem (a brief document) clearly stating its variables, constraints, and objective ...
Margi Shah's user avatar
1 vote
2 answers
121 views

Does the cvxpy replace the max function by MIP formulation under the hood?

Does the cvxpy replace the max function, which is convex, by MIP formulation under the hood when shows up in the constraints (for example, $\max(x,y)\le z$) or in the objective function? In gurobipy, ...
Hussein Sharadga's user avatar
1 vote
0 answers
65 views

How to get seed from grbtune and set it in Gurobi?

I have tuned my model with grbtune and depending on the seed used, the runtime changes a lot: For example: ...
armset's user avatar
  • 73
3 votes
1 answer
62 views

Is not the substitution method supposed to reduce the computation cost?

Is the substitution method expected to reduce the computation cost? We know it will reduce the number of variables and constraints. I mean by substitution method is to eliminate the equality ...
Hussein Sharadga's user avatar
5 votes
1 answer
322 views

How to formulate the inequality constraint $\sqrt{x^2+y^2} \leq z$ using gurobipy?

How to formulate the following constraint using gurobipy $$ \sqrt{x^2 + y^2} \le z$$ where $x, y, z$ are continuous optimization variables? I saw how to formulate it using CVXPY: ...
Hussein Sharadga's user avatar
7 votes
3 answers
474 views

Profit Maximization LP and Incentives Scenarios

I wrote a profit maximization LP with inventory, component usage, production, and machine hours constraints. When I optimize the model, it solves as expected. When applied towards a business case, ...
TroyE219's user avatar
  • 105
2 votes
1 answer
164 views

Implementing subtour constraints to a VRP in python

Hi I have a problem related to the vehicle routing problem, where I want to implement the subtour constraints $\sum_{(i,j)\in S} x_{ij} \leq \lvert S \rvert - r(S), \: \forall S \subseteq N, S > 2$ ...
Magnus M's user avatar
2 votes
1 answer
202 views

Pyomo supported solvers on NEOS

Pyomo has two solver managers to execute external solvers: neos (remote execution) serial (local execution). ...
Lars Hadidi's user avatar
3 votes
3 answers
541 views

Gurobi - Python: is there a way to express "OR" in a constraint?

I'm new to Gurobi in Python and I am wondering if there is way to express/code "or" in the following constraint, where $x_i$ are binary variables: $x_i-x_i*x_{i-1} =0$ OR $x_i*x_{i+1} =1.$ ...
M.Badaoui's user avatar
  • 185
2 votes
1 answer
169 views

Re-optimizing pyomo model based on previous computation

I am currently new to pyomo and modelling techniques but I came across information mentioning that the CPLEX and Gurobi APIs offer a functionality where you can re-use already computed values and feed ...
Pia MiA's user avatar
  • 392
3 votes
1 answer
122 views

Efficient modelling via Gurobi

I would like to model the following constraint set in gurobi-java. \begin{equation} t^n_{ij} \geq t^n_{(i-1)j}+S_{(i-1)j} - (1 - \sum_{\substack{m \in \mathcal{M} \\ G_{ijm} = 1}}\sum_{k \in \mathcal{...
mdslt's user avatar
  • 529
1 vote
2 answers
120 views

Gurobipy trip scheduling empty stop problem

I am trying to create an optimizing model for a roadtrip: 10 cities in 14 weeks. For each city I have: a distance matrix to every city The rain for every week of the year My goal is to minimize the ...
nimVo's user avatar
  • 11
3 votes
1 answer
274 views

Gurobi - Python: is there a way to express "for some" in a constraint?

I'm new to Gurobi in Python and I am wondering if there is way to express/code "for some" in the following constraint: $x_i+x_j +x_k+x_l =2$ for some $i, j, k,l \in \{0,1,2,...., 10\}$, ...
M.Badaoui's user avatar
  • 185
2 votes
0 answers
123 views

OR constraint in Gurobi - Python

I'm new to Gurobi in Python and I am wondering if there is way to code the following constraints: 1- $\sum x_i =0$ for all $i\in A$ OR for all $i \in B$ where A and B are distinch sets of integers ...
M.Badaoui's user avatar
  • 185
3 votes
1 answer
240 views

Unexpected runtime error

I have a model that contains the sets (both ordered and Days also circular): Days and Personnel, and I'm trying to make a restriction run exaclty once per Day for every member of Personnel. I'm using ...
Cyrus Roettern's user avatar
6 votes
1 answer
1k views

What exactly is the optimality-gap or what does it say in integer linear programming?

I am working since a few months with gurobi and did figure out, that the gap says how far a feasible solutions is away from the optimal solution. However, what does say it exactly? The gurobi docs ...
Mike's user avatar
  • 147
1 vote
0 answers
39 views

Finding the solutions using pyomo and gurobi

I have a code that uses pyomo and gurobi but when i try to run it, it doesn't give me the optimal solutions, just says that they exist. What can i do?
Joana Domingos's user avatar
3 votes
0 answers
84 views

Does Gurobipy exploits sparsity of the optimization problem?

What happens when a (sparse) csr matrix / array is submitted to Gurobi (via Cvxpy framework in python). Does it exploit the sparsity Information about the matrix or ...
pqrz's user avatar
  • 460
2 votes
1 answer
99 views

Construction heuristic for SDCVRP

I'm not sure how I should formulate this question as precisely as possible but at the same time retaining as much specific information as possible but I'll have a go. I have implemented a (Split ...
Parseval's user avatar
  • 207
1 vote
0 answers
65 views

Does Gurobi solve QCQMIPs with Quadratic terms faster with then Bi-Linear terms in general?

Based on the color distance function defined here i try to find $n$ RGB colors with large inter set color distances and good color distance to white. ...
worldsmithhelper's user avatar
4 votes
1 answer
281 views

Gurobi solver with multiprocessing does not reduce total solving time

Problem I use the syntax of gurobi with multiprocessing to solve multiple problems in parallel. Even though multiple problems are solved concurrently, the solving time for a single problem increases ...
Qiu Junyan's user avatar
2 votes
1 answer
219 views

linearize bilinear quadratic objective terms

I need to model a problem as a linear program. However my working solution contains a (bilinear) quadratic objective term: $$ \sum x_i * y_i \\ x \in \{0,1\} \\ y \in \mathbb{R}^+ $$ The value of $y$ ...
Mike's user avatar
  • 147
3 votes
2 answers
391 views

How to formulate this in gurobi

I have subtour elimination constraint but can't understand and formulate this in gurobipy. How to formulate this ? $$ \sum_{i \in S} \sum_{j \in S} x_{i j}^{v} \leq|S|-1 \quad v=1, \ldots, m ; S \...
overboxed's user avatar
  • 573
1 vote
2 answers
234 views

MILP modeling Code with pyomo or gurobi or cplex or GAMS. Any link?

I am looking for MILP modeling code with stochastic/deterministic demand for Inventory ordering policy (e.g. (q,r) or (s,S) policy) with pyomo or gurobi or cplex or GAMS. Any link?
Peter's user avatar
  • 29
1 vote
2 answers
393 views

Subtour elimination in SDVRP

I have the model below, based on this paper. It's a vehicle routing problem with split deliveries, i.e the locations/customers can be visited by multiple vehicles that share the demand at that vehicle....
Parseval's user avatar
  • 207

1
2 3 4 5