getsol


Purpose
Return the primal solution value of a constraint, or the calculated value of a general expression
Synopsis
function getsol(c:genctr | g:gexp) :real
Arguments
a general constraint
a general expression
Return value
For a general constraint, the primal solution value of the constraint, or zero if there is no solution or the constraint is not part of the current problem.
For a general expression, the evaluation of the expression using the solution values of the variables; zero is used as the value of a variable if it is not in the current problem, or if there is no solution.
Example
The following example solves a problem and retrieves the values of a constraint and of a general expression:
declarations
  c1, c2: genctr
  x, y: mpvar
end-declarations

  x <= 10
  y <= 10
  c1:= x^2 + y^2 <= 4 - x
  c2:= x*y >= 1
 
  SLPloadprob(x+y)
  SLPmaximize
  writeln("c1 solution value=",getsol(c1))
  writeln("x^2=",getsol(x^2))
Further information
This function requires the existence of a solution to the SLP problem. If it is called at an intermediate point during an optimization, SLPsetprobstat may be needed to ensure that solution values can be obtained.
Related topics
getact, getdual, getslack


If you have any comments or suggestions about these pages, please send mail to docs@dashoptimization.com.