gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-252-gf9a3f78
a Global And Modular Bsm Inference Tool
random.cpp
Go to the documentation of this file.
1 // GAMBIT: Global and Modular BSM Inference Tool
2 // *********************************************
10 //
16 
17 #ifdef WITH_MPI
18 #include "mpi.h"
19 #endif
20 
21 #include <vector>
22 #include <string>
23 #include <iostream>
24 
27 
28 scanner_plugin(random, version(1, 0, 0))
29 {
30  like_ptr LogLike;
31  int num, dim, numtasks, rank;
32 
34  {
35  LogLike = get_purpose(get_inifile_value<std::string>("like"));
36  num = get_inifile_value<int>("point_number", 10);
37  dim = get_dimension();
38 
39 #ifdef WITH_MPI
40  MPI_Comm_size(MPI_COMM_WORLD, &numtasks);
41  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
42 #else
43  numtasks = 1;
44  rank = 0;
45 #endif
46  }
47 
48  int plugin_main ()
49  {
50  std::vector<double> a(dim);
51 
52  std::cout << "Entering random sampler." << "\n\tnumber of points to calculate: " << num << std::endl;
53 
54  for (int k = 0; k < num; k++)
55  {
56  for (int i = rank; i < dim; i+=numtasks)
57  {
58  a[i] = Gambit::Random::draw();
59  }
60  LogLike(a);
61 
62  if (k%1000 == 0)
63  std::cout << "points: " << k << " / " << num << std::endl;
64  }
65 
66  return 0;
67  }
68 }
#define plugin_constructor
Runs when the plugin is loaded.
static double draw()
Draw a single uniform random deviate from the interval (0,1) using the chosen RNG engine...
#define plugin_main(...)
Declaration of the main function which will be ran by the interface.
A threadsafe interface to the STL random number generators.
declaration for scanner module
scanner_plugin(random, version(1, 0, 0))
Definition: random.cpp:28