SG++-Doxygen-Documentation
Loading...
Searching...
No Matches
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

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

Public Attributes

 DEFAULT_ACCURACY
 
 DEFAULT_IMAX
 
 max_threshold
 Maximal accuracy.
 

Static Public Attributes

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

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__()

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

Constructor.

Member Function Documentation

◆ calcStarting()

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

Rises LinearSolverEvents.CALC_STARTING event.

◆ complete()

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

Rises LinearSolverEvents.COMPLETE event.

◆ fromJson()

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.learner.Learner.Learner.setMemento(), python.uq.analysis.asgc.ASGCKnowledge.ASGCKnowledge.setMemento(), python.uq.learner.Learner.Learner.setMemento(), python.uq.sampler.asgc.ASGCSampler.ASGCSampler.setMemento(), and python.uq.uq_setting.UQSetting.UQSetting.setMemento().

◆ getEpsilon()

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()

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()

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()

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

◆ iterationComplete()

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

Rises LinearSolverEvents.ITERATION_COMPLETE event.

◆ setEpsilon()

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

Sets the accuracy parameter.

Parameters
accuracyfloat value of DEFAULT_ACCURACY parameter
Returns
: CG Solver itself

◆ setImax()

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()

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()

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

◆ starting()

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

Rises LinearSolverEvents.STARTING event.

◆ toString()

Member Data Documentation

◆ alpha

◆ DEFAULT_ACCURACY [1/2]

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

◆ DEFAULT_ACCURACY [2/2]

python.learner.solver.CGSolver.CGSolver.DEFAULT_ACCURACY

◆ DEFAULT_IMAX [1/2]

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

maximal number of iterations used in CG

◆ DEFAULT_IMAX [2/2]

python.learner.solver.CGSolver.CGSolver.DEFAULT_IMAX

◆ 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: