Description

Base class for ITERATIVE solvers aimed at solving complementarity problems arising from QP optimization problems.

This class does nothing: it is up to derived clases to implement specific solution methods. The problem is described by a variational inequality VI(Z*x-d,K):

| M -Cq'|*|q|- | f|= |0| , l Y, C Ny, normal cone to Y | Cq -E | |l| |-b| |c|

Also Z symmetric by flipping sign of l_i: |M Cq'|*| q|-| f|=|0| |Cq E | |-l| |-b| |c|

  • case linear problem: all Y_i = R, Ny=0, ex. all bilaterals
  • case LCP: all Y_i = R+: c>=0, l>=0, l*c=0
  • case CCP: Y_i are friction cones

#include <ChIterativeSolver.h>

Inheritance diagram for chrono::ChIterativeSolver:
Collaboration diagram for chrono::ChIterativeSolver:

Public Member Functions

 ChIterativeSolver (int mmax_iters=50, bool mwarm_start=false, double mtolerance=0.0, double momega=1.0, double mshlambda=1.0)
 
virtual bool SolveRequiresMatrix () const override
 Indicate whether ot not the Solve() phase requires an up-to-date problem matrix. More...
 
void SetMaxIterations (int mval)
 Set the maximum number of iterations. More...
 
int GetMaxIterations () const
 Get the current value for the maximum allowed number of iterations.
 
int GetTotalIterations () const
 Get the number of total iterations taken by the solver.
 
void SetOmega (double mval)
 Set the overrelaxation factor. More...
 
double GetOmega () const
 Return the current value of the overrelaxation factor.
 
virtual void SetSharpnessLambda (double mval)
 Set the sharpness factor. More...
 
virtual double GetSharpnessLambda () const
 Return the current value of the sharpness factor.
 
void SetWarmStart (bool mval)
 Enable/disable 'warm start'. More...
 
bool GetWarmStart () const
 Return a flag indicating whether or not warm start is enabled.
 
void SetTolerance (double mval)
 Set the tolerance for stopping criterion. More...
 
double GetTolerance () const
 Return the current value of the solver tolerance.
 
void SetRecordViolation (bool mval)
 Enable/disable recording of the constraint violation history. More...
 
bool GetRecordViolation () const
 Return a flag indicating whether or not constraint violations are recorded.
 
const std::vector< double > & GetViolationHistory () const
 Access the vector of constraint violation history. More...
 
const std::vector< double > & GetDeltalambdaHistory () const
 Access the vector with history of maximum change in Lagrange multipliers Note that collection of constraint violations must be enabled through SetRecordViolation. More...
 
- Public Member Functions inherited from chrono::ChSolver
virtual Type GetType () const
 Return type of the solver. More...
 
virtual double Solve (ChSystemDescriptor &sysd)=0
 Performs the solution of the problem. More...
 
virtual bool Setup (ChSystemDescriptor &sysd)
 This function does the setup operations for the solver. More...
 
void SetVerbose (bool mv)
 Set verbose output from solver.
 
bool GetVerbose () const
 

Protected Member Functions

void AtIterationEnd (double mmaxviolation, double mdeltalambda, unsigned int iternum)
 This method MUST be called by all iterative methods INSIDE their iteration loops (at the end). More...
 
virtual void ArchiveOUT (ChArchiveOut &marchive) override
 Method to allow serialization of transient data to archives.
 
virtual void ArchiveIN (ChArchiveIn &marchive) override
 Method to allow de serialization of transient data from archives.
 

Protected Attributes

int max_iterations
 maximum allowed iterations
 
int tot_iterations
 total number of iterations performed by the solver
 
bool warm_start
 indicate whether or not to use warm starting
 
double tolerance
 tolerance for termination criteria
 
double omega
 over-relaxation factor
 
double shlambda
 sharpness factor
 
bool record_violation_history
 
std::vector< double > violation_history
 
std::vector< double > dlambda_history
 
- Protected Attributes inherited from chrono::ChSolver
bool verbose
 

Additional Inherited Members

- Public Types inherited from chrono::ChSolver
enum  Type {
  SOR = 0, SYMMSOR, JACOBI, SOR_MULTITHREAD,
  PMINRES, BARZILAIBORWEIN, PCG, APGD,
  MINRES, SOLVER_DEM, CUSTOM
}
 Available types of solvers.
 

Constructor & Destructor Documentation

chrono::ChIterativeSolver::ChIterativeSolver ( int  mmax_iters = 50,
bool  mwarm_start = false,
double  mtolerance = 0.0,
double  momega = 1.0,
double  mshlambda = 1.0 
)
Parameters
mmax_itersmax.number of iterations
mwarm_startuses warm start?
mtolerancetolerance for termination criterion
momegaoverrelaxation, if any
mshlambdasharpness, if any

Member Function Documentation

void chrono::ChIterativeSolver::AtIterationEnd ( double  mmaxviolation,
double  mdeltalambda,
unsigned int  iternum 
)
protected

This method MUST be called by all iterative methods INSIDE their iteration loops (at the end).

If history recording is enabled, this function will store the current values as passed as arguments. Note: 'iternum' starts at 0 for the first iteration.

const std::vector<double>& chrono::ChIterativeSolver::GetDeltalambdaHistory ( ) const

Access the vector with history of maximum change in Lagrange multipliers Note that collection of constraint violations must be enabled through SetRecordViolation.

const std::vector<double>& chrono::ChIterativeSolver::GetViolationHistory ( ) const

Access the vector of constraint violation history.

Note that collection of constraint violations must be enabled through SetRecordViolation.

void chrono::ChIterativeSolver::SetMaxIterations ( int  mval)

Set the maximum number of iterations.

If the solver exceed this limit, it should stop even if the required tolerance isn't yet reached. Default limit: 50 iterations.

void chrono::ChIterativeSolver::SetOmega ( double  mval)

Set the overrelaxation factor.

This factor may be used by SOR-like methods. Default: 1.

void chrono::ChIterativeSolver::SetRecordViolation ( bool  mval)

Enable/disable recording of the constraint violation history.

If enabled, the maximum constraint violation at the end of each iteration is stored in a vector (see GetViolationHistory).

virtual void chrono::ChIterativeSolver::SetSharpnessLambda ( double  mval)
virtual

Set the sharpness factor.

This factor may be used by SOR-like methods with projection (see Mangasarian LCP method). Usualy in the range [0,1]. Default: 1.

void chrono::ChIterativeSolver::SetTolerance ( double  mval)

Set the tolerance for stopping criterion.

The iteration is stopped when the constraint feasability error is below this value. Default: 0.0

void chrono::ChIterativeSolver::SetWarmStart ( bool  mval)

Enable/disable 'warm start'.

If enabled, the initial guess is set to the current values of the unknowns. Useful if the variables are already near to the solution. In most iterative schemes, this is often a good option.

virtual bool chrono::ChIterativeSolver::SolveRequiresMatrix ( ) const
overridevirtual

Indicate whether ot not the Solve() phase requires an up-to-date problem matrix.

Typically, this is the case for iterative solvers (as the matrix is needed for the matrix-vector operations).

Implements chrono::ChSolver.