WPILibC++ 2027.0.0-alpha-2
Loading...
Searching...
No Matches
slp Namespace Reference

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< Variablemake_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 PoolResourceglobal_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
 

Enumeration Type Documentation

◆ DynamicsType

enum class slp::DynamicsType : uint8_t
strong

Enum describing a type of system dynamics constraints.

Enumerator
EXPLICIT_ODE 

The dynamics are a function in the form dx/dt = f(t, x, u).

DISCRETE 

The dynamics are a function in the form xₖ₊₁ = f(t, xₖ, uₖ).

◆ ExitStatus

enum class slp::ExitStatus : int8_t
strong

Solver exit status.

Negative values indicate failure.

Enumerator
SUCCESS 

Solved the problem to the desired tolerance.

CALLBACK_REQUESTED_STOP 

The solver returned its solution so far after the user requested a stop.

TOO_FEW_DOFS 

The solver determined the problem to be overconstrained and gave up.

LOCALLY_INFEASIBLE 

The solver determined the problem to be locally infeasible and gave up.

GLOBALLY_INFEASIBLE 

The problem setup frontend determined the problem to have an empty feasible region.

FACTORIZATION_FAILED 

The linear system factorization failed.

LINE_SEARCH_FAILED 

The backtracking line search failed, and the problem isn't locally infeasible.

NONFINITE_INITIAL_COST_OR_CONSTRAINTS 

The solver encountered nonfinite initial cost or constraints and gave up.

DIVERGING_ITERATES 

The solver encountered diverging primal iterates xₖ and/or sₖ and gave up.

MAX_ITERATIONS_EXCEEDED 

The solver returned its solution so far after exceeding the maximum number of iterations.

TIMEOUT 

The solver returned its solution so far after exceeding the maximum elapsed wall clock time.

◆ ExpressionType

enum class slp::ExpressionType : uint8_t
strong

Expression type.

Used for autodiff caching.

Enumerator
NONE 

There is no expression.

CONSTANT 

The expression is a constant.

LINEAR 

The expression is composed of linear and lower-order operators.

QUADRATIC 

The expression is composed of quadratic and lower-order operators.

NONLINEAR 

The expression is composed of nonlinear and lower-order operators.

◆ TimestepMethod

enum class slp::TimestepMethod : uint8_t
strong

Enum describing the type of system timestep.

Enumerator
FIXED 

The timestep is a fixed constant.

VARIABLE 

The timesteps are allowed to vary as independent decision variables.

VARIABLE_SINGLE 

The timesteps are equal length but allowed to vary as a single decision variable.

◆ TranscriptionMethod

enum class slp::TranscriptionMethod : uint8_t
strong

Enum describing an OCP transcription method.

Enumerator
DIRECT_TRANSCRIPTION 

Each state is a decision variable constrained to the integrated dynamics of the previous state.

DIRECT_COLLOCATION 

The trajectory is modeled as a series of cubic polynomials where the centerpoint slope is constrained.

SINGLE_SHOOTING 

States depend explicitly as a function of all previous states and all previous inputs.

Function Documentation

◆ abs()

SLEIPNIR_DLLEXPORT Variable slp::abs ( const Variable & x)
inline

std::abs() for Variables.

Parameters
xThe argument.

◆ acos()

SLEIPNIR_DLLEXPORT Variable slp::acos ( const Variable & x)
inline

std::acos() for Variables.

Parameters
xThe argument.

◆ allocate_intrusive_shared()

template<typename T , typename Alloc , typename... Args>
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.

Template Parameters
TType of object for intrusive shared pointer.
AllocType of allocator for T.
ArgsTypes of constructor arguments.
Parameters
allocThe allocator for T.
argsConstructor arguments for T.

◆ asin()

SLEIPNIR_DLLEXPORT Variable slp::asin ( const Variable & x)
inline

std::asin() for Variables.

Parameters
xThe argument.

◆ atan()

SLEIPNIR_DLLEXPORT Variable slp::atan ( const Variable & x)
inline

std::atan() for Variables.

Parameters
xThe argument.

◆ atan2()

SLEIPNIR_DLLEXPORT Variable slp::atan2 ( const Variable & y,
const Variable & x )
inline

std::atan2() for Variables.

Parameters
yThe y argument.
xThe x argument.

◆ block() [1/2]

SLEIPNIR_DLLEXPORT VariableMatrix slp::block ( const std::vector< std::vector< VariableMatrix > > & list)
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.

Parameters
listThe nested list of blocks.

◆ block() [2/2]

SLEIPNIR_DLLEXPORT VariableMatrix slp::block ( std::initializer_list< std::initializer_list< VariableMatrix > > list)
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.

Parameters
listThe nested list of blocks.

◆ cos()

SLEIPNIR_DLLEXPORT Variable slp::cos ( const Variable & x)
inline

std::cos() for Variables.

Parameters
xThe argument.

◆ cosh()

SLEIPNIR_DLLEXPORT Variable slp::cosh ( const Variable & x)
inline

std::cosh() for Variables.

Parameters
xThe argument.

◆ cwise_reduce()

SLEIPNIR_DLLEXPORT VariableMatrix slp::cwise_reduce ( const VariableMatrix & lhs,
const VariableMatrix & rhs,
function_ref< Variable(const Variable &x, const Variable &y)> binary_op )
inline

Applies a coefficient-wise reduce operation to two matrices.

Parameters
lhsThe left-hand side of the binary operator.
rhsThe right-hand side of the binary operator.
binary_opThe binary operator to use for the reduce operation.

◆ erf()

SLEIPNIR_DLLEXPORT Variable slp::erf ( const Variable & x)
inline

std::erf() for Variables.

Parameters
xThe argument.

◆ exp()

SLEIPNIR_DLLEXPORT Variable slp::exp ( const Variable & x)
inline

std::exp() for Variables.

Parameters
xThe argument.

◆ function_ref()

template<typename R , typename... Args>
slp::function_ref ( R(*  )(Args...)) -> function_ref< R(Args...)>

◆ global_pool_allocator()

template<typename T >
PoolAllocator< T > slp::global_pool_allocator ( )

Returns an allocator for a global pool memory resource.

Template Parameters
TThe type of object in the pool.

◆ global_pool_resource()

SLEIPNIR_DLLEXPORT PoolResource & slp::global_pool_resource ( )

Returns a global pool memory resource.

◆ hypot() [1/2]

SLEIPNIR_DLLEXPORT Variable slp::hypot ( const Variable & x,
const Variable & y )
inline

std::hypot() for Variables.

Parameters
xThe x argument.
yThe y argument.

◆ hypot() [2/2]

SLEIPNIR_DLLEXPORT Variable slp::hypot ( const Variable & x,
const Variable & y,
const Variable & z )
inline

std::hypot() for Variables.

Parameters
xThe x argument.
yThe y argument.
zThe z argument.

◆ interior_point()

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.

Parameters
[in]matrix_callbacksMatrix callbacks.
[in]iteration_callbacksThe list of callbacks to call at the beginning of each iteration.
[in]optionsSolver options.
[in,out]xThe initial guess and output location for the decision variables.
Returns
The exit status.

◆ log()

SLEIPNIR_DLLEXPORT Variable slp::log ( const Variable & x)
inline

std::log() for Variables.

Parameters
xThe argument.

◆ log10()

SLEIPNIR_DLLEXPORT Variable slp::log10 ( const Variable & x)
inline

std::log10() for Variables.

Parameters
xThe argument.

◆ make_constraints()

template<typename LHS , typename RHS >
requires (ScalarLike<LHS> || MatrixLike<LHS>) && (ScalarLike<RHS> || MatrixLike<RHS>) && (SleipnirType<LHS> || SleipnirType<RHS>)
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.

Parameters
lhsLeft-hand side.
rhsRight-hand side.

◆ make_intrusive_shared()

template<typename T , typename... Args>
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.

Template Parameters
TType of object for intrusive shared pointer.
ArgsTypes of constructor arguments.
Parameters
argsConstructor arguments for T.

◆ Multistart()

template<typename DecisionVariables >
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.

Template Parameters
DecisionVariablesThe type containing the decision variable initial guess.
Parameters
solveA user-provided function that takes a decision variable initial guess and returns a MultistartResult.
initial_guessesA list of decision variable initial guesses to try.

◆ newton()

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.

Parameters
[in]matrix_callbacksMatrix callbacks.
[in]iteration_callbacksThe list of callbacks to call at the beginning of each iteration.
[in]optionsSolver options.
[in,out]xThe initial guess and output location for the decision variables.
Returns
The exit status.

◆ operator<()

template<typename LHS , typename RHS >
requires (ScalarLike<LHS> || MatrixLike<LHS>) && (ScalarLike<RHS> || MatrixLike<RHS>) && (SleipnirType<LHS> || SleipnirType<RHS>)
InequalityConstraints slp::operator< ( LHS && lhs,
RHS && rhs )

Less-than comparison operator that returns an inequality constraint for two Variables.

Parameters
lhsLeft-hand side.
rhsLeft-hand side.

◆ operator<=()

template<typename LHS , typename RHS >
requires (ScalarLike<LHS> || MatrixLike<LHS>) && (ScalarLike<RHS> || MatrixLike<RHS>) && (SleipnirType<LHS> || SleipnirType<RHS>)
InequalityConstraints slp::operator<= ( LHS && lhs,
RHS && rhs )

Less-than-or-equal-to comparison operator that returns an inequality constraint for two Variables.

Parameters
lhsLeft-hand side.
rhsLeft-hand side.

◆ operator==()

template<typename LHS , typename RHS >
requires (ScalarLike<LHS> || MatrixLike<LHS>) && (ScalarLike<RHS> || MatrixLike<RHS>) && (SleipnirType<LHS> || SleipnirType<RHS>)
EqualityConstraints slp::operator== ( LHS && lhs,
RHS && rhs )

Equality operator that returns an equality constraint for two Variables.

