qpmad
Eigen-based C++ QP solver.
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | List of all members
qpmad::SolverTemplate< 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::SolverTemplate< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >

Definition at line 31 of file solver.h.

#include <solver.h>

Inheritance diagram for qpmad::SolverTemplate< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >:
qpmad::InputParser

Public Types

enum  ReturnStatus { OK = 0, MAXIMAL_NUMBER_OF_ITERATIONS = 4 }
 
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 >
 

Public Member Functions

 SolverTemplate ()
 
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...
 
template<int t_rows_primal, int t_rows_H, int t_cols_H, int t_rows_h, int t_rows_A, int t_cols_A, int t_rows_Alb, int t_rows_Aub>
ReturnStatus solve (Vector< t_rows_primal > &primal, Matrix< t_rows_H, t_cols_H > &H, const Vector< t_rows_h > &h, const Matrix< t_rows_A, t_cols_A > &A, const Vector< t_rows_Alb > &Alb, const Vector< t_rows_Aub > &Aub)
 
template<int t_rows_primal, int t_rows_H, int t_cols_H, int t_rows_h, int t_rows_lb, int t_rows_ub, int t_rows_A, int t_cols_A, int t_rows_Alb, int t_rows_Aub>
ReturnStatus solve (Vector< t_rows_primal > &primal, Matrix< t_rows_H, t_cols_H > &H, const Vector< t_rows_h > &h, const Vector< t_rows_lb > &lb, const Vector< t_rows_ub > &ub, const Matrix< t_rows_A, t_cols_A > &A, const Vector< t_rows_Alb > &Alb, const Vector< t_rows_Aub > &Aub)
 
template<int t_rows_primal, int t_rows_H, int t_cols_H, int t_rows_h, int t_rows_lb, int t_rows_ub>
ReturnStatus solve (Vector< t_rows_primal > &primal, Matrix< t_rows_H, t_cols_H > &H, const Vector< t_rows_h > &h, const Vector< t_rows_lb > &lb, const Vector< t_rows_ub > &ub, const SolverParameters &param)
 
template<int t_rows_primal, int t_rows_H, int t_cols_H, int t_rows_h, int t_rows_lb, int t_rows_ub>
ReturnStatus solve (Vector< t_rows_primal > &primal, Matrix< t_rows_H, t_cols_H > &H, const Vector< t_rows_h > &h, const Vector< t_rows_lb > &lb, const Vector< t_rows_ub > &ub)
 
template<int t_rows_primal, int t_rows_H, int t_cols_H, int t_rows_h, int t_rows_lb, int t_rows_ub, int t_rows_A, int t_cols_A, int t_rows_Alb, int t_rows_Aub>
ReturnStatus solve (Vector< t_rows_primal > &primal, Matrix< t_rows_H, t_cols_H > &H, const Vector< t_rows_h > &h, const Vector< t_rows_lb > &lb, const Vector< t_rows_ub > &ub, const Matrix< t_rows_A, t_cols_A > &A, const Vector< t_rows_Alb > &Alb, const Vector< t_rows_Aub > &Aub, const SolverParameters &param)
 

Protected Member Functions

template<class t_MatrixType , class t_VectorType >
void parseObjective (const t_MatrixType &H, const t_VectorType &h)
 
template<class t_VectorTypelb , class t_VectorTypeub >
void parseSimpleBounds (const t_VectorTypelb &lb, const t_VectorTypeub &ub)
 
template<class t_MatrixTypeA , class t_VectorTypelb , class t_VectorTypeub >
void parseGeneralConstraints (const t_MatrixTypeA &A, const t_VectorTypelb &lb, const t_VectorTypeub &ub)
 

Protected Attributes

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

Static Protected Attributes

static const MatrixIndex num_constraints_compile_time_
 

Private Member Functions

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
 

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::SolverTemplate< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::Matrix = Eigen::Matrix<t_Scalar, t_rows, t_cols>

Definition at line 43 of file solver.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::SolverTemplate< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::Vector = Eigen::Matrix<t_Scalar, t_rows, 1>

Definition at line 41 of file solver.h.

Member Enumeration Documentation

◆ ReturnStatus

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

Definition at line 34 of file solver.h.

Constructor & Destructor Documentation

◆ SolverTemplate()

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

Definition at line 76 of file solver.h.

Member Function Documentation

◆ checkConstraintViolation()

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
void qpmad::SolverTemplate< 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 726 of file solver.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::SolverTemplate< 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 681 of file solver.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::SolverTemplate< 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 751 of file solver.h.

◆ getHessianType()

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
SolverParameters::HessianType qpmad::SolverTemplate< 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 88 of file solver.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::SolverTemplate< 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 122 of file solver.h.

◆ getNumberOfInequalityIterations()

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
std::ptrdiff_t qpmad::SolverTemplate< 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 98 of file solver.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::SolverTemplate< 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 655 of file solver.h.

◆ parseGeneralConstraints()

template<class t_MatrixTypeA , class t_VectorTypelb , class t_VectorTypeub >
void qpmad::InputParser::parseGeneralConstraints ( const t_MatrixTypeA &  A,
const t_VectorTypelb &  lb,
const t_VectorTypeub &  ub 
)
inlineprotectedinherited

Definition at line 68 of file input_parser.h.

◆ parseObjective()

template<class t_MatrixType , class t_VectorType >
void qpmad::InputParser::parseObjective ( const t_MatrixType &  H,
const t_VectorType &  h 
)
inlineprotectedinherited

