Add collocation method for optimal control problems by murrayrm · Pull Request #799 · python-control/python-control
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 andOptimalControlProblemclass have new parameterstrajectory_methodthat be set to eithershooting(default for discrete time systems) orcollocation(default for continuous time systems). - When collocation is used, the
initial_guessparameter 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)orNonlinearConstraint(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.