Title: Constrained MPC: Differences to MATLAB and Numeric Issues for different OS · Issue #929 · python-control/python-control · GitHub
Open Graph Title: Constrained MPC: Differences to MATLAB and Numeric Issues for different OS · Issue #929 · python-control/python-control
X Title: Constrained MPC: Differences to MATLAB and Numeric Issues for different OS · Issue #929 · python-control/python-control
Description: In the context of a masters course on constrained optimal control, we were looking to implement the classic cart-pendulum example, with a hard state constraint on the angle of the pendulum. Our implementation followed the constrained MPC...
Open Graph Description: In the context of a masters course on constrained optimal control, we were looking to implement the classic cart-pendulum example, with a hard state constraint on the angle of the pendulum. Our imp...
X Description: In the context of a masters course on constrained optimal control, we were looking to implement the classic cart-pendulum example, with a hard state constraint on the angle of the pendulum. Our imp...
Opengraph URL: https://github.com/python-control/python-control/issues/929
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Constrained MPC: Differences to MATLAB and Numeric Issues for different OS","articleBody":"In the context of a masters course on constrained optimal control, we were looking to implement the classic cart-pendulum example, with a hard state constraint on the angle of the pendulum. Our implementation followed the constrained MPC [aircraft model](https://python-control.readthedocs.io/en/0.9.4/mpc_aircraft.html) example.\r\n\r\nDuring our implementation we observed that the output control sequences from the “optimal.solve_ocp” were different than from MATLAB’s “mpcActiveSetSolver” for the same model, stage cost, and prediction horizon. The following are the control sequences at time 0:\r\nsolve_ocp: 8.085e-01 1.464e-02 4.912e-01 7.621e-01 5.672e-01 5.080e-01 4.151e-01 2.398e-01 0.000e+00 0.000e+00\r\nMATLAB: 0.8750 -0.1281 0.6964 0.7551 0.7363 0.7937 0.6934 0.6644 0.6041 0.4130\r\n\r\nWe also observed that the output from “input_output_response” simulation differed based on platform (Windows vs Linux/MacOS). On Linux/MacOS the optimiser would fail to meet the state constraints, while this behaviour does not occur on Windows.\r\n\r\nI have included an implementation of our code in both Python and in JupyterLab, environment package lists, plots of the constrained state, and a comparison version in MATLAB: [MPC_PythonControl_Analysis.zip](https://github.com/python-control/python-control/files/12534268/MPC_PythonControl_Analysis.zip)\r\n\r\n\r\nAre there any plans for classic MPC implementation for the cost function to directly compute the state predictions using the discrete-time linear dynamics rather than numerically computed using the trapezoid rule (line 311-322 in optimal.py)?\r\n \r\nAre you able to provide any advice or guidance on why the numeric simulation result is different between OS versions?\r\n\r\n\r\n\r\n","author":{"url":"https://github.com/JMK593","@type":"Person","name":"JMK593"},"datePublished":"2023-09-06T06:52:54.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":11},"url":"https://github.com/929/python-control/issues/929"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:00faa7d8-4e72-2a9c-1b8a-6788c2ac889b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C892:32FD5:23888E6:2FE5C75:697ABFEA |
| html-safe-nonce | 970ae1f0b98c969848414ea5253c74fc52b9f06766e508d006f58cb5c8a3d3de |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDODkyOjMyRkQ1OjIzODg4RTY6MkZFNUM3NTo2OTdBQkZFQSIsInZpc2l0b3JfaWQiOiIyNzI3MjQ3MzA5MjMzMTExMDE4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 8e17382c28ce228e9cd57ab3338a1feacf55c3ca6b26c55c55a7a91f1cb70ac4 |
| hovercard-subject-tag | issue:1883363423 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-control/python-control/929/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1493a01497903e770d730c385d04964851f51bcdc00adccb131c697e574cf9af/python-control/python-control/issues/929 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1493a01497903e770d730c385d04964851f51bcdc00adccb131c697e574cf9af/python-control/python-control/issues/929 |
| og:image:alt | In the context of a masters course on constrained optimal control, we were looking to implement the classic cart-pendulum example, with a hard state constraint on the angle of the pendulum. Our imp... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JMK593 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 37b00135a01848812420158e49744eb9715c1ef534ee4552f790d6ef33807fc2 |
| turbo-cache-control | no-preview |
| go-import | github.com/python-control/python-control git https://github.com/python-control/python-control.git |
| octolytics-dimension-user_id | 2285872 |
| octolytics-dimension-user_login | python-control |
| octolytics-dimension-repository_id | 22791752 |
| octolytics-dimension-repository_nwo | python-control/python-control |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 22791752 |
| octolytics-dimension-repository_network_root_nwo | python-control/python-control |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 78685bd12c01954e3a0e08fc52173e9b3e48215d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width