Finding the smallest coefficient location in the matrix in the Math Program Inspector

  • 6 May 2021
  • 1 reply

Userlevel 1
Badge +4



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 6 May 2021, 16:40

View original

1 reply

Userlevel 4
Badge +2

Hi @afattahi. You can find that information if you use GMP functionality. I have attached a zip file containing a small AIMMS library. After unzipping the zip file you can include the library in your AIMMS project using the Library Manager. The library contains a procedure that can be used to find the smallest and largest coefficient (in absolute sense) in a generated math program. It will print that information to a file.

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.


Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator