Function GMP::Instance::GetObjectiveRowNumber(GMP)

GMP::Instance::GetObjectiveRowNumber

The function GMP::Instance::GetObjectiveRowNumber returns the row number corresponding to the constraint or variable definition that defines the objective of a generated mathematical program.

GMP::Instance::GetObjectiveRowNumber(
     GMP             ! (input) a generated mathematical program
     )

Arguments

Return Value

The function returns the row number as an element of the set Integers. If the generated mathematical program does not contain an objective then -1 is returned.

Note

  • You should assign the return value of this function to an element parameter with range Integers if you want to use it as (row) argument to call other GMP routines.

  • If the objective variable appears in more than one constraint (or variable definition) then the row number of the first of those constraints will be returned.

Example

Assume that we want to change the coefficients of all integer variables in the objective to 10. This can be done as follows.

RowNo := GMP::Instance::GetObjectiveRowNumber( myGMP );

ColNrs := GMP::Instance::GetColumnNumbers( myGMP, AllIntegerVariables );

for (c) do
    GMP::Coefficient::Set( myGMP, RowNo, c, 10 );
endfor;

Here RowNo is an element parameter with range Integers and ColNrs a subset of Integers with index c.