Logo ROOT   6.16/01
Reference Guide
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
30#include "Math/MCParameters.h"
31#include "Math/GenAlgoOptions.h"
32
33#include "gsl/gsl_monte_vegas.h"
34
35namespace ROOT {
36namespace Math {
37
38
39 /// default VEGAS parameters (copied from gsl/monte/vegas.c)
41 // init default values
42 alpha = 1.5;
43 iterations = 5;
44 stage = 0;
45 mode = GSL_VEGAS_MODE_IMPORTANCE;
46 verbose = -1;
47 }
48
51 (*this) = opt;
52 }
53
55 // set parameters from IOptions
56 double val = 0;
57 int ival = 0;
58 bool ret = false;
59
60 ret = opt.GetRealValue("alpha",val);
61 if (ret) alpha = val;
62 ret = opt.GetIntValue("iterations",ival);
63 if (ret) iterations = ival;
64 ret = opt.GetIntValue("stage",ival);
65 if (ret) stage = ival;
66 ret = opt.GetIntValue("mode",ival);
67 if (ret) mode = ival;
68 ret = opt.GetIntValue("verbose",ival);
69 if (ret) verbose = ival;
70 return *this;
71 }
72
74 // convert to options (return object is managed by the user)
75 GenAlgoOptions * opt = new GenAlgoOptions();
76 opt->SetRealValue("alpha",alpha);
77 opt->SetIntValue("iterations",iterations);
78 opt->SetIntValue("stage",stage);
79 opt->SetIntValue("mode",mode);
80 opt->SetIntValue("verbose",verbose);
81 return opt;
82 }
83
84
85
86 /// default MISER parameters (copied from gsl/monte/vegas.c)
87
88
90 // init default values
91 estimate_frac = 0.1;
92 min_calls = (dim>0) ? 16*dim : 160; // use default dim = 10
94 dither = 0;
95 alpha = 2.0;
96 }
97
98
99 MiserParameters::MiserParameters(const IOptions & opt, size_t dim) {
100 SetDefaultValues(dim);
101 (*this) = opt;
102 }
103
105 // set parameters from IOptions
106 double val = 0;
107 int ival = 0;
108 bool ret = false;
109
110 ret = opt.GetRealValue("alpha",val);
111 if (ret) alpha = val;
112 ret = opt.GetRealValue("dither",val);
113 if (ret) dither = val;
114 ret = opt.GetRealValue("estimate_frac",val);
115 if (ret) estimate_frac = val;
116 ret = opt.GetIntValue("min_calls",ival);
117 if (ret) min_calls = ival;
118 ret = opt.GetIntValue("min_calls_per_bisection",ival);
119 if (ret) min_calls_per_bisection = ival;
120 return *this;
121 }
122
124 // convert to options (return object is managed by the user)
125 GenAlgoOptions * opt = new GenAlgoOptions();
126 opt->SetRealValue("alpha",alpha);
127 opt->SetRealValue("dither",dither);
128 opt->SetRealValue("estimate_frac",estimate_frac);
129 opt->SetIntValue("min_calls",min_calls);
130 opt->SetIntValue("min_calls_per_bisection",min_calls_per_bisection);
131 return opt;
132 }
133
134
135} // namespace Math
136} // namespace ROOT
137
138
139
class implementing generic options for a numerical algorithm Just store the options in a map of strin...
virtual void SetRealValue(const char *name, double val)
method wich need to be re-implemented by the derived classes
virtual void SetIntValue(const char *name, int val)
Generic interface for defining configuration options of a numerical algorithm.
Definition: IOptions.h:30
virtual bool GetIntValue(const char *, int &) const
Definition: IOptions.h:85
virtual bool GetRealValue(const char *, double &) const
Definition: IOptions.h:83
Namespace for new Math classes and functions.
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
structures collecting parameters for MISER multidimensional integration
Definition: MCParameters.h:76
ROOT::Math::IOptions * operator()() const
convert to options (return object is managed by the user)
MiserParameters(size_t dim=10)
Definition: MCParameters.h:85
MiserParameters & operator=(const ROOT::Math::IOptions &opt)
void SetDefaultValues(size_t dim=10)
default MISER parameters (copied from gsl/monte/vegas.c)
structures collecting parameters for VEGAS multidimensional integration FOr implementation of default...
Definition: MCParameters.h:45
ROOT::Math::IOptions * operator()() const
convert to options (return object is managed by the user)
VegasParameters & operator=(const ROOT::Math::IOptions &opt)
void SetDefaultValues()
default VEGAS parameters (copied from gsl/monte/vegas.c)