SG++-Doxygen-Documentation
python.learner.solver.CGSolver.CGSolver Class Reference

This is a decorator for sgpp::ConjugateGradients class. More...

Inheritance diagram for python.learner.solver.CGSolver.CGSolver:

Public Member Functions

def __init__ (self)
 Constructor. More...
 
def calcStarting (self)
 Rises LinearSolverEvents.CALC_STARTING event. More...
 
def complete (self)
 Rises LinearSolverEvents.COMPLETE event. More...
 
def fromJson (cls, jsonObject)
 Restores the CGSolver object from the json object with attributes. More...
 
def getEpsilon (self)
 Return the accuracy for CG divergence criterion. More...
 
def getImax (self)
 Return the maximal number of CG iterations. More...
 
def getReuse (self)
 Returns True if the old alpha vector should be reused. More...
 
def getThreshold (self)
 
def iterationComplete (self)
 Rises LinearSolverEvents.ITERATION_COMPLETE event. More...
 
def setEpsilon (self, accuracy)
 Sets the accuracy parameter. More...
 
def setImax (self, imax)
 Sets the maximal number of iterations. More...
 
def setReuse (self, value)
 Defines whether the old alpha vector should be reused. More...
 
def setThreshold (self, threshold)
 
def starting (self)
 Rises LinearSolverEvents.STARTING event. More...
 
def toString (self)
 Returns a string that represents the object. More...
 

Public Attributes

 max_threshold
 Maximal accuracy. More...
 

Static Public Attributes

 alpha = None
 result vector More...
 
float DEFAULT_ACCURACY = 0.0001
 the relationship of the norm of end residual to the normal of initial residual More...
 
int DEFAULT_IMAX = 400
 maximal number of iterations used in CG More...
 

Detailed Description

This is a decorator for sgpp::ConjugateGradients class.

The ConjugateGradients solver is enhanced with methods of concrete subject of the observer design pattern described in LinearSolver and function for serialization end deserialization.

In order to combine high performance of C++ code and flexibility of Subscription pattern the Template design pattern was used in this class. So the CG algorithm itself is implemented in C++ class ConjugateGradients, where template methods starting(), calcStarting(), iterationComplete(), and complete() are defined and called in different phases of the CG algorithm. This methods are overridden by CGSolver to rise the corresponding events by event subscribers.

Constructor & Destructor Documentation

◆ __init__()

def python.learner.solver.CGSolver.CGSolver.__init__ (   self)

Member Function Documentation

◆ calcStarting()

def python.learner.solver.CGSolver.CGSolver.calcStarting (   self)

Rises LinearSolverEvents.CALC_STARTING event.

◆ complete()

def python.learner.solver.CGSolver.CGSolver.complete (   self)

Rises LinearSolverEvents.COMPLETE event.

◆ fromJson()

def python.learner.solver.CGSolver.CGSolver.fromJson (   cls,
  jsonObject 
)

Restores the CGSolver object from the json object with attributes.

Parameters
clspython keyword (do not specify)
jsonObjectA json object.
Returns
The restored SGSolver object.

Referenced by python.uq.sampler.asgc.ASGCSampler.ASGCSampler.setMemento(), python.uq.analysis.asgc.ASGCKnowledge.ASGCKnowledge.setMemento(), python.uq.learner.Learner.Learner.setMemento(), and python.uq.uq_setting.UQSetting.UQSetting.setMemento().

◆ getEpsilon()

def python.learner.solver.CGSolver.CGSolver.getEpsilon (   self)

Return the accuracy for CG divergence criterion.

Returns
the accuracy for CG divergence criterion

References sgpp::solver::SGSolver.myEpsilon, and sgpp::solver::SGSolverSP.myEpsilon.

◆ getImax()

def python.learner.solver.CGSolver.CGSolver.getImax (   self)

Return the maximal number of CG iterations.

Returns
the maximal number of CG iterations.

References sgpp::solver::SGSolver.nMaxIterations, and sgpp::solver::SGSolverSP.nMaxIterations.

◆ getReuse()

def python.learner.solver.CGSolver.CGSolver.getReuse (   self)

Returns True if the old alpha vector should be reused.

Returns
True if the old alpha vector should be reused

References python.learner.solver.CGSolver.CGSolver.__reuse.

◆ getThreshold()

def python.learner.solver.CGSolver.CGSolver.getThreshold (   self)

◆ iterationComplete()

def python.learner.solver.CGSolver.CGSolver.iterationComplete (   self)

Rises LinearSolverEvents.ITERATION_COMPLETE event.

◆ setEpsilon()

def python.learner.solver.CGSolver.CGSolver.setEpsilon (   self,
  accuracy 
)

Sets the accuracy parameter.

Parameters
accuracyfloat value of DEFAULT_ACCURACY parameter
Returns
: CG Solver itself

◆ setImax()

def python.learner.solver.CGSolver.CGSolver.setImax (   self,
  imax 
)

Sets the maximal number of iterations.

Parameters
imaxinteger limit of number of iterations
Returns
: SG Solver itself

References sgpp::solver::SGSolver.setMaxIterations(), and sgpp::solver::SGSolverSP.setMaxIterations().

◆ setReuse()

def python.learner.solver.CGSolver.CGSolver.setReuse (   self,
  value 
)

Defines whether the old alpha vector should be reused.

Parameters
valueTrue if the old alpha vector should be reused

References python.learner.solver.CGSolver.CGSolver.__reuse.

◆ setThreshold()

def python.learner.solver.CGSolver.CGSolver.setThreshold (   self,
  threshold 
)

◆ starting()

def python.learner.solver.CGSolver.CGSolver.starting (   self)

Rises LinearSolverEvents.STARTING event.

◆ toString()

def python.learner.solver.CGSolver.CGSolver.toString (   self)

Returns a string that represents the object.

Returns
A string that represents the object.

References create_dataset.type.

Referenced by python.uq.learner.Learner.Learner.createMemento().

Member Data Documentation

◆ alpha

◆ DEFAULT_ACCURACY

float python.learner.solver.CGSolver.CGSolver.DEFAULT_ACCURACY = 0.0001
static

the relationship of the norm of end residual to the normal of initial residual

Referenced by python.learner.solver.CGSolver.CGSolver.__init__().

◆ DEFAULT_IMAX

int python.learner.solver.CGSolver.CGSolver.DEFAULT_IMAX = 400
static

maximal number of iterations used in CG

Referenced by python.learner.solver.CGSolver.CGSolver.__init__().

◆ max_threshold

python.learner.solver.CGSolver.CGSolver.max_threshold

Maximal accuracy.

If the norm of the residuum falls below max_threshold, stop the CG iterations. Default value: -1

Referenced by python.learner.solver.CGSolver.CGSolver.getThreshold(), and python.learner.solver.CGSolver.CGSolver.setThreshold().


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