gurobimixed-integer-programming

Efficiently Adding a Large Number of Constraints in Gurobi for MILP Problem


I am working on a large-scale Mixed Integer Linear Programming (MILP) problem using Gurobi. The decision variable vector x is binary and has a dimension of approximately n = 40,000,000. The objective function is defined as:

obj = c * x

where c is a coefficient vector of the same size as x.

I also need to add a very large number of constraints in batch form. Specifically, the constraints are of the form:

A * x <= b

where:

A is a matrix with dimensions n x n_col, where n_col is approximately 3,000,000.

B is a vector of size n.

Given the scale of the problem, I need to avoid adding constraints iteratively and instead handle them in a batched manner. I am looking for the most efficient way to add these constraints to the Gurobi model.

My questions are:


Solution

  • Take a look, it will be helpful:

    Gurobi Python Interface: Matrix-friendly Modeling Techniques

    Simple example: matrix1.py