KASKADE 7 development version
Loading...
Searching...
No Matches
Kaskade::QPDirectSparse< R > Class Template Reference

A solver for sparse, medium-sized instances of bound constrained quadratic programs. More...

#include <qp.hh>

Inheritance diagram for Kaskade::QPDirectSparse< R >:
Kaskade::QPBoundSolverBase< double, QPDirectSparse< double > >

Public Types

using Real = R
using Vector = typename Base::Vector
using SparseMatrix = NumaBCRSMatrix<Dune::FieldMatrix<Real,1,1>>
using Matrix

Public Member Functions

 QPDirectSparse (SparseMatrix const &A, QPConvexificationStrategy convex=QPConvexificationStrategy::DONOTHING)
 Constructs the solver, providing the matrix \( A \).
std::tuple< Vector, int > solve (Vector const &c, Vector const &b, double tol) const
 Solves the QP for the given right hand side vectors.
void gradientStep (Vector const &c, Vector const &b, Vector &x) const
 Performs a single projected gradient step.
QPDirectSparse< double > & setMinSteps (int count)
 defines the minimal number of steps to perform in solving.
QPDirectSparse< double > & setMaxSteps (int count)
 defines the maximum allowed number of steps to perform in solving.

Protected Member Functions

Vector solveSubmatrix (std::vector< int > const &idx, Vector const &b) const
 solves a subsystem \( \tilde A x = b \).
virtual void updateWithColumn (double a, int i, Vector &s) const
 Performs the update \( s \gets s + aAe_i \), where \( e_i \) is the i-th unit vector.

Detailed Description

template<class R = double>
class Kaskade::QPDirectSparse< R >

A solver for sparse, medium-sized instances of bound constrained quadratic programs.

The solver addresses problems of the form

\[ \min_x \frac{1}{2} x^T Ax + c^T x \quad \text{s.t. } x \le b, \]

where \( A \) is a positive definite sparse matrix. A direct solver is used to solve projected subproblems.

Template Parameters
Realthe real field type of matrix/vector entries. Explicit instantiations are provided for float and double.

Definition at line 322 of file qp.hh.

Member Typedef Documentation

◆ Matrix

using Kaskade::QPBoundSolverBase< double, QPDirectSparse< double > >::Matrix
inherited

Definition at line 110 of file qp.hh.

◆ Real

template<class R = double>
using Kaskade::QPDirectSparse< R >::Real = R

Definition at line 327 of file qp.hh.

◆ SparseMatrix

template<class R = double>
using Kaskade::QPDirectSparse< R >::SparseMatrix = NumaBCRSMatrix<Dune::FieldMatrix<Real,1,1>>

Definition at line 329 of file qp.hh.

◆ Vector

template<class R = double>
using Kaskade::QPDirectSparse< R >::Vector = typename Base::Vector

Definition at line 328 of file qp.hh.

Constructor & Destructor Documentation

◆ QPDirectSparse()

template<class R = double>
Kaskade::QPDirectSparse< R >::QPDirectSparse ( SparseMatrix const & A,
QPConvexificationStrategy convex = QPConvexificationStrategy::DONOTHING )

Constructs the solver, providing the matrix \( A \).

The argument matrix is copied internally, and is not referenced later.

Throws a NonpositiveMatrixException if \( A \) is not positive definite and

Todo
write a move constructor

Member Function Documentation

◆ gradientStep()

void Kaskade::QPBoundSolverBase< double, QPDirectSparse< double > >::gradientStep ( Vector const & c,
Vector const & b,
Vector & x ) const
inherited

Performs a single projected gradient step.

This is a generalization of a Richardson smoother with linesearch, and can be used when the QP is just a subproblem, e.g. in multigrid methods, and rather well conditioned.

◆ setMaxSteps()

QPDirectSparse< double > & Kaskade::QPBoundSolverBase< double, QPDirectSparse< double > >::setMaxSteps ( int count)
inherited

defines the maximum allowed number of steps to perform in solving.

The default value is 200. If the maximum iteration count is below the minimum iteration count, the number of steps performed in solving is undefined.

◆ setMinSteps()

QPDirectSparse< double > & Kaskade::QPBoundSolverBase< double, QPDirectSparse< double > >::setMinSteps ( int count)
inherited

defines the minimal number of steps to perform in solving.

The default value is 0. If the minimum iteration count is set to less than the maximum iteration count, the number of steps performed is undefined.

◆ solve()

std::tuple< Vector, int > Kaskade::QPBoundSolverBase< double, QPDirectSparse< double > >::solve ( Vector const & c,
Vector const & b,
double tol ) const
inherited

Solves the QP for the given right hand side vectors.

Solves the QP with a projected gradient method starting at the feasible point \( x = \min(0,b)\).

Parameters
cthe linear term of the objective
bthe constraints right hand side
tolthe tolerance for termination criterion

The iteration is terminated as soon as the projected gradient \( s \) is small, i.e. \( \|s\|_2 \le \mathsf{tol} \).

Returns
a tuple \( (x,iter) \) of solution vector, and iteration count

If the QP is infeasible, an InfeasibleProblemException is thrown.

◆ solveSubmatrix()

Vector Kaskade::QPBoundSolverBase< double, QPDirectSparse< double > >::solveSubmatrix ( std::vector< int > const & idx,
Vector const & b ) const
protectedinherited

solves a subsystem \( \tilde A x = b \).

This needs to be overwritten by derived classes.

For a set idx of indices, the submatrix \( \tilde A \) in Matlab notation is A(idx,idx).

Parameters
idxthe indices defining the submatrix
bthe right hand side (of the same length as the index vector)
Returns
the solution \( x \)

◆ updateWithColumn()

virtual void Kaskade::QPBoundSolverBase< double, QPDirectSparse< double > >::updateWithColumn ( double a,
int i,
Vector & s ) const
protectedvirtualinherited

Performs the update \( s \gets s + aAe_i \), where \( e_i \) is the i-th unit vector.

The default implementation performs a complete matrix-vector product, which is performance-wise suboptimal. Override this for better performance.


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