do-mpc / do-mpc

Model predictive control python toolbox
https://www.do-mpc.com/
GNU Lesser General Public License v3.0
964 stars 179 forks source link

Error evaluating Jacobian of equality constraints at user provided starting point. No scaling factors for equality constraints computed! #26

Closed hxlee309 closed 4 years ago

hxlee309 commented 6 years ago

I got the above error when I try to run my own model. Any idea about how to fix this error?

Thanks,

Hanxiang

hxlee309 commented 6 years ago

Here's the detailed error info:


This program contains Ipopt, a library for large-scale nonlinear optimization. Ipopt is released as open source code under the Eclipse Public License (EPL). For more information visit http://projects.coin-or.org/Ipopt


This is Ipopt version 3.12.3, running with linear solver mumps. NOTE: Other linear solvers might be more efficient (see Ipopt documentation).

Number of nonzeros in equality constraint Jacobian...: 1468 Number of nonzeros in inequality constraint Jacobian.: 0 Number of nonzeros in Lagrangian Hessian.............: 119

CasADi - 2018-07-31 11:15:45 WARNING("solver:nlp_jac_g failed: NaN detected for output jac_g_x, at nonzero index 14 (row 0, col 25).") [.../casadi/core/oracle_function.cpp:249] Error evaluating Jacobian of equality constraints at user provided starting point. No scaling factors for equality constraints computed! CasADi - 2018-07-31 11:15:45 WARNING("solver:nlp_jac_g failed: NaN detected for output jac_g_x, at nonzero index 14 (row 0, col 25).") [.../casadi/core/oracle_function.cpp:249]

Number of Iterations....: 0

Number of objective function evaluations = 0 Number of objective gradient evaluations = 0 Number of equality constraint evaluations = 0 Number of inequality constraint evaluations = 0 Number of equality constraint Jacobian evaluations = 1 Number of inequality constraint Jacobian evaluations = 0 Number of Lagrangian Hessian evaluations = 0 Total CPU secs in IPOPT (w/o function evaluations) = 0.000 Total CPU secs in NLP function evaluations = 0.000

