Procedure GMP::Solution::SetRowValue(GMP, solution, row, value, valueType)


The procedure GMP::Solution::SetRowValue sets the level value or shadow price of a row in a solution in the solution repository of a generated mathematical program.

     GMP,            ! (input) a generated mathematical program
     solution,       ! (input) a solution
     row,            ! (input) a scalar reference or row number
     value,          ! (input) a scalar value
     [valueType]     ! (input/optional) a scalar value



An element in AllGeneratedMathematicalPrograms.


An integer scalar reference to a solution.


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


The value to be assigned to the row.


A scalar value specifying the value type. If 0 (the default) then the level value will be set. If 1, the shadow price.

Return Value

The procedure returns 1 on success, or 0 otherwise.


If the row has a unit then the scaled value should be passed. You can get the scale factor by using the function GMP::Row::GetScale.


Assume we have a GMP for which we want to multiply all shadow prices in a solution by some value, say 10. This can be done in a generic way using the function GMP::Instance::GetRowNumbers as follows. Here RowNrs is a subset of Integers with index r.

! Get the row numbers of all constraints in myGMP.
RowNrs := GMP::Instance::GetRowNumbers( myGMP, AllConstraints );

for ( r ) do
    ! Get shadow price of row r in solution 1.
    val := GMP::Solution::GetRowValue( myGMP, 1, r, valueType : 1 );

    ! Assign new value for shadow price to row r in solution 1.
    GMP::Solution::SetRowValue( myGMP, 1, r, 10 * val, valueType : 1 );

! Send solution to the (symbolic) model identifiers.
GMP::Solution::SendToModel( myGMP, 1 );

Note: the shadow prices will only be stored in the data structures of the constraints if the ShadowPrice property of the variables is set, or if the option Always_Store_Marginals is set.