SG++-Doxygen-Documentation
sgpp::combigrid::AveragingLevelManager Class Reference

This is a simple LevelManager implementation that does level norm prediction for adaptive refinement by averaging the norms of predecessor levels divided by their number of new points. More...

#include <AveragingLevelManager.hpp>

Inheritance diagram for sgpp::combigrid::AveragingLevelManager:
sgpp::combigrid::LevelManager

Public Member Functions

 AveragingLevelManager (std::shared_ptr< AbstractLevelEvaluator > levelEvaluator)
 
 AveragingLevelManager ()
 
virtual std::shared_ptr< LevelManagerclone ()
 
virtual ~AveragingLevelManager ()
 
- Public Member Functions inherited from sgpp::combigrid::LevelManager
void addLevel (MultiIndex const &level)
 Calls addLevel() on the underlying CombigridEvaluator. More...
 
virtual void addLevelsAdaptive (size_t maxNumPoints)
 Adds levels in an adaptive manner, such that the given maximum number of function evaluations (grid points) is not exceeded. More...
 
void addLevelsAdaptiveByNumLevels (size_t numLevels=1)
 Queue based addLevel-type function. More...
 
virtual void addLevelsAdaptiveParallel (size_t maxNumPoints, size_t numThreads)
 Does the same as addLevelsAdaptive(), but with parallel function evaluations. More...
 
void addLevelsFromSerializedStructure (std::string serializedStructure)
 Equivalent to deserializing serializedStructure and then calling addLevelsFromStructure(). More...
 
void addLevelsFromSerializedStructureParallel (std::string serializedStructure, size_t numThreads)
 Does the same as addLevelsFromSerializedStructure(), but with parallel precomputation of function values using numThreads threads. More...
 
void addLevelsFromStructure (std::shared_ptr< TreeStorage< uint8_t >> storage)
 Adds all levels for which an entry is contained in storage. More...
 
void addLevelsFromStructureParallel (std::shared_ptr< TreeStorage< uint8_t >> storage, size_t numThreads=4)
 Does the same as addLevelsFromStructure(), but with parallel precomputation of function values using numThreads threads. More...
 
void addRegularLevels (size_t q)
 
void addRegularLevelsByNumPoints (size_t maxNumPoints)
 Adds a set of level multi-indices. More...
 
void addRegularLevelsByNumPointsParallel (size_t maxNumPoints, size_t numThreads)
 Does the same as addRegularLevelsByNumPoints(), but with parallel precomputation of function values. More...
 
void addRegularLevelsParallel (size_t q, size_t numThreads)
 Does the same as addRegularLevels(), but with parallel precomputation of function values. More...
 
sgpp::base::DataMatrix convertLevelStructureToMatrix (std::shared_ptr< sgpp::combigrid::TreeStorage< uint8_t >> const &levelstructure, size_t numDims)
 writes a given level structure to a matrix More...
 
void disableStatsCollection ()
 Disables the collection of information on subspaces during refinement. More...
 
void enableStatsCollection ()
 Enables the collection of information on subspaces during refinement. More...
 
std::vector< base::DataVectorgetAllGridPoints ()
 
base::DataMatrix getGridPointMatrix ()
 
std::shared_ptr< LevelInfosgetInfoOnAddedLevels ()
 Returns information on all the subspaces that is sorted with respect to the iterations when they have been added to the combigrid during refinement. More...
 
std::shared_ptr< TreeStorage< uint8_t > > getLevelStructure () const
 
std::vector< MultiIndexgetRegularLevels (size_t q)
 
std::string getSerializedLevelStructure () const
 
size_t getUpperPointBound () const
 
 LevelManager (std::shared_ptr< AbstractLevelEvaluator > levelEvaluator, bool collectStats=true)
 Constructor. More...
 
 LevelManager ()
 Default constructor. More...
 
size_t maxNumPointsForRegular (size_t q)
 
virtual size_t numDims () const
 
size_t numGridPoints ()
 
void printLevelStructure (std::shared_ptr< sgpp::combigrid::TreeStorage< uint8_t >> const &levelstructure)
 prints a given level structure More...
 
void setLevelEvaluator (std::shared_ptr< AbstractLevelEvaluator > levelEvaluator)
 Sets the level evaluator (normally a CombigridEvaluator). More...
 
virtual ~LevelManager ()
 

Protected Member Functions

virtual double computePriority (MultiIndex const &level)
 By implementing this method in a derived class, the adaption can be customized. More...
 
- Protected Member Functions inherited from sgpp::combigrid::LevelManager
void addLevels (std::vector< MultiIndex > const &levels)
 Adds all the given levels. More...
 
bool addLevelToCombiEval (const MultiIndex &level)
 Adds the level to the combigrid evaluator. More...
 
void addStats (const MultiIndex &level)
 update stats for levels that have been added in the current iteration More...
 
virtual void addToQueue (MultiIndex const &level, std::shared_ptr< LevelInfo > levelInfo)
 Puts the given level into the priority queue (uses computePriority() first to compute its priority). More...
 
virtual void afterComputation (MultiIndex const &level)
 This function should be called after all desired precomputations (i.e. More...
 
virtual void beforeComputation (MultiIndex const &level)
 This function should be called between getting a level from the top of the priority queue and starting computations on it. More...
 
virtual std::vector< MultiIndexgetPredecessors (MultiIndex const &level)
 Helper function returning all predecessor level multi-indices. More...
 
std::vector< MultiIndexgetRegularLevelsByNumPoints (size_t maxNumPoints)
 
virtual std::vector< MultiIndexgetSuccessors (MultiIndex const &level)
 Helper function returning all successor level multi-indices. More...
 
virtual void initAdaption ()
 Initializes the data structures for adaptive level generation. More...
 
void precomputeLevelsParallel (std::vector< MultiIndex > const &levels, size_t numThreads)
 Does precomputations for all given levels in parallel with the specified number of threads. More...
 
virtual void predecessorsCompleted (MultiIndex const &level)
 This function is called after all desired precomputations (i.e. More...
 
virtual void tryAddLevel (MultiIndex const &level)
 Adds a level to levelData if all of its predecessors are already in levelData. More...
 
virtual void tryAddSuccessors (MultiIndex const &level)
 Adds successors of the given level to levelData if all of their other predecessors are also in levelData. More...
 
virtual void updatePriority (MultiIndex const &level, std::shared_ptr< LevelInfo > levelInfo)
 Updates the priority of a given level in the priority queue based on the currently available information. More...
 
void updateStats ()
 update statistics on added levels More...
 

Additional Inherited Members

- Protected Attributes inherited from sgpp::combigrid::LevelManager
bool collectStats
 Defines if statistics on the refinement process are collected or not. More...
 
std::shared_ptr< AbstractLevelEvaluatorcombiEval
 CombigridEvaluator (hidden behind an interface to avoid carrying around its template parameter here). More...
 
std::shared_ptr< LevelInfosinfoOnAddedLevels
 this object stores information on the levels during adaptive refinement More...
 
std::shared_ptr< TreeStorage< std::shared_ptr< LevelInfo > > > levelData
 Stores level information for already visited (!= computed) levels. More...
 
std::shared_ptr< std::recursive_mutex > managerMutex
 Mutex that is shared with all involved objects for evaluation parts that require mutual exclusion. More...
 
size_t numDimensions
 Dimensionality of the problem. More...
 
MultiIndexQueue queue
 Priority queue ranking levels that are not yet evaluated but ready for evaluation by their priority. More...
 

Detailed Description

This is a simple LevelManager implementation that does level norm prediction for adaptive refinement by averaging the norms of predecessor levels divided by their number of new points.

Constructor & Destructor Documentation

◆ AveragingLevelManager() [1/2]

sgpp::combigrid::AveragingLevelManager::AveragingLevelManager ( std::shared_ptr< AbstractLevelEvaluator levelEvaluator)
explicit

◆ AveragingLevelManager() [2/2]

sgpp::combigrid::AveragingLevelManager::AveragingLevelManager ( )

◆ ~AveragingLevelManager()

sgpp::combigrid::AveragingLevelManager::~AveragingLevelManager ( )
virtual

Member Function Documentation

◆ clone()

std::shared_ptr< LevelManager > sgpp::combigrid::AveragingLevelManager::clone ( )
virtual

◆ computePriority()

double sgpp::combigrid::AveragingLevelManager::computePriority ( MultiIndex const &  level)
protectedvirtual

By implementing this method in a derived class, the adaption can be customized.

It should yield a priority for the given level. Levels with higher priority value are added earlier.

Implements sgpp::combigrid::LevelManager.

References python.statsfileInfo::data, sgpp::combigrid::LevelManager::getPredecessors(), and sgpp::combigrid::LevelManager::levelData.


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