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

Classes

class  DependencyResolver
 Main dependency resolver. More...
 
struct  OutputVertexInfo
 Minimal info about outputVertices. More...
 
struct  QueueEntry
 Information in parameter queue. More...
 
struct  Rule
 A simple rule for dependency resolution (aka constraints on module and function name). More...
 

Typedefs

typedef adjacency_list< vecS, vecS, bidirectionalS, functor *, vecS > MasterGraphType
 Typedefs for central boost graph. More...
 
typedef graph_traits< MasterGraphType >::vertex_descriptor VertexID
 
typedef graph_traits< MasterGraphType >::edge_descriptor EdgeID
 
typedef property_map< MasterGraphType, vertex_index_t >::type IndexMap
 
typedef std::map< std::string, double * > inputMapType
 Typedefs for communication channels with the master-likelihood. More...
 
typedef std::map< std::string, std::vector< functor * > > outputMapType
 

Functions

bool stringComp (const str &s1, const str &s2, bool with_regex=true)
 Check whether s1 (wildcard + regex allowed) matches s2. More...
 
bool typeComp (str, str, const Utils::type_equivalency &, bool with_regex=true)
 Type comparison taking into account equivalence classes. More...
 
errordependency_resolver_error ()
 Dependency resolver errors. More...
 
warningdependency_resolver_warning ()
 Dependency resolver warnings. More...
 
void getParentVertices (const VertexID &vertex, const DRes::MasterGraphType &graph, std::set< VertexID > &myVertexList)
 
std::vector< VertexIDsortVertices (const std::set< VertexID > &set, const std::list< VertexID > &topoOrder)
 
std::vector< VertexIDgetSortedParentVertices (const VertexID &vertex, const DRes::MasterGraphType &graph, const std::list< VertexID > &topoOrder)
 
bool quantityMatchesIniEntry (const sspair &quantity, const IniParser::ObservableType &observable, const Utils::type_equivalency &eq)
 
bool capabilityMatchesIniEntry (const sspair &quantity, const IniParser::ObservableType &observable)
 
bool moduleFuncMatchesIniEntry (functor *f, const IniParser::ObservableType &e, const Utils::type_equivalency &eq)
 
bool backendFuncMatchesIniEntry (functor *f, const IniParser::ObservableType &e, const Utils::type_equivalency &eq)
 
int getEntryLevelForOptions (const IniParser::ObservableType &e)
 
bool matchesRules (functor *f, const Rule &rule)
 
double getTimeEstimate (const std::set< VertexID > &vertexList, const DRes::MasterGraphType &graph)
 

Variables

bool use_regex
 Global flag for regex use. More...
 

Typedef Documentation

◆ EdgeID

typedef graph_traits<MasterGraphType>::edge_descriptor Gambit::DRes::EdgeID

Definition at line 62 of file depresolver.hpp.

◆ IndexMap

typedef property_map<MasterGraphType,vertex_index_t>::type Gambit::DRes::IndexMap

Definition at line 63 of file depresolver.hpp.

◆ inputMapType

typedef std::map<std::string, double *> Gambit::DRes::inputMapType

Typedefs for communication channels with the master-likelihood.

Definition at line 68 of file depresolver.hpp.

◆ MasterGraphType

typedef adjacency_list<vecS, vecS, bidirectionalS, functor*, vecS> Gambit::DRes::MasterGraphType

Typedefs for central boost graph.

Definition at line 60 of file depresolver.hpp.

◆ outputMapType

typedef std::map<std::string, std::vector<functor*> > Gambit::DRes::outputMapType

Definition at line 69 of file depresolver.hpp.

◆ VertexID

typedef graph_traits<MasterGraphType>::vertex_descriptor Gambit::DRes::VertexID

Definition at line 61 of file depresolver.hpp.

Function Documentation

◆ backendFuncMatchesIniEntry()

bool Gambit::DRes::backendFuncMatchesIniEntry ( functor f,
const IniParser::ObservableType e,
const Utils::type_equivalency eq 
)

Definition at line 161 of file depresolver.cpp.

References Gambit::IniParser::Types::Observable::backend, Gambit::IniParser::Types::Observable::capability, Gambit::functor::capability(), Gambit::IniParser::Types::Observable::function, Gambit::functor::name(), Gambit::functor::origin(), stringComp(), Gambit::IniParser::Types::Observable::type, Gambit::functor::type(), typeComp(), Gambit::IniParser::Types::Observable::version, and Gambit::functor::version().

