herwig is hosted by Hepforge, IPPP Durham
Herwig 7.3.0
ExSample::CellGrid Class Reference

A binary cell grid. More...

#include <CellGrid.h>

Inheritance diagram for ExSample::CellGrid:

Public Member Functions

 CellGrid ()
 Default constructor.
 
 CellGrid (const std::vector< double > &newLowerLeft, const std::vector< double > &newUpperRight, double newWeight=0.0)
 Construct given boundaries and a weight.
 
virtual CellGridmakeInstance () const
 Produce a new instance of a cell grid.
 
virtual CellGridmakeInstance (const std::vector< double > &newLowerLeft, const std::vector< double > &newUpperRight, double newWeight=0.0) const
 Produce a new instance of a cell grid.
 
virtual ~CellGrid ()
 The destructor.
 
void boundaries (const std::vector< double > &newLowerLeft, const std::vector< double > &newUpperRight)
 Set the boundaries.
 
const std::vector< double > & lowerLeft () const
 Return the lower left corner of the cell grid.
 
const std::vector< double > & upperRight () const
 Return the upper right corner of the cell grid.
 
const std::vector< bool > & upperBoundInclusive () const
 Flag in which dimension this cell is upper bound inclusive.
 
double volume (const std::vector< double > &lowerLeft, const std::vector< double > &upperRight) const
 Calculate a volume given upper and lower bound.
 
bool isLeaf () const
 Return true, if this is a leaf in the tree.
 
std::size_t depth () const
 Return the depth of this grid.
 
std::size_t size () const
 Return the number of nodes contained in this grid.
 
virtual void split (std::size_t newSplitDimension, double newSplitCoordinate)
 Split this cell grid in the given dimension and coordinate, if it is a leaf.
 
std::pair< std::size_t, double > splitPoint () const
 Return the dimension and coordinate along which the first split of this grid occurs.
 
const CellGridfirstChild () const
 Return the first child.
 
CellGridfirstChild ()
 Access the first child.
 
const CellGridsecondChild () const
 Return the second child.
 
CellGridsecondChild ()
 Access the second child.
 
void splitCoordinates (std::size_t, std::set< double > &) const
 Fill split coordinates along a given dimension.
 
bool active () const
 Return true, if this grid is active with respect to the last parameter point passed.
 
double volume () const
 Return the volume relevant for the last parameter point set.
 
double integral () const
 Return the integral relevant for the last parameter point set.
 
double weight () const
 Return the weight.
 
void weight (double w)
 Set the weight.
 
void updateIntegral ()
 Update the integrals.
 
void minimumSelection (double p=0.1)
 Ensure a minimum cell selection probability.
 
bool contains (const std::vector< double > &point, const std::vector< bool > &parameterFlags) const
 Return true, if this grid contains the given parameter point.
 
double nonParametricVolume (const std::vector< double > &point, const std::vector< bool > &parameterFlags) const
 Get the volume relevant for the dimensions not considered parameters.
 
void updateIntegral (const std::vector< double > &point, const std::vector< bool > &parameterFlags, std::vector< bool >::iterator hashPosition)
 Set a parameter point and flag which dimensions are considered parameters.
 
double projectInterval (const std::pair< double, double > &interval, std::size_t dimension) const
 Return the projection to the given interval and dimension, provided the interval is not overlapping with more than one cell in the given dimension.
 
std::map< std::pair< double, double >, double > project (std::pair< double, double > interval, std::size_t dimension) const
 Return the projection to the given interval and dimension.
 
virtual void fromXML (const XML::Element &)
 Fill CellGrid data from an XML element.
 
virtual XML::Element toXML () const
 Return an XML element for the data of this CellGrid.
 
template<class RndGenerator >
void randomGrid (RndGenerator &rnd, std::size_t maxDepth, bool forceSplit=true)
 Generate a random grid of given maximum depth.
 
void dumpToC (std::ostream &os, const std::string &name) const
 Write out C code corresponding to the cell grid function.
 
void dumpPartToC (std::ostream &os, std::string prefix="") const
 Write out C code corresponding to the cell grid function.
 

Private Member Functions

void doMinimumSelection (double r, double ref)
 Ensure a minimum cell selection probability.
 

Private Attributes

std::vector< double > theLowerLeft
 The lower left corner of the cell grid.
 
std::vector< double > theUpperRight
 The upper right corner of the cell grid.
 
std::vector< bool > theUpperBoundInclusive
 Flag in which dimension this cell is upper bound inclusive.
 
double theVolumeOrIntegral
 The volume (leafs) or integral (nodes) relevant for the last parameter point set.
 
double theWeight
 The weight.
 
std::vector< CellGrid * > theChildren
 The children cell grids.
 

Detailed Description

A binary cell grid.

Author
Simon Platzer

Definition at line 42 of file CellGrid.h.

Constructor & Destructor Documentation

◆ CellGrid()

ExSample::CellGrid::CellGrid ( )
inline

Default constructor.

Definition at line 49 of file CellGrid.h.

