gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-2191-ga4742ac
a Global And Modular Bsm Inference Tool
Gambit::Scanner Namespace Reference

Namespaces

 Errors
 
 Plugins
 

Classes

struct  __find_variadic_type__
 
struct  __find_variadic_type__< false, false, true, T... >
 
struct  __find_variadic_type__< false, true, b2, T... >
 
struct  __find_variadic_type__< true, b1, b2, T... >
 
struct  __find_variadic_type_convert__
 
struct  __find_variadic_type_convert__< b, Tc, T1, T... >
 
struct  __find_variadic_type_convert__< true, Tc, T1, T... >
 
struct  __find_variadic_type_not_exact__
 
struct  __find_variadic_type_not_exact__< void(args...), ret(args...), T1, T... >
 
struct  __find_variadic_type_not_exact__< void(args...), ret(args2...), T1, T... >
 
struct  __is_args_convertible__
 
struct  __is_args_convertible__< false, T1, T2 >
 
struct  _find_variadic_type_convert_
 
struct  _find_variadic_type_convert_< Tc, T1, T... >
 
struct  _find_variadic_type_not_exact_
 
struct  _find_variadic_type_not_exact_< T1, T2, T... >
 
class  Factory_Base
 Pure Base class of a plugin Factory function. More...
 
struct  find_variadic_type
 
struct  find_variadic_type_convert
 
struct  find_variadic_type_convert< ret(args...)>
 
struct  find_variadic_type_exact
 
struct  find_variadic_type_exact< void(args...), ret(args...), T... >
 
struct  find_variadic_type_exact< void(args...), ret(args2...), T... >
 
struct  find_variadic_type_exact< void(args...)>
 
struct  find_variadic_type_not_exact
 
struct  find_variadic_type_not_exact< void(args...)>
 
struct  first_arg_type
 
struct  first_arg_type< ret(T, args...)>
 
struct  func_ptr_type
 
struct  func_ptr_type< void(args...)>
 
class  Function_Base
 Generic function base used by the scanner. Can be Likelihood, observables, etc. More...
 
class  Function_Base< ret(args...)>
 Base function for the object that is upputed by "set_purpose". More...
 
class  Function_Deleter
 Functor that deletes a Function_Base functor. More...
 
class  Function_Deleter< ret(args...)>
 
struct  is_args_convertible
 
struct  is_args_convertible< ret1(arg1, args1...), ret2(arg2, args2...)>
 
class  like_ptr
 likelihood container for scanner plugins. More...
 
class  Multi_Scanner_Plugin_Function
 
class  Multi_Scanner_Plugin_Function< ret(args...)>
 Objective functor made up of multiple plugins. More...
 
class  Plugin_Function_Factory
 Factory class to make objectives using objective plugins. More...
 
class  RanNumGen
 
struct  remove_all_func
 
struct  remove_all_func< ret(args...)>
 
class  resume_params_func
 class to interface with the plugin manager resume functions. More...
 
struct  return_type
 
struct  return_type< ret(args...)>
 
class  Scan_Manager
 
class  scan_ptr
 Generic ptr that takes ownership of a Function_Base. This is how a plugin will call a function. More...
 
class  scan_ptr< ret(args...)>
 Container class that hold the output of the "get_purpose" function. More...
 
class  Scanner_Plugin_Function
 
class  Scanner_Plugin_Function< ret(args...)>
 Objective functor made up a single plugin. More...
 

Typedefs

typedef Priors::BasePrior prior_interface
 
typedef voidmulti_func_type(const std::map< std::string, std::vector< std::string >> &, const std::vector< std::pair< std::string, std::string >> &)
 
typedef Printers::BasePrinterManager printer_interface
 typedef printer_interface_temp printer_interface; More...
 
typedef Printers::BaseBasePrinter printer
 Type of the printer objects. More...
 

Functions

 LOAD_FUNC_TEMPLATE (Scanner_Plugin_Function, double(std::unordered_map< std::string, double > &))
 
 LOAD_FUNC_TEMPLATE (Scanner_Plugin_Function, void(const std::vector< double > &, std::unordered_map< std::string, double > &))
 
 LOAD_FUNC_TEMPLATE (Scanner_Plugin_Function, std::vector< double >(std::unordered_map< std::string, double > &))
 
 LOAD_MULTI_FUNC_TEMPLATE (Multi_Scanner_Plugin_Function, double(std::unordered_map< std::string, double > &))
 
void assign_aux_numbers ()
 
template<typename... T>
void assign_aux_numbers (const std::string &tag, const T &... params)
 
EXPORT_SYMBOLS errorscan_error ()
 Scanner errors. More...
 
EXPORT_SYMBOLS warningscan_warning ()
 Scanner warnings. More...
 
template<typename... T>
auto zip (const T &... containers) -> boost::iterator_range< boost::zip_iterator< decltype(boost::make_tuple(std::begin(containers)...))>>
 Use for combine container in a range loop: for (auto &&x : zip(a, b)){...}. More...
 
std::string demangle (const std::string &in)
 Demangles gnu c++ name. More...
 
template<typename T >
std::vector< T > get_yaml_vector (const YAML::Node &node)
 Input a vector from the yaml file of the following forms: vec: [a, b, ...] vec: a, b, ... More...
 
int StringToInt (const std::string &str)
 Converts a string to an int. More...
 
std::string IntToString (const int &in)
 Converts a int into a string. More...
 
double pi ()
 Output pi. More...
 
std::map< std::string, std::vector< std::string > > convert_to_map (const std::vector< std::string > &vec)
 Turns a vector with enters [model::parameter, ...] into a map with [{model, parameter}, ...]. More...
 
int register_ScannerBit_handlers ()
 
bool notUnit (const std::vector< double > &in)
 
template<typename T >
T::iterator::pointer c_ptr (T &it)
 
std::vector< std::vector< double > > calcCov (const std::vector< std::vector< double >> &pts)
 
std::vector< std::vector< double > > calcIndent (const std::vector< std::vector< double >> &pts)
 
void TWalk (Gambit::Scanner::like_ptr LogLike, Gambit::Scanner::printer_interface &printer, Gambit::Scanner::resume_params_func set_resume_params, const int &dimension, const double &div, const int &proj, const double &din, const double &alim, const double &alimt, const long long &rand, const double &sqrtR, const int &NChains, const bool &hyper_grid, const int &burn_in, const int &save_freq, const double &hrs_max)
 
YAML::Node combineNodes (const std::map< std::string, YAML::Node > &nodesMap, const YAML::Node &node)
 
void input_variadic_vector (std::vector< void *> &)
 Inputs a varibadic pack into a vector. More...
 
template<typename T , typename... args>
void input_variadic_vector (std::vector< void *> &input, const T &value, const args &... params)
 
template<typename ret >
std::enable_if<!std::is_floating_point< ret >::value, ret >::type scanner_plugin_def_ret ()
 Turns a type into an object. More...
 
template<typename ret >
std::enable_if< std::is_floating_point< ret >::value, ret >::type scanner_plugin_def_ret ()
 
template<int i>
double pow (const double &a)
 Outputs a^i. More...
 
template<>
double pow< 0 > (const double &)
 
template<>
double pow< 1 > (const double &a)
 
template<int i>
int pow (const int &a)
 
template<>
int pow< 0 > (const int &)
 
template<>
int pow< 1 > (const int &a)
 
template<typename T >
std::enable_if< is_container< T >::value, std::ostream & >::type operator<< (std::ostream &out, const T &in)
 Outputs containers to an output stream. More...
 
template<typename T >
std::enable_if< is_pair< T >::value, std::ostream & >::type operator<< (std::ostream &out, const T &in)
 
template<typename T >
std::enable_if<!is_container< T >::value &&!is_pair< T >::value, void >::type resume_file_output (std::ofstream &out, T &param)
 Functions to output data for the plugin resume functions. More...
 
template<typename T >
std::enable_if< is_container< T >::value, void >::type resume_file_output (std::ofstream &out, T &param)
 
template<typename T >
std::enable_if< is_pair< T >::value, void >::type resume_file_output (std::ofstream &out, T &param)
 
template<typename T >
std::enable_if<!is_container< T >::value &&!is_pair< T >::value, void >::type resume_file_input (std::ifstream &in, T &param)
 
template<typename T >
std::enable_if< is_container< T >::value, void >::type resume_file_input (std::ifstream &in, T &param)
 
template<typename T >
std::enable_if< is_pair< T >::value, void >::type resume_file_input (std::ifstream &in, T &param)
 
template<typename T >
std::enable_if<!is_container< T >::value &&!is_pair< T >::value, size_t >::type resume_size_of (T &)
 
template<typename T >
std::enable_if< is_container< T >::value, size_t >::type resume_size_of (T &param)
 
template<typename T >
std::enable_if< is_pair< T >::value, size_t >::type resume_size_of (T &)
 
void resume_file_input (std::ifstream &in, std::string &param)
 
void resume_file_output (std::ofstream &out, std::string &param)
 
size_t resume_size_of (std::string &param)
 

Variables

 gambit_registry
 
std::unordered_map< type_index, func_type *, Gambit::type_hasher, Gambit::type_equal_to__functions__
 
std::unordered_map< type_index, multi_func_type * > __multi_functions__
 
int ScannerBit_handlers = register_ScannerBit_handlers()
 

Typedef Documentation

◆ multi_func_type

typedef void* Gambit::Scanner::multi_func_type(const std::map< std::string, std::vector< std::string >> &, const std::vector< std::pair< std::string, std::string >> &)

Definition at line 52 of file plugin_factory.hpp.

◆ printer

Type of the printer objects.

Definition at line 34 of file printer_interface.hpp.

◆ printer_interface

typedef printer_interface_temp printer_interface;

Definition at line 31 of file printer_interface.hpp.

◆ prior_interface

Function Documentation

◆ assign_aux_numbers() [1/2]

void Gambit::Scanner::assign_aux_numbers ( )
inline

Definition at line 36 of file printer_interface.hpp.

Referenced by assign_aux_numbers(), scanner_plugin(), and TWalk().

36 {}
Here is the caller graph for this function:

◆ assign_aux_numbers() [2/2]

template<typename... T>
void Gambit::Scanner::assign_aux_numbers ( const std::string &  tag,
const T &...  params 
)
inline

Definition at line 39 of file printer_interface.hpp.

References assign_aux_numbers(), and Gambit::Printers::get_aux_param_id().

40  {
42  assign_aux_numbers(params...);
43  }
EXPORT_SYMBOLS int get_aux_param_id(const std::string &)
Returns unique negative parameter id; just a thin wrapper for get_param_id.
void assign_aux_numbers(const std::string &tag, const T &... params)
Here is the call graph for this function:

◆ c_ptr()

template<typename T >
T::iterator::pointer Gambit::Scanner::c_ptr ( T &  it)
inline

Definition at line 47 of file twalk.hpp.

Referenced by TWalk().

47 {return &(*it.begin());}
Here is the caller graph for this function:

◆ calcCov()

std::vector<std::vector<double> > Gambit::Scanner::calcCov ( const std::vector< std::vector< double >> &  pts)
inline

Definition at line 49 of file twalk.hpp.

References generate_raster_scan_settings::N.

50  {
51  static size_t dim = pts[0].size();
52  static size_t N = pts.size();
53 
54  std::vector<std::vector<double>> covar(dim, std::vector<double>(dim, 0.0));
55  std::vector<double> avg(dim, 0.0);
56  size_t i, j;
57 
58  for (auto it = pts.begin(), pt_end = pts.end(); it != pt_end; ++it)
59  {
60  for (i = 0; i < dim; i++)
61  {
62  avg[i] += (*it)[i];
63  for (j = 0; j < dim; j++)
64  {
65  covar[i][j] += (*it)[i]*(*it)[j];
66  }
67  }
68  }
69 
70  for (i = 0; i < dim; i++)
71  {
72  for (j = 0; j < dim; j++)
73  {
74  covar[i][j] = covar[i][j]/N - avg[i]*avg[j]/N/N;
75  }
76  }
77 
78  return covar;
79  }

◆ calcIndent()

std::vector<std::vector<double> > Gambit::Scanner::calcIndent ( const std::vector< std::vector< double >> &  pts)
inline

Definition at line 81 of file twalk.hpp.

82  {
83  static size_t dim = pts[0].size();
84 
85  std::vector<std::vector<double>> covar(dim, std::vector<double>(dim, 0.0));
86  std::vector<double> hi(dim, 1.0), low(dim, 0.0);
87  size_t i;
88 
89  for (auto it = pts.begin(), end = pts.end(); it != end; ++it)
90  {
91  for (i = 0; i < dim; i++)
92  {
93  if (hi[i] < (*it)[i])
94  {
95  hi[i] = (*it)[i];
96  }
97 
98  if (low[i] > (*it)[i])
99  {
100  low[i] = (*it)[i];
101  }
102  }
103  }
104 
105  for (i = 0; i < dim; i++)
106  {
107  covar[i][i] = (hi[i] - low[i])*(hi[i] - low[i])/12.0;
108  }
109 
110  return covar;
111  }

◆ combineNodes()

YAML::Node Gambit::Scanner::combineNodes ( const std::map< std::string, YAML::Node > &  nodesMap,
const YAML::Node &  node 
)
inline

Definition at line 38 of file scan.cpp.

Referenced by Gambit::Scanner::Scan_Manager::Scan_Manager().

39  {
40  YAML::Node outNode = node;
41 
42  for (auto it = nodesMap.begin(), end = nodesMap.end(); it != end; it++)
43  {
44  outNode[it->first] = it->second;
45  }
46 
47  return outNode;
48  }
Here is the caller graph for this function:

◆ convert_to_map()

std::map<std::string, std::vector<std::string> > Gambit::Scanner::convert_to_map ( const std::vector< std::string > &  vec)
inline

Turns a vector with enters [model::parameter, ...] into a map with [{model, parameter}, ...].

Definition at line 271 of file scanner_utils.hpp.

Referenced by Gambit::Scanner::Plugin_Function_Factory::Plugin_Function_Factory().

272  {
273  std::map<std::string, std::vector<std::string>> ret;
274 
275  for (auto it = vec.begin(), end = vec.end(); it != end; it++)
276  {
277  std::string::size_type pos = it->find("::");
278  ret[it->substr(0, pos)].push_back(*it);
279  }
280 
281  return ret;
282  }
Here is the caller graph for this function:

◆ demangle()

std::string Gambit::Scanner::demangle ( const std::string &  in)
inline

Demangles gnu c++ name.

Definition at line 137 of file scanner_utils.hpp.

References scan_end, and scan_err.

Referenced by Gambit::Scanner::Plugins::Plugin_Main_Interface_Base< ret(args...)>::enterMain().