Referenced by Gambit::DRes::DependencyResolver::solveRequirement().

162  {
163  return (e.capability != "" ? stringComp(e.capability, f->capability()) : true)
164  and (e.type != "" ? typeComp (e.type, f->type(), eq) : true)
165  and (e.function != "" ? stringComp(e.function, f->name()) : true)
166  and (e.backend != "" ? stringComp(e.backend, f->origin()) : true)
167  and (e.version != "" ? stringComp(e.version, f->version()) : true);
168  }
bool typeComp(str, str, const Utils::type_equivalency &, bool with_regex=true)
Type comparison taking into account equivalence classes.
bool stringComp(const str &s1, const str &s2, bool with_regex=true)
Check whether s1 (wildcard + regex allowed) matches s2.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ capabilityMatchesIniEntry()

bool Gambit::DRes::capabilityMatchesIniEntry ( const sspair quantity,
const IniParser::ObservableType observable 
)

Definition at line 141 of file depresolver.cpp.

References Gambit::IniParser::Types::Observable::capability, and stringComp().

Referenced by Gambit::DRes::DependencyResolver::findIniEntry().

142  {
143  // Compares dependency specifications of rules entries or observable
144  // entries with capability (capabilities have to be unique for these
145  // lists)
146  return ( stringComp( observable.capability, quantity.first ) );
147  }
bool stringComp(const str &s1, const str &s2, bool with_regex=true)
Check whether s1 (wildcard + regex allowed) matches s2.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dependency_resolver_error()

error & Gambit::DRes::dependency_resolver_error ( )

◆ dependency_resolver_warning()

warning & Gambit::DRes::dependency_resolver_warning ( )

Dependency resolver warnings.

Definition at line 49 of file error_handlers.cpp.

References Gambit::LogTags::dependency_resolver.

50  {
51  static warning local("A problem has been raised by the dependency resolver subsystem.","dependency_resolver_warning", dependency_resolver);
52  return local;
53  }

◆ getEntryLevelForOptions()

int Gambit::DRes::getEntryLevelForOptions ( const IniParser::ObservableType e)

Definition at line 171 of file depresolver.cpp.

References Gambit::IniParser::Types::Observable::capability, Gambit::IniParser::Types::Observable::function, Gambit::IniParser::Types::Observable::module, and Gambit::IniParser::Types::Observable::type.

Referenced by Gambit::DRes::DependencyResolver::collectIniOptions().

172  {
173  int z = 0;
174  if ( e.module != "" ) z = 1;
175  if ( e.capability != "" ) z = 2;
176  if ( e.type != "" ) z = 3;
177  if ( e.function != "" ) z = 4;
178  return z;
179  }
Here is the caller graph for this function:

◆ getParentVertices()

void Gambit::DRes::getParentVertices ( const VertexID vertex,
const DRes::MasterGraphType graph,
std::set< VertexID > &  myVertexList 
)

Definition at line 84 of file depresolver.cpp.

Referenced by Gambit::DRes::DependencyResolver::getObsLikeOrder(), getSortedParentVertices(), and Gambit::DRes::DependencyResolver::printFunctorEvalOrder().

86  {
87  graph_traits<DRes::MasterGraphType>::in_edge_iterator it, iend;
88 
89  for (boost::tie(it, iend) = in_edges(vertex, graph);
90  it != iend; ++it)
91  {
92  if ( std::find(myVertexList.begin(), myVertexList.end(), source(*it, graph)) == myVertexList.end() )
93  {
94  myVertexList.insert(source(*it, graph));
95  getParentVertices(source(*it, graph), graph, myVertexList);
96  }
97  }
98  }
void getParentVertices(const VertexID &vertex, const DRes::MasterGraphType &graph, std::set< VertexID > &myVertexList)
Definition: depresolver.cpp:84
Here is the caller graph for this function:

◆ getSortedParentVertices()

std::vector<VertexID> Gambit::DRes::getSortedParentVertices ( const VertexID vertex,
const DRes::MasterGraphType graph,
const std::list< VertexID > &  topoOrder 
)

Definition at line 114 of file depresolver.cpp.

References getParentVertices(), and sortVertices().

Referenced by Gambit::DRes::DependencyResolver::doResolution().

