- Procedure GMP::Coefficient::SetMulti(GMP, binding, row, column, value)
GMP::Coefficient::SetMulti
The procedure GMP::Coefficient::SetMulti
sets the value of a range
of (linear) coefficients for a group of columns and rows, belonging to a
variable and constraint, in a generated mathematical program.
GMP::Coefficient::SetMulti(
GMP, ! (input) a generated mathematical program
binding, ! (input) an index binding
row, ! (input) a constraint expression
column, ! (input) a variable expression
value ! (input) a numerical expression
)
Arguments
- GMP
An element in
AllGeneratedMathematicalPrograms
.- binding
An index binding that specifies and possibly limits the scope of indices.
- row
A constraint that, combined with the binding domain, specifies the rows.
- column
A variable that, combined with the binding domain, specifies the columns.
- value
The new coefficient for each combination of row and column, defined over the binding domain.
Return Value
The procedure returns 1 on success, or 0 otherwise.
Note
This procedure cannot be used if the objective variable is passed as column.
In case the generated mathematical program is nonlinear, this procedure will fail if one the columns is part of a nonlinear term in one of the rows. 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 of procedure
GMP::Coefficient::Set
.
Example
To set the coefficients of variable
x(j)
in constraintc(i)
tocoef(i,j)
we can use:for (i,j) do GMP::Column::Set( myGMP, c(i), x(j), coef(i,j) ); endfor;It is more efficient to use:
GMP::Coefficient::SetMulti( myGMP, (i,j), c(i), x(j), coef(i,j) );If we only want to set the coefficients of those
x(j)
for whichdom(j)
is unequal to zero, then we use:GMP::Coefficient::SetMulti( myGMP, (i,j) | dom(j), c(i), x(j), coef(i,j) );
See also
The routines GMP::Coefficient::Get
, GMP::Coefficient::Set
and GMP::QuadraticCoefficient::Set
.