Procedure GMP::Coefficient::Set(GMP, row, column, value)


The procedure GMP::Coefficient::Set sets the value of a (linear) coefficient in a generated mathematical program.

     GMP,            ! (input) a generated mathematical program
     row,            ! (input) a scalar reference or row number
     column,         ! (input) a scalar reference or column number
     value           ! (input) a scalar numerical value



An element in AllGeneratedMathematicalPrograms.


A scalar reference to an existing row in the model or the number of that row in the range \(\{ 0 .. m-1 \}\) where \(m\) is the number of rows in the matrix.


A scalar reference to an existing column in the model or the number of that column in the range \(\{ 0 .. n-1 \}\) where \(n\) is the number of columns in the matrix.


A scalar numerical value indicating the value for the coefficient.

Return Value

The procedure returns 1 on success, or 0 otherwise.


  • Use GMP::Coefficient::SetMulti or GMP::Coefficient::SetRaw if many coefficients have to be set because that will be more efficient.

  • This procedure cannot be used if the column refers to the objective variable.

  • In case the generated mathematical program is nonlinear, this procedure will fail if the column is part of a nonlinear term in the row. However, if the row is pure quadratic, then this procedure can be used to set the linear coefficient value for a quadratic column.

  • GMP procedures operate on a generated mathematical program in which all variables are moved to the left-hand-side of each constraint. This can have an influence on the sign of the coeffients as demonstrated in the example below.


Assume that we have the following variable and constraint declarations (in ams format):.

Variable y;
Variable z;
Variable x1;
Constraint c1 {
    Definition: x1 - 2*y - 3*z = 0;
Variable x2 {
    Definition: 2*y + 3*z;

To change the coefficient of variable y in constraint c1 to 4 we use:

GMP::Coefficient::Set( myGMP, c1, y, 4 );

This results in the row x1 + 4*y - 3*z = 0.

The definition of variable x2 is generated as the row x2 - 2*y - 3*z = 0 by AIMMS. Therefore, using

GMP::Coefficient::Set( myGMP, x2_definition, y, -4 );

will result in the row x2 - 4*y - 3*z = 0.