Rapid-Design-of-Systems-Laboratory / beluga

General purpose indirect trajectory optimization
Other
26 stars 6 forks source link

Use Sympy's lambdify to clean-up codegen #206

Closed SeanMatthewNolan closed 4 years ago

SeanMatthewNolan commented 5 years ago

Sympy has a built-in lambdify that should help make codegen cleaner.

SeanMatthewNolan commented 5 years ago

I have been really slow with this issue, but it is working pretty well now. There are significant speed increases. BFR now only takes 23 sec compared to 1 min 24 sec, Moonlander takes 1.9 sec compared to 3.9 sec, and Goddard Rocket takes 1.2 sec compared to 3.6 sec. I think this is due to more thorough compilation and maybe less variable copying. I need to finish things, so it passes everything. I am pretty sure custom functions will fail. @msparapa Look at it and see if you are happy with it.

msparapa commented 5 years ago

Sick! I'll need to check this out later tonight. It'll likely be an easy merge with my other changes.

msparapa commented 5 years ago

2 Things I noticed before I can merge this back into master.

  1. I didn't try custom functions, but maybe have a mode to fall back on when these cases appear.

  2. Shooting methods seem to be broken. I tried debugging it but couldn't get down to the bottom of it. The initial guess is generated just fine, but then the first iteration of shooting will crash. I tried this on brachistochrone and I suspect it is something in the compute control function. Maybe sqrt() is getting negative numbers? Not sure...

SeanMatthewNolan commented 5 years ago

Thanks, I know how I want to do custom functions; I just haven't yet. I am fixing shooting right now.

SeanMatthewNolan commented 4 years ago

I pushed the new codegen module.