Parameters
lhsLeft-hand side.
rhsLeft-hand side.

◆ operator>()

template<typename LHS , typename RHS >
requires (ScalarLike<LHS> || MatrixLike<LHS>) && (ScalarLike<RHS> || MatrixLike<RHS>) && (SleipnirType<LHS> || SleipnirType<RHS>)
InequalityConstraints slp::operator> ( LHS && lhs,
RHS && rhs )

Greater-than comparison operator that returns an inequality constraint for two Variables.

Parameters
lhsLeft-hand side.
rhsLeft-hand side.

◆ operator>=()

template<typename LHS , typename RHS >
requires (ScalarLike<LHS> || MatrixLike<LHS>) && (ScalarLike<RHS> || MatrixLike<RHS>) && (SleipnirType<LHS> || SleipnirType<RHS>)
InequalityConstraints slp::operator>= ( LHS && lhs,
RHS && rhs )

Greater-than-or-equal-to comparison operator that returns an inequality constraint for two Variables.

Parameters
lhsLeft-hand side.
rhsLeft-hand side.

◆ pow()

SLEIPNIR_DLLEXPORT Variable slp::pow ( const Variable & base,
const Variable & power )
inline

std::pow() for Variables.

Parameters
baseThe base.
powerThe power.

◆ print() [1/2]

template<typename... T>
void slp::print ( fmt::format_string< T... > fmt,
T &&... args )
inline

Wrapper around fmt::print() that squelches write failure exceptions.

◆ print() [2/2]

template<typename... T>
void slp::print ( std::FILE * f,
fmt::format_string< T... > fmt,
T &&... args )
inline

Wrapper around fmt::print() that squelches write failure exceptions.

◆ println() [1/2]

template<typename... T>
void slp::println ( fmt::format_string< T... > fmt,
T &&... args )
inline

Wrapper around fmt::println() that squelches write failure exceptions.

◆ println() [2/2]

template<typename... T>
void slp::println ( std::FILE * f,
fmt::format_string< T... > fmt,
T &&... args )
inline

Wrapper around fmt::println() that squelches write failure exceptions.

◆ rk4()

template<typename F , typename State , typename Input , typename Time >
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.

Parameters
fThe function to integrate. It must take two arguments x and u.
xThe initial value of x.
uThe value u held constant over the integration period.
t0The initial time.
dtThe time over which to integrate.

◆ sign()

SLEIPNIR_DLLEXPORT Variable slp::sign ( const Variable & x)
inline

sign() for Variables.

Parameters
xThe argument.

◆ sin()

SLEIPNIR_DLLEXPORT Variable slp::sin ( const Variable & x)
inline

std::sin() for Variables.

Parameters
xThe argument.

◆ sinh()

SLEIPNIR_DLLEXPORT Variable slp::sinh ( const Variable & x)
inline

std::sinh() for Variables.

Parameters
xThe argument.

◆ solve()

SLEIPNIR_DLLEXPORT VariableMatrix slp::solve ( const VariableMatrix & A,
const VariableMatrix & B )

Solves the VariableMatrix equation AX = B for X.

Parameters
AThe left-hand side.
BThe right-hand side.
Returns
The solution X.

◆ sqp()

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.

Parameters
[in]matrix_callbacksMatrix callbacks.
[in]iteration_callbacksThe list of callbacks to call at the beginning of each iteration.
[in]optionsSolver options.
[in,out]xThe initial guess and output location for the decision variables.
Returns
The exit status.

◆ sqrt()

SLEIPNIR_DLLEXPORT Variable slp::sqrt ( const Variable & x)
inline

std::sqrt() for Variables.

Parameters
xThe argument.

◆ swap()

template<typename R , typename... Args>
void slp::swap ( function_ref< R(Args...)> & lhs,
function_ref< R(Args...)> & rhs )
constexprnoexcept

Swaps the referred callables of lhs and rhs.

◆ tan()

SLEIPNIR_DLLEXPORT Variable slp::tan ( const Variable & x)
inline

std::tan() for Variables.

Parameters
xThe argument.

◆ tanh()

SLEIPNIR_DLLEXPORT Variable slp::tanh ( const Variable & x)
inline

std::tanh() for Variables.

Parameters
xThe argument.

◆ to_message() [1/2]

SLEIPNIR_DLLEXPORT constexpr std::string_view slp::to_message ( const ExitStatus & exit_status)
constexpr

Returns user-readable message corresponding to the solver exit status.

Parameters
exit_statusSolver exit status.

◆ to_message() [2/2]

SLEIPNIR_DLLEXPORT constexpr std::string_view slp::to_message ( const ExpressionType & type)
constexpr

Returns user-readable message corresponding to the expression type.

Parameters
typeExpression type.

Variable Documentation

◆ Hessian

template<int UpLo = Eigen::Lower | Eigen::Upper>
class SLEIPNIR_DLLEXPORT slp::Hessian

◆ Jacobian

class SLEIPNIR_DLLEXPORT slp::Jacobian