Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
MCParameters.cxx
Go to the documentation of this file.
1// @(#)root/mathmore:$Id$
2// Author: Lorenzo Moneta 11/2010
3
4 /**********************************************************************
5 * *
6 * Copyright (c) 2007 ROOT Foundation, CERN/PH-SFT *
7 * *
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU General Public License *
10 * as published by the Free Software Foundation; either version 2 *
11 * of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this library (see file COPYING); if not, write *
20 * to the Free Software Foundation, Inc., 59 Temple Place, Suite *
21 * 330, Boston, MA 02111-1307 USA, or contact the author. *
22 * *
23 **********************************************************************/
24//
25// implementation file for class MCParameters
26// Author: Lorenzo Moneta , Nov 2010
27//
28//
29#include "Math/MCParameters.h"
30#include "Math/GenAlgoOptions.h"
31
32#include "gsl/gsl_monte_vegas.h"
33
34namespace ROOT {
35namespace Math {
36
37
38 /// default VEGAS parameters (copied from gsl/monte/vegas.c)
40 // init default values
41 alpha = 1.5;
42 iterations = 5;
43 stage = 0;
44 mode = GSL_VEGAS_MODE_IMPORTANCE;
45 verbose = -1;
46 }
47
50 (*this) = opt;
51 }
52
54 // set parameters from IOptions
55 double val = 0;
56 int ival = 0;
57 bool ret = false;
58
59 ret = opt.GetRealValue("alpha",val);
60 if (ret) alpha = val;
61 ret = opt.GetIntValue("iterations",ival);
62 if (ret) iterations = ival;
63 ret = opt.GetIntValue("stage",ival);
64 if (ret) stage = ival;
65 ret = opt.GetIntValue("mode",ival);
66 if (ret) mode = ival;
67 ret = opt.GetIntValue("verbose",ival);
68 if (ret) verbose = ival;
69 return *this;
70 }
71
72 std::unique_ptr<ROOT::Math::IOptions> VegasParameters::MakeIOptions() const {
73 // convert to options (return object is managed by the user)
74 auto opt = std::make_unique<GenAlgoOptions>();
75 opt->SetRealValue("alpha",alpha);
76 opt->SetIntValue("iterations",iterations);
77 opt->SetIntValue("stage",stage);
78 opt->SetIntValue("mode",mode);
79 opt->SetIntValue("verbose",verbose);
80 return opt;
81 }
82
83
84
85 /// default MISER parameters (copied from gsl/monte/vegas.c)
86
87
89 // init default values
90 estimate_frac = 0.1;
91 min_calls = (dim>0) ? 16*dim : 160; // use default dim = 10
93 dither = 0;
94 alpha = 2.0;
95 }
96
97
98 MiserParameters::MiserParameters(const IOptions & opt, size_t dim) {
100 (*this) = opt;
101 }
102
104 // set parameters from IOptions
105 double val = 0;
106 int ival = 0;
107 bool ret = false;
108
109 ret = opt.GetRealValue("alpha",val);
110 if (ret) alpha = val;
111 ret = opt.GetRealValue("dither",val);
112 if (ret) dither = val;
113 ret = opt.GetRealValue("estimate_frac",val);
114 if (ret) estimate_frac = val;
115 ret = opt.GetIntValue("min_calls",ival);
116 if (ret) min_calls = ival;
117 ret = opt.GetIntValue("min_calls_per_bisection",ival);
118 if (ret) min_calls_per_bisection = ival;
119 return *this;
120 }
121
122 std::unique_ptr<ROOT::Math::IOptions> MiserParameters::MakeIOptions() const {
123 // convert to options (return object is managed by the user)
124 auto opt = std::make_unique<GenAlgoOptions>();
125 opt->SetRealValue("alpha",alpha);
126 opt->SetRealValue("dither",dither);
127 opt->SetRealValue("estimate_frac",estimate_frac);
128 opt->SetIntValue("min_calls",min_calls);
129 opt->SetIntValue("min_calls_per_bisection",min_calls_per_bisection);
130 return opt;
131 }
132
133
134} // namespace Math
135} // namespace ROOT
136
137
138
Generic interface for defining configuration options of a numerical algorithm.
Definition IOptions.h:28
virtual bool GetIntValue(const char *, int &) const
Definition IOptions.h:64
virtual bool GetRealValue(const char *, double &) const
Definition IOptions.h:63
Namespace for new Math classes and functions.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Structure collecting parameters for MISER multidimensional integration.
MiserParameters(size_t dim=10)
MiserParameters & operator=(const ROOT::Math::IOptions &opt)
void SetDefaultValues(size_t dim=10)
default MISER parameters (copied from gsl/monte/vegas.c)
std::unique_ptr< ROOT::Math::IOptions > MakeIOptions() const
convert to options (return object is managed by the user)
Structures collecting parameters for VEGAS multidimensional integration For implementation of default...
VegasParameters & operator=(const ROOT::Math::IOptions &opt)
void SetDefaultValues()
default VEGAS parameters (copied from gsl/monte/vegas.c)
std::unique_ptr< ROOT::Math::IOptions > MakeIOptions() const
Convert to options.