Skip to main content

How to use NumNZs value for assesing model

Answered

Comments

2 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?.
  • Jaromił Najman
    • Gurobi Staff

    Hi Baturay,

    The number of nonzeros is measuring the density of the constraint matrix. As a concrete example let us have a look at the mip1.py example. The number of nonzeros is 5 while the size of the constraint matrix is \(2\times 3\), i.e., 5 out of possible 6 constraint coefficients are \(\neq 0\). One would say that this matrix is rather dense. The density of the constraint matrix affects most of the algorithmic steps in the solution of a linear program, e.g., factorization, i.e., it has a direct influence on the performance of the optimization algorithm but not on the complexity of the underlying problem.

    Solving extremely large optimization problems works well most of the time, because the constraint matrices are sparse, i.e., there are only a few nonzero coefficients compared to the maximum matrix size which have to be stored in memory. Additionally, large problems most often have some specific structure which can be exploited by the optimization algorithms. However, a dense matrix is no indicator for the complexity of the problem. One can formulate large problems with a dense constraint matrix which can be solved rather quickly while in contrast a different small problem with a sparse matrix cannot be solved within several hours. The MIPLIB2017 holds multiple such instances.

    What one can say is that a problem with more nonzeros will most likely require more memory to be stored, since more coefficients have to be held in memory.

    Best regards,
    Jaromił

    0

Post is closed for comments.