qpmad
Eigen-based C++ QP solver.
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Static Private Member Functions | List of all members
qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number > Class Template Reference

Detailed Description

template<typename t_Scalar, int t_primal_size, int t_has_bounds, int t_general_ctr_number>
class qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >

Definition at line 32 of file implementation.h.

#include <implementation.h>

Public Types

enum  ReturnStatus { OK = 0 , MAXIMAL_NUMBER_OF_ITERATIONS = 4 , UNDEFINED = -1 }
 
template<int t_rows>
using Vector = Eigen::Matrix< t_Scalar, t_rows, 1 >
 
template<int t_rows, int t_cols>
using Matrix = Eigen::Matrix< t_Scalar, t_rows, t_cols >
 
using Scalar = t_Scalar
 

Public Member Functions

 SolverBase ()
 
SolverParameters::HessianType getHessianType () const
 Returns type of the Hessian produced by the latest execution of solve(). More...
 
std::ptrdiff_t getNumberOfInequalityIterations () const
 Returns number of inequality iterations during the latest execution of solve(). More...
 
template<int t_status_size, int t_dual_size, int t_index_size>
void getInequalityDual (Vector< t_dual_size > &dual, Eigen::Matrix< MatrixIndex, t_index_size, 1 > &indices, Eigen::Matrix< bool, t_status_size, 1 > &is_lower) const
 Returns dual variables (Lagrange multipliers) corresponding to inequality constraints. Must be called after successful solve(), the result is undefined if previous call to solve() failed. More...
 
void reserve (const MatrixIndex primal_size, const MatrixIndex num_simple_bounds, const MatrixIndex num_general_constraints)
 

Protected Types

using MatrixRef = Eigen::Ref< Eigen::Matrix< t_Scalar, Eigen::Dynamic, Eigen::Dynamic > >
 
using VectorRef = Eigen::Ref< Eigen::Matrix< t_Scalar, Eigen::Dynamic, 1 > >
 

Protected Member Functions

template<class t_primal , class t_H , class t_h , class t_lb , class t_ub , class t_A , class t_Alb , class t_Aub >
ReturnStatus solveGeneric (t_primal &primal, t_H &H, const t_h &h, const t_lb &lb, const t_ub &ub, const t_A &A, const t_Alb &Alb, const t_Aub &Aub, const SolverParameters &param)
 

Protected Attributes

Vector< t_primal_size > dual_
 
Vector< t_primal_size > primal_step_direction_
 
Vector< t_primal_size > dual_step_direction_
 
ActiveSet< t_primal_size > active_set_
 
FactorizationData< t_Scalar, t_primal_size > factorization_data_
 
MatrixIndex primal_size_
 
MatrixIndex h_size_
 
MatrixIndex num_simple_bounds_
 
MatrixIndex num_general_constraints_
 
MatrixIndex num_constraints_
 
Vector< t_general_ctr_number > general_ctr_dot_primal_
 
std::ptrdiff_t iter_counter_
 
ChosenConstraint chosen_ctr_
 
SolverParameters::HessianType hessian_type_
 
bool machinery_initialized_
 
Eigen::Array< uint8_t, num_constraints_compile_time_, 1 > constraints_status_
 

Static Protected Attributes

static const MatrixIndex num_constraints_compile_time_
 

Private Member Functions

void reserveMachinery (const MatrixIndex primal_size, const MatrixIndex num_general_constraints)
 
void reserveDual (const MatrixIndex primal_size)
 
template<class t_MatrixType >
void initializeMachineryLazy (t_MatrixType &H, const bool return_inverted_cholesky_factor)
 
template<class t_Primal , class t_LowerBounds , class t_UpperBounds , class t_Constraints , class t_ConstraintsLowerBounds , class t_ConstraintsUpperBounds >
void chooseConstraint (const t_Primal &primal, const t_LowerBounds &lb, const t_UpperBounds &ub, const t_Constraints &A, const t_ConstraintsLowerBounds &Alb, const t_ConstraintsUpperBounds &Aub, const double tolerance)
 
void checkConstraintViolation (const MatrixIndex i, const double lb_i, const double ub_i, const double ctr_i_dot_primal)
 
template<class t_VectorType , class t_MatrixType >
double getConstraintDotPrimalStepDirection (const t_VectorType &primal_step_direction, const t_MatrixType &A) const
 
template<class t_primal >
void setZero (t_primal &primal)
 
void setZero (VectorRef primal)
 

Static Private Member Functions

template<int... t_Other>
static void factorizeCholeskyInPlace (Eigen::Matrix< t_Scalar, t_Other... > &H)
 
static void factorizeCholeskyInPlace (MatrixRef &H)
 