116  {
117  std::set<VertexID> set;
118  getParentVertices(vertex, graph, set);
119  set.insert(vertex);
120  return sortVertices(set, topoOrder);
121  }
std::vector< VertexID > sortVertices(const std::set< VertexID > &set, const std::list< VertexID > &topoOrder)
void getParentVertices(const VertexID &vertex, const DRes::MasterGraphType &graph, std::set< VertexID > &myVertexList)
Definition: depresolver.cpp:84
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTimeEstimate()

double Gambit::DRes::getTimeEstimate ( const std::set< VertexID > &  vertexList,
const DRes::MasterGraphType graph 
)

Definition at line 242 of file depresolver.cpp.

Referenced by Gambit::DRes::DependencyResolver::getObsLikeOrder().

243  {
244  double result = 0;
245  for (std::set<VertexID>::iterator it = vertexList.begin(); it != vertexList.end(); ++it)
246  {
247  result += graph[*it]->getRuntimeAverage();
248  }
249  return result;
250  }
Here is the caller graph for this function:

◆ matchesRules()

bool Gambit::DRes::matchesRules ( functor f,
const Rule rule 
)

Definition at line 183 of file depresolver.cpp.

References Gambit::Utils::fix_type(), Gambit::DRes::Rule::function, Gambit::DRes::Rule::module, and stringComp().

Referenced by Gambit::DRes::DependencyResolver::resolveDependencyFromRules().

184  {
185  #ifdef DEPRES_DEBUG
186  cout << (*f).name() << " vs " << rule.function << endl;
187  cout << (*f).origin() << " vs " << rule.module << endl;
188  #endif
189  return ( stringComp( rule.function, (*f).name()) and
190  stringComp( rule.module, (*f).origin())
191  );
192  }
bool stringComp(const str &s1, const str &s2, bool with_regex=true)
Check whether s1 (wildcard + regex allowed) matches s2.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ moduleFuncMatchesIniEntry()

bool Gambit::DRes::moduleFuncMatchesIniEntry ( functor f,
const IniParser::ObservableType e,
const Utils::type_equivalency eq 
)

Definition at line 151 of file depresolver.cpp.

References Gambit::IniParser::Types::Observable::capability, Gambit::functor::capability(), Gambit::IniParser::Types::Observable::function, Gambit::IniParser::Types::Observable::module, Gambit::functor::name(), Gambit::functor::origin(), stringComp(), Gambit::IniParser::Types::Observable::type, Gambit::functor::type(), and typeComp().

Referenced by Gambit::DRes::DependencyResolver::collectIniOptions(), Gambit::DRes::DependencyResolver::collectSubCaps(), Gambit::DRes::DependencyResolver::findIniEntry(), Gambit::DRes::DependencyResolver::resolveDependency(), and Gambit::DRes::DependencyResolver::resolveDependencyFromRules().

152  {
153  return (e.capability != "" ? stringComp(e.capability, f->capability()) : true)
154  and (e.type != "" ? typeComp (e.type, f->type(), eq) : true)
155  and (e.function != "" ? stringComp(e.function, f->name()) : true)
156  and (e.module != "" ? stringComp(e.module, f->origin()) : true);
157  }
bool typeComp(str, str, const Utils::type_equivalency &, bool with_regex=true)
Type comparison taking into account equivalence classes.
bool stringComp(const str &s1, const str &s2, bool with_regex=true)
Check whether s1 (wildcard + regex allowed) matches s2.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ quantityMatchesIniEntry()

bool Gambit::DRes::quantityMatchesIniEntry ( const sspair quantity,
const IniParser::ObservableType observable,
const Utils::type_equivalency eq 
)

Definition at line 130 of file depresolver.cpp.

References Gambit::IniParser::Types::Observable::capability, stringComp(), Gambit::IniParser::Types::Observable::type, and typeComp().

Referenced by Gambit::DRes::DependencyResolver::resolveDependencyFromRules().

131  {
132  // Compares dependency specifications of rules entries or observable
133  // entries with capability (capabilities have to be unique for these
134  // lists)
135  return ( stringComp( observable.capability, quantity.first ) and
136  typeComp ( observable.type, quantity.second, eq ));
137  }
bool typeComp(str, str, const Utils::type_equivalency &, bool with_regex=true)
Type comparison taking into account equivalence classes.
bool stringComp(const str &s1, const str &s2, bool with_regex=true)
Check whether s1 (wildcard + regex allowed) matches s2.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sortVertices()

std::vector<VertexID> Gambit::DRes::sortVertices ( const std::set< VertexID > &  set,
const std::list< VertexID > &  topoOrder 
)

Definition at line 101 of file depresolver.cpp.

Referenced by Gambit::DRes::DependencyResolver::doResolution(), and getSortedParentVertices().

103  {
104  std::vector<VertexID> result;
105  for(std::list<VertexID>::const_iterator it = topoOrder.begin(); it != topoOrder.end(); it++)
106  {
107  if (set.find(*it) != set.end())
108  result.push_back(*it);
109  }
110  return result;
111  }
Here is the caller graph for this function:

◆ stringComp()

bool Gambit::DRes::stringComp ( const str s1,
const str s2,
bool  with_regex = true 
)

Check whether s1 (wildcard + regex allowed) matches s2.

Definition at line 253 of file depresolver.cpp.

References dependency_resolver_error(), Gambit::LogTags::err, and LOCAL_INFO.

Referenced by backendFuncMatchesIniEntry(), capabilityMatchesIniEntry(), matchesRules(), moduleFuncMatchesIniEntry(), quantityMatchesIniEntry(), Gambit::DRes::DependencyResolver::resolveDependency(), Gambit::DRes::DependencyResolver::resolveDependencyFromRules(), and typeComp().

254  {
255  if ( s1 == s2 ) return true;
256  if ( s1 == "" ) return true;
257  if ( s1 == "*" ) return true;
258  try
259  {
260  if (with_regex) if (std::regex_match(s2, std::regex(s1))) return true;
261  }
262  catch (std::regex_error & err)
263  {
264  std::ostringstream errmsg;
265  errmsg << "ERROR during regex string comparison." << std::endl;
266  errmsg << " Comparing regular expression: " << s1 << std::endl;
267  errmsg << " with test string: " << s2 << std::endl;
268  dependency_resolver_error().raise(LOCAL_INFO,errmsg.str());
269  }
270  return false;
271  }
#define LOCAL_INFO
Definition: local_info.hpp:34
error & dependency_resolver_error()
Dependency resolver errors.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ typeComp()

bool Gambit::DRes::typeComp ( str  s1,
str  s2,
const Utils::type_equivalency eq,
bool  with_regex = true 
)

Type comparison taking into account equivalence classes.

Definition at line 274 of file depresolver.cpp.

References Gambit::Utils::type_equivalency::equivalency_classes, Gambit::Utils::replace_leading_namespace(), and stringComp().

Referenced by backendFuncMatchesIniEntry(), Gambit::DRes::DependencyResolver::checkTypeMatch(), moduleFuncMatchesIniEntry(), Gambit::DRes::DependencyResolver::printObsLike(), quantityMatchesIniEntry(), Gambit::DRes::DependencyResolver::resolveDependency(), Gambit::DRes::DependencyResolver::resolveDependencyFromRules(), and Gambit::DRes::DependencyResolver::solveRequirement().

275  {
276  bool match1, match2;
277  // Loop over all the default versions of BOSSed backends and replace any corresponding *_default leading namespace with the explicit version.
278  for (auto it = Backends::backendInfo().default_safe_versions.begin(); it != Backends::backendInfo().default_safe_versions.end(); ++it)
279  {
280  s1 = Utils::replace_leading_namespace(s1, it->first+"_default", it->first+"_"+it->second);
281  s2 = Utils::replace_leading_namespace(s2, it->first+"_default", it->first+"_"+it->second);
282  }
283  // Does it just match?
284  if (stringComp(s1, s2, with_regex)) return true;
285  // Otherwise loop over equivalence classes.
286  for (auto it1 = eq.equivalency_classes.begin(); it1 != eq.equivalency_classes.end(); it1++)
287  {
288  match1 = match2 = false;
289  for (auto it2 = it1->begin(); it2 != it1->end(); it2++)
290  {
291  if (s2 == *it2) match1 = true;
292  if (stringComp(s1, *it2, with_regex)) match2 = true;
293  }
294  if (match1 and match2) return true;
295  }
296  return false;
297  }
EXPORT_SYMBOLS str replace_leading_namespace(str s, str ns, str ns_new)
Replaces a namespace at the start of a string, or after "const".
bool stringComp(const str &s1, const str &s2, bool with_regex=true)
Check whether s1 (wildcard + regex allowed) matches s2.
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ use_regex

bool Gambit::DRes::use_regex

Global flag for regex use.

Definition at line 239 of file depresolver.cpp.