SG++-Doxygen-Documentation
Loading...
Searching...
No Matches
sgpp::datadriven::ClassificationRefinementFunctor Class Reference

Classification refinement builds up the combined grid of all classes, then iterates through it always keeping track of the neighbors to detect class changes between neighbors. More...

#include <ClassificationRefinementFunctor.hpp>

Inheritance diagram for sgpp::datadriven::ClassificationRefinementFunctor:
sgpp::datadriven::MultiGridRefinementFunctor sgpp::base::RefinementFunctor

Public Member Functions

std::vector< std::vector< size_t > > adaptAllGrids ()
 Refine and Coarsen all grids of the model.
 
 ClassificationRefinementFunctor (std::vector< base::Grid * > grids, std::vector< base::DataVector * > alphas, std::vector< double > priors, size_t refinements_num=1, size_t coarsenings_num=1, bool level_penalize=true, sgpp::base::AdaptivityThresholdType thresholdType=sgpp::base::AdaptivityThresholdType::Absolute, double refinementThreshold=0.0, double coarseningThreshold=1.0, bool coarsenInitialPoints=true, size_t minimumCoarseningIndex=0)
 Constructor.
 
size_t getNumGrids () override
 Returns the number of grids the functor can / does refine.
 
size_t getRefinementsNum () const override
 Returns the maximal number of points that should be refined.
 
double getRefinementThreshold () const override
 Returns the threshold for refinement.
 
double operator() (base::GridStorage &storage, size_t seq) const override
 This should be returning a refinement value for every grid point.
 
