![]() |
WPILibC++ 2027.0.0-alpha-2
|
Namespaces | |
namespace | detail |
namespace | slicing |
Classes | |
struct | EqualityConstraints |
A vector of equality constraints of the form cₑ(x) = 0. More... | |
class | function_ref |
class | function_ref< R(Args...)> |
An implementation of std::function_ref, a lightweight non-owning reference to a callable. More... | |
class | Gradient |
This class calculates the gradient of a a variable with respect to a vector of variables. More... | |
class | Hessian |
This class calculates the Hessian of a variable with respect to a vector of variables. More... | |
struct | InequalityConstraints |
A vector of inequality constraints of the form cᵢ(x) ≥ 0. More... | |
struct | InteriorPointMatrixCallbacks |
Matrix callbacks for the interior-point method solver. More... | |
class | IntrusiveSharedPtr |
A custom intrusive shared pointer implementation without thread synchronization overhead. More... | |
struct | IterationInfo |
Solver iteration information exposed to an iteration callback. More... | |
class | Jacobian |
This class calculates the Jacobian of a vector of variables with respect to a vector of variables. More... | |
struct | MultistartResult |
The result of a multistart solve. More... | |
struct | NewtonMatrixCallbacks |
Matrix callbacks for the Newton's method solver. More... | |
class | OCP |
This class allows the user to pose and solve a constrained optimal control problem (OCP) in a variety of ways. More... | |
struct | Options |
Solver options. More... | |
class | PoolAllocator |
This class is an allocator for the pool resource. More... | |
class | PoolResource |
This class implements a pool memory resource. More... | |
class | Problem |
This class allows the user to pose a constrained nonlinear optimization problem in natural mathematical notation and solve it. More... | |
class | Slice |
Represents a sequence of elements in an iterable object. More... | |
class | Spy |
Writes the sparsity pattern of a sparse matrix to a file. More... | |
struct | SQPMatrixCallbacks |
Matrix callbacks for the Sequential Quadratic Programming (SQP) solver. More... | |
class | Variable |
An autodiff variable pointing to an expression node. More... | |
class | VariableBlock |
A submatrix of autodiff variables with reference semantics. More... | |
class | VariableMatrix |
A matrix of autodiff variables. More... | |
Concepts | |
concept | ScalarLike |
concept | SleipnirScalarLike |
concept | EigenMatrixLike |
concept | SleipnirMatrixLike |
concept | SleipnirType |
concept | MatrixLike |
Enumerations | |
enum class | TranscriptionMethod : uint8_t { DIRECT_TRANSCRIPTION , DIRECT_COLLOCATION , SINGLE_SHOOTING } |
Enum describing an OCP transcription method. More... | |
enum class | DynamicsType : uint8_t { EXPLICIT_ODE , DISCRETE } |
Enum describing a type of system dynamics constraints. More... | |
enum class | TimestepMethod : uint8_t { FIXED , VARIABLE , VARIABLE_SINGLE } |
Enum describing the type of system timestep. More... | |
enum class | ExitStatus : int8_t { SUCCESS = 0 , CALLBACK_REQUESTED_STOP = 1 , TOO_FEW_DOFS = -1 , LOCALLY_INFEASIBLE = -2 , GLOBALLY_INFEASIBLE = -3 , FACTORIZATION_FAILED = -4 , LINE_SEARCH_FAILED = -5 , NONFINITE_INITIAL_COST_OR_CONSTRAINTS = -6 , DIVERGING_ITERATES = -7 , MAX_ITERATIONS_EXCEEDED = -8 , TIMEOUT = -9 } |
Solver exit status. More... | |
enum class | ExpressionType : uint8_t { NONE , CONSTANT , LINEAR , QUADRATIC , NONLINEAR } |
Expression type. More... | |
Functions | |
template<typename T , typename... Args> | |
IntrusiveSharedPtr< T > | make_intrusive_shared (Args &&... args) |
Constructs an object of type T and wraps it in an intrusive shared pointer using args as the parameter list for the constructor of T. | |
template<typename T , typename Alloc , typename... Args> | |
IntrusiveSharedPtr< T > | allocate_intrusive_shared (Alloc alloc, Args &&... args) |
Constructs an object of type T and wraps it in an intrusive shared pointer using alloc as the storage allocator of T and args as the parameter list for the constructor of T. | |
SLEIPNIR_DLLEXPORT VariableMatrix | cwise_reduce (const VariableMatrix &lhs, const VariableMatrix &rhs, function_ref< Variable(const Variable &x, const Variable &y)> binary_op) |
Applies a coefficient-wise reduce operation to two matrices. | |
SLEIPNIR_DLLEXPORT VariableMatrix | block (std::initializer_list< std::initializer_list< VariableMatrix > > list) |
Assemble a VariableMatrix from a nested list of blocks. | |
SLEIPNIR_DLLEXPORT VariableMatrix | block (const std::vector< std::vector< VariableMatrix > > &list) |
Assemble a VariableMatrix from a nested list of blocks. | |
SLEIPNIR_DLLEXPORT VariableMatrix | solve (const VariableMatrix &A, const VariableMatrix &B) |
Solves the VariableMatrix equation AX = B for X. | |
template<typename R , typename... Args> | |
constexpr void | swap (function_ref< R(Args...)> &lhs, function_ref< R(Args...)> &rhs) noexcept |
Swaps the referred callables of lhs and rhs . | |
template<typename R , typename... Args> | |
function_ref (R(*)(Args...)) -> function_ref< R(Args...)> | |
SLEIPNIR_DLLEXPORT Variable | abs (const Variable &x) |
std::abs() for Variables. | |
SLEIPNIR_DLLEXPORT Variable | acos (const Variable &x) |
std::acos() for Variables. | |
SLEIPNIR_DLLEXPORT Variable | asin (const Variable &x) |
std::asin() for Variables. | |
SLEIPNIR_DLLEXPORT Variable | atan (const Variable &x) |
std::atan() for Variables. | |
SLEIPNIR_DLLEXPORT Variable | atan2 (const Variable &y, const Variable &x) |
std::atan2() for Variables. | |
SLEIPNIR_DLLEXPORT Variable | cos (const Variable &x) |
std::cos() for Variables. | |
SLEIPNIR_DLLEXPORT Variable | cosh (const Variable &x) |
std::cosh() for Variables. | |
SLEIPNIR_DLLEXPORT Variable | erf (const Variable &x) |
std::erf() for Variables. | |
SLEIPNIR_DLLEXPORT Variable | exp (const Variable &x) |
std::exp() for Variables. | |
SLEIPNIR_DLLEXPORT Variable | hypot (const Variable &x, const Variable &y) |
std::hypot() for Variables. | |
SLEIPNIR_DLLEXPORT Variable | pow (const Variable &base, const Variable &power) |
std::pow() for Variables. | |
SLEIPNIR_DLLEXPORT Variable | log (const Variable &x) |
std::log() for Variables. | |
SLEIPNIR_DLLEXPORT Variable | log10 (const Variable &x) |
std::log10() for Variables. | |
SLEIPNIR_DLLEXPORT Variable | sign (const Variable &x) |
sign() for Variables. | |
SLEIPNIR_DLLEXPORT Variable | sin (const Variable &x) |
std::sin() for Variables. | |
SLEIPNIR_DLLEXPORT Variable | sinh (const Variable &x) |
std::sinh() for Variables. | |
SLEIPNIR_DLLEXPORT Variable | sqrt (const Variable &x) |
std::sqrt() for Variables. | |
SLEIPNIR_DLLEXPORT Variable | tan (const Variable &x) |
std::tan() for Variables. | |
SLEIPNIR_DLLEXPORT Variable | tanh (const Variable &x) |
std::tanh() for Variables. | |
SLEIPNIR_DLLEXPORT Variable | hypot (const Variable &x, const Variable &y, const Variable &z) |
std::hypot() for Variables. | |
template<typename LHS , typename RHS > requires (ScalarLike<LHS> || MatrixLike<LHS>) && (ScalarLike<RHS> || MatrixLike<RHS>) && (SleipnirType<LHS> || SleipnirType<RHS>) | |
gch::small_vector< Variable > | make_constraints (LHS &&lhs, RHS &&rhs) |
Make a list of constraints. | |
template<typename LHS , typename RHS > requires (ScalarLike<LHS> || MatrixLike<LHS>) && (ScalarLike<RHS> || MatrixLike<RHS>) && (SleipnirType<LHS> || SleipnirType<RHS>) | |
EqualityConstraints | operator== (LHS &&lhs, RHS &&rhs) |
Equality operator that returns an equality constraint for two Variables. | |
template<typename LHS , typename RHS > requires (ScalarLike<LHS> || MatrixLike<LHS>) && (ScalarLike<RHS> || MatrixLike<RHS>) && (SleipnirType<LHS> || SleipnirType<RHS>) | |
InequalityConstraints | operator< (LHS &&lhs, RHS &&rhs) |
Less-than comparison operator that returns an inequality constraint for two Variables. | |
template<typename LHS , typename RHS > requires (ScalarLike<LHS> || MatrixLike<LHS>) && (ScalarLike<RHS> || MatrixLike<RHS>) && (SleipnirType<LHS> || SleipnirType<RHS>) | |
InequalityConstraints | operator<= (LHS &&lhs, RHS &&rhs) |
Less-than-or-equal-to comparison operator that returns an inequality constraint for two Variables. | |
template<typename LHS , typename RHS > requires (ScalarLike<LHS> || MatrixLike<LHS>) && (ScalarLike<RHS> || MatrixLike<RHS>) && (SleipnirType<LHS> || SleipnirType<RHS>) | |
InequalityConstraints | operator> (LHS &&lhs, RHS &&rhs) |
Greater-than comparison operator that returns an inequality constraint for two Variables. | |
template<typename LHS , typename RHS > requires (ScalarLike<LHS> || MatrixLike<LHS>) && (ScalarLike<RHS> || MatrixLike<RHS>) && (SleipnirType<LHS> || SleipnirType<RHS>) | |
InequalityConstraints | operator>= (LHS &&lhs, RHS &&rhs) |
Greater-than-or-equal-to comparison operator that returns an inequality constraint for two Variables. | |
SLEIPNIR_DLLEXPORT PoolResource & | global_pool_resource () |
Returns a global pool memory resource. | |
template<typename T > | |
PoolAllocator< T > | global_pool_allocator () |
Returns an allocator for a global pool memory resource. | |
SLEIPNIR_DLLEXPORT ExitStatus | newton (const NewtonMatrixCallbacks &matrix_callbacks, std::span< std::function< bool(const IterationInfo &info)> > iteration_callbacks, const Options &options, Eigen::VectorXd &x) |
Finds the optimal solution to a nonlinear program using Newton's method. | |
SLEIPNIR_DLLEXPORT ExitStatus | sqp (const SQPMatrixCallbacks &matrix_callbacks, std::span< std::function< bool(const IterationInfo &info)> > iteration_callbacks, const Options &options, Eigen::VectorXd &x) |
Finds the optimal solution to a nonlinear program using Sequential Quadratic Programming (SQP). | |
SLEIPNIR_DLLEXPORT ExitStatus | interior_point (const InteriorPointMatrixCallbacks &matrix_callbacks, std::span< std::function< bool(const IterationInfo &info)> > iteration_callbacks, const Options &options, Eigen::VectorXd &x) |
Finds the optimal solution to a nonlinear program using the interior-point method. | |
template<typename... T> | |
void | print (fmt::format_string< T... > fmt, T &&... args) |
Wrapper around fmt::print() that squelches write failure exceptions. | |
template<typename... T> | |
void | print (std::FILE *f, fmt::format_string< T... > fmt, T &&... args) |
Wrapper around fmt::print() that squelches write failure exceptions. | |
template<typename... T> | |
void | println (fmt::format_string< T... > fmt, T &&... args) |
Wrapper around fmt::println() that squelches write failure exceptions. | |
template<typename... T> | |
void | println (std::FILE *f, fmt::format_string< T... > fmt, T &&... args) |
Wrapper around fmt::println() that squelches write failure exceptions. | |
template<typename F , typename State , typename Input , typename Time > | |
State | rk4 (F &&f, State x, Input u, Time t0, Time dt) |
Performs 4th order Runge-Kutta integration of dx/dt = f(t, x, u) for dt. | |
SLEIPNIR_DLLEXPORT constexpr std::string_view | to_message (const ExitStatus &exit_status) |
Returns user-readable message corresponding to the solver exit status. | |
SLEIPNIR_DLLEXPORT constexpr std::string_view | to_message (const ExpressionType &type) |
Returns user-readable message corresponding to the expression type. | |
template<typename DecisionVariables > | |
MultistartResult< DecisionVariables > | Multistart (function_ref< MultistartResult< DecisionVariables >(const DecisionVariables &initial_guess)> solve, std::span< const DecisionVariables > initial_guesses) |
Solves an optimization problem from different starting points in parallel, then returns the solution with the lowest cost. | |
Variables | |
template<int UpLo = Eigen::Lower | Eigen::Upper> | |
class SLEIPNIR_DLLEXPORT | Hessian |
class SLEIPNIR_DLLEXPORT | Jacobian |
|
strong |
|
strong |
Solver exit status.
Negative values indicate failure.
|
strong |
Expression type.
Used for autodiff caching.
|
strong |
|
strong |
Enum describing an OCP transcription method.
|
inline |
std::abs() for Variables.
x | The argument. |
|
inline |
std::acos() for Variables.
x | The argument. |
IntrusiveSharedPtr< T > slp::allocate_intrusive_shared | ( | Alloc | alloc, |
Args &&... | args ) |
Constructs an object of type T and wraps it in an intrusive shared pointer using alloc as the storage allocator of T and args as the parameter list for the constructor of T.
T | Type of object for intrusive shared pointer. |
Alloc | Type of allocator for T. |
Args | Types of constructor arguments. |
alloc | The allocator for T. |
args | Constructor arguments for T. |
|
inline |
std::asin() for Variables.
x | The argument. |
|
inline |
std::atan() for Variables.
x | The argument. |
|
inline |
std::atan2() for Variables.
y | The y argument. |
x | The x argument. |
|
inline |
Assemble a VariableMatrix from a nested list of blocks.
Each row's blocks must have the same height, and the assembled block rows must have the same width. For example, for the block matrix [[A, B], [C]] to be constructible, the number of rows in A and B must match, and the number of columns in [A, B] and [C] must match.
This overload is for Python bindings only.
list | The nested list of blocks. |
|
inline |
Assemble a VariableMatrix from a nested list of blocks.
Each row's blocks must have the same height, and the assembled block rows must have the same width. For example, for the block matrix [[A, B], [C]] to be constructible, the number of rows in A and B must match, and the number of columns in [A, B] and [C] must match.
list | The nested list of blocks. |
|
inline |
std::cos() for Variables.
x | The argument. |
|
inline |
std::cosh() for Variables.
x | The argument. |
|
inline |
Applies a coefficient-wise reduce operation to two matrices.
lhs | The left-hand side of the binary operator. |
rhs | The right-hand side of the binary operator. |
binary_op | The binary operator to use for the reduce operation. |
|
inline |
std::erf() for Variables.
x | The argument. |
|
inline |
std::exp() for Variables.
x | The argument. |
slp::function_ref | ( | R(* | )(Args...) | ) | -> function_ref< R(Args...)> |
PoolAllocator< T > slp::global_pool_allocator | ( | ) |
Returns an allocator for a global pool memory resource.
T | The type of object in the pool. |
SLEIPNIR_DLLEXPORT PoolResource & slp::global_pool_resource | ( | ) |
Returns a global pool memory resource.
|
inline |
std::hypot() for Variables.
x | The x argument. |
y | The y argument. |
|
inline |
std::hypot() for Variables.
x | The x argument. |
y | The y argument. |
z | The z argument. |
SLEIPNIR_DLLEXPORT ExitStatus slp::interior_point | ( | const InteriorPointMatrixCallbacks & | matrix_callbacks, |
std::span< std::function< bool(const IterationInfo &info)> > | iteration_callbacks, | ||
const Options & | options, | ||
Eigen::VectorXd & | x ) |
Finds the optimal solution to a nonlinear program using the interior-point method.
A nonlinear program has the form:
min_x f(x) subject to cₑ(x) = 0 cᵢ(x) ≥ 0
where f(x) is the cost function, cₑ(x) are the equality constraints, and cᵢ(x) are the inequality constraints.
[in] | matrix_callbacks | Matrix callbacks. |
[in] | iteration_callbacks | The list of callbacks to call at the beginning of each iteration. |
[in] | options | Solver options. |
[in,out] | x | The initial guess and output location for the decision variables. |
|
inline |
std::log() for Variables.
x | The argument. |
|
inline |
std::log10() for Variables.
x | The argument. |
gch::small_vector< Variable > slp::make_constraints | ( | LHS && | lhs, |
RHS && | rhs ) |
Make a list of constraints.
The standard form for equality constraints is c(x) = 0, and the standard form for inequality constraints is c(x) ≥ 0. This function takes constraints of the form lhs = rhs or lhs ≥ rhs and converts them to lhs - rhs = 0 or lhs - rhs ≥ 0.
lhs | Left-hand side. |
rhs | Right-hand side. |
IntrusiveSharedPtr< T > slp::make_intrusive_shared | ( | Args &&... | args | ) |
Constructs an object of type T and wraps it in an intrusive shared pointer using args as the parameter list for the constructor of T.
T | Type of object for intrusive shared pointer. |
Args | Types of constructor arguments. |
args | Constructor arguments for T. |
MultistartResult< DecisionVariables > slp::Multistart | ( | function_ref< MultistartResult< DecisionVariables >(const DecisionVariables &initial_guess)> | solve, |
std::span< const DecisionVariables > | initial_guesses ) |
Solves an optimization problem from different starting points in parallel, then returns the solution with the lowest cost.
Each solve is performed on a separate thread. Solutions from successful solves are always preferred over solutions from unsuccessful solves, and cost (lower is better) is the tiebreaker between successful solves.
DecisionVariables | The type containing the decision variable initial guess. |
solve | A user-provided function that takes a decision variable initial guess and returns a MultistartResult. |
initial_guesses | A list of decision variable initial guesses to try. |
SLEIPNIR_DLLEXPORT ExitStatus slp::newton | ( | const NewtonMatrixCallbacks & | matrix_callbacks, |
std::span< std::function< bool(const IterationInfo &info)> > | iteration_callbacks, | ||
const Options & | options, | ||
Eigen::VectorXd & | x ) |
Finds the optimal solution to a nonlinear program using Newton's method.
A nonlinear program has the form:
min_x f(x)
where f(x) is the cost function.
[in] | matrix_callbacks | Matrix callbacks. |
[in] | iteration_callbacks | The list of callbacks to call at the beginning of each iteration. |
[in] | options | Solver options. |
[in,out] | x | The initial guess and output location for the decision variables. |
InequalityConstraints slp::operator< | ( | LHS && | lhs, |
RHS && | rhs ) |
Less-than comparison operator that returns an inequality constraint for two Variables.
lhs | Left-hand side. |
rhs | Left-hand side. |
InequalityConstraints slp::operator<= | ( | LHS && | lhs, |
RHS && | rhs ) |
Less-than-or-equal-to comparison operator that returns an inequality constraint for two Variables.
lhs | Left-hand side. |
rhs | Left-hand side. |
EqualityConstraints slp::operator== | ( | LHS && | lhs, |
RHS && | rhs ) |
Equality operator that returns an equality constraint for two Variables.
lhs | Left-hand side. |
rhs | Left-hand side. |
InequalityConstraints slp::operator> | ( | LHS && | lhs, |
RHS && | rhs ) |
Greater-than comparison operator that returns an inequality constraint for two Variables.
lhs | Left-hand side. |
rhs | Left-hand side. |
InequalityConstraints slp::operator>= | ( | LHS && | lhs, |
RHS && | rhs ) |
Greater-than-or-equal-to comparison operator that returns an inequality constraint for two Variables.
lhs | Left-hand side. |
rhs | Left-hand side. |
|
inline |
std::pow() for Variables.
base | The base. |
power | The power. |
|
inline |
Wrapper around fmt::print() that squelches write failure exceptions.
|
inline |
Wrapper around fmt::print() that squelches write failure exceptions.
|
inline |
Wrapper around fmt::println() that squelches write failure exceptions.
|
inline |
Wrapper around fmt::println() that squelches write failure exceptions.
State slp::rk4 | ( | F && | f, |
State | x, | ||
Input | u, | ||
Time | t0, | ||
Time | dt ) |
Performs 4th order Runge-Kutta integration of dx/dt = f(t, x, u) for dt.
f | The function to integrate. It must take two arguments x and u. |
x | The initial value of x. |
u | The value u held constant over the integration period. |
t0 | The initial time. |
dt | The time over which to integrate. |
|
inline |
sign() for Variables.
x | The argument. |
|
inline |
std::sin() for Variables.
x | The argument. |
|
inline |
std::sinh() for Variables.
x | The argument. |
SLEIPNIR_DLLEXPORT VariableMatrix slp::solve | ( | const VariableMatrix & | A, |
const VariableMatrix & | B ) |
Solves the VariableMatrix equation AX = B for X.
A | The left-hand side. |
B | The right-hand side. |
SLEIPNIR_DLLEXPORT ExitStatus slp::sqp | ( | const SQPMatrixCallbacks & | matrix_callbacks, |
std::span< std::function< bool(const IterationInfo &info)> > | iteration_callbacks, | ||
const Options & | options, | ||
Eigen::VectorXd & | x ) |
Finds the optimal solution to a nonlinear program using Sequential Quadratic Programming (SQP).
A nonlinear program has the form:
min_x f(x) subject to cₑ(x) = 0
where f(x) is the cost function and cₑ(x) are the equality constraints.
[in] | matrix_callbacks | Matrix callbacks. |
[in] | iteration_callbacks | The list of callbacks to call at the beginning of each iteration. |
[in] | options | Solver options. |
[in,out] | x | The initial guess and output location for the decision variables. |
|
inline |
std::sqrt() for Variables.
x | The argument. |
|
constexprnoexcept |
Swaps the referred callables of lhs
and rhs
.
|
inline |
std::tan() for Variables.
x | The argument. |
|
inline |
std::tanh() for Variables.
x | The argument. |
|
constexpr |
Returns user-readable message corresponding to the solver exit status.
exit_status | Solver exit status. |
|
constexpr |
Returns user-readable message corresponding to the expression type.
type | Expression type. |
class SLEIPNIR_DLLEXPORT slp::Hessian |
class SLEIPNIR_DLLEXPORT slp::Jacobian |