13 #include "ACDCTraits.h" 14 #include "ACDCGenCell.h" 15 #include "ThePEG/Utilities/Exception.h" 47 template <
typename Rnd,
typename FncPtr>
125 inline double lastF()
const;
136 inline size_type
last()
const;
147 inline void eps(
double newEps);
154 inline void margin(
double newMargin);
161 inline void nTry(size_type newNTry);
190 inline long n()
const;
197 inline long N()
const;
208 inline int nBins()
const;
213 inline int depth()
const;
219 inline double maxInt()
const;
227 inline double eps()
const;
233 inline double margin()
const;
239 inline size_type
nTry()
const;
245 inline long maxTry()
const;
257 inline size_type
size()
const;
293 inline void setRnd(Rnd * r);
298 inline double rnd()
const;
303 inline double rnd(
double lo,
double up)
const;
319 inline long rndInt(
long x)
const;
329 template <
typename POStream>
330 void output(POStream &)
const;
336 template <
typename PIStream>
337 void input(PIStream &);
349 inline const FncVector &
functions()
const;
354 inline FncPtrType
function(size_type i)
const;
375 inline const CellVector &
cells()
const;
591 void divideandconquer();
610 double shiftmaxmin();
762 #include "ACDCGen.icc" DimType lastDimension() const
Return the dimension of the function chosen for the last generated point.
long rndInt(long x) const
Integer in the interval [0,x[.
vector< Level > LevelVector
A vector (stack) of levels.
size_type nTry() const
The number of points used to initialize the tree of cells to use in the generation.
This is a help struct to perform the divide-and-conquer slicing of cells before starting the compensa...
ACDCRandomTraits< RndType > RndTraits
Template argument typedef.
multimap< double, DimType > rateslice
The dimensions to slice in rated by the resulting fractional volume of the resulting slice...
DVector lo
The lower-left corner of the current cell.
ACDCGen is a general class for sampling multi-dimensional functions.
vector< long > theNI
The number of attempts per function so far.
DVector up
The integration limits for the cell being compensated.
double integralErr(FncPtrType f=FncPtrType()) const
Return the error on the current Monte Carlo estimate of the integral of the specified function (or al...
double eps() const
The minimum cell size considered for this generation.
size_type size() const
The number of functions used.
ACDCFncTraits defines the interface to functions to be sampled by ACDCGen.
const DVector & sumMaxInts() const
Return a vector with the incremental sum of overestimated integrals for each function.
ACDCFncTraits< FncPtrType > FncTraits
Template argument typedef.
ACDCGen & operator=(const ACDCGen &)
Assignment is private and not implemented.
bool cheapRandom() const
Returns true if generating random numbers are so cheap that a new one can be thrown everytime a sub-c...
double rnd() const
Double precision number in the interval ]0,1[.
double theMargin
The factor controlling the loss of efficiency when compensating.
long n() const
The number of accepted points so far.
DVector theSumW
The summed weights per function so far.
DVector firstup
The upper-right corner of the 'first' cell.
bool compensating()
Returns true if the generator is currently in a state of compensating an erroneous overestimation of ...
double theEps
The smallest possible division allowed.
DVector lo
The integration limits for the cell being compensated.
DVector fhu
The function values found for the xhu point.
ACDCGenCell * theLastCell
The last cell chosen.
bool useCheapRandom
True if generating random numbers are so cheap that a new one can be thrown everytime a sub-cell is c...
DimType dimension(size_type i) const
Return the dimension of the i'th function.
CellVector thePrimaryCells
The root of the cell tree for the functions in theFunctions.
size_type last() const
return the index of the function chosen for the last generated point.
double g
The previous max value in the Cell to compensate.
DVector theSumW2
The summed squared weights per function so far.
vector< ACDCGenCell * > CellVector
A vector of cells.
double lastF() const
Return the value of the last chosen function in the last point.
FncPtr FncPtrType
Template argument typedef.
DVector xcl
The lower-left point found closest to the current point which gives a function value below the overes...
ACDCGenCell * lastPrimary() const
Return the root cell for the function chosen for the last generated point.
double margin() const
The safety margin used to multiply the highest found function value in a cell when setting its overes...
DVector up
The upper-right corner of the current cell.
long maxTry() const
The maximum number of attempts to generate a phase space point, or to find non-zero points in the ini...
ACDCGenCell * lastCell() const
Return the cell chosen for the last generated point.
long N() const
The number of calls to generate() so far.
DimVector::size_type size_type
The size type of the vectors used.
DVector firstlo
The lower-left corner of the 'first' cell.
const CellVector & cells() const
Return the roots of all cell trees.
RndType * theRnd
The random number generator to be used for this Generator.
FncVector theFunctions
A vector of functions.
ACDCGenCell * first
The cell which resulted from the first slicing procedure.
long theNAcc
The number of accepted points (weight > 0) so far.
void reject()
Reject the last generated point.
int nBins() const
Return the number of active cells created so far.
bool wholecomp
If true, then the whole original cell should compensated in the continued generation.
void output(POStream &) const
This function is to be used in ThePEG for output to a persistent stream and will not work properly fo...
double fsel
The function value in the current point.
ACDCGen()
Default Constructor.
FncPtr f
A pointer to the function to be used.
DimVector theDimensions
The dimensions of the functions in theFunctions.
size_type index
The index corresponding to the cell being compensated.
double epsilon
The epsilon() value obtained from the controlling ACDCGen object.
static size_type maxsize
The maximum recursion depth of the compensation so far.
void chooseCell(DVector &lo, DVector &up)
Choose a function according to its overestimated integral and choose a cell to generate a point in...
double minf
The minimu function value found in the current sliced cell (set by shiftmaxmin()).
DVector xsel
The current point around which we are slicing.
LevelVector levels
The vector (stack) of levels.
short DimType
The integer type used to represent the dimension of the a functions to be sampled-.
double efficiency() const
The ratio of the number of accepted and number of tried points n()/N();.
double doMaxInt()
Calculate the overestimated integral for all functions.
long theN
The number of attempted points so far.
DVector xhl
The lower-left point furthest away from the current point which gives a function value abov the overe...
A helper struct representing a level of compensation.
Rnd RndType
Template argument typedef.
vector< FncPtrType > FncVector
A vector of function objects.
void input(PIStream &)
This function is to be used in ThePEG for input from a persistent stream and will not work properly f...
DVector fhl
The function values found for the xhl point.
ACDCGenCell * cell
The cell which is being compensated.
long lastN
The number of attempts after which this level disapprears.
double theLastF
The function value of the last point.
int depth() const
Return the maximum depth of any tree of cells used.
vector< DimType > DimVector
A vector of integers.
DVector xcu
The upper-right point found closest to the current point which gives a function value below the overe...
void setRnd(Rnd *r)
Set a new random number generator.
bool addFunction(DimType dim, FncPtrType f, double maxrat=-1.0)
Add a function of a given dimension, dim, according to which points will be generated.
long theMaxTry
The maximum number of attempts to generate a phase space point, or to find non-zero points in the ini...
double maxInt() const
Return the current overestimation of the full integral of all specified functions over the unit volum...
FncPtrType lastFunction() const
Return the function chosen for the last generated point.
vector< double > DVector
A vector of doubles.
is the main config header file for ACDCGen.
long compleft() const
Return an estimate of how many points need to be sampled before the generator finishes compensating...
double margin
The margin() value obtained from the controlling ACDCGen object.
ACDCGenCell * cell(size_type i) const
Return the root cell for the i'th function.
DimType D
The dimension of the cell to be sliced.
const DVector & lastPoint() const
Return the last generated point.
void clear()
Remove all added functions and reset the generator;.
void compensate(const DVector &lo, const DVector &up)
Start the compensation procedure for the last chosen cell when a function velue has been found which ...
FncPtrType generate()
Generate a point, choosing between the different functions specified.
DVector xhu
The upper-right point furthest away from the current point which gives a function value abov the over...
The namespace in which all ACDCGen classes are defined.
vector< ACDCGenCellInfo > extractCellInfo() const
Return a vector with information about all cells.
const DimVector & dimensions() const
Return a vector with the dimensions of all functions.
DVector theLastPoint
The last point generated.
DVector theSumMaxInts
The accumulated sum of overestimated integrals of the functions in theFunctions.
double integral(FncPtrType f=FncPtrType()) const
Return the current Monte Carlo estimate of the integral of the specified function (or all functions i...
size_type theNTry
The number of points to use to find initial average.
const FncVector & functions() const
Return the vector of functions.
ACDCGenCell is the class representing a generation cell in ACDCGen.
ACDCRandomTraits defines the interface to random number generator objects to be used by ACDCGen...
ACDCGenCell * current
The current cell.
size_type theLast
The last index chosen.