void preComputeEvaluations () override
 Used if expensive computations (eg.
 
void setGridIndex (size_t grid_index) override
 Sets the index (into the vector of grids) of the grid to be refined.
 
double start () const override
 Returns the lower bound of refinement criterion (e.g., alpha or error) (lower bound).
 
 ~ClassificationRefinementFunctor () override
 
- Public Member Functions inherited from sgpp::datadriven::MultiGridRefinementFunctor
virtual ~MultiGridRefinementFunctor ()
 
- Public Member Functions inherited from sgpp::base::RefinementFunctor
virtual double getTotalRefinementValue (GridStorage &storage) const
 Returns the total sum of local (error) indicators used for refinement.
 
 RefinementFunctor ()
 Constructor.
 
virtual ~RefinementFunctor ()
 Destructor.
 

Protected Member Functions

void collectNeighbors (base::HashGridPoint leaf, base::HashGridPoint neighbor, size_t dim, bool isLeft)
 Stores the relation of two found neighbors.
 
std::vector< double > getEvalVector (size_t ind, size_t seq) const
 Gets the evaluations of all grids at the coords of seq.
 
void insertCoarseningCandidate (size_t y, std::vector< std::multimap< double, std::tuple< size_t, size_t, bool > > > &classMapsCoarsening, size_t leafSeqNumber, double score, std::tuple< size_t, size_t, bool > candidate)
 Checks if a refinement candidate should be inserted into the map of candidates.
 
int sgn (double d) const
 
void stepDown (size_t d, size_t minDim, base::HashGridPoint &gp, std::vector< std::pair< base::HashGridPoint, base::HashGridPoint > > &neighbors)
 Iterate through the sparse grid tree.
 

Protected Attributes

std::vector< base::DataVector * > alphas
 
size_t coarsenings_num
 Maximum number of coarsened points per iteration.
 
double coarseningThreshold
 
bool coarsenInitialPoints
 Whether or not to coarsen initial grid points.
 
std::vector< base::Grid * > grids
 
bool level_penalize
 
size_t minimumCoarseningIndex
 
std::vector< std::tuple< size_t, size_t, size_t, bool, base::GridPoint::level_type > > neighborRels
 
std::vector< std::map< std::string, double > > pre_comp_evals
 Stores grid evaluations at all grids (vector) at the union of grid point coordinates over all grids (hashed by string representation in the map)
 
std::vector< double > priors
 
size_t refinements_num
 
double refinementThreshold
 
sgpp::base::AdaptivityThresholdType thresholdType
 
base::GridStorage total_grid
 Maximum index of the initial grid points.
 

Additional Inherited Members

- Public Types inherited from sgpp::base::RefinementFunctor
typedef double value_type
 

Detailed Description

Classification refinement builds up the combined grid of all classes, then iterates through it always keeping track of the neighbors to detect class changes between neighbors.

Only the children in the relevant dimension and direction will be added to the grid.

Constructor & Destructor Documentation

◆ ClassificationRefinementFunctor()

sgpp::datadriven::ClassificationRefinementFunctor::ClassificationRefinementFunctor ( std::vector< base::Grid * >  grids,
std::vector< base::DataVector * >  alphas,
std::vector< double >  priors,
size_t  refinements_num = 1,
size_t  coarsenings_num = 1,
bool  level_penalize = true,
sgpp::base::AdaptivityThresholdType  thresholdType = sgpp::base::AdaptivityThresholdType::Absolute,
double  refinementThreshold = 0.0,
double  coarseningThreshold = 1.0,
bool  coarsenInitialPoints = true,
size_t  minimumCoarseningIndex = 0 
)

Constructor.

Parameters
gridsVector of grids. current_grid_index specifies the grid to be refined
alphasVector of surpluses related to the grids
priorsVector of priors related to the classificator
refinements_numMaximum number of refinements done
coarsenings_numMaximum number of coarsenings done
level_penalizeIf a level penalizing is multiplied to the score (2^{|l|_1})
thresholdTypetype of the threshold: absolute score value or relative score value
refinementThresholdThreshold for refinement scores
coarseningThresholdThreshold for coarsening scores
coarsenInitialPointsWhether or not to coarsen initial grid points
minimumCoarseningIndexMimimum index of grid points that can be coarsened, used when coarsenInitialPoints = false.

◆ ~ClassificationRefinementFunctor()

sgpp::datadriven::ClassificationRefinementFunctor::~ClassificationRefinementFunctor ( )
inlineoverride

Member Function Documentation

◆ adaptAllGrids()

◆ collectNeighbors()

void sgpp::datadriven::ClassificationRefinementFunctor::collectNeighbors ( base::HashGridPoint  leaf,
base::HashGridPoint  neighbor,
size_t  dim,
bool  isLeft 
)
protected

◆ getEvalVector()

std::vector< double > sgpp::datadriven::ClassificationRefinementFunctor::getEvalVector ( size_t  ind,
size_t  seq 
) const
protected

Gets the evaluations of all grids at the coords of seq.

◆ getNumGrids()

size_t sgpp::datadriven::ClassificationRefinementFunctor::getNumGrids ( )
overridevirtual

Returns the number of grids the functor can / does refine.

Implements sgpp::datadriven::MultiGridRefinementFunctor.

References grids.

◆ getRefinementsNum()

size_t sgpp::datadriven::ClassificationRefinementFunctor::getRefinementsNum ( ) const
overridevirtual

Returns the maximal number of points that should be refined.

The maximal number of points to refine is set in the constructor of the implementing class.

Returns
number of points that should refined. Default value: 1.

Reimplemented from sgpp::base::RefinementFunctor.

References refinements_num.

◆ getRefinementThreshold()

double sgpp::datadriven::ClassificationRefinementFunctor::getRefinementThreshold ( ) const
overridevirtual

Returns the threshold for refinement.

Only the grid points with absolute value of refinement criterion (e.g., alpha or error) greater or equal to this threshold will be refined.

Returns
threshold value for refinement. Default value: 0.

Implements sgpp::base::RefinementFunctor.

References refinementThreshold.

◆ insertCoarseningCandidate()

void sgpp::datadriven::ClassificationRefinementFunctor::insertCoarseningCandidate ( size_t  y,
std::vector< std::multimap< double, std::tuple< size_t, size_t, bool > > > &  classMapsCoarsening,
size_t  leafSeqNumber,
double  score,
std::tuple< size_t, size_t, bool >  candidate 
)
protected

Checks if a refinement candidate should be inserted into the map of candidates.

Referenced by adaptAllGrids().

◆ operator()()

double sgpp::datadriven::ClassificationRefinementFunctor::operator() ( base::GridStorage storage,
size_t  seq 
) const
overridevirtual

This should be returning a refinement value for every grid point.

The point with the highest value will be refined first.

Parameters
storagereference to the grids storage object
seqsequence number in the coefficients array
Returns
refinement value

Implements sgpp::base::RefinementFunctor.

◆ preComputeEvaluations()

void sgpp::datadriven::ClassificationRefinementFunctor::preComputeEvaluations ( )
overridevirtual

Used if expensive computations (eg.

grid evaluations) are cached, usually for one refinement step.

Reimplemented from sgpp::datadriven::MultiGridRefinementFunctor.

◆ setGridIndex()

void sgpp::datadriven::ClassificationRefinementFunctor::setGridIndex ( size_t  grid_index)
overridevirtual

Sets the index (into the vector of grids) of the grid to be refined.

Parameters
grid_indexThe index of the grid to be refined

Implements sgpp::datadriven::MultiGridRefinementFunctor.

◆ sgn()

int sgpp::datadriven::ClassificationRefinementFunctor::sgn ( double  d) const
protected

◆ start()

double sgpp::datadriven::ClassificationRefinementFunctor::start ( ) const
overridevirtual

Returns the lower bound of refinement criterion (e.g., alpha or error) (lower bound).

The refinement value of grid points to be refined have to be larger than this value

Returns
lower bound

Implements sgpp::base::RefinementFunctor.

◆ stepDown()

void sgpp::datadriven::ClassificationRefinementFunctor::stepDown ( size_t  d,
size_t  minDim,
base::HashGridPoint gp,
std::vector< std::pair< base::HashGridPoint, base::HashGridPoint > > &  neighbors 
)
protected

Member Data Documentation

◆ alphas

std::vector<base::DataVector*> sgpp::datadriven::ClassificationRefinementFunctor::alphas
protected

Referenced by adaptAllGrids().

◆ coarsenings_num

size_t sgpp::datadriven::ClassificationRefinementFunctor::coarsenings_num
protected

Maximum number of coarsened points per iteration.

Referenced by adaptAllGrids().

◆ coarseningThreshold

double sgpp::datadriven::ClassificationRefinementFunctor::coarseningThreshold
protected

Referenced by adaptAllGrids().

◆ coarsenInitialPoints

bool sgpp::datadriven::ClassificationRefinementFunctor::coarsenInitialPoints
protected

Whether or not to coarsen initial grid points.

Referenced by adaptAllGrids().

◆ grids

std::vector<base::Grid*> sgpp::datadriven::ClassificationRefinementFunctor::grids
protected

Referenced by adaptAllGrids(), and getNumGrids().

◆ level_penalize

bool sgpp::datadriven::ClassificationRefinementFunctor::level_penalize
protected

◆ minimumCoarseningIndex

size_t sgpp::datadriven::ClassificationRefinementFunctor::minimumCoarseningIndex
protected

Referenced by adaptAllGrids().

◆ neighborRels

std::vector<std::tuple<size_t, size_t, size_t, bool, base::GridPoint::level_type> > sgpp::datadriven::ClassificationRefinementFunctor::neighborRels
protected

Referenced by adaptAllGrids(), and collectNeighbors().

◆ pre_comp_evals

std::vector<std::map<std::string, double> > sgpp::datadriven::ClassificationRefinementFunctor::pre_comp_evals
protected

Stores grid evaluations at all grids (vector) at the union of grid point coordinates over all grids (hashed by string representation in the map)

◆ priors

std::vector<double> sgpp::datadriven::ClassificationRefinementFunctor::priors
protected

Referenced by adaptAllGrids().

◆ refinements_num

size_t sgpp::datadriven::ClassificationRefinementFunctor::refinements_num
protected

Referenced by adaptAllGrids(), and getRefinementsNum().

◆ refinementThreshold

double sgpp::datadriven::ClassificationRefinementFunctor::refinementThreshold
protected

◆ thresholdType

sgpp::base::AdaptivityThresholdType sgpp::datadriven::ClassificationRefinementFunctor::thresholdType
protected

Referenced by adaptAllGrids().

◆ total_grid

base::GridStorage sgpp::datadriven::ClassificationRefinementFunctor::total_grid
protected

Maximum index of the initial grid points.

Referenced by adaptAllGrids(), collectNeighbors(), and stepDown().


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