EXIT: Invalid number in NLP function or derivative detected. t_proc [s] t_wall [s] n_eval nlp_grad 2.8e-05 2.85e-05 1 nlp_grad_f 6e-06 5.59e-06 1 solver 0.000783 0.000783 1 CasADi - 2018-07-31 11:15:45 WARNING("simulator:odeF failed: NaN detected for output ode, at (row 0, col 0).") [.../casadi/core/oracle_function.cpp:249] CasADi - 2018-07-31 11:15:45 WARNING("simulator:odeF failed: NaN detected for output ode, at (row 0, col 0).") [.../casadi/core/oracle_function.cpp:249] CasADi - 2018-07-31 11:15:45 WARNING("simulator:odeF failed: NaN detected for output ode, at (row 0, col 0).") [.../casadi/core/oracle_function.cpp:249] CasADi - 2018-07-31 11:15:45 WARNING("simulator:odeF failed: NaN detected for output ode, at (row 0, col 0).") [.../casadi/core/oracle_function.cpp:249] CasADi - 2018-07-31 11:15:45 WARNING("simulator:odeF failed: NaN detected for output ode, at (row 0, col 0).") [.../casadi/core/oracle_function.cpp:249] CasADi - 2018-07-31 11:15:45 WARNING("simulator:jacF failed: NaN detected for output o0, at nonzero index 1 (row 0, col 1).") [.../casadi/core/oracle_function.cpp:249] psetup failed: .../casadi/interfaces/sundials/cvodes_interface.cpp:637: 'jacF' calculation failed CasADi - 2018-07-31 11:15:45 WARNING("simulator:odeF failed: NaN detected for output ode, at (row 0, col 0).") [.../casadi/core/oracle_function.cpp:249] CasADi - 2018-07-31 11:15:45 WARNING("simulator:jacF failed: NaN detected for output o0, at nonzero index 1 (row 0, col 1).") [.../casadi/core/oracle_function.cpp:249] psetup failed: .../casadi/interfaces/sundials/cvodes_interface.cpp:637: 'jacF' calculation failed CasADi - 2018-07-31 11:15:45 WARNING("simulator:odeF failed: NaN detected for output ode, at (row 0, col 0).") [.../casadi/core/oracle_function.cpp:249] CasADi - 2018-07-31 11:15:45 WARNING("simulator:jacF failed: NaN detected for output o0, at nonzero index 1 (row 0, col 1).") [.../casadi/core/oracle_function.cpp:249] psetup failed: .../casadi/interfaces/sundials/cvodes_interface.cpp:637: 'jacF' calculation failed CasADi - 2018-07-31 11:15:45 WARNING("simulator:odeF failed: NaN detected for output ode, at (row 0, col 0).") [.../casadi/core/oracle_function.cpp:249] CasADi - 2018-07-31 11:15:45 WARNING("simulator:jacF failed: NaN detected for output o0, at nonzero index 1 (row 0, col 1).") [.../casadi/core/oracle_function.cpp:249] psetup failed: .../casadi/interfaces/sundials/cvodes_interface.cpp:637: 'jacF' calculation failed CasADi - 2018-07-31 11:15:45 WARNING("simulator:odeF failed: NaN detected for output ode, at (row 0, col 0).") [.../casadi/core/oracle_function.cpp:249] CasADi - 2018-07-31 11:15:45 WARNING("simulator:jacF failed: NaN detected for output o0, at nonzero index 1 (row 0, col 1).") [.../casadi/core/oracle_function.cpp:249] psetup failed: .../casadi/interfaces/sundials/cvodes_interface.cpp:637: 'jacF' calculation failed CasADi - 2018-07-31 11:15:45 WARNING("simulator:odeF failed: NaN detected for output ode, at (row 0, col 0).") [.../casadi/core/oracle_function.cpp:249] CasADi - 2018-07-31 11:15:45 WARNING("simulator:jacF failed: NaN detected for output o0, at nonzero index 1 (row 0, col 1).") [.../casadi/core/oracle_function.cpp:249] psetup failed: .../casadi/interfaces/sundials/cvodes_interface.cpp:637: 'jacF' calculation failed CasADi - 2018-07-31 11:15:45 WARNING("simulator:odeF failed: NaN detected for output ode, at (row 0, col 0).") [.../casadi/core/oracle_function.cpp:249] CasADi - 2018-07-31 11:15:45 WARNING("simulator:jacF failed: NaN detected for output o0, at nonzero index 1 (row 0, col 1).") [.../casadi/core/oracle_function.cpp:249] psetup failed: .../casadi/interfaces/sundials/cvodes_interface.cpp:637: 'jacF' calculation failed CasADi - 2018-07-31 11:15:45 WARNING("simulator:odeF failed: NaN detected for output ode, at (row 0, col 0).") [.../casadi/core/oracle_function.cpp:249] CasADi - 2018-07-31 11:15:45 WARNING("simulator:jacF failed: NaN detected for output o0, at nonzero index 1 (row 0, col 1).") [.../casadi/core/oracle_function.cpp:249] psetup failed: .../casadi/interfaces/sundials/cvodes_interface.cpp:637: 'jacF' calculation failed CasADi - 2018-07-31 11:15:45 WARNING("simulator:odeF failed: NaN detected for output ode, at (row 0, col 0).") [.../casadi/core/oracle_function.cpp:249] CasADi - 2018-07-31 11:15:45 WARNING("simulator:jacF failed: NaN detected for output o0, at nonzero index 1 (row 0, col 1).") [.../casadi/core/oracle_function.cpp:249] psetup failed: .../casadi/interfaces/sundials/cvodes_interface.cpp:637: 'jacF' calculation failed CasADi - 2018-07-31 11:15:45 WARNING("simulator:odeF failed: NaN detected for output ode, at (row 0, col 0).") [.../casadi/core/oracle_function.cpp:249] CasADi - 2018-07-31 11:15:45 WARNING("simulator:jacF failed: NaN detected for output o0, at nonzero index 1 (row 0, col 1).") [.../casadi/core/oracle_function.cpp:249] psetup failed: .../casadi/interfaces/sundials/cvodes_interface.cpp:637: 'jacF' calculation failed At t = 0 and h = 6.54651e-11, the corrector convergence test failed repeatedly or with |h| = hmin. Traceback (most recent call last): File "do-mpc.py", line 92, in configuration_1.make_step_simulator() File "../../code/core_do_mpc.py", line 252, in make_step_simulator result = self.simulator.simulator(x0 = self.simulator.x0_sim, p = vertcat(u_mpc,p_real,tv_p_real)) File "/usr/local/lib/python2.7/dist-packages/casadi/casadi.py", line 13627, in call return self.call(kwargs) File "/usr/local/lib/python2.7/dist-packages/casadi/casadi.py", line 12690, in call return _casadi.Function_call(self, *args) RuntimeError: .../casadi/interfaces/sundials/cvodes_interface.cpp:379: CVode returned "CV_CONV_FAILURE". Consult CVODES documentation.

