KASKADE 7 development version
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Kaskade::QPMultiGridBase< d, Prolongation, Smoother, CoarseSmoother, Real > Class Template Referenceabstract

A base class for multigrid solver for QPs. More...

#include <qpmg.hh>

Detailed Description

template<int d, class Prolongation, class Smoother, class CoarseSmoother = Smoother, class Real = double>
class Kaskade::QPMultiGridBase< d, Prolongation, Smoother, CoarseSmoother, Real >

A base class for multigrid solver for QPs.

This base class implements a multigrid solver for 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 defined on a hierarchy of grids, i.e. for a given prolongation stack defining the (geometric) relation between a sequence of grids.

To the QP on fine grids we apply a block Gauss-Seidel method, which treats DOFs coupled by the constraints

\[ Bx \le b \]

jointly. These local QPs are then solved by the smoother on the corresponsing level. On the corse grid the system is solver either by a direct solver (dense or sparse) or by a few smoothing steps.

Template Parameters
dthe dimension of (vector valued) optimization variables
Prolongationdefines the data type of the prolongation matrices defining the hierarchy
Smootherthe smoother for the local QPs on all grids but the coarse one
CoarseSmootherthe smoother for the coarse grid

Definition at line 92 of file qpmg.hh.

Public Types

using VectorX = Dune::BlockVector< Dune::FieldVector< Real, d > >
 
using VectorB = Dune::BlockVector< Dune::FieldVector< Real, 1 > >
 
using MatrixA = NumaBCRSMatrix< EntryA >
 
using MatrixB = NumaBCRSMatrix< Dune::FieldMatrix< Real, 1, d > >
 
using Self = QPMultiGridBase< d, Prolongation, Smoother, CoarseSmoother, Real >
 
using SmootherType = std::conditional_t< smoothersEqual, Smoother, std::variant< Smoother, CoarseSmoother > >
 

Public Member Functions

 QPMultiGridBase (MatrixA A, MatrixB const &B, std::vector< Prolongation > &&prolongations, Real smootherRegularization=0, bool blocks=true, bool directOnCoarse=true)
 Constructs the solver, providing the matrices \( A \) and \( B \). More...
 
virtual ~QPMultiGridBase ()
 Destructor. More...
 
VectorX step (VectorX const &x, VectorX c, VectorB b) const
 Computes a single V-cycle correction for approximately solving the QP for the given right hand side vectors. More...
 
std::tuple< VectorX, int > solve (VectorX x, VectorX const &c, VectorB const &b, double tol, int vcycles) const
 Approximately solves the QP for the given right hand side vectors up to a given tolerance. More...
 
SelfsetCoarseLevel (int coarselevel)
 Defines the grid level to be used as coarse grid. More...
 
SelfsetSmoothings (int pre, int post)
 
SelfsetCoarseCorrections (int n)
 Sets the number of coarse corrections to compute and apply. More...
 
SelfsetBulkMode (ParallelMode m)
 Defines the smoothing strategy to use for unconstrained degrees of freedom. More...
 
SelfsetLogger (MGSolverStatistics< d, Real > *logger)
 Sets the logging facility for reporting solver statistics. More...
 

Static Public Attributes

static constexpr bool smoothersEqual = std::is_same<Smoother,CoarseSmoother>::value
 

Protected Member Functions

virtual double computeEnergy (MatrixA const &A, MatrixB const &B, VectorX const &c, VectorB const &b, VectorX const &x) const =0
 Compute the problem energy of current iterate for logging purposes. More...
 
virtual std::tuple< VectorX, VectorB, int > gradient (MatrixA const &A, MatrixB const &B, VectorX const &c, VectorB const &b, VectorX const &x) const =0
 Compute the problem gradient of current iterate. More...
 
virtual std::tuple< VectorX, VectorX, VectorX, VectorB, int > gradient_extended (MatrixA const &A, MatrixB const &B, VectorX const &c, VectorB const &b, VectorX const &x) const =0
 Computes the gradient of current iterate, giving more information on the components of the gradient. (It might be split in several terms grad0 and grad1). More...
 
virtual double qpLinesearch (MatrixA const &A, MatrixB const &B, VectorX const &c, VectorB const &b, VectorX const &dx) const =0
 Compute the optimal step size in direction of dx. More...
 
MatrixB const & B () const
 Provides a reference to the fine grid constraints. More...
 

Protected Attributes

std::vector< SmootherTypesmoothers
 

Member Typedef Documentation

◆ MatrixA

template<int d, class Prolongation , class Smoother , class CoarseSmoother = Smoother, class Real = double>
using Kaskade::QPMultiGridBase< d, Prolongation, Smoother, CoarseSmoother, Real >::MatrixA = NumaBCRSMatrix<EntryA>

Definition at line 98 of file qpmg.hh.

◆ MatrixB

