Skip to content

Add collocation method for optimal control problems #799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 2, 2022

Conversation

murrayrm
Copy link
Member

@murrayrm murrayrm commented Nov 26, 2022

This PR changes the default way that optimal control problems are solved from using a shooting method to using collocation. This results in more robust (and faster) solutions, especially for trajectory generation for unstable or marginally stable systems (where shooting is very sensitive to small parameter variations).

The following new functionality is included:

  • The solve_ocp() function and OptimalControlProblem class have new parameters trajectory_method that be set to either shooting (default for discrete time systems) or collocation (default for continuous time systems).
  • When collocation is used, the initial_guess parameter can either be an input trajectory (as before) or a tuple consisting of a state trajectory and an input trajectory.
  • Constraints can now be specified in the form LinearConstraint(A, lb, ub) or NonlinearConstraint(fun, lb, ub) instead of the previous forms (LinearConstraint, A, lb, ub) and (NonlinearConstraint, fun, lb, ub). The legacy format is still supported.
  • The documentation (docstrings and manual) have been updated to reflect the new functionality.
  • New unit tests are included that tease out the functionality of the various possibilities.
  • Benchmarks comparing shooting and collocation have been added.

This PR also addresses issue #782 (see also discussion in #781) which were showing some of the weakness of the shooting methodology.

@coveralls
Copy link

coveralls commented Nov 26, 2022

Coverage Status

Coverage decreased (-0.03%) to 94.803% when pulling dd5e42d on murrayrm:fix_horizon-19Nov2022 into 4d89991 on python-control:main.

@murrayrm murrayrm force-pushed the fix_horizon-19Nov2022 branch from 27a200e to e0f71f4 Compare November 26, 2022 21:03
@murrayrm murrayrm added this to the 0.9.3 milestone Nov 27, 2022
@sawyerbfuller
Copy link
Contributor

LGTM

@murrayrm
Copy link
Member Author

murrayrm commented Dec 2, 2022

Updated the initial post to reflect the additional commits, so that we don't lose track of the changes.

@murrayrm murrayrm merged commit 9d65bf8 into python-control:main Dec 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

About the "horizon" parameter in the solve_ocp() method
3 participants