Method eval_g

with prototype
virtual bool eval_g(Index n, const Number* x, 
                    bool new_x, Index m, Number* g)
Return the value of the constraint function at the point $ x$.

The values returned in g should be only the $ g(x)$ values, do not add or subtract the bound values $ g^L$ or $ g^U$.

The boolean variable new_x will be false if the last call to any of the evaluation methods (eval_*) used the same $ x$ values. This can be helpful when users have efficient implementations that calculate multiple outputs at once. IPOPT internally caches results from the TNLP and generally, this flag can be ignored.

The variables n and m are passed in for your convenience. These variables will have the same values you specified in get_nlp_info.

In our example, we ignore the new_x flag and calculate the values of constraint functions.

bool HS071_NLP::eval_g(Index n, const Number* x, bool new_x, Index m, Number* g)
{
  assert(n == 4);
  assert(m == 2);

  g[0] = x[0] * x[1] * x[2] * x[3];
  g[1] = x[0]*x[0] + x[1]*x[1] + x[2]*x[2] + x[3]*x[3];

  return true;
}

Andreas Waechter 2010-12-22