Method eval_f

with prototype
virtual bool eval_f(Index n, const Number* x, 
                    bool new_x, Number& obj_value)
Return the value of the objective function at the point $ x$.

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 variable n is passed in for your convenience. This variable will have the same value you specified in get_nlp_info.

For our example, we ignore the new_x flag and calculate the objective.

bool HS071_NLP::eval_f(Index n, const Number* x, bool new_x, Number& obj_value)
{
  assert(n == 4);

  obj_value = x[0] * x[3] * (x[0] + x[1] + x[2]) + x[2];

  return true;
}



Andreas Waechter 2010-12-22