Problem with Julia Ipopt

I am trying to do vehicle control. I am trying to use the magic formula which is given by

@defNLExpr(mdl, FyR[i = 1:N] , Dsin(Catan(B * (atan((v_y[i] - b*r[i])/v_x[i])))) )

Now when i run the code i am getting a error:

EXIT: Invalid number in NLP function or derivative detected.
WARNING: Ipopt finished with status Invalid_Number_Detected

How do I get around this problem?

Probably the division by v_x. If that was 0, then your function calculated an infinity or a nan and Ipopt gave you that error. Anything that appears in a denominator, you should make sure to initialize it to a nonzero starting point, and if possible, constrain it away from zero.

Try introducing an intermediate variable:

@variable(mdl, my_intr[i = 1:N]) # Add bounds if possible
@NLconstraint(mdl, calc_my_intr[i = 1:N], my_intr[i] * v_x[i] == v_y[i] - b*r[i])

This will avoid derivatives from exploding as v_x[i] goes to 0.

Now for some shameless self-promotion. I recently shared a collection of JuMP model diagnostic tools on github. One feature includes finding NaNs in the Jacobian and printing out the offending constraint/variable.

Thanks for your help. I tried doing that but still it gives me the same error if I have anything in division.

Thanks I will try and get back to you asap