JuliaMPC / NLOptControl.jl

nonlinear control optimization tool
Other
109 stars 26 forks source link

Ipopt finished with status Invalid_Number_Detected #6

Closed baggepinnen closed 6 years ago

baggepinnen commented 6 years ago

I am trying out this package but run into an error which I find hard to debug. The code below is self contained and runs into

WARNING: Ipopt finished with status Invalid_Number_Detected
WARNING: Not solved to optimality, status: Error

when calling optimize!. Any ideas on the source of the error, bug or my fault?

using Ipopt
using NLOptControl

ni    = 1000
l     = 0.345
lact  = 0.4
g     = 9.81
# m = Model(solver     = solver)
X0  = [-0.8, 0, 0, 0, 0]
XF  = [0, 0, 0, 0, NaN]
CL  = [-100.]
CU  = [100.]

n   = define(numStates = 5, numControls=1, X0=X0, XF=XF, CL=CL, CU=CU)
states!(n,[:p, :pd, :theta, :thetad, :ar],descriptions=["p(t)", "ṗ(t)", "θ(t)","θ̇(t)", "aᵣ(t)"])
controls!(n,[:ard],descriptions=["ȧᵣ(t)"])

# Setup model equations ================================================================
dx    = Array{Expr}(5)
dx[1] = :(pd[j])
dx[2] = :(ar[j])
dx[3] = :(thetad[j])
dx[4] = :(-$g/$l*sin(theta[j])-0.04*thetad[j]+1/$l -$g/$l*sin(theta[j])-0.04*thetad[j]+1/$l*cos(theta[j])*ar[j])
dx[5] = :(ard[j])
dynamics!(n,dx)

# Pendulum constraints
x_p = :(p[j]-$lact*sin(theta[j]))
y_p = :(-$lact*cos(theta[j]))
constraints!(n, [:((($x_p+0.3)/0.05)^2 + (($y_p+0.4)/0.3)^2 >= 1)])

configure!(n; (:Nck=>[ni]), (:finalTimeDV=>true))
@NLobjective(n.mdl, Min, n.tf)
optimize!(n)
huckl3b3rry87 commented 6 years ago

@baggepinnen sorry for the delay on this.

It is doubtful that it is a bug. It can be hard to formulate optimization problems. I often get that type of error from IPOPT when I am setting up optimization problems, make sure that the constraints make sense.

I played with this some, but could not figure out what is going wrong and do not have time right now to look into it more.

I am closing this because is likely that it has to do with setting up NLPs.