Monte Carlo numerical integrators#
The modularity of CepGen also allows for multiple integration algorithms to be steered and profit for some increased numerical stability of a wise choice of parameters.
Several interfaces to external algorithms are provided in the core and CepGenAddOns
libraries.
In the Python cards parsing these can be steered through the integrator
keyword.
All modules are derived from a common cepgen::Integrator object, described below:
A full list of the algorithms and their parameters can be found here.
-
class Integrator : public NamedModule<Integrator>#
Subclassed by GSLIntegrator
Detailed description
Click to show
-
class Integrator : public NamedModule<Integrator>
Integration algorithm.
Subclassed by GSLIntegrator
Public Functions
-
inline virtual bool oneDimensional() const
Is the integrator designed for one-dimensional case?
-
virtual double eval(Integrand&, const std::vector<double>&) const
Compute function value at one point.
-
Value integrate(Integrand &integrand, const std::vector<Limits>& = {})
Evaluate the integral for a given range.
-
Value integrate(const std::function<double(double)> &integrand, const Limits &range_1d = {0., 1.})
Evaluate the integral of a function for a given range.
- Parameters:
integrand – [in] Function to integrate
range_1d – [in] integration range
-
Value integrate(const std::function<double(const std::vector<double>&)> &integrand, const std::vector<Limits> &range)
Evaluate the integral of a function for a given range.
- Parameters:
integrand – [in] Function to integrate
range – [in] integration range
-
inline const std::string &name() const
Module unique indexing name.
-
inline bool operator==(const SteeredObject &oth) const
Equality operator.
-
inline bool operator!=(const SteeredObject &oth) const
Inequality operator.
-
inline virtual const ParametersList ¶meters() const override
Module user-defined parameters.
-
inline virtual void setParameters(const ParametersList ¶ms) override
Set module parameters.
-
inline void setDescribedParameters(const ParametersList ¶ms_orig)
Set (documented) module parameters.
-
inline virtual bool oneDimensional() const
GSL Monte Carlo integrator algorithms#
This category encompasses all “historical” integrator algorithms.
Relying on the GSL implementation of gsl_monte_xxx
integration routines, they are all characterised by a set of algorithm-specific relevent parameters (see the GSL manual for a description).
Currently, three modules are provided natively in CepGen:
cepgen::VegasIntegrator for the Vegas algorithm by G. P. Lepage (also provided as a Python module, see below). The various steering parameters are listed here ;
cepgen::MISERIntegrator for the MISER algorithm. The various steering parameters are listed here ;
cepgen::PlainIntegrator for the “plain”, trial/error algorithm. The various steering parameters are listed here.
In CepGen, all interfacing modules are derivatives of the base cepgen::GSLIntegrator object:
-
class GSLIntegrator : public Integrator#
ROOT integration algorithms#
Added in version 0.9.10.
This two-in-one cepgen::root::Integrator interfacing object allows the numerical integration of an integrand through the two ROOT numerical integration algorithms:
a one-dimensional integrator (see ROOT::Math::IntegratorOneDim) ;
a multidimensional integrator (see ROOT::Math::IntegratorMultiDim).
According to the user’s request, either of the two objects is populated and configured. The following parameters are to be steered by the end user:
type
: integrator algorithm type: : -gauss
,legendre
,adaptive
,adaptiveSingular
,nonAdaptive
, for one-dimensional integration,adaptive
,plain
,miser
,vegas
for multidimensional integration. The last three are one-to-one equivalent to the GSL Monte Carlo algorithms described above (except for the interface and parameters definition).
absToL
: desired absolute error ;relToL
: desired relative error ;size
: maximum number of sub-intervals.
Foam integration algorithm#
Added in version 0.9.10.
Whenever found in the ROOT installation path, an interface to the Foam algorithm is also provided (either for numerical integration, or for unweighted event generation). The interfacing object, cepgen::FoamIntegrator, can be steered using the parameters listed here.
Python integration algorithms#
Added in version 1.2.0.
The cepgen::python::Integrator Python extension module allows the interfacing between CepGen and any Python numerical integrator algorithm. It relies on the definition of a Python wrapper/interfacing function of the form:
def integrate(f, # [](vector<double>) -> double, C++ integrand wrapper
num_dim: int, # number of dimensions to integrate
num_iter: int, # (optional) number of iterations for integration
num_warmup: int, # number of function calls for (optional) warmup
num_calls: int, # number of function calls at each iteration
limits: list[tuple[float]]=[] # list of (min, max) variables limits
):
# definition of integration procedure
# [...]
return (average, standard_deviation)
Among centrally provided implementations of Python integrators wrapper (found in the python/IntegrationAlgos
directory), one may quote:
MCint.py, interface to the MCint MC numerical integration tool ;
Scipy.py, interface to the
scipy.integrate
integration/ODE package of scipy ;Torchquad.py, interface to the torchquad GPU multidimensional numerical integator based on PyTorch ;
Vegas.py, interface to the Python version of the vegas integrator by G. P. Lepage.