gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-2191-ga4742ac
a Global And Modular Bsm Inference Tool
core.cpp
Go to the documentation of this file.
1 // GAMBIT: Global and Modular BSM Inference Tool
2 // *********************************************
24 
25 #include <algorithm>
26 #include <fstream>
27 #include <map>
28 #include <sstream>
29 #include <vector>
30 
31 // Headers for GNU getopt command line parsing library
32 #include <getopt.h>
33 #include <stdlib.h>
34 
35 // Gambit headers
36 #include "gambit/Core/core.hpp"
42 #include "gambit/Utils/version.hpp"
43 #include "gambit/cmake/cmake_variables.hpp"
44 
45 // Boost
46 #include <boost/algorithm/string/replace.hpp>
47 
48 // MPI
49 #ifdef WITH_MPI
51 #define GET_RANK GMPI::Comm().Get_rank()
52 #define GET_SIZE GMPI::Comm().Get_size()
53 #else
54 #define GET_RANK 0
55 #define GET_SIZE 1
56 #endif
57 
58 namespace Gambit
59 {
61 
63  gambit_core::gambit_core(const Models::ModelFunctorClaw &claw, const Backends::backend_info &beinfo)
64  : modelInfo(&claw), backendData(&beinfo), input_capability_descriptions(GAMBIT_DIR "/config/capabilities.dat"), input_model_descriptions(GAMBIT_DIR "/config/models.dat"),
65  outprec(8)
66  /* command line flags */
67  ,
68  processed_options(false), show_runorder(false), resume(true), verbose_flag(false), found_inifile(false)
69  {
70  }
71 
73  int gambit_core::get_outprec() const { return outprec; }
74 
76  void gambit_core::bail(int mpirank)
77  {
78  if (mpirank < 0) mpirank = GET_RANK;
79  if (mpirank == 0)
80  {
81  cout << "\nusage: gambit [options] [<command>] "
82  "\n "
83  "\nRun scan: "
84  "\n gambit -f <inifile> Start a scan using instructions from inifile "
85  "\n e.g.: gambit -f gambit.yaml "
86  "\n "
87  "\nAvailable commands: "
88  "\n modules List registered modules "
89  "\n backends List registered backends and their status "
90  "\n models List registered models and output model graph "
91  "\n capabilities List all registered function capabilities "
92  "\n scanners List registered scanners "
93  "\n test-functions List registered scanner test objective functions "
94  "\n <name> Give info on a specific module, backend, model, "
95  "\n capability or scanner "
96  "\n e.g.: gambit DarkBit "
97  "\n gambit Pythia "
98  "\n gambit MSSM "
99  "\n gambit IC79WL_loglike "
100  "\n gambit MultiNest "
101  "\n "
102  "\nBasic options: "
103  "\n --version Display GAMBIT version information "
104  "\n -h/--help Display this usage information "
105  "\n -f <inifile> Start scan using <inifile> "
106  "\n -v/--verbose Turn on verbose mode "
107  "\n -d/--dryrun List the function evaluation order computed based "
108  "\n on inifile "
109  "\n -r/--restart Restart the scan defined by <inifile>. Existing "
110  "\n output files for the run will be overwritten. "
111  "\n Default behaviour in the absence of this option is"
112  "\n to attempt to resume the scan from any existing "
113  "\n output. "
114  "\n"
115  << endl
116  << endl;
117  }
118  logger().disable();
119  throw SilentShutdownException();
120  }
121 
124  {
125  int index;
126  int iarg = 0;
127  str filename;
128 
130  // Basically this is a clone of the example in the getopt_long documentation
131  // (http://www.gnu.org/savannah-checkouts/gnu/libc/manual/html_node/Getopt-Long-Option-Example.html#Getopt-Long-Option-Example)
132  //
133  // Note that specialised versions of this structure exist for some of the special run modes.
134  const struct option primary_options[] = {
135  {"version", no_argument, 0, 1}, /*1 is just a unique integer key to identify this argument*/
136  {"verbose", no_argument, 0, 'v'}, {"help", no_argument, 0, 'h'},
137  {"dryrun", no_argument, 0, 'd'}, {"restart", no_argument, 0, 'r'}, {0, 0, 0, 0},
138  };
139 
140  // Must at least have one argument.
141  if (argc < 2) bail();
142 
143  while (iarg != -1)
144  {
145  iarg = getopt_long(argc, argv, "vhdrf:", primary_options, &index);
146  switch (iarg)
147  {
148  case 1:
149  {
150  // Shut down.
151  logger().disable();
152  throw SilentShutdownException();
153  }
154  case 'v':
155  // Turn on verbose mode
156  verbose_flag = true;
157  break;
158  case 'h':
159  case '?':
160  // display usage message and quit (also happens on unrecognised options)
161  bail();
162  break;
163  case 'd':
164  // Display proposed functor evaluation order and quit
165  show_runorder = true; // Sorted out in dependency resolver
166  // Should not allow this on multiple processes, just produces
167  // mixed up junk output.
168  if (GET_SIZE > 1)
169  {
170  cout << "Tried to run GAMBIT dry-run mode in parallel! This is not allowed, please use only one process when performing dry-runs." << endl;
171  logger().disable();
172  throw SilentShutdownException();
173  }
174  break;
175  case 'r':
176  // Restart scan (turn off "resume" mode, activate output overwrite)
177  resume = false;
178  break;
179  case 'f':
180  // Argument must contain the ini-filename
181  filename = optarg;
182  found_inifile = true;
183  }
184  }
185  if (show_runorder and not resume)
186  {
187  cout << "This is a dry-run, ignoring the restart flag (-r/--restart), i.e. not deleting any files." << endl;
188  resume = true;
189  }
190  // Set flag telling core object that command line option processing is complete
191  processed_options = true;
192  return filename;
193  }
194 
196  void gambit_core::registerModule(str module) { modules.insert(module); }
197 
200  {
201  functorList.push_back(&f);
202  capabilities.insert(f.capability());
203  }
204 
207 
210  {
211  backendFunctorList.push_back(&f);
212  capabilities.insert(f.capability());
213  }
214 
216  void gambit_core::registerBackend(str be, str version) { backend_versions[be].insert(version); }
217 
220  {
221  primaryModelFunctorList.push_back(&f);
222  capabilities.insert(f.capability());
223  }
224 
227  {
228  for (const auto &f : fvec) { activeModelFunctorList[f->origin()] = f; }
229  }
230 
233 
236 
239 
242 
245 
250  {
251  // Create a map of all the registered backends that are connected and fully functional (including factories for classloading)
252  std::map<str, std::set<str>> working_bes;
253  // Start by looping over all registered backends
254  for (const auto &backend : backend_versions)
255  {
256  // Then loop over all registered versions of this backend
257  for (const auto &version : backend.second)
258  {
259  const str be_ver = backend.first + version;
260  if (backendData->works.at(be_ver))
261  {
262  if (backendData->classloader.at(be_ver))
263  {
264  if (backendData->classes_OK.at(be_ver)) working_bes[backend.first].insert(version);
265  }
266  else
267  {
268  working_bes[backend.first].insert(version);
269  }
270  }
271  }
272  }
273  // Feed the new map to each of the module functors.
274  for (const auto &functor : functorList) { functor->notifyOfBackends(working_bes); }
275  }
276 
279  {
280  // Loop through registered capabilities and try to find their descriptions (potentially from many files, but for now just checking one)
281  DescriptionDatabase description_file(input_capability_descriptions); // Load descriptions file
282  // std::set<str> parsed_descriptions; // Set of capabilities whose description we have parsed
283  bool missing_flag = false; // Lets us know if any missing descriptions identified
284 
285  // Check for duplicate description keys
286  std::map<str, int> duplicates = description_file.check_for_duplicates();
287 
288  // Search through GAMBIT for information about registered capabilities to match to the descriptions
289  for (const auto &capability : capabilities)
290  {
291  capability_info capinfo;
292  capinfo.name = capability;
293 
294  // Make sets of matching module and backend functions
295  for (const auto &functor : functorList)
296  {
297  if (functor->capability() == capability)
298  {
299  const str origin(functor->origin());
300  const std::pair<str, str> name_type(functor->name(), functor->type());
301  if (capinfo.modset.find(origin) == capinfo.modset.end()) capinfo.modset[origin] = std::set<std::pair<str, str>>();
302  capinfo.modset[origin].insert(name_type);
303  }
304  }
305  for (const auto &functor : backendFunctorList)
306  {
307  if (functor->capability() == capability)
308  {
309  const str origin(functor->origin() + " v" + functor->version());
310  const std::pair<str, str> name_type(functor->name(), functor->type());
311  if (capinfo.beset.find(origin) == capinfo.beset.end()) capinfo.beset[origin] = std::set<std::pair<str, str>>();
312  capinfo.beset[origin].insert(name_type);
313  }
314  }
315 
316  // Check original description files for descriptions matching this capability
317  if (description_file.hasKey(capability))
318  {
319  // Check whether there are duplicates of this key
320  if (duplicates[capability] > 0)
321  {
322  const std::vector<str> dups = description_file.get_all_values(capability);
323  std::ostringstream errmsg;
324  errmsg << "Error! Duplicate capability descriptions found for capability \"" << capability
325  << "\"! Only one description is permitted, since all capabilities going by the same name "
326  "must provide the same information. Please rename a capability or delete one of the descriptions."
327  << endl;
328  errmsg << "The duplicate descriptions are:" << endl;
329  errmsg << "---------------------" << endl;
330  int dup_num = 0;
331  for (const auto &dup : dups)
332  {
333  errmsg << dup_num << ":" << endl;
334  errmsg << dup;
335  errmsg << "----------------------" << endl;
336  dup_num++;
337  }
338  core_error().raise(LOCAL_INFO, errmsg.str());
339  }
340  else
341  {
342  capinfo.description = description_file.getValue<str>(capability);
343  capinfo.has_description = true;
344  }
345  }
346  else
347  {
348  // Record that this description is missing
349  capinfo.description = "Missing!";
350  capinfo.has_description = false;
351  missing_flag = true;
352  }
353  capability_dbase.push_back(capinfo);
354  }
355 
357 
358  if (missing_flag)
359  {
360  // Warn user of missing descriptions
362  }
363 
364  // Write out the centralised database file containing all this information
365  // (we could also keep this in memory for other functions to use; it's probably not that large)
366  // Should probably sort it by module or something.
367 
368  // Could have built this directly in the other loop, but for now it is separate.
369  YAML::Emitter out;
370  out << YAML::BeginSeq;
371  for (const auto &capability : capability_dbase)
372  {
373  out << capability; // custom emitter to do this is in yaml_description_database.hpp
374  }
375  out << YAML::EndSeq;
376  // Create file and write YAML output there
377  std::ofstream outfile;
378  outfile.open(Utils::runtime_scratch() + "central_capabilities.dat");
379  outfile << "# Auto-generated capability description library. Edits will be erased." << endl;
380  outfile << "# Edit \"" << input_capability_descriptions << "\" instead." << endl << endl << out.c_str();
381 
382  // Now the models
383  // This is distressingly similar to the capabilities case, but it doesn't seem so straightforward to modularise any further...
384 
385  // Loop through registered models and try to find their descriptions (potentially from many files, but for now just checking one)
386  DescriptionDatabase model_description_file(input_model_descriptions); // Load descriptions file
387  missing_flag = false; // reset this flag
388 
389  // Check for duplicate description keys
390  duplicates = description_file.check_for_duplicates();
391 
392  // Search through GAMBIT for information about registered models to match to the descriptions
393  for (const auto &functor : primaryModelFunctorList)
394  {
395  model_info model;
396  model.name = functor->origin();
397 
398  // Check original description files for descriptions matching this capability
399  if (model_description_file.hasKey(model.name))
400  {
401  // Check whether there are duplicates of this key
402  if (duplicates[model.name] > 0)
403  {
404  const std::vector<str> dups = model_description_file.get_all_values(model.name);
405  std::ostringstream errmsg;
406  errmsg << "Error! Duplicate model descriptions found for model \"" << model.name
407  << "\"! Only one description is permitted, since model names must be unique. "
408  "Please rename a model or delete one of the descriptions."
409  << endl;
410  errmsg << "The duplicate descriptions are:" << endl;
411  errmsg << "---------------------" << endl;
412  int dup_num = 0;
413  for (const auto &dup : dups)
414  {
415  errmsg << dup_num << ":" << endl;
416  errmsg << dup;
417  errmsg << "----------------------" << endl;
418  dup_num++;
419  }
420  core_error().raise(LOCAL_INFO, errmsg.str());
421  }
422  else
423  {
424  model.description = model_description_file.getValue<str>(model.name);
425  model.has_description = true;
426  }
427  }
428  else
429  {
430  // Record that this description is missing
431  model.description = "Missing!";
432  model.has_description = false;
433  missing_flag = true;
434  }
435 
436  // Get the rest of the info
437  model.nparams = functor->valuePtr()->getNumberOfPars();
438  model.parameters = functor->valuePtr()->getKeys();
439  model.parent = modelInfo->get_parent(model.name);
440  model.lineage = modelInfo->get_lineage(model.name);
441  model.descendants = modelInfo->get_descendants(model.name);
442 
443  model_dbase.push_back(model);
444  }
445 
446  if (missing_flag)
447  {
448  // Warn user of missing descriptions
449  cout << "Descriptions are missing for the following models:" << endl;
450  for (const auto &model : model_dbase)
451  {
452  if (not model.has_description) { cout << " " << model.name << endl; }
453  }
454  cout << "Please add descriptions of these to " << input_model_descriptions << endl;
455  }
456 
457  // Write out the centralised database file containing all this information
458  // (we could also keep this in memory for other functions to use; it's probably not that large)
459  // Should probably sort it by module or something.
460 
461  // Could have built this directly in the other loop, but for now it is separate.
462  YAML::Emitter out2;
463  out2 << YAML::BeginSeq;
464  for (const auto &model : model_dbase)
465  {
466  out2 << model; // custom emitter to do this is in yaml_description_database.hpp
467  }
468  out2 << YAML::EndSeq;
469  // Create file and write YAML output there
470  std::ofstream outfile2;
471  outfile2.open(Utils::runtime_scratch() + "central_models.dat");
472  outfile2 << "# Auto-generated model description library. Edits will be erased." << endl;
473  outfile2 << "# Edit \"" << input_model_descriptions << "\" instead." << endl << endl << out2.c_str();
474  }
475 
477  {
478 
480  {
481  cout << "Descriptions are missing for the following capabilities:" << endl;
482  for (const auto &capability : capability_dbase)
483  {
484  if (not capability.has_description) { cout << " " << capability.name << endl; }
485  }
486  cout << "Please add descriptions of these to " << input_capability_descriptions << endl;
487  }
488  }
489 
492  {
493  for (const auto &capability : capability_dbase)
494  {
495  if (capability.name == name)
496  {
497  return capability; // Should only be one match possible after database check
498  }
499  }
500  // if no match...
501  std::ostringstream errmsg;
502  errmsg << "No capability with the name \"" << name
503  << "\" could be found in the capability database. "
504  "This function should not run when we don't know if the capability exists! Either there is a bug "
505  "in the calling code, or something went wrong creating the capability database.";
506  core_error().raise(LOCAL_INFO, errmsg.str());
507  return capability_info();
508  }
509 
511  {
512  for (const auto &model : model_dbase)
513  {
514  if (model.name == name)
515  {
516  return model; // Should only be one match possible after database check
517  }
518  }
519  // if no match...
520  std::ostringstream errmsg;
521  errmsg << "No model with the name \"" << name
522  << "\" could be found in the model database. This function "
523  "should not run when we don't know if the model exists! Either there is a bug in the calling code, or "
524  "something went wrong creating the model database.";
525  core_error().raise(LOCAL_INFO, errmsg.str());
526  return model_info();
527  }
528 
530  str gambit_core::backend_status(const str &be, const str &version, bool &no_failures)
531  {
532  const str OK = "OK";
533  const str bad = "absent/broken";
534  const str badclass = "bad types";
535  const str missingMath = "Mathematica absent";
536  str status;
537  if (backendData->works.at(be + version))
538  {
539  if (backendData->classloader.at(be + version)) { status = (backendData->classes_OK.at(be + version) ? OK : badclass); }
540  else
541  {
542  status = OK;
543  }
544  }
545  else if (backendData->needsMathematica.at(be + version))
546  {
547 #ifdef HAVE_MATHEMATICA
548  status = bad;
549 #else
550  status = missingMath;
551 #endif
552  }
553  else if (backendData->missingPythonVersion.at(be + version) > 0)
554  {
555  std::ostringstream status_stream;
556  status_stream << "needs Python " << backendData->missingPythonVersion.at(be + version);
557  status = status_stream.str();
558  }
559  else
560  {
561  status = bad;
562  }
563  if (status == bad or status == badclass) no_failures = false;
564  return status;
565  }
566 
568  str gambit_core::run_diagnostic(int argc, char **argv)
569  {
570  const int mpirank = GET_RANK; // Get MPI rank (assume MPI already initialised)
571  str filename;
572  str command = "none";
573  std::vector<std::string> didyoumean;
574 
575  // Parse the arguments, ignoring everything before gambit executable
576  if (argc > 1)
577  {
578  for (int i = 0; i < argc - 1; i++)
579  {
580  const str arg = argv[i];
581  const str x(GAMBIT_EXECUTABLE);
582  const int len = arg.length();
583  const int xlen = x.length();
584  if (len >= xlen and arg.substr(len - xlen, xlen) == x)
585  {
586  command = argv[i + 1];
587  break;
588  }
589  }
590  }
591 
592  // Initial list of valid diagnostic commands
593  std::vector<str> valid_commands = initVector<str>("modules", "backends", "models", "capabilities", "scanners", "test-functions");
594 
595  // Test if the user has requested one of the basic diagnostics
596  if (std::find(valid_commands.begin(), valid_commands.end(), command) == valid_commands.end())
597  {
598  // If we aren't just checking what stuff is registered, we could end up running a scan, or needing the descriptions of things.
599  // Therefore we must construct the description databases and make sure there are no naming conflicts etc.
600  check_databases();
601 
602  // Add other valid diagnostic commands
603  valid_commands.insert(valid_commands.end(), modules.begin(), modules.end());
604  valid_commands.insert(valid_commands.end(), capabilities.begin(), capabilities.end());
605  for (const auto &backend_version : backend_versions) valid_commands.push_back(backend_version.first);
606  for (const auto &primaryModelFunctor : primaryModelFunctorList) valid_commands.push_back(primaryModelFunctor->origin());
607  const std::vector<std::string> scanner_names = Scanner::Plugins::plugin_info().print_plugin_names("scanner");
608  const std::vector<std::string> objective_names = Scanner::Plugins::plugin_info().print_plugin_names("objective");
609  const std::vector<std::string> prior_groups = Scanner::Plugins::plugin_info().list_prior_groups();
610  valid_commands.insert(valid_commands.end(), scanner_names.begin(), scanner_names.end());
611  valid_commands.insert(valid_commands.end(), objective_names.begin(), objective_names.end());
612  valid_commands.insert(valid_commands.end(), prior_groups.begin(), prior_groups.end());
613 
614  // If the user hasn't asked for a diagnostic at all, process the command line options for the standard run mode and get out.
615  if (std::find(valid_commands.begin(), valid_commands.end(), command) == valid_commands.end())
616  {
617  if (not processed_options)
618  {
619  filename = process_primary_options(argc, argv);
621  // Check if we indeed received a valid filename (needs the -f option)
622  if (found_inifile) return filename;
623  // Ok then, report an unrecognised command and bail
624  if (mpirank == 0) cout << "Unrecognised command received!" << endl;
625  // Give a list of valid commands that user might have mistyped
626  for (const auto &valid_command : valid_commands)
627  {
628  if (Utils::are_similar(command, valid_command)) didyoumean.push_back(valid_command);
629  }
630  if (didyoumean.size() > 0)
631  {
632  if (mpirank == 0)
633  {
634  cout << "Did you mean one of the following?" << endl;
635  for (const auto &proposedCommand : didyoumean)
636  {
637  if (Utils::are_similar(command, proposedCommand)) { cout << " " << proposedCommand << endl; }
638  }
639  cout << endl;
640  cout << "Run \"gambit --help\" for a full list of options and usage instructions" << endl;
641  }
642  logger().disable();
643  throw SilentShutdownException();
644  }
645  else
646  {
647  bail(mpirank);
648  }
649  }
650  else
651  {
652  if (mpirank == 0)
653  cout << "Command line options have already been "
654  "processed in a special run mode... GAMBIT should not reach this "
655  "point. Quitting..."
656  << endl;
657  logger().disable();
658  throw SilentShutdownException();
659  }
660  }
661  }
662 
663  // Guaranteed from this point that no scans (nor scanners) will be invoked.
664 
665  // Disable all but the master MPI node
666  if (mpirank == 0)
667  {
668  if (command == "modules") module_diagnostic();
669  if (command == "backends") backend_diagnostic();
670  if (command == "models") model_diagnostic();
671  if (command == "capabilities") capability_diagnostic();
672  if (command == "scanners") scanner_diagnostic();
673  if (command == "test-functions") test_function_diagnostic();
674  if (command == "priors") prior_diagnostic();
675  ff_module_diagnostic(command);
676  ff_backend_diagnostic(command);
677  ff_model_diagnostic(command);
678  ff_capability_diagnostic(command);
679  ff_scanner_diagnostic(command);
681  ff_prior_diagnostic(command);
682  cout << endl;
683  }
684 
685  // Silently print the logs to scratch/run_time/<processID>/default.log
686  logger().emit_backlog(false);
687  // Split.
688  logger().disable();
689  throw SilentShutdownException();
690  return "";
691  }
692 
693 } // namespace Gambit
void ff_capability_diagnostic(const str &)
Free-form capability diagnostic function.
bool hasKey(const args &... keys) const
Getters for key/value pairs (which is all the options node should contain)
Exception object declarations.
str version() const
Getter for the version of the wrapped function&#39;s origin (module or backend)
Definition: functors.cpp:123
Define overloadings of the stream operator for various containers.
std::map< str, std::set< str > > backend_versions
Map from backend names to a list of all registered versions of the backend.
Definition: core.hpp:56
std::map< str, std::set< std::pair< str, str > > > modset
Set of modules and module functions in which capability is used, along with corresponding result type...
str backend_status(const str &, const str &, bool &)
Compute the status of a given backend.
Definition: core.cpp:530
void registerPrimaryModelFunctor(primary_model_functor &)
Add a new primary model functor to primaryModelFunctorList.
Definition: core.cpp:219
Special exception used during clean exit from diagnostics.
Definition: exceptions.hpp:336
int nparams
Number of parameters ( parameters.size() )
std::vector< capability_info > capability_dbase
Vector of all capability_info objects.
Definition: core.hpp:208
void capability_diagnostic()
Basic capability diagnostic function.
bool has_description
Flag to check if description is missing.
std::vector< str > parameters
Parameter names.
Helper struct to carry around model information.
void ff_prior_diagnostic(const str &)
Functors specific to primary ModelParameters objects.
Definition: functors.hpp:1001
const pmfVec & getPrimaryModelFunctors() const
Get a reference to the list of primary model functors.
Definition: core.cpp:241
bool verbose_flag
Verbosity mode.
Definition: core.hpp:136
bool has_description
Flag to check if description is missing.
capability_info get_capability_info(const str &) const
Get the description (and other info) of the named item from the capability database.
Definition: core.cpp:491
void registerActiveModelFunctors(const pmfVec &)
Add entries to the map of activated primary model functors.
Definition: core.cpp:226
#define LOCAL_INFO
Definition: local_info.hpp:34
Function wrapper (functor) base class.
Definition: functors.hpp:87
void ff_module_diagnostic(const str &)
Free-form diagnostic functions.
void model_diagnostic()
Basic model diagnostic function.
void check_databases()
Check the named database for conflicts and missing descriptions.
Definition: core.cpp:278
model_info get_model_info(const str &) const
Get the description (and other info) of the named item from the model database.
Definition: core.cpp:510
void ff_model_diagnostic(const str &)
Free-form model diagnostic function.
error & core_error()
Core errors.
void backend_diagnostic()
Basic backend diagnostic function.
Definition: diagnostics.cpp:84
str get_parent(const str &) const
Retrieve the parent model for a given model.
Definition: models.cpp:244
const fVec & getBackendFunctors() const
Get a reference to the list of backend model functors.
Definition: core.cpp:238
void emit_backlog(bool verbose)
Print the backlogs to the default log file.
Definition: logmaster.cpp:137
Small wrapper object for parsing and emitting capability/model etc.
str origin() const
Getter for the wrapped function&#39;s origin (module or backend name)
Definition: functors.cpp:121
const fVec & getNestedModuleFunctors() const
Get a reference to the list of nested module functors.
Definition: core.cpp:235
fVec functorList
List of all declared module functors.
Definition: core.hpp:65
std::set< str > capabilities
List of all declared capabilities.
Definition: core.hpp:59
const fVec & getModuleFunctors() const
Get a reference to the list of module functors.
Definition: core.cpp:232
void registerModule(str)
Add a new module to modules list.
Definition: core.cpp:196
std::vector< str > get_all_values(str key)
Return vector of descriptions matching key (for retrieving values with non-unique keys) ...
void registerNestedModuleFunctor(functor &)
Add a new module functor to nestFunctorList.
Definition: core.cpp:206
General small utility functions.
Models object that performs initialisation and checking operations on a primary_model_functor list...
Definition: models.hpp:55
std::map< str, int > check_for_duplicates()
Check &#39;descriptions&#39; for duplicate keys.
void ff_scanner_diagnostic(const str &)
Free-form scanner diagnostic function.
std::vector< primary_model_functor * > pmfVec
Definition: core.hpp:42
str name() const
Getter for the wrapped function&#39;s name.
Definition: functors.cpp:115
const pmfMap & getActiveModelFunctors() const
Get a reference to the map of all user-activated primary model functors.
Definition: core.cpp:244
gambit_core(const Models::ModelFunctorClaw &, const Backends::backend_info &)
Constructor.
Definition: core.cpp:63
void bail(int mpirank=-1)
Command-line info function.
Definition: core.cpp:76
const str input_model_descriptions
Filename of the file from which to harvest model descriptions.
Definition: core.hpp:82
bool found_inifile
Flag recording whether an inifile has been supplied.
Definition: core.hpp:139
bool processed_options
Flag specifying whether command line options have been processed yet.
Definition: core.hpp:88
#define GET_RANK
Definition: core.cpp:54
std::set< str > modules
Set of all declared modules.
Definition: core.hpp:53
void ff_test_function_diagnostic(const str &)
Free-form test function diagnostic function.
bool resume
Flag to trigger "resume" mode.
Definition: core.hpp:132
pmfVec primaryModelFunctorList
List of all declared primary model functors.
Definition: core.hpp:74
const str input_capability_descriptions
Filename of the file from which to harvest capability descriptions.
Definition: core.hpp:80
std::map< str, std::set< std::pair< str, str > > > beset
Set of backends and backend functions in which capability is used, along with corresponding type sign...
GAMBIT Core driver class.
int get_outprec() const
Getter for precision to use for cout.
Definition: core.cpp:73
EXPORT_SYMBOLS Logging::LogMaster & logger()
Function to retrieve a reference to the Gambit global log object.
Definition: logger.cpp:95
str type() const
Getter for the wrapped function&#39;s reported return type.
Definition: functors.cpp:119
#define GET_SIZE
Definition: core.cpp:55
str process_primary_options(int, char **)
Process default command line options.
Definition: core.cpp:123
std::vector< functor * > fVec
Internal typedefs to keep things readable.
Definition: core.hpp:41
std::string str
Shorthand for a standard string.
Definition: Analysis.hpp:35
void test_function_diagnostic()
Basic test function diagnostic function.
str capability() const
Getter for the wrapped function&#39;s reported capability.
Definition: functors.cpp:117
fVec nestedFunctorList
List of all module functors that are declared as nested (i.e. require loop managers) ...
Definition: core.hpp:68
Helper struct to carry around capability information.
TYPE getValue(const args &... keys) const
A small wrapper object for &#39;description database&#39; nodes.
void scanner_diagnostic()
Basic scanner diagnostic function.
int show_runorder
Flags set by command line options Flag to trigger dependency resolver to report functor run order...
Definition: core.hpp:129
void ff_backend_diagnostic(const str &)
Free-form backend diagnostic function.
EXPORT_SYMBOLS const str & runtime_scratch()
Return the path to the run-specific scratch directory Don&#39;t call this from a destructor, as the internal static str may have already been destroyed.
const Models::ModelFunctorClaw * modelInfo
Internal model claw pointer.
Definition: core.hpp:47
A simple C++ wrapper for the MPI C bindings.
void accountForMissingClasses() const
Tell the module functors which backends are actually present.
Definition: core.cpp:249
std::vector< str > descendants
All children and later descendants.
std::vector< str > lineage
Parent and all ancestor models.
bool missing_capability_description
set to true if capability descriptions missing
Definition: core.hpp:202
void module_diagnostic()
Basic diagnostic functions.
Definition: diagnostics.cpp:41
virtual void notifyOfBackends(std::map< str, std::set< str > >)
Indicate to the functor which backends are actually loaded and working.
Definition: functors.cpp:341
str description
Full description of capability.
std::map< str, primary_model_functor * > pmfMap
Definition: core.hpp:43
void registerBackend(str, str)
Register a new backend.
Definition: core.cpp:216
Loader singleton class for scanner plugins.
std::vector< model_info > model_dbase
Vector of all model_info objects.
Definition: core.hpp:211
std::vector< str > get_lineage(const str &) const
Retrieve the lineage for a given model.
Definition: models.cpp:250
EXPORT_SYMBOLS pluginInfo plugin_info
Access Functor for plugin info.
std::vector< str > get_descendants(const str &) const
Retrieve the descendants for a given model.
Definition: models.cpp:238
fVec backendFunctorList
List of all declared backend functors.
Definition: core.hpp:71
Version numbering.
str parent
Parent model name.
void registerModuleFunctor(functor &)
Add a new module functor to functorList.
Definition: core.cpp:199
TODO: see if we can use this one:
Definition: Analysis.hpp:33
pmfMap activeModelFunctorList
A map of all user-activated primary model functors.
Definition: core.hpp:77
void check_capability_descriptions()
Check for missing capability descriptions (after reading in runtime flags)
Definition: core.cpp:476
str description
Full description of capability.
void registerBackendFunctor(functor &)
Add a new backend functor to backendFunctorList.
Definition: core.cpp:209
const int outprec
Precision to use for cout.
Definition: core.hpp:85
EXPORT_SYMBOLS bool are_similar(const str &s1, const str &s2)
Check if two strings are a "close" match Used for "did you mean?" type checking during command line a...
const Backends::backend_info * backendData
Internal backend info pointer.
Definition: core.hpp:50
str run_diagnostic(int, char **)
Diagnostics function.
Definition: core.cpp:568