KASKADE 7 development version
Public Types | Public Member Functions | Static Public Attributes | List of all members
Kaskade::QPALSolver< d, sparsity, Real > Class Template Reference

An augmented Lagrangian solver for small instances of a particular class of quadratic programs. More...

#include <qp.hh>

Detailed Description

template<int d, QPStructure sparsity = QPStructure::DENSE, class Real = double>
class Kaskade::QPALSolver< d, sparsity, Real >

An augmented Lagrangian solver for small instances of a particular class of quadratic programs.

The solver addresses problems of the form

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

where \( A \) is positive semidefinite, and approximates the solution by minimizing the Powell-Hestenes-Rockafellar augmented Lagrangian

\[ \min_{x} \frac{1}{2} x^T Ax + c^T x + \frac{\gamma}{2}\left\|Bx-\Big(b-\frac{\lambda}{\gamma}\Big)\right\|_+^2 \]

using a semismooth Newton method with exact linesearch and first-order multiplier updates.

The penalty parameter \( \gamma \) affects both, solution quality and solution effort. For \( \gamma\to\infty \), the augmented Lagrangian iteration converges faster, but the penalized problem's condition gets worse. A reasonable default value is chosen based on theoretical estimates of the convergence rate, aiming at a contraction factor of 0.01 (a very rough estimate, but should work as a default).

A good multiplier estimate \(\lambda\) improves the solution accuracy significantly. Compared to the standard augmented Lagrangian where a linear term \( \lambda^T (Bx-b) \) is added, the PHR version with shiftet constraints has the advantage that in the inner penalized QPs that are to be solved the strongly active constraints remain strongly active. In the standard formulation, they become weakly active in the course of the AL iteration, which can induce frequent switching of constraints between active and inactive.

Template Parameters
dthe dimension of (vector valued) optimization variables
sparsitythe type of linear algebra data structures to use, either DENSE or SPARSE
Realthe real field type of matrix/vector entries. Explicit instantiations are provided for float and double.

Definition at line 698 of file qp.hh.

Public Types

using VectorX = Dune::BlockVector< Dune::FieldVector< Real, d > >
 
using VectorB = Dune::BlockVector< Dune::FieldVector< Real, 1 > >
 
using MatrixA = std::conditional_t< sparsity==QPStructure::DENSE, DynamicMatrix< AEntry >, NumaBCRSMatrix< AEntry > >
 
using MatrixB = std::conditional_t< sparsity==QPStructure::DENSE, DynamicMatrix< BEntry >, NumaBCRSMatrix< BEntry > >
 

Public Member Functions

 QPALSolver (MatrixA const &A, MatrixB const &B)
 Constructs the solver, providing the matrices \( A \) and \( B \). More...
 
QPALSolver< d, sparsity, Real > & setMinSteps (int i)
 Sets the minimum number of augmented Lagrangian steps to perform. More...
 
QPALSolver< d, sparsity, Real > & setMaxSteps (int i)
 Sets the maximum number of projected gradient steps to perform. More...
 
QPALSolver< d, sparsity, Real > & setPenalty (Real gamma)
 Sets the penalty parameter \( \gamma \). More...
 
Real getPenalty () const
 
std::tuple< VectorX, VectorB, int > solve (VectorX const &c, VectorB const &b, double tol) const
 Solves the QP approximately for the given right hand side vectors. More...
 
std::tuple< VectorX, VectorB, int > solve (VectorX const &c, VectorB const &b, double tol, VectorX x) const
 Solves the QP approximately for the given right hand side vectors. More...
 

Static Public Attributes

static constexpr QPStructure sparse = sparsity
 Given info on whether dense or sparse arithmetic is used (i.e. the choice of template parameter used in this class). More...
 

Member Typedef Documentation

◆ MatrixA

template<int d, QPStructure sparsity = QPStructure::DENSE, class Real = double>
using Kaskade::QPALSolver< d, sparsity, Real >::MatrixA = std::conditional_t<sparsity==QPStructure::DENSE, DynamicMatrix<AEntry>, NumaBCRSMatrix<AEntry> >

Definition at line 706 of file qp.hh.

◆ MatrixB

template<int d, QPStructure sparsity = QPStructure::DENSE, class Real = double>
using Kaskade::QPALSolver< d, sparsity, Real >::MatrixB = std::conditional_t<sparsity==QPStructure::DENSE, DynamicMatrix<BEntry>, NumaBCRSMatrix<BEntry> >

Definition at line 709 of file qp.hh.

◆ VectorB

template<int d, QPStructure sparsity = QPStructure::DENSE, class Real = double>
using Kaskade::QPALSolver< d, sparsity, Real >::VectorB = Dune::BlockVector<Dune::FieldVector<Real,1> >

Definition at line 705 of file qp.hh.

◆ VectorX

template<int d, QPStructure sparsity = QPStructure::DENSE, class Real = double>
using Kaskade::QPALSolver< d, sparsity, Real >::VectorX = Dune::BlockVector<Dune::FieldVector<Real,d> >

Definition at line 704 of file qp.hh.

Constructor & Destructor Documentation

◆ QPALSolver()

template<int d, QPStructure sparsity = QPStructure::DENSE, class Real = double>
Kaskade::QPALSolver< d, sparsity, Real >::QPALSolver ( MatrixA const &  A,
MatrixB const &  B 
)

Constructs the solver, providing the matrices \( A \) and \( B \).

The argument matrices are copied internally, and are not referenced later.

Todo:
write a move constructor

Member Function Documentation

◆ getPenalty()

template<int d, QPStructure sparsity = QPStructure::DENSE, class Real = double>
Real Kaskade::QPALSolver< d, sparsity, Real >::getPenalty ( ) const
inline

Definition at line 749 of file qp.hh.

◆ setMaxSteps()

template<int d, QPStructure sparsity = QPStructure::DENSE, class Real = double>
QPALSolver< d, sparsity, Real > & Kaskade::QPALSolver< d, sparsity, Real >::setMaxSteps ( int  i)

Sets the maximum number of projected gradient steps to perform.

Parameters
ithe maximum number of steps, needs to be nonnegative

If i is less than the minimum number of steps, the latter ist decreased to the same value.

◆ setMinSteps()

template<int d, QPStructure sparsity = QPStructure::DENSE, class Real = double>
QPALSolver< d, sparsity, Real > & Kaskade::QPALSolver< d, sparsity, Real >::setMinSteps ( int  i)

Sets the minimum number of augmented Lagrangian steps to perform.

Parameters
ithe minimum number of steps, needs to be nonnegative

If i is larger than the maximum number of steps, the latter ist increased to the same value.

◆ setPenalty()

template<int d, QPStructure sparsity = QPStructure::DENSE, class Real = double>
QPALSolver< d, sparsity, Real > & Kaskade::QPALSolver< d, sparsity, Real >::setPenalty ( Real  gamma)

Sets the penalty parameter \( \gamma \).

The default on construction is \( \gamma = \).

◆ solve() [1/2]

template<int d, QPStructure sparsity = QPStructure::DENSE, class Real = double>
std::tuple< VectorX, VectorB, int > Kaskade::QPALSolver< d, sparsity, Real >::solve ( VectorX const &  c,
VectorB const &  b,
double  tol 
) const

Solves the QP approximately for the given right hand side vectors.

The starting point is \( x = 0 \).

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

The iteration is terminated as soon as the projected gradient \( s \) is small, i.e. \( \|s\|_2 \le \mathsf{tol}\). Together with the solution vector, a multiplier estimate based on the first order update \( \lambda \gets \lambda - (Bx-s) \) is computed.

Returns
a tuple \( (x,\lambda,\mathrm{iter}) \) of solution vector, multiplier estimate, and iteration count.

If the QP is infeasible, an InfeasibleProblemException is thrown.

◆ solve() [2/2]

template<int d, QPStructure sparsity = QPStructure::DENSE, class Real = double>
std::tuple< VectorX, VectorB, int > Kaskade::QPALSolver< d, sparsity, Real >::solve ( VectorX const &  c,
VectorB const &  b,
double  tol,
VectorX  x 
) const

Solves the QP approximately for the given right hand side vectors.

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

The iteration is terminated as soon as the projected gradient \( s \) is small, i.e. \( \|s\|_2 \le \mathsf{tol}\). Together with the solution vector, a multiplier estimate based on the first order update \( \lambda \gets \lambda - (Bx-s) \) is computed.

Returns
a tuple \( (x,\delta\lambda,\mathrm{iter}) \) of solution vector, multiplier update, and iteration count

If the QP is infeasible, an InfeasibleProblemException is thrown.

Member Data Documentation

◆ sparse

template<int d, QPStructure sparsity = QPStructure::DENSE, class Real = double>
constexpr QPStructure Kaskade::QPALSolver< d, sparsity, Real >::sparse = sparsity
staticconstexpr

Given info on whether dense or sparse arithmetic is used (i.e. the choice of template parameter used in this class).

Definition at line 794 of file qp.hh.


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