template<int d, class Prolongation , class Smoother , class CoarseSmoother = Smoother, class Real = double>
using Kaskade::QPMultiGridBase< d, Prolongation, Smoother, CoarseSmoother, Real >::MatrixB = NumaBCRSMatrix<Dune::FieldMatrix<Real,1,d> >

Definition at line 99 of file qpmg.hh.

◆ Self

template<int d, class Prolongation , class Smoother , class CoarseSmoother = Smoother, class Real = double>
using Kaskade::QPMultiGridBase< d, Prolongation, Smoother, CoarseSmoother, Real >::Self = QPMultiGridBase<d,Prolongation,Smoother,CoarseSmoother,Real>

Definition at line 100 of file qpmg.hh.

◆ SmootherType

template<int d, class Prolongation , class Smoother , class CoarseSmoother = Smoother, class Real = double>
using Kaskade::QPMultiGridBase< d, Prolongation, Smoother, CoarseSmoother, Real >::SmootherType = std::conditional_t<smoothersEqual, Smoother, std::variant<Smoother,CoarseSmoother> >

Definition at line 105 of file qpmg.hh.

◆ VectorB

template<int d, class Prolongation , class Smoother , class CoarseSmoother = Smoother, class Real = double>
using Kaskade::QPMultiGridBase< d, Prolongation, Smoother, CoarseSmoother, Real >::VectorB = Dune::BlockVector<Dune::FieldVector<Real,1> >

Definition at line 97 of file qpmg.hh.

◆ VectorX

template<int d, class Prolongation , class Smoother , class CoarseSmoother = Smoother, class Real = double>
using Kaskade::QPMultiGridBase< d, Prolongation, Smoother, CoarseSmoother, Real >::VectorX = Dune::BlockVector<Dune::FieldVector<Real,d> >

Definition at line 96 of file qpmg.hh.

Constructor & Destructor Documentation

◆ QPMultiGridBase()

template<int d, class Prolongation , class Smoother , class CoarseSmoother = Smoother, class Real = double>
Kaskade::QPMultiGridBase< d, Prolongation, Smoother, CoarseSmoother, Real >::QPMultiGridBase ( MatrixA  A,
MatrixB const &  B,
std::vector< Prolongation > &&  prolongations,
Real  smootherRegularization = 0,
bool  blocks = true,
bool  directOnCoarse = true 
)

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

Parameters
Athe Hessian. The matrix is referenced internally and has to exist during the lifetime of the smoother.
Bthe constraints. The matrix is referenced internally and has to exist during the lifetime of the smoother.
blocks
  • block=true: treat blocks of dof coupled by constraints jointly (default)
  • block=false: treat all dofs individually (only for testing and comparison purposes)
Warning
This is intended for testing purposes only and may be removed in future.
Parameters
directOnCoarse
  • directOnCoarse=true use direct solver for problem on coarse grid
  • directOnCoarse=false use a few iterative (smoothing) steps on coarse grid (block Jacobi/Gauss Seidel)

◆ ~QPMultiGridBase()

template<int d, class Prolongation , class Smoother , class CoarseSmoother = Smoother, class Real = double>
virtual Kaskade::QPMultiGridBase< d, Prolongation, Smoother, CoarseSmoother, Real >::~QPMultiGridBase ( )
virtual

Destructor.

Member Function Documentation

◆ B()

template<int d, class Prolongation , class Smoother , class CoarseSmoother = Smoother, class Real = double>
MatrixB const & Kaskade::QPMultiGridBase< d, Prolongation, Smoother, CoarseSmoother, Real >::B ( ) const
protected

Provides a reference to the fine grid constraints.

◆ computeEnergy()

template<int d, class Prolongation , class Smoother , class CoarseSmoother = Smoother, class Real = double>
virtual double Kaskade::QPMultiGridBase< d, Prolongation, Smoother, CoarseSmoother, Real >::computeEnergy ( MatrixA const &  A,
MatrixB const &  B,
VectorX const &  c,
VectorB const &  b,
VectorX const &  x 
) const
protectedpure virtual

Compute the problem energy of current iterate for logging purposes.

◆ gradient()

template<int d, class Prolongation , class Smoother , class CoarseSmoother = Smoother, class Real = double>
virtual std::tuple< VectorX, VectorB, int > Kaskade::QPMultiGridBase< d, Prolongation, Smoother, CoarseSmoother, Real >::gradient ( MatrixA const &  A,
MatrixB const &  B,
VectorX const &  c,
VectorB const &  b,
VectorX const &  x 
) const
protectedpure virtual

Compute the problem gradient of current iterate.

◆ gradient_extended()

template<int d, class Prolongation , class Smoother , class CoarseSmoother = Smoother, class Real = double>
virtual std::tuple< VectorX, VectorX, VectorX, VectorB, int > Kaskade::QPMultiGridBase< d, Prolongation, Smoother, CoarseSmoother, Real >::gradient_extended ( MatrixA const &  A,
MatrixB const &  B,
VectorX const &  c,
VectorB const &  b,
VectorX const &  x 
) const
protectedpure virtual

Computes the gradient of current iterate, giving more information on the components of the gradient. (It might be split in several terms grad0 and grad1).

◆ qpLinesearch()

template<int d, class Prolongation , class Smoother , class CoarseSmoother = Smoother, class Real = double>
virtual double Kaskade::QPMultiGridBase< d, Prolongation, Smoother, CoarseSmoother, Real >::qpLinesearch ( MatrixA const &  A,
MatrixB const &  B,
VectorX const &  c,
VectorB const &  b,
VectorX const &  dx 
) const
protectedpure virtual

Compute the optimal step size in direction of dx.

◆ setBulkMode()

template<int d, class Prolongation , class Smoother , class CoarseSmoother = Smoother, class Real = double>
Self & Kaskade::QPMultiGridBase< d, Prolongation, Smoother, CoarseSmoother, Real >::setBulkMode ( ParallelMode  m)

Defines the smoothing strategy to use for unconstrained degrees of freedom.

In contact problems, those are usually the interior nodes, and the ones without potential contact partner. The smoother can operate in parallel (Jacobi) or sequentially (Gauss-Seidel). In the parallel way, an exact linesearch is performed after the smoothing in order to guarantee descent.

◆ setCoarseCorrections()

template<int d, class Prolongation , class Smoother , class CoarseSmoother = Smoother, class Real = double>
Self & Kaskade::QPMultiGridBase< d, Prolongation, Smoother, CoarseSmoother, Real >::setCoarseCorrections ( int  n)

Sets the number of coarse corrections to compute and apply.

Parameters
nnumber of coarse corrections
  • n=0: just the smoother on the fine grid is performed, no multigrid at all (for testing purposes only).
  • n=1: V-cycle (default)
  • n=2: W-cycle

◆ setCoarseLevel()

template<int d, class Prolongation , class Smoother , class CoarseSmoother = Smoother, class Real = double>
Self & Kaskade::QPMultiGridBase< d, Prolongation, Smoother, CoarseSmoother, Real >::setCoarseLevel ( int  coarselevel)

Defines the grid level to be used as coarse grid.

Parameters
coarselevelthe coarse grid level, between 0 and the max grid level

If coarselevel is outside its allowed range, it is projected onto that range.

◆ setLogger()

template<int d, class Prolongation , class Smoother , class CoarseSmoother = Smoother, class Real = double>
Self & Kaskade::QPMultiGridBase< d, Prolongation, Smoother, CoarseSmoother, Real >::setLogger ( MGSolverStatistics< d, Real > *  logger)

Sets the logging facility for reporting solver statistics.

Parameters
loggera pointer to the logger object. This can be a nullpointer, in which case logging is stopped.

Ownership of the logger object remains with the caller. The logger object needs to exist for the lifetime of the QPMultiGrid class or until it is replaced by a different logger (or none).

◆ setSmoothings()

template<int d, class Prolongation , class Smoother , class CoarseSmoother = Smoother, class Real = double>
Self & Kaskade::QPMultiGridBase< d, Prolongation, Smoother, CoarseSmoother, Real >::setSmoothings ( int  pre,
int  post 
)

◆ solve()

template<int d, class Prolongation , class Smoother , class CoarseSmoother = Smoother, class Real = double>
std::tuple< VectorX, int > Kaskade::QPMultiGridBase< d, Prolongation, Smoother, CoarseSmoother, Real >::solve ( VectorX  x,
VectorX const &  c,
VectorB const &  b,
double  tol,
int  vcycles 
) const

Approximately solves the QP for the given right hand side vectors up to a given tolerance.

Parameters
xinitial guess for the solution
clinear objective term
bconstant constraint term
toltolerance
Returns
a tuple \( (x,\mathrm{iter}) \) of solution vector, multiplier update, and iteration count

◆ step()

template<int d, class Prolongation , class Smoother , class CoarseSmoother = Smoother, class Real = double>
VectorX Kaskade::QPMultiGridBase< d, Prolongation, Smoother, CoarseSmoother, Real >::step ( VectorX const &  x,
VectorX  c,
VectorB  b 
) const

Computes a single V-cycle correction for approximately solving the QP for the given right hand side vectors.

Parameters
xinitial guess for the solution
clinear objective term
bconstant constraint term
Returns
the correction dx

Member Data Documentation

◆ smoothers

template<int d, class Prolongation , class Smoother , class CoarseSmoother = Smoother, class Real = double>
std::vector<SmootherType> Kaskade::QPMultiGridBase< d, Prolongation, Smoother, CoarseSmoother, Real >::smoothers
protected

Definition at line 228 of file qpmg.hh.

◆ smoothersEqual

template<int d, class Prolongation , class Smoother , class CoarseSmoother = Smoother, class Real = double>
constexpr bool Kaskade::QPMultiGridBase< d, Prolongation, Smoother, CoarseSmoother, Real >::smoothersEqual = std::is_same<Smoother,CoarseSmoother>::value
staticconstexpr

Definition at line 104 of file qpmg.hh.


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