René's URL Explorer Experiment


Title: Optimal control module by murrayrm · Pull Request #549 · python-control/python-control · GitHub

Open Graph Title: Optimal control module by murrayrm · Pull Request #549 · python-control/python-control

X Title: Optimal control module by murrayrm · Pull Request #549 · python-control/python-control

Description: 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!

Open Graph Description: 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 unde...

X Description: 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 unde...

Opengraph URL: https://github.com/python-control/python-control/pull/549

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:38e622ce-58ac-2304-2547-67e68a570c73
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id973C:3FA4EE:48B27A:62EAAD:697BD146
html-safe-nonce8f61e47cd4fcdca7098b12b00c0bcbf1461250e0f49f3bd169ff42b1d3101da3
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NzNDOjNGQTRFRTo0OEIyN0E6NjJFQUFEOjY5N0JEMTQ2IiwidmlzaXRvcl9pZCI6IjE0MTAxMDU2NDI3MDk2NjgxNjYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmaca682b693794f31df57a784f42551bcb65bbc7a335920c75e6aa53b146b2accbe
hovercard-subject-tagpull_request:577027033
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python-control/python-control/pull/549/files
twitter:imagehttps://avatars.githubusercontent.com/u/293362?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/293362?s=400&v=4
og:image:altThis 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 unde...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None88b7b3079ea5046bb661ad315dabef17ecc28e5f9f988d30044f4f6e56520728
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/python-control/python-control git https://github.com/python-control/python-control.git
octolytics-dimension-user_id2285872
octolytics-dimension-user_loginpython-control
octolytics-dimension-repository_id22791752
octolytics-dimension-repository_nwopython-control/python-control
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id22791752
octolytics-dimension-repository_network_root_nwopython-control/python-control
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release42cddef55c232612d1a39797b85abf955112a1b4
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python-control/python-control/pull/549/changes#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-control%2Fpython-control%2Fpull%2F549%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-control%2Fpython-control%2Fpull%2F549%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python-control%2Fpython-control
Reloadhttps://github.com/python-control/python-control/pull/549/changes
Reloadhttps://github.com/python-control/python-control/pull/549/changes
Reloadhttps://github.com/python-control/python-control/pull/549/changes
python-control https://github.com/python-control
python-controlhttps://github.com/python-control/python-control
Notifications https://github.com/login?return_to=%2Fpython-control%2Fpython-control
Fork 447 https://github.com/login?return_to=%2Fpython-control%2Fpython-control
Star 2k https://github.com/login?return_to=%2Fpython-control%2Fpython-control
Code https://github.com/python-control/python-control
Issues 87 https://github.com/python-control/python-control/issues
Pull requests 8 https://github.com/python-control/python-control/pulls
Discussions https://github.com/python-control/python-control/discussions
Actions https://github.com/python-control/python-control/actions
Projects 0 https://github.com/python-control/python-control/projects
Wiki https://github.com/python-control/python-control/wiki
Security 0 https://github.com/python-control/python-control/security
Insights https://github.com/python-control/python-control/pulse
Code https://github.com/python-control/python-control
Issues https://github.com/python-control/python-control/issues
Pull requests https://github.com/python-control/python-control/pulls
Discussions https://github.com/python-control/python-control/discussions
Actions https://github.com/python-control/python-control/actions
Projects https://github.com/python-control/python-control/projects
Wiki https://github.com/python-control/python-control/wiki
Security https://github.com/python-control/python-control/security
Insights https://github.com/python-control/python-control/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fpython-control%2Fpython-control%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython-control%2Fpython-control%2Fissues%2Fnew%2Fchoose
sawyerbfullerhttps://github.com/sawyerbfuller
python-control:masterhttps://github.com/python-control/python-control/tree/master
murrayrm:obchttps://github.com/murrayrm/python-control/tree/obc
Conversation 2 https://github.com/python-control/python-control/pull/549
Commits 18 https://github.com/python-control/python-control/pull/549/commits
Checks 0 https://github.com/python-control/python-control/pull/549/checks
Files changed https://github.com/python-control/python-control/pull/549/files
Please reload this pagehttps://github.com/python-control/python-control/pull/549/changes
Optimal control module https://github.com/python-control/python-control/pull/549/changes#top
Show all changes 18 commits https://github.com/python-control/python-control/pull/549/files
00297d6 draft unit test murrayrm Dec 28, 2020 https://github.com/python-control/python-control/pull/549/commits/00297d6881aa423c5dd30143e4b539691984d7c0
23cb793 convert to pytest murrayrm Dec 30, 2020 https://github.com/python-control/python-control/pull/549/commits/23cb793909b7bcb1cd040c8d4fb0971109d7a0c9
8711900 initial minimal implementation (working) murrayrm Feb 13, 2021 https://github.com/python-control/python-control/pull/549/commits/8711900e309e1c9a9f589383aa2982df52c82669
6f9c092 minor refactoring plus additional comments on method murrayrm Feb 13, 2021 https://github.com/python-control/python-control/pull/549/commits/6f9c092b26f0167c5f5f47ccdeb182475a835f5d
bd322e7 remove polytope dependence; implement MPC iosys w/ notebook example murrayrm Feb 15, 2021 https://github.com/python-control/python-control/pull/549/commits/bd322e7befd85e67492d87f87e5291bfcf800357
0d14642 add'l unit tests, cache sim results, equality constraint support murrayrm Feb 15, 2021 https://github.com/python-control/python-control/pull/549/commits/0d14642f22373ed22e4598d448b0482adc13060c
2456f36 slight code refactoring + docstrings + initial doc/obc.rst murrayrm Feb 16, 2021 https://github.com/python-control/python-control/pull/549/commits/2456f365057c96393d2ec93be7e49380b6bc9e5e
769eaa5 add info/debug messages + code refactor, result object murrayrm Feb 19, 2021 https://github.com/python-control/python-control/pull/549/commits/769eaa5ec980f7e46fc64e4182ad6af5f53e4e18
ea2884d slight refactoring of cost functions + example tweaks murrayrm Feb 20, 2021 https://github.com/python-control/python-control/pull/549/commits/ea2884d0287aa56d2ea6b4693b48868c10f20f62
9494092 rename obc to optimal, new examples/unit tests murrayrm Feb 20, 2021 https://github.com/python-control/python-control/pull/549/commits/94940927221a914738e612394d168ca61ec4a3d0
acc4439 update unit tests for speed and coverage murrayrm Feb 21, 2021 https://github.com/python-control/python-control/pull/549/commits/acc4439075acd50680b0bef9266e918f45a05339
5f261cc updated argument checking + unit tests (and coverage) + fixes murrayrm Feb 21, 2021 https://github.com/python-control/python-control/pull/549/commits/5f261ccb132801f079892f19cfe4daed8b0e0d0a
980fa5f PEP8 cleanup murrayrm Feb 21, 2021 https://github.com/python-control/python-control/pull/549/commits/980fa5f5ab0daf9e59aca375f7b448e165b05eab
7741fe9 add basis functions, solver options, examples/tests murrayrm Feb 27, 2021 https://github.com/python-control/python-control/pull/549/commits/7741fe9fbbd42dc99f4f6a1084d80c586dac925f
df91cac set up benchmarks/profiling via asv murrayrm Feb 27, 2021 https://github.com/python-control/python-control/pull/549/commits/df91cac6772f626df2ca3035b9a66d347f814e6d
d735f79 add unit tests for additional coverage murrayrm Feb 28, 2021 https://github.com/python-control/python-control/pull/549/commits/d735f794701a1eb5bab4230073eb4ce81ff55160
5838c2f clean up steering-optimal example murrayrm Feb 28, 2021 https://github.com/python-control/python-control/pull/549/commits/5838c2fa2da69cab46935d03a801be3ca63275d3
c49ee90 updated benchmarks + performance tweaks murrayrm Mar 1, 2021 https://github.com/python-control/python-control/pull/549/commits/c49ee9038e2e2d94f9d1b4937dba5c901687e7ff
Clear filters https://github.com/python-control/python-control/pull/549/files
Please reload this pagehttps://github.com/python-control/python-control/pull/549/changes
Please reload this pagehttps://github.com/python-control/python-control/pull/549/changes
.gitignore https://github.com/python-control/python-control/pull/549/changes#diff-bc37d034bad564583790a46f19d807abfe519c5671395fd494d8cce506c42947
asv.conf.json https://github.com/python-control/python-control/pull/549/changes#diff-d18ceac2def9772dfdf24d7a83cbe688bf5717e334108eff2aeb581d9992d531
README https://github.com/python-control/python-control/pull/549/changes#diff-369b4cda4f9a4786ca631e4e16f90d1d8c7e2bf868b1c71dc6c7df3a3e16a817
__init__.py https://github.com/python-control/python-control/pull/549/changes#diff-c154eee9decb8fc4aca2b76f877f3082419528ad848f3800074693860239d9f4
optimal_bench.py https://github.com/python-control/python-control/pull/549/changes#diff-6f5124f16143cce65ee38232c84268adec7f3929cae87765eaaa7176f3ecad4a
config.py https://github.com/python-control/python-control/pull/549/changes#diff-d1ad1d32d49067e21beadf8da713ffdea3d1673aedb13dbbf54028cb7e8e4cb5
__init__.py https://github.com/python-control/python-control/pull/549/changes#diff-dfc763bf9a1b4ad920c03e8c17e26c2b0774c15f2cdc77608bf29e2d6577660d
basis.py https://github.com/python-control/python-control/pull/549/changes#diff-4d1628be0ac467eeae964f0484605d32f083216773660fdfedb9d56c02a7748e
bezier.py https://github.com/python-control/python-control/pull/549/changes#diff-123c1531a9577a0e059978f323d4432428149ec4af2cfd52ea0e7c74549a78a6
iosys.py https://github.com/python-control/python-control/pull/549/changes#diff-12b378d96d36c9d59a9fbc5afbc7cc158d153ff7591b4769f8312772e1d74ed1
optimal.py https://github.com/python-control/python-control/pull/549/changes#diff-19ca2bf58874b6519164f42d62448fdcc1e05efe2b45263f6761f39392cdde01
config_test.py https://github.com/python-control/python-control/pull/549/changes#diff-5eadccfa15bf2713ea447a592131d9404915a826d9b41f54d5ef4b2631f24067
optimal_test.py https://github.com/python-control/python-control/pull/549/changes#diff-bca0c81c34fee75364f4e38c7cc0005a45ecd9fa9a40901c2b846f07945eb5d0
classes.rst https://github.com/python-control/python-control/pull/549/changes#diff-7ace42a025609df89447e9513968d95b8191259149e34bb7d088987aa28ec85e
examples.rst https://github.com/python-control/python-control/pull/549/changes#diff-2a75ce1d5fcc083639c4620bb785827882f0224ccb145a58160a42d248bde9e2
index.rst https://github.com/python-control/python-control/pull/549/changes#diff-3161f66a61b9ed68303607f1dbdce1c7bdcc69c42f8ea1c2051a07a579ebcf5d
mpc-overview.png https://github.com/python-control/python-control/pull/549/changes#diff-9ceb898ca0c5f2a27044fbd70a62fe72dc7647c49b0ae00259c10affd77ec156
mpc_aircraft.ipynb https://github.com/python-control/python-control/pull/549/changes#diff-d56ffa3fdcd2146049390ce749cb1e68cd1e8f9eefe7bd2059de155eef5c274c
optimal.rst https://github.com/python-control/python-control/pull/549/changes#diff-7a587fcc2ce0d45f27f08ebd590bad2db607818b399c646d0e2455ce96d9096e
steering-optimal.png https://github.com/python-control/python-control/pull/549/changes#diff-bbd943650d2701a97546b40a0db32d9e25214c42b79e03c02f69a29ad3c69cdc
mpc_aircraft.ipynb https://github.com/python-control/python-control/pull/549/changes#diff-9f8e75cf8d93cd8e6a5354ed142d2cdf9e8c802993f57def95fe1fab2a1b0d23
run_examples.sh https://github.com/python-control/python-control/pull/549/changes#diff-ba0c1386fea4628bfda91096e6901974e30ae63103ecf3148cb6d779a62310e1
steering-optimal.py https://github.com/python-control/python-control/pull/549/changes#diff-42a66769802bd9ec9593531800662a3bd5faf0962f113d6105ab81ad21791df8
.gitignorehttps://github.com/python-control/python-control/pull/549/changes#diff-bc37d034bad564583790a46f19d807abfe519c5671395fd494d8cce506c42947
View file https://github.com/murrayrm/python-control/blob/c49ee9038e2e2d94f9d1b4937dba5c901687e7ff/.gitignore
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python-control/python-control/pull/549/{{ revealButtonHref }}
https://github.com/python-control/python-control/pull/549/changes#diff-bc37d034bad564583790a46f19d807abfe519c5671395fd494d8cce506c42947
https://github.com/python-control/python-control/pull/549/changes#diff-bc37d034bad564583790a46f19d807abfe519c5671395fd494d8cce506c42947
asv.conf.jsonhttps://github.com/python-control/python-control/pull/549/changes#diff-d18ceac2def9772dfdf24d7a83cbe688bf5717e334108eff2aeb581d9992d531
View file https://github.com/murrayrm/python-control/blob/c49ee9038e2e2d94f9d1b4937dba5c901687e7ff/asv.conf.json
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python-control/python-control/pull/549/{{ revealButtonHref }}
benchmarks/READMEhttps://github.com/python-control/python-control/pull/549/changes#diff-369b4cda4f9a4786ca631e4e16f90d1d8c7e2bf868b1c71dc6c7df3a3e16a817
View file https://github.com/murrayrm/python-control/blob/c49ee9038e2e2d94f9d1b4937dba5c901687e7ff/benchmarks/README
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python-control/python-control/pull/549/{{ revealButtonHref }}
benchmarks/__init__.pyhttps://github.com/python-control/python-control/pull/549/changes#diff-c154eee9decb8fc4aca2b76f877f3082419528ad848f3800074693860239d9f4
View file https://github.com/murrayrm/python-control/blob/c49ee9038e2e2d94f9d1b4937dba5c901687e7ff/benchmarks/__init__.py
Open in desktop https://desktop.github.com
Please reload this pagehttps://github.com/python-control/python-control/pull/549/changes
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.