HI,

Having the Math Program Inspector is one of the great add-ins of AIMMS. One of the features that I really like is the matrix summary, where I can see the smallest and largest coefficients. However, I want to identify which variables and constraints are involved in those smallest or largest coefficients. One way is to look at the matrix graphical representation, but my model is big and I couldn't find those small coefficients.

Now I have some e-14 coefficients that cause numerical instabilities. I was thinking to scale my model, but I would like to find the variables and constraints related to this e-14 coefficient.

Is there any way to find the smallest or largest coefficients location in the matrix, without looking at the matrix graphical representation?

**Best answer by Marcel Hunting**

Hi

For a math program MP you can call this procedure as:

`solve MP;`

gmmc::GetMinMaxCoefs( 'MP' );

Here ‘gmmc’ is the prefix of the library. You do not have to solve the math program first; it is sufficient to generate it, i.e., you can also use:

`myGMP := GMP::Instance::Generate( MP );`

gmmc::GetMinMaxCoefs( myGMP );

The procedure contains two optional arguments, with a default of 0, which can be used to print all coefficients that are smaller than the first threshold value or larger than the second threshold value. For example:

`gmmc::GetMinMaxCoefs( 'MP', 1e-5, 1e5 );`

This will print all coefficients smaller than 1e-5 or larger than 1e5.

**Note 1**: The library uses an undocumented procedure, namely GMP::Coefficient::GetMultiSpecial which is much more efficient than using GMP::Coefficient::Get (in a for-loop).

**Note 2**: AIMMS can automatically scale the model for you if you use the Solvers General option ‘Scale model’. This option has been introduced in AIMMS 4.78.