Function and gradient evaluation in same function Ipopt