alexandru-tc commented 6 years ago

Dear hxlee309,

usually when we see this kind of errors, it's got to do with the ODEs of your model, the initial point x0 or a combination of the two. Remember that the jacobian of the NLP is obtained from the model, which itself becomes an equality constraint of the NLP via the contraints imposed on the MPC predictions.

The first thing to check would be that your equations are correctly posed. Make sure you do not have divisions by 0 or other strange terms in your ODEs. Also, while at it, make sure that the initial point is within the upper and lower bounds (both states and inputs). If you are using scaling factors, it's a good idea to first try it without them (i.e. x_scaling = ones(...)) and only after to introduce them - only if needed.

If both the equations and the initial values are okay, the NLP can be typically solved [very] fast by IPOPT. Please let us know if you've managed to track down the problem.

Cheers, Alex

hxlee309 commented 6 years ago

Hi Alex,

It works now on some settings. Whether it works or not depends heavily on how I set up the cost function, input penalty and initial state. It returns NaN or "infeasible problem" in most of the settings. Is there any way to improve the robustness of finding a solution?

Please also let me know how to install additional linear solver.

Thanks,

Hanxiang

alexandru-tc commented 6 years ago

Dear Hanxiang,

this sounds rather strange... Can you tell me what is the application you are using do-mpc for? What model do you have, and what cost function are you using? What is the optimal solution that you expect to get, or the behavior of the controlled system?

It is hard to give you some hints if we don't know what you're trying to achieve. In my experience, if the problem is set up correctly (i.e. correct and differentiable equations, good initial condition, correct upper and lower bounds, correct scaling) then IPOPT will also find a solution.

However, in some cases there might be tuning required on the part of the solver too. I could recommend to have a look at the parameters of IPOPT in their own user manual: https://projects.coin-or.org/Ipopt/browser/stable/3.11/Ipopt/doc/documentation.pdf?format=raw (the Options Reference chapter) In order to change them you will have to "open up the box" and look inside core_do_mpc. I hope that won't be the case though...

That's it for now. When you provide more infor I will have a look and try to help you further. Cheers, Alex

hxlee309 commented 6 years ago

Hi Alexandru,

The application I am using for is control of autonomous car. The model I have is a 6-state (x,y,phi: vehicle position/yaw angle, u,v,r: vehicle speed/yaw rate) Pacejka model, which contains lots of trigonometric functions. Attached are the state-space model, range of input, and value of parameters. The cost function I am using is the standard quadratic form (F = (x'-x_s')Q(x-x_s), where x_s is the desired state in the current prediction horizon). The optimal solution I am trying to get is the real-time control of vehicle steering angle and tractive force based on real-time updated desired state (rely on traffic condition/motion planning result). Also, the code of our vehicle model is attached below.

Please what kind of parameters I need to tune in core_do_mpc if necessary.

Looking forward to your reply.

Thanks and Best Regards,

Hanxiang

On Wed, Aug 1, 2018 at 5:18 AM, alexandru-tc notifications@github.com wrote:

Dear Hanxiang,

this sounds rather strange... Can you tell me what is the application you are using do-mpc for? What model do you have, and what cost function are you using? What is the optimal solution that you expect to get, or the behavior of the controlled system?

It is hard to give you some hints if we don't know what you're trying to achieve. In my experience, if the problem is set up correctly (i.e. correct and differentiable equations, good initial condition, correct upper and lower bounds, correct scaling) then IPOPT will also find a solution.

However, in some cases there might be tuning required on the part of the solver too. I could recommend to have a look at the parameters of IPOPT in their own user manual: https://projects.coin-or.org/ Ipopt/browser/stable/3.11/Ipopt/doc/documentation.pdf?format=raw (the Options Reference chapter) In order to change them you will have to "open up the box" and look inside core_do_mpc. I hope that won't be the case though...

That's it for now. When you provide more infor I will have a look and try to help you further. Cheers, Alex

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/do-mpc/do-mpc/issues/26#issuecomment-409510112, or mute the thread https://github.com/notifications/unsubscribe-auth/AgUCQkPJbXDW82uHRy7A0rh2hcQOomvGks5uMXJ-gaJpZM4VoYkx .

--

Hanxiang Li Department of Mechanical Engineering, M.S.E University of Michigan

4flixt commented 4 years ago

I am closing this issue now because it refers to the previous version of do-mpc. Please reopen a new issue if the problem persists.