|
| OCPSolver (int numStates, int numInputs, std::chrono::duration< double > dt, int numSteps, function_ref< VariableMatrix(const VariableMatrix &x, const VariableMatrix &u)> dynamics, DynamicsType dynamicsType=DynamicsType::kExplicitODE, TimestepMethod timestepMethod=TimestepMethod::kFixed, TranscriptionMethod method=TranscriptionMethod::kDirectTranscription) |
|
| OCPSolver (int numStates, int numInputs, std::chrono::duration< double > dt, int numSteps, function_ref< VariableMatrix(const Variable &t, const VariableMatrix &x, const VariableMatrix &u, const Variable &dt)> dynamics, DynamicsType dynamicsType=DynamicsType::kExplicitODE, TimestepMethod timestepMethod=TimestepMethod::kFixed, TranscriptionMethod method=TranscriptionMethod::kDirectTranscription) |
|
template<typename T >
requires ScalarLike<T> || MatrixLike<T> |
void | ConstrainInitialState (const T &initialState) |
|
template<typename T >
requires ScalarLike<T> || MatrixLike<T> |
void | ConstrainFinalState (const T &finalState) |
|
void | ForEachStep (const function_ref< void(const VariableMatrix &x, const VariableMatrix &u)> callback) |
|
void | ForEachStep (const function_ref< void(const Variable &t, const VariableMatrix &x, const VariableMatrix &u, const Variable &dt)> callback) |
|
template<typename T >
requires ScalarLike<T> || MatrixLike<T> |
void | SetLowerInputBound (const T &lowerBound) |
|
template<typename T >
requires ScalarLike<T> || MatrixLike<T> |
void | SetUpperInputBound (const T &upperBound) |
|
void | SetMinTimestep (std::chrono::duration< double > minTimestep) |
|
void | SetMaxTimestep (std::chrono::duration< double > maxTimestep) |
|
VariableMatrix & | X () |
|
VariableMatrix & | U () |
|
VariableMatrix & | DT () |
|
VariableMatrix | InitialState () |
|
VariableMatrix | FinalState () |
|
| OptimizationProblem () noexcept=default |
|
Variable | DecisionVariable () |
|
VariableMatrix | DecisionVariable (int rows, int cols=1) |
|
VariableMatrix | SymmetricDecisionVariable (int rows) |
|
void | Minimize (const Variable &cost) |
|
void | Minimize (Variable &&cost) |
|
void | Maximize (const Variable &objective) |
|
void | Maximize (Variable &&objective) |
|
void | SubjectTo (const EqualityConstraints &constraint) |
|
void | SubjectTo (EqualityConstraints &&constraint) |
|
void | SubjectTo (const InequalityConstraints &constraint) |
|
void | SubjectTo (InequalityConstraints &&constraint) |
|
SolverStatus | Solve (const SolverConfig &config=SolverConfig{}) |
|
template<typename F >
requires requires(F callback, const SolverIterationInfo& info) { { callback(info) } -> std::same_as<void>; } |
void | Callback (F &&callback) |
|
template<typename F >
requires requires(F callback, const SolverIterationInfo& info) { { callback(info) } -> std::same_as<bool>; } |
void | Callback (F &&callback) |
|
This class allows the user to pose and solve a constrained optimal control problem (OCP) in a variety of ways.
The system is transcripted by one of three methods (direct transcription, direct collocation, or single-shooting) and additional constraints can be added.
In direct transcription, each state is a decision variable constrained to the integrated dynamics of the previous state. In direct collocation, the trajectory is modeled as a series of cubic polynomials where the centerpoint slope is constrained. In single-shooting, states depend explicitly as a function of all previous states and all previous inputs.
Explicit ODEs are integrated using RK4.
For explicit ODEs, the function must be in the form dx/dt = f(t, x, u). For discrete state transition functions, the function must be in the form xₖ₊₁ = f(t, xₖ, uₖ).
Direct collocation requires an explicit ODE. Direct transcription and single-shooting can use either an ODE or state transition function.
https://underactuated.mit.edu/trajopt.html goes into more detail on each transcription method.