Questions tagged [gurobi]

Gurobi is a commercial optimization solver for linear programming (LP), quadratic programming (QP), quadratically constrained programming (QCP), mixed-integer linear programming (MILP), mixed-integer quadratic programming (MIQP), and mixed-integer quadratically constrained non-convex programming (MIQCP).

As described on Wikipedia:

The Gurobi Optimizer is a commercial optimization solver for linear programming (LP), quadratic programming (QP), quadratically constrained programming (QCP), mixed integer linear programming (MILP), mixed-integer quadratic programming (MIQP), and mixed-integer quadratically constrained programming (MIQCP).

Problems can be defined and solved via Gurobi's interactive shell or one of its many programming languages interfaces: C, C++, Java, Microsoft, .NET, Python, MATLAB, R.

1089 questions
6
votes
2 answers

Extract gurobi muti-dimensional variable value and form a numpy array

I want to know that when I defined a multi-dimension variables in Gurobi, how can I extract all the value of the solution and organize them in to a Numpy array according to the original coordinate of the variable. I have the following decision…
Loading Zone
  • 177
  • 2
  • 12
6
votes
1 answer

Why do I get "GurobiError: Variable not in model" after using Model.copy()?

I need to optimize a model with different sets of constraints, but a subset of those constraints will be the same for each model. My idea was to build a base model with all the variables and all the constraints that will be needed every time.…
io.lite
  • 81
  • 1
  • 7
6
votes
1 answer

How to set a timeout for gurobi using python

I want to solve ILPs using the python interface to gurobi. I also want to set a timeout of 5 minutes. I tried e = gurobipy.Env() e.setParam('TimeLimit', 5*60) m = gurobipy.Model(env=e) but i get the error File "env.pxi", line 18, in…
Leevi L
  • 1,538
  • 2
  • 13
  • 28
5
votes
1 answer

Gurobi and java and empty solution

I'm using Gurobi with java to solve a ILP problem. I set all and I start the program. But Gurobi doesn't even try to solve my problem and gives my an empty solution all variable set to 0. During the relaxed step Gurobi shows that the minimum value…
5
votes
1 answer

TypeError: unsupported operand type(s) for -: 'generator' and 'NoneType'

When trying to do a simple substraction Python gives me a typererror : TypeError: unsupported operand type(s) for -: 'generator' and 'NoneType'. In my idea the 2 sides are just numbers, so I do not understand the problem really. This is my…
Student grun
  • 51
  • 1
  • 2
5
votes
1 answer

Minimize the max value in Gurobi optimaztion

I am developing a model to solve a MIP problem using gurobi and python. The problem involves travel times over a set of predefined routes. One of the objective functions I am trying to realize is to minimize the maximum travel time for the selected…
David Oliver
  • 127
  • 2
  • 9
5
votes
2 answers

Gurobi Python API: model.addVars() too slow

I'm currently working on using Gurobi Python API to solve a large-scale LP. I found that the process of adding variables takes too much time, in some cases even more than the optimizing time. My code is roughly like this (I deleted the read data…
user12345
  • 117
  • 8
5
votes
1 answer

Gurobi Python: how to write nested sum in a constraint

I have an optimization problem and I'm using Python and Gurobi to optimize it. In my problem formulation there is a constraint that has a nested sum. constraint I've recently started learning python and I searched in gurobi documentation and example…
nanika
  • 71
  • 2
  • 2
  • 8
5
votes
2 answers

Installing Gurobi in Virtualenv without Anaconda

I would like to use Gurobi Optimization library with Python3.5 inside a virtualenv environment, without having to install the whole Anaconda Framework. This implies to be able to install Gurobi library (gurobipy) via Pipy. On Gurobi website is only…
Edouard Berthe
  • 1,393
  • 2
  • 18
  • 38
5
votes
1 answer

What is Objective coefficient for new variable

In order to create new GRBVar, I need to provide Objective coefficient for new variable: GRBVar var = model.addVar (double lowerBound, double upperBound, double obj, // objective coefficient char type, String…
Long Thai
  • 807
  • 3
  • 12
  • 34
5
votes
1 answer

Gurobi model modification slow, can I modify the constraint matrix directly?

I want to make changes to the coefficients in an existing model. Currently (with the Python API) I'm looping through the constraints and calling model.chgCoeff but it's quite slow. Is there a faster way, perhaps accessing the constraint matrix…
akxlr
  • 1,142
  • 9
  • 23
5
votes
1 answer

AMPL vs. Python - Importing tables (multi-dimensional dictionaries?)

I am an AMPL user trying to write a linear programming optimization model using Python (My first Python code). I am trying to find how to declare indexed parameters over compound sets. For example, in AMPL, i would say: Set A Set B Set…
4
votes
1 answer

Retrieve constraints matrix from Gurobi or MOI or JuMP in Julia

I want to retrieve an LP model in matrix form from Gurobi. I am using package JuMP in Julia. I can print all the constraints using MathOptInterface but not in matrix form. I have no idea how to print the problem matrix from Gurobi. Could anyone help…
Hongyu
  • 183
  • 5
4
votes
1 answer

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 certain api calls that I use very…
Connor
  • 545
  • 4
  • 20
4
votes
4 answers

How to install Gurobi in python 3?

I tried to install the gurobi package on python 3 but it didn't work. The command that i am using on my macbook is: pip install gurobipy, but it doesn't work, it shows me this: ERROR: Could not find a version that satisfies the requirement gurobipy…
M.HANHASSE
  • 129
  • 1
  • 6
1
2
3
72 73