getcoeff
getcoeff |
Purpose
Synopsis
function getcoeff(c:linctr):real
function getcoeff(c:linctr, x:mpvar):real
Arguments
c
|
A linear constraint
|
x
|
A decision variable
|
Return value
Coefficient of the variable or the 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