STATS Command

The STATS command lists summary statistics for your model. The statistics vary slightly depending on whether the model you’re working with is linear or nonlinear. In this next example, we will read in a linear transportation model, run the STATS command, and explain some of the details of the report.

: take \lingo\samples\tran.lng

: stats

 

Rows=    8 Vars=   12 No. integer vars=    0  ( all are linear)

Nonzeros=   43 Constraint nonz=  24(  24 are +- 1) Density=0.413

Smallest and largest elements in abs value= 1.00000   30.0000

No. < :   3 No. =:   0 No. > :   4, Obj=MIN, GUBs <=   4

Single cols=    0

The STATS report for linear models consists of five lines.

In line 1, we see the number of rows (constraints), variables (columns), and integer variables. The STATS command lets us know the model is linear by stating that all the variables are linear.

Line 2 of the report gives a count of the number of nonzero coefficients appearing in the model. The first count is the number of nonzero coefficients in the entire model. The Constraint nonz count is the number of coefficients on the left-hand sides of all the constraints, excluding the nonzero objective and right-hand side coefficients. Next, STATS gives a count of the number of constraint coefficients that are plus or minus one. In general, a linear programming model is easier to solve when the number of unity coefficients increases. Finally, STATS reports a density figure, defined as: (total nonzeros) / [(number of rows) * (number of columns + 1)]. For large models, densities under .01 are common. High densities can mean that a problem will take longer to solve.

Line 3 lists the smallest and largest coefficients in the model in absolute value. For stability reasons, the ratio of the largest coefficient to the smallest should, ideally, be close to 1. Also, in absolute terms, it is best to keep coefficient values in the range of 0.0001 to 100,000. Values outside this range can cause numerical difficulties for the linear solver.

Line 4 lists the number of constraints by type (<, =, and >), the sense of the objective, and an upper bound on the number of Generalized Upper Bound (GUB) constraints. A GUB constraint is a constraint that does not intersect with the remainder of the model. Given this, the GUB statistic is a measure of model simplicity. If all the constraints were nonintersecting the problem could be solved by inspection by considering each constraint as a separate problem.

Line 5 lists the number of variables that appear in only one row. Such a variable is effectively a slack. If you did not explicitly add slack variables to your model and the single column count is greater than zero, then it suggests a misspelled variable name.

In the next example, we will read a nonlinear model, DNRISK.LNG, into LINGO and review its model statistics.

: take \lingo\samples\dnrisk.lng

: stats

Rows=     17 Vars=     17 No. integer vars=      0

Nonlinear rows= 1 Nonlinear vars= 7 Nonlinear constraints=  0

Nonzeros=     68 Constraint nonz=    52 Density=0.222

No. < :   0 No. =:   8 No. > :   8, Obj=MIN Single cols=    0

The nonlinear STATS report drops information about the range of coefficient values, the number of +/-1 coefficients, and the GUB upper bound. A count of the number of nonlinear variables and rows is added in line two. The nonlinear rows count includes the objective, while the nonlinear constraint count does not.