Questions about new opti stack syntax

732 views
Skip to first unread message

pablope...@gmail.com

unread,
Nov 6, 2017, 12:50:17 PM11/6/17
to CasADi
Hello,

I discovered Opti helper classes last week and i found them great because they are offer to the user a high level coding way for describing problems (as pyomo or jmodellica do), but some doubts have arisen about them:

1) It is stated in Casadi blog that they are ideal for teaching, so I wonder if there is any problem with performance lack using them.
2) The example about race car is great for me (first time I see minimal time problem in Casadi) but they use RK4 for integrator. I have tried use a Radau collocation method in it, but I have failed until now. Is there any example available for Opti stack with collocation integrator?
3) In old opti stack project (before joining to Casadi trunk), there was a way for generating C code. Is this feature still availble and if so, how it is activated and used?
4) About Opti.minimize() function, is there any helper class for indicating an integral operation to minimize (I mean, in race car example, instead of minimize(T) use minimize(Integrate(aceleration)) or something like that)?

Thank you very much,
Pablo

Joris Gillis

unread,
Nov 7, 2017, 3:54:57 AM11/7/17
to CasADi
Dear Pablo,

1) There are performance penalities in the 'solve()' step (it copies the problem) and the 'value()' retrieval in values.
We may create a variant without performance penalities in the future (kind of like yalmip has 'optimizer').
That said, oftentimes, the bottleneck is in the optimizer and the function evaluations; there is no overhead there.

2) Not available, but planned after the semester is over. Not that we have collocation examples for non-Opti syntax; bringing them in a simpler syntax should be easy.
If it succeeds for you, why not contribute it to us?

3) Yes, you may pass any options to the solver:
opti.solver('ipopt',struct('jit',true))

4) No, Opti is about NLPs only, not OCPs. You could easily create a micro-language for OCPs on top of Opti.
I'm not sure if it is desirable to have it in CasADi. We don't want to compete with groups/companies that create convenient interfaces for declaring/solving OCPs.
We supply the building blocks to make a great OCP interface, not a finished product.


Best regards,
  Joris

pablope...@gmail.com

unread,
Nov 8, 2017, 7:29:04 AM11/8/17
to CasADi
Dear Joris,

thank you for your quick answer. I will look forward any new advances and examples in Opti stack. I really think that this new syntax will allow increasing Casadi users in future due that normal syntax is kind of "intimidating" for people not so used to such "low level" math (and sadly, I am amongst them).

While reviewing example again, I got these two new doubts:

5) Is this syntax available for the cpp api? (Sorry, unfortunately I can not test by myself because I don't have a fully compliant c++11 compiler in my research environmet).

6) In the car race example, there is used a very cool feature: The system ODE is discretized with respect to the time, but the speed limit constraint is provided with respect to a state variable: the position!!! I only have seen this kind of feature in commercial languages as AMPL, so for me this is closer to black magic than to math science. I have not seen nothing like that in normal python examples. Please, might you tell me if this feature could be used in Casadi normal syntax? Can you give me a clue of how should this be implemented?

Thanks and best regards,
Pablo

Joris Gillis

unread,
Nov 8, 2017, 9:57:34 AM11/8/17
to CasADi
Thank you for the nice feedback.
Opti is available in C++ as well: https://github.com/casadi/casadi/blob/develop/docs/examples/cplusplus/race_car.cpp

The speed limit constraints is nothing special. Its just the general path constraint form h(x(t),u(t))<=0 for all t. Anything you can do with Opti you can do with more primitive casadi constructs, and vica versa


Joris

st fn

unread,
Jan 3, 2019, 5:59:48 AM1/3/19
to CasADi
Were you able to use the generated c-code in any way? I have some struggle to load it as Casadi-function (I get some errors).
Reply all
Reply to author
Forward
0 new messages