GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Optimal control module by murrayrm · Pull Request #549 · python-control/python-control

Conversation

@murrayrm

@murrayrm murrayrm commented Feb 21, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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):

  • I have called the module control.optimal and it is not loaded by default. So, like the scipy.optimize package, you have to load the module separately if you want to use it (control.flatsys is also like this, so there is a precedent). I'm initially called the module obc (for optimization-based control, but decided that optimalwas probably better (and matchedoptimize`, used in SciPy).
  • The module is basically just a wrapper around the scipy.optimize.minimize function: 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 with scipy.optimize when possible (eg, the form of constraints, the way results are returned).
  • The unit tests are a bit finicky and seem to depend on what system they are tested on. Everything is working in GitHub Actions, but you'll see some conditional checks in the code for things that work differently there versus my local machine. For this reason, it would be useful if people can try things out on other platforms and let me know what happens.
  • Finally, as noted already above, the code is not super efficient, particularly for continuous time systems. You'll see this if you run the examples/steering-optimal.py script, which takes about 30 seconds to do solve some pretty straightforward problems. It also takes about 15 seconds for control/tests/optimal_test.py to run on my Mac, which can get annoying (a full pytest run takes about a 45 seconds, so this is 30% for just one module).

Other changes along the way:

  • Added in some functionality to check for unrecognized keywords in the config.py parsing function _get_param.
  • 28 Feb 2021: Added a new 'bezier' basis function in flatsys, though only a partial implementation (needed for examples of optimizing over a set of basis functions).
  • 28 Feb 2021: Added a benchmark directory 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!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@murrayrm
murrayrm marked this pull request as draft February 21, 2021 00:24
@coveralls

coveralls commented Feb 21, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.07%) to 88.861% when pulling c49ee90 on murrayrm:obc into 8cba949 on python-control:master.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@murrayrm murrayrm mentioned this pull request Feb 22, 2021
Add code to check for unrecognized keywords associated with default settings #528
Closed
@sawyerbfuller

sawyerbfuller commented Feb 23, 2021

Copy link
Copy Markdown
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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@murrayrm murrayrm mentioned this pull request Feb 25, 2021
Release 0.8.4 and 0.9.0 sequencing #451
Closed
murrayrm added 18 commits February 26, 2021 22:46
@murrayrm
draft unit test
00297d6
@murrayrm
convert to pytest
23cb793
@murrayrm
initial minimal implementation (working)
8711900
@murrayrm
minor refactoring plus additional comments on method
6f9c092
@murrayrm
remove polytope dependence; implement MPC iosys w/ notebook example
bd322e7
@murrayrm
add'l unit tests, cache sim results, equality constraint support
0d14642
@murrayrm
slight code refactoring + docstrings + initial doc/obc.rst
2456f36
@murrayrm
add info/debug messages + code refactor, result object
769eaa5
@murrayrm
slight refactoring of cost functions + example tweaks
ea2884d
@murrayrm
rename obc to optimal, new examples/unit tests
9494092
@murrayrm
update unit tests for speed and coverage
acc4439
@murrayrm
updated argument checking + unit tests (and coverage) + fixes
5f261cc
@murrayrm
PEP8 cleanup
980fa5f
@murrayrm
add basis functions, solver options, examples/tests
7741fe9
@murrayrm
set up benchmarks/profiling via asv
df91cac
@murrayrm
add unit tests for additional coverage
d735f79
@murrayrm
clean up steering-optimal example
5838c2f
@murrayrm
updated benchmarks + performance tweaks
c49ee90
@murrayrm
murrayrm force-pushed the obc branch from a396286 to c49ee90 Compare March 1, 2021 06:13
@murrayrm
murrayrm marked this pull request as ready for review March 1, 2021 21:39
@sawyerbfuller
sawyerbfuller merged commit 66d4a53 into python-control:master Mar 2, 2021
@murrayrm
murrayrm deleted the obc branch March 3, 2021 02:56
@murrayrm murrayrm mentioned this pull request Mar 11, 2021
new dynamics() and output() methods in StateSpace #546
Closed
@murrayrm murrayrm added this to the 0.9.0 milestone Mar 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

0.9.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@murrayrm @coveralls @sawyerbfuller
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.