138  {
139 #ifdef __GNUG__
140  int status = -4;
141  char *result = abi::__cxa_demangle (in.c_str(), NULL, NULL, &status);
142 
143  if (status)
144  {
145  scan_err << "Error demangling \"" << in << "\" status code: " << status << scan_end;
146  return in;
147  }
148 
149  std::string ret(result);
150  std::free(result);
151  return ret;
152 #else
153  return in;
154 #endif
155  }
#define scan_err
Defined to macros to output errors in the form: scan_err << "error" << scan_end; scan_warn << "warnin...
#define scan_end
Here is the caller graph for this function:

◆ get_yaml_vector()

template<typename T >
std::vector<T> Gambit::Scanner::get_yaml_vector ( const YAML::Node &  node)
inline

Input a vector from the yaml file of the following forms: vec: [a, b, ...] vec: a, b, ...

vec: a; b; ...

Definition at line 166 of file scanner_utils.hpp.

References scan_end, and scan_err.

167  {
168  if (node.IsSequence())
169  {
170  return node.as< std::vector<T> >();
171  }
172  else if (node.IsScalar())
173  {
174  std::string plug = node.as<std::string>();
175 
176  std::string::size_type pos = plug.find_first_of(",;");
177  while (pos != std::string::npos)
178  {
179  plug[pos] = ' ';
180  pos = plug.find_first_of(",;", pos + 1);
181  }
182 
183  std::stringstream ss;
184  ss << plug;
185  std::vector<T> ret;
186  T temp;
187  while (ss >> temp) ret.push_back(temp);
188 
189  return ret;
190  }
191  else if (node.IsMap())
192  {
193  std::vector<T> ret;
194  for (auto it = node.begin(), end = node.end(); it != end; ++it)
195  {
196  ret.push_back(it->first.as<T>());
197  }
198 
199  return ret;
200  }
201  else
202  {
203  scan_err << "\"" << node << "\" input value not usable in the inifile." << scan_end;
204  return std::vector <T> ();
205  }
206  }
#define scan_err
Defined to macros to output errors in the form: scan_err << "error" << scan_end; scan_warn << "warnin...
#define scan_end

◆ input_variadic_vector() [1/2]

void Gambit::Scanner::input_variadic_vector ( std::vector< void *> &  )
inline

Inputs a varibadic pack into a vector.

Definition at line 226 of file scanner_utils.hpp.

References find_all_gambit_bits::args.

Referenced by Gambit::Scanner::Plugins::Plugin_Interface_Base::initPlugin(), and input_variadic_vector().

226 {}
Here is the caller graph for this function:

◆ input_variadic_vector() [2/2]

template<typename T , typename... args>
void Gambit::Scanner::input_variadic_vector ( std::vector< void *> &  input,
const T &  value,
const args &...  params 
)
inline

Definition at line 229 of file scanner_utils.hpp.

References input_variadic_vector().

230  {
231  input.push_back((void *)&value);
232  input_variadic_vector(input, params...);
233  }
void input_variadic_vector(std::vector< void *> &input, const T &value, const args &... params)
Here is the call graph for this function:

◆ IntToString()

std::string Gambit::Scanner::IntToString ( const int in)
inline

Converts a int into a string.

Definition at line 252 of file scanner_utils.hpp.

Referenced by Gambit::Scanner::Plugins::Plugin_Details::Plugin_Details().

253  {
254  std::stringstream ss;
255  ss << in;
256  return ss.str();
257  }
Here is the caller graph for this function:

◆ LOAD_FUNC_TEMPLATE() [1/3]

Gambit::Scanner::LOAD_FUNC_TEMPLATE ( Scanner_Plugin_Function  ,
double(std::unordered_map< std::string, double > &)   
)

Referenced by Gambit::Scanner::Multi_Scanner_Plugin_Function< ret(args...)>::main().

Here is the caller graph for this function:

◆ LOAD_FUNC_TEMPLATE() [2/3]

Gambit::Scanner::LOAD_FUNC_TEMPLATE ( Scanner_Plugin_Function  ,
void(const std::vector< double > &, std::unordered_map< std::string, double > &)   
)

◆ LOAD_FUNC_TEMPLATE() [3/3]

Gambit::Scanner::LOAD_FUNC_TEMPLATE ( Scanner_Plugin_Function  ,
std::vector< double std::unordered_map< std::string, double > & 
)

◆ LOAD_MULTI_FUNC_TEMPLATE()

Gambit::Scanner::LOAD_MULTI_FUNC_TEMPLATE ( Multi_Scanner_Plugin_Function  ,
double(std::unordered_map< std::string, double > &)   
)

Referenced by Gambit::Scanner::Multi_Scanner_Plugin_Function< ret(args...)>::main().

Here is the caller graph for this function:

◆ notUnit()

bool Gambit::Scanner::notUnit ( const std::vector< double > &  in)
inline

Definition at line 33 of file twalk.hpp.

Referenced by TWalk().

34  {
35  for (auto it = in.begin(), end = in.end(); it != end; ++it)
36  {
37  if(*it < 0.0 || *it > 1.0 || *it == -(*it))
38  {
39  return true;
40  }
41  }
42 
43  return false;
44  }
Here is the caller graph for this function:

◆ operator<<() [1/2]

template<typename T >
std::enable_if<is_container<T>::value, std::ostream &>::type Gambit::Scanner::operator<< ( std::ostream &  out,
const T &  in 
)
inline

Outputs containers to an output stream.

Definition at line 609 of file scanner_utils.hpp.

610  {
611  if (in.size() == 0)
612  return out << "[]";
613 
614 
615  auto it = in.begin();
616  auto end = in.end();
617  out << "[" << *it;
618  for (++it; it != end; ++it)
619  {
620  out << ", " << *it;
621  }
622 
623  return out << "]";
624  }

◆ operator<<() [2/2]

template<typename T >
std::enable_if<is_pair<T>::value, std::ostream &>::type Gambit::Scanner::operator<< ( std::ostream &  out,
const T &  in 
)
inline

Definition at line 628 of file scanner_utils.hpp.

629  {
630  return out << "{" << in.first << " : " << in.second << "}";
631  }

◆ pi()

double Gambit::Scanner::pi ( )
inline

Output pi.

Definition at line 264 of file scanner_utils.hpp.

264 {return 3.14159265358979323846;}

◆ pow() [1/2]

template<int i>
double Gambit::Scanner::pow ( const double a)
inline

Outputs a^i.

Definition at line 310 of file scanner_utils.hpp.

Referenced by Gambit::ColliderBit::_gsl_calc_Analysis_MinusLogLike(), Gambit::ColliderBit::_setEventWeight_fromCrossSection(), Gambit::FlavBit::Penguins::A1R(), Gambit::FlavBit::Penguins::A2L(), Gambit::FlavBit::Penguins::A2R(), Gambit::ColliderBit::ALEPH_Selectron_Conservative_LLike(), Gambit::ColliderBit::ALEPH_Smuon_Conservative_LLike(), Gambit::ColliderBit::ALEPH_Stau_Conservative_LLike(), Gambit::DarkBit::alt_erg_integrand(), Gambit::DarkBit::annihilation_rate_Sun(), Gambit::FlavBit::FormFactors::ASLL(), Gambit::FlavBit::FormFactors::ASLR(), Gambit::FlavBit::FormFactors::ASRL(), Gambit::FlavBit::FormFactors::ASRR(), Gambit::FlavBit::FormFactors::AVLL(), Gambit::FlavBit::FormFactors::AVLR(), Gambit::FlavBit::FormFactors::AVRL(), Gambit::FlavBit::FormFactors::AVRR(), Gambit::DarkBit::axion_mass_temp(), Gambit::FlavBit::LoopFunctions::B0(), Gambit::FlavBit::LoopFunctions::B02C00C0(), Gambit::FlavBit::LoopFunctions::B1(), Gambit::FlavBit::FormFactors::BSLL(), Gambit::FlavBit::FormFactors::BSLR(), Gambit::FlavBit::FormFactors::BSRL(), Gambit::FlavBit::FormFactors::BSRR(), Gambit::FlavBit::FormFactors::BVLL(), Gambit::FlavBit::FormFactors::BVLR(), Gambit::FlavBit::FormFactors::BVRL(), Gambit::FlavBit::FormFactors::BVRR(), Gambit::FlavBit::LoopFunctions::C0(), Gambit::FlavBit::LoopFunctions::C00(), Gambit::DarkBit::calc_AxionOscillationTemperature(), Gambit::DarkBit::calc_CAST2007_signal_vac(), Gambit::DarkBit::calc_CAST2017_signal_vac(), Gambit::DarkBit::calc_lnL_RParameter(), Gambit::DarkBit::calc_PhotonFluence_SN1987A_Conversion(), Gambit::DarkBit::calc_RParameter(), Gambit::ColliderBit::calcMT_1l(), Gambit::DarkBit::cascadeMC_Histograms(), Gambit::DecayBit::chargino_plus_1_decays_smallsplit(), Gambit::SpecBit::check_EW_stability_ScalarSingletDM_Z3(), Gambit::SpecBit::check_perturb(), Gambit::SpecBit::check_perturb_MDM(), Gambit::SpecBit::check_perturb_to_min_lambda(), Gambit::ColliderBit::convert_xsecs_to_fb(), Gambit::FlavBit::FormFactors::CSLL(), Gambit::FlavBit::FormFactors::CSLR(), Gambit::FlavBit::FormFactors::CSRL(), Gambit::FlavBit::FormFactors::CSRR(), Gambit::FlavBit::FormFactors::CVLL(), Gambit::FlavBit::FormFactors::CVLR(), Gambit::FlavBit::FormFactors::CVRL(), Gambit::FlavBit::FormFactors::CVRR(), Gambit::FlavBit::LoopFunctions::D0(), Gambit::FlavBit::LoopFunctions::D27(), Gambit::DarkBit::DD_couplings_DiracSingletDM_Z2(), Gambit::DarkBit::DD_couplings_MajoranaSingletDM_Z2(), Gambit::DarkBit::DD_couplings_VectorSingletDM_Z2(), Gambit::DecayBit::DiracSingletDM_Higgs_decays(), Gambit::DarkBit::dRdE(), Gambit::DarkBit::dump_GammaSpectrum(), Gambit::FlavBit::LoopFunctions::E(), AdvanceDevs::EllipseDev(), MultiNormDev::EllipseDev(), Gambit::DarkBit::equilibration_time_Sun(), Gambit::DecayBit::SM_Z::TwoLoop::error(), Gambit::DecayBit::SM_Z::TwoLoop::error_BR(), Gambit::SpecBit::fill_MDM_input(), Gambit::SpecBit::fill_ScalarSingletDM_input(), Gambit::SpecBit::find_min_lambda_Helper(), Gambit::SpecBit::find_non_perturb_scale_MDM(), Gambit::FlavBit::G(), Gambit::FlavBit::LoopFunctions::G1(), Gambit::DarkBit::DarkBit_utils::gamma3bdy_limits(), Gambit::DecayBit::MSSM_Z::gamma_chi_0(), Gambit::DecayBit::MSSM_H::gamma_h_chi_gL(), Gambit::Stats::gaussian_loglikelihood(), Gambit::Stats::gaussian_upper_limit(), Gambit::SpecBit::get_DiracSingletDM_Z2_spectrum(), Gambit::SpecBit::get_MajoranaSingletDM_Z2_spectrum(), Gambit::DarkBit::get_ScalarSingletDM_DD_couplings(), Gambit::SpecBit::get_ScalarSingletDM_Z2_spectrum(), Gambit::SpecBit::get_ScalarSingletDM_Z3_spectrum(), my_simplex::get_sigma(), Gambit::Printers::HDF5MasterBuffer::get_sizeMB(), Gambit::SpecBit::get_SMINPUTS(), Gambit::SpecBit::get_VectorSingletDM_Z2_spectrum(), Gambit::ColliderBit::getPIDPairCrossSectionsMap_prospino(), Gambit::DarkBit::getYield(), Gambit::FlavBit::FormFactors::K1R(), Gambit::FlavBit::FormFactors::K2L(), Gambit::FlavBit::FormFactors::K2R(), RandomPlane::KWalkDev(), Gambit::ColliderBit::L3_Chargino_All_Channels_Conservative_LLike(), Gambit::ColliderBit::L3_Chargino_Leptonic_Conservative_LLike(), Gambit::ColliderBit::L3_Gravitino_LLike(), Gambit::ColliderBit::L3_Neutralino_All_Channels_Conservative_LLike(), Gambit::ColliderBit::L3_Neutralino_Leptonic_Conservative_LLike(), Gambit::ColliderBit::L3_Selectron_Conservative_LLike(), Gambit::ColliderBit::L3_Smuon_Conservative_LLike(), Gambit::ColliderBit::L3_Stau_Conservative_LLike(), Gambit::DecayBit::MSSM_H::lambda(), Gambit::DecayBit::lnL_W_decays_chi2(), Gambit::DecayBit::lnL_Z_inv(), Gambit::Stats::lognormal_loglikelihood_relerror(), daFunk::logspace(), Gambit::DecayBit::MajoranaSingletDM_Higgs_decays(), Gambit::FlavBit::LoopFunctions::MFVV(), Gambit::SpecBit::MSSM_higgs_couplings_FH(), Gambit::DecayBit::SM_Z::TwoLoop::observable(), Gambit::ColliderBit::OPAL_Chargino_All_Channels_Conservative_LLike(), Gambit::ColliderBit::OPAL_Chargino_Hadronic_Conservative_LLike(), Gambit::ColliderBit::OPAL_Chargino_Leptonic_Conservative_LLike(), Gambit::ColliderBit::OPAL_Chargino_SemiLeptonic_Conservative_LLike(), Gambit::ColliderBit::OPAL_Neutralino_Hadronic_Conservative_LLike(), my_func::operator()(), Gambit::Priors::Gaussian::operator()(), Gambit::Priors::LogNormal::operator()(), pow(), Gambit::DarkBit::profile_Einasto(), Gambit::DarkBit::profile_gNFW(), RandomPlane::RandomPlane(), Gambit::DarkBit::RD_oh2_Axions(), Gambit::DarkBit::RD_oh2_DS5_general(), Gambit::Printers::HDF5Printer2::resume_reader_options(), Gambit::FlavBit::RHN_l2lll(), Gambit::FlavBit::RHN_mueAu(), Gambit::FlavBit::RHN_mueee(), Gambit::FlavBit::RHN_muegamma(), Gambit::FlavBit::RHN_muePb(), Gambit::FlavBit::RHN_mueTi(), Gambit::PrecisionBit::RHN_mw(), Gambit::FlavBit::RHN_RK(), Gambit::FlavBit::RHN_RKstar_0045_11(), Gambit::FlavBit::RHN_RKstar_11_60(), Gambit::FlavBit::RHN_taueee(), Gambit::FlavBit::RHN_taueemu(), Gambit::FlavBit::RHN_tauegamma(), Gambit::FlavBit::RHN_tauemumu(), Gambit::FlavBit::RHN_taumuee(), Gambit::FlavBit::RHN_taumugamma(), Gambit::FlavBit::RHN_taumumue(), Gambit::FlavBit::RHN_taumumumu(), Gambit::DecayBit::RHN_W_to_l_decays(), Gambit::Spectrum::rhoplusieta(), Gambit::DecayBit::ScalarSingletDM_Higgs_decays(), scanner_plugin(), Gambit::FlavBit::Penguins::ShsumLL(), Gambit::FlavBit::Penguins::ShsumLR(), Gambit::FlavBit::Penguins::ShsumRL(), Gambit::FlavBit::Penguins::ShsumRR(), Gambit::FlavBit::Penguins::Shw2w4LL(), Gambit::FlavBit::Penguins::Shw2w4RR(), Gambit::DarkBit::sigma_SD_n_simple(), Gambit::DarkBit::sigma_SD_p_simple(), Gambit::DarkBit::sigma_SI_n_simple(), Gambit::DarkBit::sigma_SI_p_simple(), Gambit::DarkBit::sigma_SI_vnqn(), Gambit::DarkBit::SimpleHist::SimpleHist(), Gambit::DecayBit::stau_1_decays_smallsplit(), Gambit::DarkBit::TH_ProcessCatalog_WIMP(), RandomPlane::TransDev(), Gambit::Priors::LogNormal::transform(), Gambit::DecayBit::SM_Z::TwoLoop::TwoLoop(), Gambit::DarkBit::TH_ProcessCatalog::validate(), daFunk::FunkDelta::value(), Gambit::DecayBit::VectorSingletDM_Higgs_decays(), Gambit::FlavBit::Boxes::VsumdLL(), Gambit::FlavBit::Boxes::VsumlLL(), Gambit::FlavBit::Boxes::VsumuLL(), Gambit::FlavBit::Vertices::VuL(), Gambit::FlavBit::Boxes::Vw4dLL(), Gambit::FlavBit::Boxes::Vw4lLL(), Gambit::FlavBit::Boxes::Vw4uLL(), Gambit::FlavBit::Boxes::Vw8lLL(), Gambit::FlavBit::Penguins::VZsumLL(), Gambit::FlavBit::Penguins::VZsumLR(), Gambit::FlavBit::Penguins::VZsumRL(), Gambit::FlavBit::Penguins::VZsumRR(), Gambit::FlavBit::Penguins::VZw10LL(), Gambit::FlavBit::Penguins::VZw2w4LL(), Gambit::FlavBit::Penguins::VZw2w4RR(), Gambit::FlavBit::Penguins::VZw8LL(), RandomPlane::WalkDev(), Gambit::Spectrum::Wolf2V_cb(), Gambit::Spectrum::Wolf2V_cd(), Gambit::Spectrum::Wolf2V_cs(), Gambit::Spectrum::Wolf2V_tb(), Gambit::Spectrum::Wolf2V_td(), Gambit::Spectrum::Wolf2V_ts(), Gambit::Spectrum::Wolf2V_ub(), Gambit::Spectrum::Wolf2V_ud(), Gambit::Spectrum::Wolf2V_us(), Gambit::ColliderBit::xsec_chaichaj(), Gambit::ColliderBit::xsec_sleislej(), and Gambit::DecayBit::Z_gamma_nu_2l().

311  {
312  return a*pow<i-1>(a);
313  };
int pow(const int &a)
Here is the caller graph for this function:

◆ pow() [2/2]

template<int i>
int Gambit::Scanner::pow ( const int a)
inline

Definition at line 328 of file scanner_utils.hpp.

References pow().

Referenced by scanner_plugin_def_ret().

329  {
330  return a*pow<i-1>(a);
331  };
int pow(const int &a)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pow< 0 >() [1/2]

template<>
double Gambit::Scanner::pow< 0 > ( const double )
inline

Definition at line 316 of file scanner_utils.hpp.

317  {
318  return 1.0;
319  };

◆ pow< 0 >() [2/2]

template<>
int Gambit::Scanner::pow< 0 > ( const int )
inline

Definition at line 334 of file scanner_utils.hpp.

335  {
336  return 1;
337  };

◆ pow< 1 >() [1/2]

template<>
double Gambit::Scanner::pow< 1 > ( const double a)
inline

Definition at line 322 of file scanner_utils.hpp.

323  {
324  return a;
325  };

◆ pow< 1 >() [2/2]

template<>
int Gambit::Scanner::pow< 1 > ( const int a)
inline

Definition at line 340 of file scanner_utils.hpp.

341  {
342  return a;
343  };

◆ register_ScannerBit_handlers()

int Gambit::Scanner::register_ScannerBit_handlers ( )

Definition at line 32 of file scannerbit.hpp.

References scan_error(), and scan_warning().

33  {
34  try
35  {
36  error e = scan_error();
37  warning w = scan_warning();
38  }
39  catch (std::exception& e)
40  {
41  std::cout << "ScannerBit has failed to initialise due to a fatal exception: " << e.what() << std::endl;
42  throw(e);
43  }
44  return 0;
45  }
EXPORT_SYMBOLS warning & scan_warning()
Scanner warnings.
EXPORT_SYMBOLS error & scan_error()
Scanner errors.
Here is the call graph for this function:

◆ resume_file_input() [1/4]

template<typename T >
std::enable_if<!is_container<T>::value && !is_pair<T>::value, void>::type Gambit::Scanner::resume_file_input ( std::ifstream &  in,
T &  param 
)

Definition at line 668 of file scanner_utils.hpp.

Referenced by Gambit::Scanner::Plugins::pluginInfo::get_resume(), and resume_file_input().

669  {
670  in.read((char *)&param, sizeof(T));
671  //in >> param;
672  };
Here is the caller graph for this function:

◆ resume_file_input() [2/4]

template<typename T >
std::enable_if<is_container<T>::value, void>::type Gambit::Scanner::resume_file_input ( std::ifstream &  in,
T &  param 
)
inline

Definition at line 676 of file scanner_utils.hpp.

References resume_file_input().

677  {
678  for (auto it = param.begin(); it != param.end(); it++)
679  {
680  resume_file_input(in, *it);
681  }
682  }
void resume_file_input(std::ifstream &in, std::string &param)
Here is the call graph for this function:

◆ resume_file_input() [3/4]

template<typename T >
std::enable_if<is_pair<T>::value, void>::type Gambit::Scanner::resume_file_input ( std::ifstream &  in,
T &  param 
)
inline

Definition at line 686 of file scanner_utils.hpp.

References resume_file_input().

687  {
688  resume_file_input(in, param.first);
689  resume_file_input(in, param.second);
690  }
void resume_file_input(std::ifstream &in, std::string &param)
Here is the call graph for this function:

◆ resume_file_input() [4/4]

void Gambit::Scanner::resume_file_input ( std::ifstream &  in,
std::string &  param 
)
inline

Definition at line 713 of file scanner_utils.hpp.

714  {
715  in.read((char *)param.c_str(), param.length());
716  }

◆ resume_file_output() [1/4]

template<typename T >
std::enable_if<!is_container<T>::value && !is_pair<T>::value, void>::type Gambit::Scanner::resume_file_output ( std::ofstream &  out,
T &  param 
)
inline

Functions to output data for the plugin resume functions.

Definition at line 642 of file scanner_utils.hpp.

Referenced by resume_file_output().

643  {
644  out.write(reinterpret_cast<char *>(&param), sizeof(T));
645  //out << param << std::endl;
646  };
Here is the caller graph for this function:

◆ resume_file_output() [2/4]

template<typename T >
std::enable_if<is_container<T>::value, void>::type Gambit::Scanner::resume_file_output ( std::ofstream &  out,
T &  param 
)
inline

Definition at line 650 of file scanner_utils.hpp.

References resume_file_output().

651  {
652  for (auto it = param.begin(); it != param.end(); it++)
653  {
654  resume_file_output(out, *it);
655  }
656  }
void resume_file_output(std::ofstream &out, std::string &param)
Here is the call graph for this function:

◆ resume_file_output() [3/4]

template<typename T >
std::enable_if<is_pair<T>::value, void>::type Gambit::Scanner::resume_file_output ( std::ofstream &  out,
T &  param 
)
inline

Definition at line 660 of file scanner_utils.hpp.

References resume_file_output().

661  {
662  resume_file_output(out, param.first);
663  resume_file_output(out, param.second);
664  }
void resume_file_output(std::ofstream &out, std::string &param)
Here is the call graph for this function:

◆ resume_file_output() [4/4]

void Gambit::Scanner::resume_file_output ( std::ofstream &  out,
std::string &  param 
)
inline

Definition at line 718 of file scanner_utils.hpp.

719  {
720  out.write((char *)param.c_str(), param.length());
721  }

◆ resume_size_of() [1/4]

template<typename T >
std::enable_if<!is_container<T>::value && !is_pair<T>::value, size_t>::type Gambit::Scanner::resume_size_of ( T &  )
inline

Definition at line 694 of file scanner_utils.hpp.

Referenced by Gambit::Scanner::Plugins::pluginInfo::get_size_of().

695  {
696  return sizeof(T);
697  };
Here is the caller graph for this function:

◆ resume_size_of() [2/4]

template<typename T >
std::enable_if<is_container<T>::value, size_t>::type Gambit::Scanner::resume_size_of ( T &  param)
inline

Definition at line 701 of file scanner_utils.hpp.

702  {
703  return param.size()*sizeof(typename is_container<T>::type);
704  }

◆ resume_size_of() [3/4]

template<typename T >
std::enable_if<is_pair<T>::value, size_t>::type Gambit::Scanner::resume_size_of ( T &  )
inline

Definition at line 708 of file scanner_utils.hpp.

709  {
710  return sizeof(typename is_pair<T>::first_type) + sizeof(typename is_pair<T>::second_type);
711  }

◆ resume_size_of() [4/4]

size_t Gambit::Scanner::resume_size_of ( std::string &  param)
inline

Definition at line 723 of file scanner_utils.hpp.

724  {
725  return param.length();
726  }

◆ scan_error()

◆ scan_warning()

warning & Gambit::Scanner::scan_warning ( )

Scanner warnings.

Definition at line 35 of file scanner_utils.cpp.

References Gambit::LogTags::scanner.

Referenced by Gambit::Scanner::Errors::_bool_(), and register_ScannerBit_handlers().

36  {
37  static warning local("A problem has been raised by ScannerBit.","scan_warning", LogTags::scanner);
38  return local;
39  }
Here is the caller graph for this function:

◆ scanner_plugin_def_ret() [1/2]

template<typename ret >
std::enable_if<!std::is_floating_point<ret>::value, ret>::type Gambit::Scanner::scanner_plugin_def_ret ( )

Turns a type into an object.

If it's a floating point number, it replaces it with a big negative number.

Definition at line 291 of file scanner_utils.hpp.

292  {
293  return ret();
294  }

◆ scanner_plugin_def_ret() [2/2]

template<typename ret >
std::enable_if<std::is_floating_point<ret>::value, ret>::type Gambit::Scanner::scanner_plugin_def_ret ( )

Definition at line 297 of file scanner_utils.hpp.

References pow().

298  {
299  return -std::pow(10.0, std::numeric_limits<double>::max_exponent10);
300  };
int pow(const int &a)
Here is the call graph for this function:

◆ StringToInt()

int Gambit::Scanner::StringToInt ( const std::string &  str)
inline

Converts a string to an int.

Definition at line 241 of file scanner_utils.hpp.

Referenced by Gambit::Scanner::Plugins::Plugin_Details::Plugin_Details(), and Gambit::Scanner::Plugins::VersionCompareBottom::VersionCompareBottom().

242  {
243  int ret;
244  std::stringstream ss(str);
245  if (ss >> ret)
246  return ret;
247  else
248  return 0;
249  }
std::string str
Shorthand for a standard string.
Definition: Analysis.hpp:35
Here is the caller graph for this function:

◆ TWalk()

void Gambit::Scanner::TWalk ( Gambit::Scanner::like_ptr  LogLike,
Gambit::Scanner::printer_interface printer,
Gambit::Scanner::resume_params_func  set_resume_params,
const int dimension,
const double div,
const int proj,
const double din,
const double alim,
const double alimt,
const long long &  rand,
const double sqrtR,
const int NChains,
const bool &  hyper_grid,
const int burn_in,
const int save_freq,
const double hrs_max 
)

Definition at line 90 of file twalk.cpp.

References assign_aux_numbers(), c_ptr(), double, Gambit::Scanner::resume_params_func::dump(), Gambit::Scanner::Plugins::pluginInfo::early_shutdown_in_progress(), Gambit::Printers::BaseBasePrinter::flush(), Gambit::Printers::BasePrinterManager::get_stream(), Gambit::Scanner::resume_params_func::get_temp_file_name(), combine_hdf5::ids, Gambit::LogTags::info, int, LOCAL_INFO, notUnit(), Gambit::Scanner::resume_params_func::NumTasks(), Gambit::Scanner::Plugins::plugin_info, Gambit::Printers::BaseBasePrinter::print(), Gambit::Scanner::resume_params_func::Rank(), combine_hdf5::rank, and scan_error().

Referenced by scanner_plugin(), and Gambit::Scanner::RanNumGen::~RanNumGen().

106  {
107 
108  const double massiveR = 1e100;
109 
110  std::vector<double> chisq(NChains);
111  std::vector<double> aNext(dimension);
112  std::vector<std::vector<double>> a0(NChains, std::vector<double>(dimension));
113  double ans, chisqnext;
114  std::vector<int> mult(NChains, 1);
115  std::vector<int> totN(NChains, 0);
116  std::vector<int> count(NChains, 1);
117  int t, tt;
118  int total = 1, ttotal = 0;
119 
120  std::vector<std::vector<double>> covT(NChains, std::vector<double>(dimension, 0.0));
121  std::vector<std::vector<double>> avgT(NChains, std::vector<double>(dimension, 0.0));
122  std::vector<double> W(dimension, 0.0);
123  std::vector<double> avgTot(dimension, 0.0);
124  bool converged = false;
125  std::vector<unsigned long long int> ids(NChains);
126  std::vector<int> ranks(NChains);
127  unsigned long long int next_id;
128  double Rsum = massiveR, Rmax = massiveR;
129  bool resumed = false;
130 
131  unsigned int quit = 0; // signal for early shutdown
132 
133  std::chrono::time_point<std::chrono::system_clock> startTWalk;
134 
135  set_resume_params(chisq, a0, mult, totN, count, total, ttotal, covT, avgT, W, avgTot, ids, ranks, resumed);
136 
137  Gambit::Scanner::assign_aux_numbers("mult", "chain");
138 
139  int rank = set_resume_params.Rank();
140  int numtasks = set_resume_params.NumTasks();
141 
142  #ifdef WITH_MPI
143  std::vector<int> tints(NChains);
144  for (int i = 0; i < NChains; i++) tints[i] = i;
145  std::vector<int> talls(2*numtasks);
146  set_resume_params(tints, talls);
147  #endif
148 
149  std::ofstream temp_file_out;
150 
151  if (mins_max > 0 and rank == 0)
152  {
153  // Begin timing of TWalk run
154  startTWalk = std::chrono::system_clock::now();
155  }
156 
157  std::vector<RanNumGen *> gDev;
158  for (int i = 0; i < NChains; i++)
159  {
160  gDev.push_back(new RanNumGen(proj, dimension, din, alim, alimt, div, rand));
161  }
162 
163  // Try opening the temporary file for saving the mutliplicities etc.
164  str filename = set_resume_params.get_temp_file_name("temp");
165  temp_file_out.open(filename, std::ofstream::binary | std::ofstream::app);
166  if (not temp_file_out.is_open()) scan_error().raise(LOCAL_INFO, "Problem opening temp file " + filename + " in TWalk!");
167 
168  if (resumed)
169  {
170  #ifdef WITH_MPI
171  for (int i = 0; i < numtasks; i++)
172  {
173  MPI_Barrier(MPI_COMM_WORLD);
174  MPI_Bcast (c_ptr(a0[talls[i]]), a0[talls[i]].size(), MPI_DOUBLE, i, MPI_COMM_WORLD);
175  MPI_Bcast (&chisq[talls[i]], 1, MPI_DOUBLE, i, MPI_COMM_WORLD);
176  MPI_Bcast (&mult[talls[i]], 1, MPI_INT, i, MPI_COMM_WORLD);
177  MPI_Bcast (&count[talls[i]], 1, MPI_INT, i, MPI_COMM_WORLD);
178  MPI_Bcast (&ranks[talls[i]], 1, MPI_INT, i, MPI_COMM_WORLD);
179  MPI_Bcast (&ids[talls[i]], 1, MPI_UNSIGNED_LONG_LONG, i, MPI_COMM_WORLD);
180  }
181  #endif
182  }
183  else
184  {
185  resumed = true;
186  for (t = 0; t < NChains; t++)
187  {
188  if (rank == 0)
189  {
190  for (int j = 0; j < dimension; j++)
191  a0[t][j] = (gDev[t]->Doub());
192  chisq[t] = -LogLike(a0[t]);
194  ids[t] = LogLike->getPtID();
195  ranks[t] = rank;
196  }
197  #ifdef WITH_MPI
198  MPI_Barrier(MPI_COMM_WORLD);
199  MPI_Bcast (c_ptr(a0[t]), a0[t].size(), MPI_DOUBLE, 0, MPI_COMM_WORLD);
200  MPI_Bcast (&quit, 1, MPI_UNSIGNED, 0, MPI_COMM_WORLD);
201  #endif
202  if(quit)
203  {
204  std::cout
205  #ifdef WITH_MPI
206  <<"Rank "<<rank<<": "
207  #endif
208  <<"Quit signal received during TWalk chain initialisation, aborting run" << std::endl;
209  break;
210  }
211  }
212  }
213 
214  #ifdef WITH_MPI
215  MPI_Barrier(MPI_COMM_WORLD);
216  MPI_Bcast (c_ptr(chisq), chisq.size(), MPI_DOUBLE, 0, MPI_COMM_WORLD);
217  MPI_Bcast (c_ptr(ids), ids.size(), MPI_UNSIGNED_LONG_LONG, 0, MPI_COMM_WORLD);
218  MPI_Bcast (c_ptr(ranks), ranks.size(), MPI_INT, 0, MPI_COMM_WORLD);
219  #endif
220 
221  std::cout << "Metropolis Hastings/TWalk Algorithm Started" << std::endl;
222 
223  while (not converged and not quit)
224  {
225  #ifdef WITH_MPI
226  if (rank == 0)
227  {
228  int j = NChains;
229  for(int i = 0; i < numtasks; i++)
230  {
231  int temp = int((j--)*gDev[0]->Doub());
232  talls[i] = tints[temp];
233  tints[temp] = tints[j];
234  tints[j] = talls[i];
235  }
236 
237  for(int i = numtasks, end = talls.size(); i < end; i++)
238  {
239  talls[i] = tints[int(j*gDev[0]->Doub())];
240  }
241  }
242 
243  MPI_Barrier(MPI_COMM_WORLD);
244  MPI_Bcast (c_ptr(talls), talls.size(), MPI_INT, 0, MPI_COMM_WORLD);
245  MPI_Bcast (c_ptr(tints), tints.size(), MPI_INT, 0, MPI_COMM_WORLD);
246 
247  t = talls[rank];
248  tt = talls[rank + numtasks];
249  double logZ = gDev[t]->Dev(aNext, a0, t, tt, NChains - numtasks, tints);
250  #else
251  t = int(NChains*gDev[0]->Doub());
252  tt = int((NChains - 1)*gDev[0]->Doub());
253  if (tt >= t) tt++;
254  double logZ = gDev[t]->Dev(aNext, a0, t, tt);
255  #endif
256 
257  if(!(hyper_grid && notUnit(aNext)))
258  {
259  chisqnext = -LogLike(aNext);
260  ans = chisqnext - chisq[t] - logZ;
261  next_id = LogLike->getPtID();
262  if ((ans <= 0.0)||(gDev[0]->ExpDev() >= ans))
263  {
264  //out_stream->print(mult[t], "mult", ranks[t], ids[t]);
265  //out_stream->print(t, "chain", ranks[t], ids[t]);
266  point_info info = {mult[t], t, ranks[t], ids[t]};
267  temp_file_out.write((char *)&info, sizeof(point_info));
268 
269  ids[t] = next_id;
270  a0[t] = aNext;
271  chisq[t] = chisqnext;
272  ranks[t] = rank;
273  mult[t] = 0;
274  count[t]++;
275  }
276  else
277  {
278  //out_stream->print(0, "mult", rank, next_id);
279  //out_stream->print(-1, "chain", rank, next_id);
280  point_info info = {0, -1, rank, next_id};
281  temp_file_out.write((char *)&info, sizeof(point_info));
282  }
283  }
284 
285  #ifdef WITH_MPI
286  for (int i = 0; i < numtasks; i++)
287  {
288  MPI_Barrier(MPI_COMM_WORLD);
289  MPI_Bcast (c_ptr(a0[talls[i]]), a0[talls[i]].size(), MPI_DOUBLE, i, MPI_COMM_WORLD);
290  MPI_Bcast (&chisq[talls[i]], 1, MPI_DOUBLE, i, MPI_COMM_WORLD);
291  MPI_Bcast (&mult[talls[i]], 1, MPI_INT, i, MPI_COMM_WORLD);
292  MPI_Bcast (&count[talls[i]], 1, MPI_INT, i, MPI_COMM_WORLD);
293  MPI_Bcast (&ranks[talls[i]], 1, MPI_INT, i, MPI_COMM_WORLD);
294  MPI_Bcast (&ids[talls[i]], 1, MPI_UNSIGNED_LONG_LONG, i, MPI_COMM_WORLD);
295  }
296  #endif
297 
298  for (int l = 0; l < NChains; l++) mult[l]++;
299 
300  total++;
301 
302  if (total%save_freq == 0)
303  {
304  set_resume_params.dump();
305  //out_stream->reset();
306  }
307 
308  if (rank == 0)
309  {
310  int cnt = 0;
311  for (auto it = count.begin(); it != count.end(); ++it)
312  {
313  cnt += *it;
314  }
315 
316  if (total%NChains == 0 && cnt >= burn_in*NChains)
317  {
318  for (int i = 0; i < NChains; i++) for (int j = 0; j < dimension; j++)
319  {
320  if (ttotal == 0)
321  {
322  covT[i][j] = avgT[i][j] = avgTot[j] = W[j] = 0.0;
323  }
324  else
325  {
326  double davg = (a0[i][j]-avgT[i][j])/(ttotal+1.0);
327  double dcov = ttotal*davg*davg - covT[i][j]/(ttotal+1.0);
328  avgTot[j] += davg/NChains;
329  covT[i][j] += dcov;
330  avgT[i][j] += davg;
331  W[j] += dcov/NChains;
332  }
333  }
334  ttotal++;
335 
336  // Loop over each dimension in the parameter space, and compute R for each.
337  // Trigger convergence only if R is below the requested threshold in every dimension.
338  Rsum = Rmax = 0.0;
339  converged = true;
340  for (int i = 0; i < dimension; i++)
341  {
342  double Bn = 0;
343  for (int ts = 0; ts < NChains; ts++)
344  {
345  Bn += (avgT[ts][i] - avgTot[i])*(avgT[ts][i] - avgTot[i]);
346  }
347  Bn /= double(NChains - 1);
348 
349  double R = W[i] > 0.0 ? 1.0 + double(NChains + 1)*Bn / (W[i] * double(NChains)) : massiveR;
350 
351  Rsum += R;
352  Rmax = std::max(Rmax, R);
353 
354  if (R < 1.0) scan_error().raise(LOCAL_INFO, "R < 1 in TWalk!");
355  if (R >= sqrtR*sqrtR) converged = false;
356  }
357  }
358 
359  // Check if the requested maximum runtime has been reached.
360  if (mins_max > 0)
361  {
362  std::chrono::duration<double> runtime = std::chrono::system_clock::now() - startTWalk;
363  double runtime_ms = std::chrono::duration_cast<std::chrono::milliseconds>(runtime).count();
364  if (runtime_ms / 60e3 >= mins_max)
365  {
366  std::cout << "TWalk reached requested time limit of " << mins_max << " minutes. Finalising run now." << std::endl;
367  converged = true;
368  }
369  }
370 
371  // Print out progress to stdout
372  if (converged or cnt % 100 == 0)
373  {
374  std::cout << "Points = " << cnt << " (" << cnt/double(NChains) << " per chain)" << std::endl;
375  std::cout << "\tAcceptance ratio = " << (double)cnt/(double)total/(double)numtasks << std::endl;
376  std::cout << "\tsqrt(R) (averaged over all dimensions) = " << sqrt(Rsum/dimension) << std::endl;
377  std::cout << "\tsqrt(R) (largest in any dimension) = " << sqrt(Rmax) << std::endl;
378  }
379 
380  }
381 
383  #ifdef WITH_MPI
384  MPI_Barrier(MPI_COMM_WORLD);
385  MPI_Bcast (&converged, 1, MPI_C_BOOL, 0, MPI_COMM_WORLD);
386  MPI_Bcast (&quit, 1, MPI_UNSIGNED, 0, MPI_COMM_WORLD);
387  #endif
388  if(quit)
389  {
390  std::cout
391  #ifdef WITH_MPI
392  <<"Rank "<<rank<<": "
393  #endif
394  <<"TWalk received quit signal! Terminating run." << std::endl;
395  }
396  }
397 
398  if(quit)
399  {
400  std::cout
401  #ifdef WITH_MPI
402  <<"Rank "<<rank<<": "
403  #endif
404  << "Writing resume data for TWalk" << std::endl;
405  // This is a bit awkward, but if we just call .dump() with no argument then
406  // ScannerBit will write resume data for ALL active plugins (which seems a
407  // weird thing for TWalk to trigger) and also try to finalise the printer
408  // (which will cause a crash when ScannerBit automatically tries to
409  // finalise the printer later).
410  // I would just add this dump stuff to scan.cpp, where the printer finalise
411  // is called, but I think that is AFTER the plugins are destructed, so
412  // I don't think that can work.
413  // Doing this will dump JUST the TWalk resume data, though I had to
414  // add this hacky get_name to the set_resume_params object in order to
415  // get the name by which ScannerBit identifies the TWalk plugin.
416  //Gambit::Scanner::Plugins::plugin_info.dump(set_resume_params.get_name());
417  set_resume_params.dump(); // Better way
418  // This works I think, but it still has problems. In particular,
419  // it looks like you must resume with the same number of processes
420  // that you started the run with, which is kind of crap.
421  }
422 
423  for (auto &&gd : gDev) delete gd;
424 
425  temp_file_out.close();
426  Gambit::Scanner::printer *out_stream = printer.get_stream("txt");
427  std::ifstream temp_file_in(set_resume_params.get_temp_file_name("temp").c_str(), std::ifstream::binary);
428  point_info info;
429  int i = 0;
430  while (temp_file_in.read((char *)&info, sizeof(point_info)))
431  {i++;
432  //std::cout<<"Twalk rank "<<rank<<" printing mult and chain for "<<i<<"th point of posterior chain (rank="<<info.rank<<", pointID="<<info.id<<")"<<std::endl;
433  out_stream->print(info.mult, "mult", info.rank, info.id);
434  out_stream->print(info.chain, "chain", info.rank, info.id);
435  }
436  out_stream->flush();
437 
438  std::cout << "TWalk has finished in process " << rank << "." << std::endl;
439 
440  return;
441  }
void print(T const &in, const std::string &label, const int vertexID, const uint rank, const ulong pointID)
DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry double
std::string get_temp_file_name(const std::string &temp_file)
Definition: plugin_defs.hpp:84
#define LOCAL_INFO
Definition: local_info.hpp:34
bool notUnit(const std::vector< double > &in)
Definition: twalk.hpp:33
std::string str
Shorthand for a standard string.
Definition: Analysis.hpp:35
T::iterator::pointer c_ptr(T &it)
Definition: twalk.hpp:47
DS5_MSPCTM DS_INTDOF int
virtual BaseBasePrinter * get_stream(const std::string &="")=0
Getter for auxiliary printer objects.
EXPORT_SYMBOLS error & scan_error()
Scanner errors.
EXPORT_SYMBOLS pluginInfo plugin_info
Access Functor for plugin info.
virtual void flush()=0
Signal printer to flush data in buffers to disk Printers should do this automatically as needed...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zip()

template<typename... T>
auto Gambit::Scanner::zip ( const T &...  containers) -> boost::iterator_range<boost::zip_iterator<decltype(boost::make_tuple(std::begin(containers)...))>>
inline

Use for combine container in a range loop: for (auto &&x : zip(a, b)){...}.

Definition at line 125 of file scanner_utils.hpp.

Referenced by hdf5tools::check_for_duplicates(), scanner+_harvester::main(), and scanner_plugin().

126  {
127  return boost::make_iterator_range(
128  boost::make_zip_iterator(boost::make_tuple(std::begin(containers)...)),
129  boost::make_zip_iterator(boost::make_tuple(std::end(containers)...)));
130  }
Here is the caller graph for this function:

Variable Documentation

◆ __functions__

std::unordered_map<type_index, func_type *, Gambit::type_hasher, Gambit::type_equal_to> Gambit::Scanner::__functions__

◆ __multi_functions__

std::unordered_map<type_index, multi_func_type *> Gambit::Scanner::__multi_functions__

◆ gambit_registry

Gambit::Scanner::gambit_registry
Initial value:
{
typedef void* func_type(const std::vector<std::string> &, const std::string &)

Definition at line 50 of file plugin_factory.hpp.

◆ ScannerBit_handlers

int Gambit::Scanner::ScannerBit_handlers = register_ScannerBit_handlers()

Definition at line 47 of file scannerbit.hpp.