Member Function Documentation

◆ fromXML()

virtual void ExSample::CellGrid::fromXML ( const XML::Element )
virtual

Fill CellGrid data from an XML element.

Reimplemented in ExSample::SimpleCellGrid.

◆ isLeaf()

bool ExSample::CellGrid::isLeaf ( ) const
inline

Return true, if this is a leaf in the tree.

Definition at line 108 of file CellGrid.h.

References theChildren.

Referenced by ExSample::SimpleCellGrid::explore(), and ExSample::SimpleCellGrid::selectCell().

◆ lowerLeft()

const std::vector< double > & ExSample::CellGrid::lowerLeft ( ) const
inline

Return the lower left corner of the cell grid.

Definition at line 87 of file CellGrid.h.

References theLowerLeft.

Referenced by ExSample::SimpleCellGrid::explore(), randomGrid(), and ExSample::SimpleCellGrid::sampleFlatPoint().

◆ makeInstance() [1/2]

virtual CellGrid * ExSample::CellGrid::makeInstance ( ) const
virtual

Produce a new instance of a cell grid.

Reimplemented in ExSample::SimpleCellGrid.

◆ makeInstance() [2/2]

virtual CellGrid * ExSample::CellGrid::makeInstance ( const std::vector< double > &  newLowerLeft,
const std::vector< double > &  newUpperRight,
double  newWeight = 0.0 
) const
virtual

Produce a new instance of a cell grid.

Reimplemented in ExSample::SimpleCellGrid.

◆ projectInterval()

double ExSample::CellGrid::projectInterval ( const std::pair< double, double > &  interval,
std::size_t  dimension 
) const

Return the projection to the given interval and dimension, provided the interval is not overlapping with more than one cell in the given dimension.

Use splitCoordinates() to determine appropriate intervals.

◆ randomGrid()

template<class RndGenerator >
void ExSample::CellGrid::randomGrid ( RndGenerator &  rnd,
std::size_t  maxDepth,
bool  forceSplit = true 
)
inline

Generate a random grid of given maximum depth.

Definition at line 291 of file CellGrid.h.

References firstChild(), lowerLeft(), randomGrid(), secondChild(), size(), split(), upperRight(), and weight().

Referenced by randomGrid().

◆ split()

virtual void ExSample::CellGrid::split ( std::size_t  newSplitDimension,
double  newSplitCoordinate 
)
virtual

Split this cell grid in the given dimension and coordinate, if it is a leaf.

Reimplemented in ExSample::SimpleCellGrid.

Referenced by randomGrid().

◆ toXML()

virtual XML::Element ExSample::CellGrid::toXML ( ) const
virtual

Return an XML element for the data of this CellGrid.

Reimplemented in ExSample::SimpleCellGrid.

◆ updateIntegral()

void ExSample::CellGrid::updateIntegral ( const std::vector< double > &  point,
const std::vector< bool > &  parameterFlags,
std::vector< bool >::iterator  hashPosition 
)

Set a parameter point and flag which dimensions are considered parameters.

Calculate a hash for the relevant subgrid.

◆ upperBoundInclusive()

const std::vector< bool > & ExSample::CellGrid::upperBoundInclusive ( ) const
inline

Flag in which dimension this cell is upper bound inclusive.

Definition at line 97 of file CellGrid.h.

References theUpperBoundInclusive.

◆ upperRight()

const std::vector< double > & ExSample::CellGrid::upperRight ( ) const
inline

Return the upper right corner of the cell grid.

Definition at line 92 of file CellGrid.h.

References theUpperRight.

Referenced by randomGrid(), and ExSample::SimpleCellGrid::sampleFlatPoint().

◆ weight()

double ExSample::CellGrid::weight ( ) const
inline

Member Data Documentation

◆ theChildren

std::vector<CellGrid*> ExSample::CellGrid::theChildren
private

The children cell grids.

Definition at line 281 of file CellGrid.h.

Referenced by isLeaf().

◆ theLowerLeft

std::vector<double> ExSample::CellGrid::theLowerLeft
private

The lower left corner of the cell grid.

Definition at line 255 of file CellGrid.h.

Referenced by lowerLeft().

◆ theUpperBoundInclusive

std::vector<bool> ExSample::CellGrid::theUpperBoundInclusive
private

Flag in which dimension this cell is upper bound inclusive.

Definition at line 265 of file CellGrid.h.

Referenced by upperBoundInclusive().

◆ theUpperRight

std::vector<double> ExSample::CellGrid::theUpperRight
private

The upper right corner of the cell grid.

Definition at line 260 of file CellGrid.h.

Referenced by upperRight().

◆ theVolumeOrIntegral

double ExSample::CellGrid::theVolumeOrIntegral
private

The volume (leafs) or integral (nodes) relevant for the last parameter point set.

Definition at line 271 of file CellGrid.h.

◆ theWeight

double ExSample::CellGrid::theWeight
private

The weight.

Definition at line 276 of file CellGrid.h.

Referenced by weight().


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