Optimal control module#549
Merged
sawyerbfuller merged 18 commits intopython-control:masterfrom Mar 2, 2021
Merged
Conversation
Contributor
|
This is super cool. Having these features conveniently in the library (rather than having to roll your own optimal controller) seems like it could facilitate incorporating these more advanced controls concepts into the digital controls class I teach, whcih is something I've been wanting to do. I probably won't be able to try your version before it's merged with the master branch, but I'll let you know if I encounter any issues once it is and I've gotten a chance to try it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a new optimal control module,
control.optimal, that implements finite horizon optimal control problems with constraints, including rudimentary model predictive control (MPC). The underlying algorithms are not super-efficient, so this is more of a "reference implementation" than something that you could use on a large problem, but it does allow you to explore ideas around tradeoffs in various types of cost functions, constraints, and other concepts. The PR includes unit tests and documentation on the use of the module.(The motivation for this PR is that I'll be teaching an optimal control class next year, and I'd like to have some tools around that students can use to get a feel for the concepts. The hope is to implement most of the concepts that are in my (very incomplete) notes on "Optimization-Based Control".)
A few notes (for feedback):
control.optimaland it is not loaded by default. So, like thescipy.optimizepackage, you have to load the module separately if you want to use it (control.flatsysis also like this, so there is a precedent). I'm initially called the moduleobc(for optimization-based control, but decided thatoptimalwas probably better (and matchedoptimize`, used in SciPy).scipy.optimize.minimizefunction: it essentially takes the element of an optimal control problem and creates an optimization problem for SciPy to solve. For this reason I have tried to make things consistent withscipy.optimizewhen possible (eg, the form of constraints, the way results are returned).examples/steering-optimal.pyscript, which takes about 30 seconds to do solve some pretty straightforward problems.It also takes about 15 seconds forcontrol/tests/optimal_test.pyto run on my Mac, which can get annoying (a fullpytestrun takes about a 45 seconds, so this is 30% for just one module).Other changes along the way:
config.pyparsing function_get_param.flatsys, though only a partial implementation (needed for examples of optimizing over a set of basis functions).benchmarkdirectory with some airspeed velocity (asv) benchmarks for optimal control. These are mainly for development purposes, but might be something we use more generally at a future date.Comments and advice welcome!