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