-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sluggish ALTROSolver function #30
Comments
In my case, it took about 1 hour and 15 min to run the |
Can you provide some more details on your problem setup? What are the dimensions of your problem? I've never had a solver take that long to initialize. |
@bjack205 I am actually trying to write the updated version of your the RA-L code and extend it. with a rigid body load. The original implementation was in the early version of TrajectoryOptimization.jl and it ran quite fast, but had to use the newer version of RobotDynamics.jl for time-varying models. Now, I believe my nested (quadrotors and load inside the batch model) dynamics model takes a lot of allocations. (about 35285 allocations for I have also used SVectors for states and controls. Do you think maybe I can reduce these allocations using other data types for my dynamics model? The Thank you for your fast reply. |
I pushed changes to both Btw, with 100 trajectory segments, it only took about 2 minutes to initialize before, and now it takes about 8 seconds. I'm not sure how it was taking over an hour for you unless you're running on a computer with very limited resources or have an extremely high number of segments. |
Thank you for the updates. I will try the newer versions and let you know here and share the Yeah, I am also confused about this. By trajectory segments, do you mean the number of Knotpoints? But I guess I am scratching the surface of this :) |
Just a quick note so we're on the same page, your issue is with initializing the solver? Or the solve in general? Solver initialization should be independent of the dynamics implementation, since it's only allocating memory based on the state dimension, control dimension, and horizon (number of knotpoints). If 1st time initialization is the issue, Also, as a general comment, DDP-based algorithms like ALTRO are ill-suited to deal with system with lots of sparsity in the dynamics. The team-lift paper we wrote a while back avoided this issue using some relatively naive approaches of splitting the problem into smaller, dense problems over each of the individual dynamics. Also, it might be worth special-casing your dynamics Jacobian using the chain rule and using ForwardDiff (usually much faster than FiniteDiff.jl) for the individual models. For large problems, the computation time is often dominated by the time to calculate the dynamics Jacobians, so make sure that is dialed in. |
I just tested the updates, and At first, my problem was with I have put I also tried to test with 2 knot points to see if I could get through the solution without overloading my RAM, but it seems the number of Knot-points doesn't affect the issue. I am now trying to reproduce the batch problem of that paper with the newest versions of the packages, and interestingly the batch problem was fast to compute with TrajectoryOptimization.jl version 0.1.0 . Regarding special-casing to ForwadDiff, I suppose that's the default option, isn't it? I saw that FiniteDiff is used in RobotDynamics.jl and ALtro to make I hope we will fix this issue; I might have to revert to version 0.1 and write the time-varying models from RobotDynamics to the older version. Please let me know what you think and what the issue could be. |
The biggest difference with the new version is that it uses StaticArrays throughout (usually SizedArrays, which simply wrap a normal array in a fixed size). This gives massive wins for small to medium-sized problems but can lead to large precompilation times for larger sizes. Apparently I haven't successfully eliminated instances where it tried to convert a A couple things to try:
As for the dynamics Jacobians, the default is ForwardDiff, but it will diff through the batch dynamics, which is wasteful when you have lots of sparsity in your dynamics. Instead, it'll probably be faster to diff through each of the models and then use the chain rule to get the batch dynamics Jacobian. I don't have a lot of free time to address this, but if you are able to find the bottlenecks for compilation time during the initial part of the solve, please submit a PR. |
Sure, I will try to apply the points you mentioned in the following days and let you know about the results. |
It was odd that this command takes a long time to execute fully and make the solver object.
I was wondering if there is a way to make this command to be executed faster.
@bjack205
What are the critical factors determining the speed of this command?
Many thanks,
The text was updated successfully, but these errors were encountered: