SG++
sgpp::datadriven::ZeroCrossingRefinementFunctor Class Reference

Zero-crossing-based refinement uses zero crossings of the difference PDFS f_1 - f_2 to determine areas of interest for the refinement process. More...

#include <ZeroCrossingRefinementFunctor.hpp>

Inheritance diagram for sgpp::datadriven::ZeroCrossingRefinementFunctor:
sgpp::datadriven::MultiGridRefinementFunctor sgpp::base::RefinementFunctor sgpp::datadriven::MultipleClassRefinementFunctor

Public Member Functions

size_t getNumGrids () override
 Returns the number of grids the functor can / does refine. More...
 
size_t getRefinementsNum () const override
 Returns the maximal number of points that should be refined. More...
 
double getRefinementThreshold () const override
 Returns the threshold for refinement. More...
 
double operator() (base::GridStorage &storage, size_t seq) const override
 This should be returning a refinement value for every grid point. More...
 
void preComputeEvaluations () override
 Precomputes grid evaluations for all grids. More...
 
void setGridIndex (size_t grid_index) override
 Sets the index (into the vector of grids) of the grid to be refined. More...
 
double start () const override
 Returns the lower bound of refinement criterion (e.g., alpha or error) (lower bound). More...
 
 ZeroCrossingRefinementFunctor (std::vector< base::Grid * > grids, std::vector< base::DataVector * > alphas, size_t refinements_num=1, bool level_penalize=false, bool pre_compute=false, double threshold=0.0)
 Constructor. More...
 
virtual ~ZeroCrossingRefinementFunctor ()
 
- 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. More...
 
 RefinementFunctor ()
 Constructor. More...
 
virtual ~RefinementFunctor ()
 Destructor. More...
 

Protected Member Functions

void getChild (const base::HashGridPoint &gp, size_t d, bool left, base::HashGridPoint &child) const
 
std::vector< double > getEvalVector (size_t ind, size_t seq) const
 Gets the evaluations of all grids at the coords of seq. More...
 
void getParent (const base::HashGridPoint &gp, size_t d, base::HashGridPoint &par) const
 
void goDown (base::HashGridPoint &gp, base::HashGridPoint &down, size_t d, bool left) const
 Used for non-leaf grid points. More...
 
void goUp (base::HashGridPoint &gp, base::HashGridPoint &up, size_t d, bool left) const
 Used for leaf grid points. More...
 
bool hasChild (const base::HashGridPoint &gp, size_t d, bool left) const
 
bool isLeftChild (const base::HashGridPoint &gp, size_t d) const
 
int sgn (double d) const
 

Protected Attributes

std::vector< base::DataVector * > alphas
 
size_t current_grid_index
 
std::vector< base::Grid * > grids
 
bool level_penalize
 
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) More...
 
bool pre_compute
 
size_t refinements_num
 
double threshold
 

Additional Inherited Members

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

Detailed Description

Zero-crossing-based refinement uses zero crossings of the difference PDFS f_1 - f_2 to determine areas of interest for the refinement process.

The signs of a grid point pair evaluated at two PDFs are compared and only if the signs differ (a zero crossing lies between them) are they considered for the scoring.

The pairs of grid points are geometric neighbors, determined for each dimension separately.

Constructor & Destructor Documentation

sgpp::datadriven::ZeroCrossingRefinementFunctor::ZeroCrossingRefinementFunctor ( std::vector< base::Grid * >  grids,
std::vector< base::DataVector * >  alphas,
size_t  refinements_num = 1,
bool  level_penalize = false,
bool  pre_compute = false,
double  threshold = 0.0 
)

Constructor.

Parameters
gridsVector of grids. current_grid_index specifies the grid to be refined
alphasVector of surpluses related to the grids
refinements_numMaximum number of refinements done
level_penalizeIf a level penalizing is multiplied to the score (2^{|l|_1})
pre_computeFlag for precomputation of necessary grid evals. If true preComputeEvaluations needs to be called before each refinement step
thresholdThreshold for refinement scores

References pre_comp_evals.

virtual sgpp::datadriven::ZeroCrossingRefinementFunctor::~ZeroCrossingRefinementFunctor ( )
inlinevirtual

Member Function Documentation

void sgpp::datadriven::ZeroCrossingRefinementFunctor::getChild ( const base::HashGridPoint gp,
size_t  d,
bool  left,
base::HashGridPoint child 
) const
protected
Parameters
gpthe grid point we want the child from
childgets set to the left/right child in dim d of gp
leftspecifies if left or right child is returned
dspecifies the dimension of the child. All other dims are kept constant

References sgpp::base::HashGridPoint::getIndex(), sgpp::base::HashGridPoint::getLevel(), and sgpp::base::HashGridPoint::set().

Referenced by goDown(), sgpp::datadriven::MultipleClassRefinementFunctor::operator()(), and operator()().

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

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

References alphas, sgpp::op_factory::createOperationEval(), sgpp::base::HashGridPoint::getStandardCoordinates(), grids, pre_comp_evals, and pre_compute.

Referenced by operator()().

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

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

Implements sgpp::datadriven::MultiGridRefinementFunctor.

References grids.

Referenced by ~ZeroCrossingRefinementFunctor().

void sgpp::datadriven::ZeroCrossingRefinementFunctor::getParent ( const base::HashGridPoint gp,
size_t  d,
base::HashGridPoint par 
) const
protected
Parameters
gpthe grid point we want the parent from
pargets set to the parent in dim d of gp
dspecifies the dimension of the child. All other dims are kept constant

References sgpp::base::HashGridPoint::getIndex(), sgpp::base::HashGridPoint::getLevel(), and sgpp::base::HashGridPoint::set().

Referenced by goUp().

size_t sgpp::datadriven::ZeroCrossingRefinementFunctor::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.

double sgpp::datadriven::ZeroCrossingRefinementFunctor::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 threshold.

void sgpp::datadriven::ZeroCrossingRefinementFunctor::goDown ( base::HashGridPoint gp,
base::HashGridPoint down,
size_t  d,
bool  left 
) const
protected

Used for non-leaf grid points.

Decends the tree in dir left until a leaf is reached. Modifies both gp and down. Result in down.

References getChild(), sgpp::base::HashGridPoint::getIndex(), sgpp::base::HashGridPoint::getLevel(), hasChild(), and sgpp::base::HashGridPoint::set().

Referenced by operator()().

void sgpp::datadriven::ZeroCrossingRefinementFunctor::goUp ( base::HashGridPoint gp,
base::HashGridPoint up,
size_t  d,
bool  left 
) const
protected

Used for leaf grid points.

Goes up the tree in dir left until the current grid point is not left/right child of the parent grid point. Modifies both gp and up. Result in up.

References getParent(), and isLeftChild().

Referenced by operator()().

bool sgpp::datadriven::ZeroCrossingRefinementFunctor::hasChild ( const base::HashGridPoint gp,
size_t  d,
bool  left 
) const
protected
bool sgpp::datadriven::ZeroCrossingRefinementFunctor::isLeftChild ( const base::HashGridPoint gp,
size_t  d 
) const
protected

References sgpp::base::HashGridPoint::getIndex().

Referenced by goUp().

double sgpp::datadriven::ZeroCrossingRefinementFunctor::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.

References current_grid_index, getChild(), sgpp::base::HashGridStorage::getDimension(), getEvalVector(), sgpp::base::HashGridPoint::getIndex(), sgpp::base::HashGridPoint::getLevel(), sgpp::base::HashGridPoint::getLevelSum(), sgpp::base::HashGridStorage::getPoint(), sgpp::base::HashGridStorage::getSequenceNumber(), goDown(), goUp(), grids, hasChild(), level_penalize, sgpp::combigrid::pow(), and sgn().

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

Precomputes grid evaluations for all grids.

Used in combination with pre_compute flag = true. Should be called before refinement is done and needs to be re-called after a refinement step is over ie. the surplus vectors got recomputed

Reimplemented from sgpp::datadriven::MultiGridRefinementFunctor.

References alphas, sgpp::op_factory::createOperationEval(), grids, and pre_comp_evals.

Referenced by ~ZeroCrossingRefinementFunctor().

void sgpp::datadriven::ZeroCrossingRefinementFunctor::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.

References current_grid_index.

Referenced by sgpp::datadriven::MultipleClassRefinementFunctor::refine(), and ~ZeroCrossingRefinementFunctor().

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

Referenced by operator()().

double sgpp::datadriven::ZeroCrossingRefinementFunctor::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.

Member Data Documentation

std::vector<base::DataVector*> sgpp::datadriven::ZeroCrossingRefinementFunctor::alphas
protected
size_t sgpp::datadriven::ZeroCrossingRefinementFunctor::current_grid_index
protected
bool sgpp::datadriven::ZeroCrossingRefinementFunctor::level_penalize
protected

Referenced by operator()().

std::vector<std::map<std::string, double> > sgpp::datadriven::ZeroCrossingRefinementFunctor::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)

Referenced by getEvalVector(), preComputeEvaluations(), and ZeroCrossingRefinementFunctor().

bool sgpp::datadriven::ZeroCrossingRefinementFunctor::pre_compute
protected

Referenced by getEvalVector().

size_t sgpp::datadriven::ZeroCrossingRefinementFunctor::refinements_num
protected
double sgpp::datadriven::ZeroCrossingRefinementFunctor::threshold
protected

Referenced by getRefinementThreshold().


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