NLPSOL cost function as Casadi Function

365 views
Skip to first unread message

Stuart

unread,
Aug 3, 2022, 11:44:43 AM8/3/22
to CasADi
Hello, I'm modifying the single_shooting.py example on the casadi repository ( https://github.com/casadi/casadi/blob/master/docs/examples/python/direct_single_shooting.py ) in various ways. One way is that I want the cost function for the NLP solver to be a casadi Function. However, I get the following error when the code calls the nlpsol function: 'Wrong number or type of arguments for overloaded function 'nlpsol'.

Code is a bit long but not very complex, I've just made a few changes to the original repository example. Here's the link: https://gist.github.com/StuartShanks/72ef61dd31f6fef8e7eb9653d5bc10c1

The error occurs at line 112. If I change J_sym back to J, like it originally was, the error disappears. So I assume the problem is with using a Casadi Function for the cost function. 

Cheers

Otávio Ivo

unread,
Aug 3, 2022, 12:13:01 PM8/3/22
to Stuart, CasADi
Hello,

J_sym is just a function caller. It needs to be defined by having some inputs at line 111. 

Regards,
Otávio Ivo 

--
Sent from CasADi's user forum at http://forum.casadi.org.
---
You received this message because you are subscribed to the Google Groups "CasADi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to casadi-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/casadi-users/f45aa9d5-5854-40fb-891a-26ec2b4305d8n%40googlegroups.com

Stuart

unread,
Aug 3, 2022, 12:25:25 PM8/3/22
to CasADi
Hello,

You're right! I fixed it now, cheers

Reply all
Reply to author
Forward
0 new messages