template<int t_Options, typename t_StorageIndex >
static void factorizeCholeskyInPlace (Eigen::SparseMatrix< t_Scalar, t_Options, t_StorageIndex > &H)
 

Member Typedef Documentation

◆ Matrix

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
template<int t_rows, int t_cols>
using qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::Matrix = Eigen::Matrix<t_Scalar, t_rows, t_cols>

Definition at line 45 of file implementation.h.

◆ MatrixRef

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
using qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::MatrixRef = Eigen::Ref<Eigen::Matrix<t_Scalar, Eigen::Dynamic, Eigen::Dynamic> >
protected

Definition at line 50 of file implementation.h.

◆ Scalar

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
using qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::Scalar = t_Scalar
Deprecated:

Definition at line 46 of file implementation.h.

◆ Vector

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
template<int t_rows>
using qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::Vector = Eigen::Matrix<t_Scalar, t_rows, 1>

Definition at line 43 of file implementation.h.

◆ VectorRef

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
using qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::VectorRef = Eigen::Ref<Eigen::Matrix<t_Scalar, Eigen::Dynamic, 1> >
protected

Definition at line 51 of file implementation.h.

Member Enumeration Documentation

◆ ReturnStatus

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
enum qpmad::SolverBase::ReturnStatus
Enumerator
OK 
MAXIMAL_NUMBER_OF_ITERATIONS 
UNDEFINED 

Definition at line 35 of file implementation.h.

Constructor & Destructor Documentation

◆ SolverBase()

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::SolverBase ( )
inline

Definition at line 90 of file implementation.h.

Member Function Documentation

◆ checkConstraintViolation()

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
void qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::checkConstraintViolation ( const MatrixIndex  i,
const double  lb_i,
const double  ub_i,
const double  ctr_i_dot_primal 
)
inlineprivate

Definition at line 689 of file implementation.h.

◆ chooseConstraint()

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
template<class t_Primal , class t_LowerBounds , class t_UpperBounds , class t_Constraints , class t_ConstraintsLowerBounds , class t_ConstraintsUpperBounds >
void qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::chooseConstraint ( const t_Primal &  primal,
const t_LowerBounds &  lb,
const t_UpperBounds &  ub,
const t_Constraints &  A,
const t_ConstraintsLowerBounds &  Alb,
const t_ConstraintsUpperBounds &  Aub,
const double  tolerance 
)
inlineprivate

Definition at line 644 of file implementation.h.

◆ factorizeCholeskyInPlace() [1/3]

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
template<int... t_Other>
static void qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::factorizeCholeskyInPlace ( Eigen::Matrix< t_Scalar, t_Other... > &  H)
inlinestaticprivate

Definition at line 729 of file implementation.h.

◆ factorizeCholeskyInPlace() [2/3]

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
template<int t_Options, typename t_StorageIndex >
static void qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::factorizeCholeskyInPlace ( Eigen::SparseMatrix< t_Scalar, t_Options, t_StorageIndex > &  H)
inlinestaticprivate

Definition at line 744 of file implementation.h.

◆ factorizeCholeskyInPlace() [3/3]

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
static void qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::factorizeCholeskyInPlace ( MatrixRef H)
inlinestaticprivate

Definition at line 736 of file implementation.h.

◆ getConstraintDotPrimalStepDirection()

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
template<class t_VectorType , class t_MatrixType >
double qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::getConstraintDotPrimalStepDirection ( const t_VectorType &  primal_step_direction,
const t_MatrixType &  A 
) const
inlineprivate

Definition at line 714 of file implementation.h.

◆ getHessianType()

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
SolverParameters::HessianType qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::getHessianType ( ) const
inline

Returns type of the Hessian produced by the latest execution of solve().

Definition at line 107 of file implementation.h.

◆ getInequalityDual()

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
template<int t_status_size, int t_dual_size, int t_index_size>
void qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::getInequalityDual ( Vector< t_dual_size > &  dual,
Eigen::Matrix< MatrixIndex, t_index_size, 1 > &  indices,
Eigen::Matrix< bool, t_status_size, 1 > &  is_lower 
) const
inline

Returns dual variables (Lagrange multipliers) corresponding to inequality constraints. Must be called after successful solve(), the result is undefined if previous call to solve() failed.

Template Parameters
t_status_size
t_dual_size
t_index_size
Parameters
[out]dualdual variables
[out]indicesconstraint indices corresponding to the dual variables, index 0 corresponds to the first simple bound if present or to the first general constraint otherwise
[out]is_lowerflags indicating if lower or upper bound is active

Definition at line 141 of file implementation.h.

◆ getNumberOfInequalityIterations()

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
std::ptrdiff_t qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::getNumberOfInequalityIterations ( ) const
inline

Returns number of inequality iterations during the latest execution of solve().

Definition at line 117 of file implementation.h.

◆ initializeMachineryLazy()

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
template<class t_MatrixType >
void qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::initializeMachineryLazy ( t_MatrixType &  H,
const bool  return_inverted_cholesky_factor 
)
inlineprivate

Definition at line 620 of file implementation.h.

◆ reserve()

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
void qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::reserve ( const MatrixIndex  primal_size,
const MatrixIndex  num_simple_bounds,
const MatrixIndex  num_general_constraints 
)
inline

Definition at line 173 of file implementation.h.

◆ reserveDual()

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
void qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::reserveDual ( const MatrixIndex  primal_size)
inlineprivate

Definition at line 612 of file implementation.h.

◆ reserveMachinery()

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
void qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::reserveMachinery ( const MatrixIndex  primal_size,
const MatrixIndex  num_general_constraints 
)
inlineprivate

Definition at line 602 of file implementation.h.

◆ setZero() [1/2]

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
template<class t_primal >
void qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::setZero ( t_primal &  primal)
inlineprivate

Definition at line 754 of file implementation.h.

◆ setZero() [2/2]

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
void qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::setZero ( VectorRef  primal)
inlineprivate

Definition at line 759 of file implementation.h.

◆ solveGeneric()

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
template<class t_primal , class t_H , class t_h , class t_lb , class t_ub , class t_A , class t_Alb , class t_Aub >
ReturnStatus qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::solveGeneric ( t_primal &  primal,
t_H &  H,
const t_h &  h,
const t_lb &  lb,
const t_ub &  ub,
const t_A &  A,
const t_Alb &  Alb,
const t_Aub &  Aub,
const SolverParameters param 
)
inlineprotected

Definition at line 186 of file implementation.h.

Member Data Documentation

◆ active_set_

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
ActiveSet<t_primal_size> qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::active_set_
protected

Definition at line 60 of file implementation.h.

◆ chosen_ctr_

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
ChosenConstraint qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::chosen_ctr_
protected

Definition at line 80 of file implementation.h.

◆ constraints_status_

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
Eigen::Array<uint8_t, num_constraints_compile_time_, 1> qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::constraints_status_
protected

Definition at line 85 of file implementation.h.

◆ dual_

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
Vector<t_primal_size> qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::dual_
protected

Definition at line 55 of file implementation.h.

◆ dual_step_direction_

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
Vector<t_primal_size> qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::dual_step_direction_
protected

Definition at line 58 of file implementation.h.

◆ factorization_data_

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
FactorizationData<t_Scalar, t_primal_size> qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::factorization_data_
protected

Definition at line 61 of file implementation.h.

◆ general_ctr_dot_primal_

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
Vector<t_general_ctr_number> qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::general_ctr_dot_primal_
protected

Definition at line 77 of file implementation.h.

◆ h_size_

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
MatrixIndex qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::h_size_
protected

Definition at line 64 of file implementation.h.

◆ hessian_type_

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
SolverParameters::HessianType qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::hessian_type_
protected

Definition at line 82 of file implementation.h.

◆ iter_counter_

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
std::ptrdiff_t qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::iter_counter_
protected

Definition at line 79 of file implementation.h.

◆ machinery_initialized_

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
bool qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::machinery_initialized_
protected

Definition at line 83 of file implementation.h.

◆ num_constraints_

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
MatrixIndex qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::num_constraints_
protected

Definition at line 67 of file implementation.h.

◆ num_constraints_compile_time_

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
const MatrixIndex qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::num_constraints_compile_time_
staticprotected
Initial value:
=
Eigen::Dynamic == t_general_ctr_number ?
Eigen::Dynamic :
(0 == t_has_bounds ? t_general_ctr_number :
(Eigen::Dynamic == t_primal_size ? Eigen::Dynamic :
t_general_ctr_number + t_primal_size))

Definition at line 69 of file implementation.h.

◆ num_general_constraints_

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
MatrixIndex qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::num_general_constraints_
protected

Definition at line 66 of file implementation.h.

◆ num_simple_bounds_

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
MatrixIndex qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::num_simple_bounds_
protected

Definition at line 65 of file implementation.h.

◆ primal_size_

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
MatrixIndex qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::primal_size_
protected

Definition at line 63 of file implementation.h.

◆ primal_step_direction_

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
Vector<t_primal_size> qpmad::SolverBase< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::primal_step_direction_
protected

Definition at line 57 of file implementation.h.


The documentation for this class was generated from the following file: