00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "Math/MCParameters.h"
00031 #include "Math/GenAlgoOptions.h"
00032
00033 #include "gsl/gsl_monte_vegas.h"
00034
00035 namespace ROOT {
00036 namespace Math {
00037
00038
00039
00040 void VegasParameters::SetDefaultValues() {
00041
00042 alpha = 1.5;
00043 iterations = 5;
00044 stage = 0;
00045 mode = GSL_VEGAS_MODE_IMPORTANCE;
00046 verbose = -1;
00047 }
00048
00049 VegasParameters::VegasParameters(const IOptions & opt) {
00050 SetDefaultValues();
00051 (*this) = opt;
00052 }
00053
00054 VegasParameters & VegasParameters::operator= (const IOptions & opt) {
00055
00056 double val = 0;
00057 int ival = 0;
00058 bool ret = false;
00059
00060 ret = opt.GetRealValue("alpha",val);
00061 if (ret) alpha = val;
00062 ret = opt.GetIntValue("iterations",ival);
00063 if (ret) iterations = ival;
00064 ret = opt.GetIntValue("stage",ival);
00065 if (ret) stage = ival;
00066 ret = opt.GetIntValue("mode",ival);
00067 if (ret) mode = ival;
00068 ret = opt.GetIntValue("verbose",ival);
00069 if (ret) verbose = ival;
00070 return *this;
00071 }
00072
00073 IOptions * VegasParameters::operator() () const {
00074
00075 GenAlgoOptions * opt = new GenAlgoOptions();
00076 opt->SetRealValue("alpha",alpha);
00077 opt->SetIntValue("iterations",iterations);
00078 opt->SetIntValue("stage",stage);
00079 opt->SetIntValue("mode",mode);
00080 opt->SetIntValue("verbose",verbose);
00081 return opt;
00082 }
00083
00084
00085
00086
00087
00088
00089 void MiserParameters::SetDefaultValues(size_t dim) {
00090
00091 estimate_frac = 0.1;
00092 min_calls = (dim>0) ? 16*dim : 160;
00093 min_calls_per_bisection = 32*min_calls;
00094 dither = 0;
00095 alpha = 2.0;
00096 }
00097
00098
00099 MiserParameters::MiserParameters(const IOptions & opt, size_t dim) {
00100 SetDefaultValues(dim);
00101 (*this) = opt;
00102 }
00103
00104 MiserParameters & MiserParameters::operator= (const IOptions & opt) {
00105
00106 double val = 0;
00107 int ival = 0;
00108 bool ret = false;
00109
00110 ret = opt.GetRealValue("alpha",val);
00111 if (ret) alpha = val;
00112 ret = opt.GetRealValue("dither",val);
00113 if (ret) dither = val;
00114 ret = opt.GetRealValue("estimate_frac",val);
00115 if (ret) estimate_frac = val;
00116 ret = opt.GetIntValue("min_calls",ival);
00117 if (ret) min_calls = ival;
00118 ret = opt.GetIntValue("min_calls_per_bisection",ival);
00119 if (ret) min_calls_per_bisection = ival;
00120 return *this;
00121 }
00122
00123 IOptions * MiserParameters::operator() () const {
00124
00125 GenAlgoOptions * opt = new GenAlgoOptions();
00126 opt->SetRealValue("alpha",alpha);
00127 opt->SetRealValue("dither",dither);
00128 opt->SetRealValue("estimate_frac",estimate_frac);
00129 opt->SetIntValue("min_calls",min_calls);
00130 opt->SetIntValue("min_calls_per_bisection",min_calls_per_bisection);
00131 return opt;
00132 }
00133
00134
00135 }
00136 }
00137
00138
00139