Example details

Let us now walk through the example, line by line, to understand how it achieves the desired result of optimizing the indicated model.

The example begins by importing the Gurobi functions and classes, as well as the NumPy and SciPy packages:

import gurobipy as gp
from gurobipy import GRB
import numpy as np
import scipy.sparse as sp

Gurobi Python applications should always start with the first two lines. If you want to use the matrix interface, the last two lines are needed as well.