Definition at line 35 of file input_parser.h.

◆ parseSimpleBounds()

template<class t_VectorTypelb , class t_VectorTypeub >
void qpmad::InputParser::parseSimpleBounds ( const t_VectorTypelb &  lb,
const t_VectorTypeub &  ub 
)
inlineprotectedinherited

Definition at line 48 of file input_parser.h.

◆ solve() [1/5]

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
template<int t_rows_primal, int t_rows_H, int t_cols_H, int t_rows_h, int t_rows_A, int t_cols_A, int t_rows_Alb, int t_rows_Aub>
ReturnStatus qpmad::SolverTemplate< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::solve ( Vector< t_rows_primal > &  primal,
Matrix< t_rows_H, t_cols_H > &  H,
const Vector< t_rows_h > &  h,
const Matrix< t_rows_A, t_cols_A > &  A,
const Vector< t_rows_Alb > &  Alb,
const Vector< t_rows_Aub > &  Aub 
)
inline

Definition at line 154 of file solver.h.

◆ solve() [2/5]

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
template<int t_rows_primal, int t_rows_H, int t_cols_H, int t_rows_h, int t_rows_lb, int t_rows_ub, int t_rows_A, int t_cols_A, int t_rows_Alb, int t_rows_Aub>
ReturnStatus qpmad::SolverTemplate< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::solve ( Vector< t_rows_primal > &  primal,
Matrix< t_rows_H, t_cols_H > &  H,
const Vector< t_rows_h > &  h,
const Vector< t_rows_lb > &  lb,
const Vector< t_rows_ub > &  ub,
const Matrix< t_rows_A, t_cols_A > &  A,
const Vector< t_rows_Alb > &  Alb,
const Vector< t_rows_Aub > &  Aub 
)
inline

Definition at line 177 of file solver.h.

◆ solve() [3/5]

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
template<int t_rows_primal, int t_rows_H, int t_cols_H, int t_rows_h, int t_rows_lb, int t_rows_ub>
ReturnStatus qpmad::SolverTemplate< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::solve ( Vector< t_rows_primal > &  primal,
Matrix< t_rows_H, t_cols_H > &  H,
const Vector< t_rows_h > &  h,
const Vector< t_rows_lb > &  lb,
const Vector< t_rows_ub > &  ub,
const SolverParameters param 
)
inline

Definition at line 192 of file solver.h.

◆ solve() [4/5]

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
template<int t_rows_primal, int t_rows_H, int t_cols_H, int t_rows_h, int t_rows_lb, int t_rows_ub>
ReturnStatus qpmad::SolverTemplate< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::solve ( Vector< t_rows_primal > &  primal,
Matrix< t_rows_H, t_cols_H > &  H,
const Vector< t_rows_h > &  h,
const Vector< t_rows_lb > &  lb,
const Vector< t_rows_ub > &  ub 
)
inline

Definition at line 205 of file solver.h.

◆ solve() [5/5]

template<typename t_Scalar , int t_primal_size, int t_has_bounds, int t_general_ctr_number>
template<int t_rows_primal, int t_rows_H, int t_cols_H, int t_rows_h, int t_rows_lb, int t_rows_ub, int t_rows_A, int t_cols_A, int t_rows_Alb, int t_rows_Aub>
ReturnStatus qpmad::SolverTemplate< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::solve ( Vector< t_rows_primal > &  primal,
Matrix< t_rows_H, t_cols_H > &  H,
const Vector< t_rows_h > &  h,
const Vector< t_rows_lb > &  lb,
const Vector< t_rows_ub > &  ub,
const Matrix< t_rows_A, t_cols_A > &  A,
const Vector< t_rows_Alb > &  Alb,
const Vector< t_rows_Aub > &  Aub,
const SolverParameters param 
)
inline

Definition at line 229 of file solver.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::SolverTemplate< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::active_set_
protected

Definition at line 56 of file solver.h.

◆ chosen_ctr_

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

Definition at line 68 of file solver.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::SolverTemplate< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::constraints_status_
protected

Definition at line 66 of file solver.h.

◆ dual_

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

Definition at line 59 of file solver.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::SolverTemplate< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::dual_step_direction_
protected

Definition at line 62 of file solver.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::SolverTemplate< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::factorization_data_
protected

Definition at line 57 of file solver.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::SolverTemplate< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::general_ctr_dot_primal_
protected

Definition at line 64 of file solver.h.

◆ h_size_

MatrixIndex qpmad::InputParser::h_size_
protectedinherited

Definition at line 19 of file input_parser.h.

◆ hessian_type_

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

Definition at line 72 of file solver.h.

◆ iter_counter_

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

Definition at line 70 of file solver.h.

◆ machinery_initialized_

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

Definition at line 54 of file solver.h.

◆ num_constraints_

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

Definition at line 53 of file solver.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::SolverTemplate< 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 47 of file solver.h.

◆ num_general_constraints_

MatrixIndex qpmad::InputParser::num_general_constraints_
protectedinherited

Definition at line 21 of file input_parser.h.

◆ num_simple_bounds_

MatrixIndex qpmad::InputParser::num_simple_bounds_
protectedinherited

Definition at line 20 of file input_parser.h.

◆ primal_size_

MatrixIndex qpmad::InputParser::primal_size_
protectedinherited

Definition at line 18 of file input_parser.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::SolverTemplate< t_Scalar, t_primal_size, t_has_bounds, t_general_ctr_number >::primal_step_direction_
protected

Definition at line 61 of file solver.h.


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