Initializing help system before first use

getcoeff

getcoeff


Purpose
Get a constraint coefficient or constant term.
Synopsis
function getcoeff(c:linctr):real
function getcoeff(c:linctr, x:mpvar):real
function getcoeff(c:linctr, n:integer):real
Arguments
A linear constraint
A decision variable
-1 for constant term, -2 for range lower bound
Return value
Coefficient of the variable or a constant term.
Example
In this example a single constraint with three variables is defined. The calls to getcoeff result in r taking the value -1 and s taking the value -12.
declarations
 x,y,z:mpvar
end-declarations

c:= 4*x + y -z <= 12
r:= getcoeff(c, z)
r:= getcoeff(c)
Further information
This function returns the coefficient of a given variable in a constraint, or if no variable is given, the constant term (= -RHS) of the constraint. The returned values correspond to a normalised constraint representation with all variable and constant terms on the left side of the (in)equality sign.
Related topics