Skip to content

Commit 5aa727a

Browse files
authored
Merge pull request #48 from GambitBSM/gambit_light_sync
Gambit light sync
2 parents 543666a + dd7810d commit 5aa727a

24 files changed

Lines changed: 493 additions & 43 deletions

File tree

.github/workflows/ci_linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Gambit-light Linux CI on Wino
1+
name: Gambit-light Linux CI
22

33
on:
44
push:

Backends/include/gambit/Backends/backend_macros.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,9 @@ namespace Gambit
284284
<< "which is supposed to contain the factory for class " << std::endl \
285285
<< fixns(STRINGIFY(BARENAME) STRINGIFY(CONVERT_VARIADIC_ARG(ARGS)))<<", "<<std::endl\
286286
<< "is missing or catastrophically broken." << std::endl \
287-
<< "Fix or find that backend yo -- or don't use the type." << std::endl; \
287+
<< "If running gambit with the -b flag, this backend is required to " << std::endl \
288+
<< "run this yaml file or check what other backends are also required." << std::endl\
289+
<< "Otherwise, fix or find that backend -- or don't use the type." << std::endl; \
288290
backend_error().raise(LOCAL_INFO BOOST_PP_COMMA() err.str()); \
289291
return NULL; \
290292
} \

Core/include/gambit/Core/depresolver.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ namespace Gambit
7777
{
7878
VertexID vertex;
7979
str purpose;
80+
bool critical;
8081
};
8182

8283
/// Information in resolution queue
@@ -88,6 +89,7 @@ namespace Gambit
8889
VertexID toVertex;
8990
int dependency_type;
9091
bool printme;
92+
bool critical;
9193
const Observable* obslike;
9294
};
9395

@@ -163,6 +165,10 @@ namespace Gambit
163165
/// Non-null only if the functor corresponds to an ObsLike entry in the ini file.
164166
const str& getPurpose(VertexID);
165167

168+
/// Returns whether a given functor is critical
169+
/// True only if the functor corresponds to a critical ObsLike entry in the ini file.
170+
bool getCritical(VertexID);
171+
166172
/// Tell functor that it invalidated the current point in model space (due to a large or NaN contribution to lnL)
167173
void invalidatePointAt(VertexID, bool);
168174

Core/include/gambit/Core/observable.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ namespace Gambit
6565
/// Instruction to printer as to whether to write result to disk.
6666
bool printme;
6767

68+
/// Allowed to invalidate a point.
69+
bool critical;
70+
6871
/// Whether or not to log matches to the observable with functors.
6972
bool log_matches;
7073

@@ -100,6 +103,7 @@ namespace Gambit
100103
functionChain(),
101104
subcaps(),
102105
printme(true),
106+
critical(false),
103107
log_matches(true),
104108
include_all(false)
105109
{}

Core/src/depresolver.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,13 @@ namespace Gambit
256256
for (const Observable& obslike : obslikes)
257257
{
258258
// Format output
259-
logger() << LogTags::dependency_resolver << endl << obslike.capability << " (" << obslike.type << ") [" << obslike.purpose << "]";
259+
logger() << LogTags::dependency_resolver << endl << obslike.capability << " (" << obslike.type << ") [" << obslike.purpose << "] critical:" << obslike.critical << "";
260260
QueueEntry target;
261261
target.quantity.first = obslike.capability;
262262
target.quantity.second = obslike.type;
263263
target.obslike = &obslike;
264264
target.printme = obslike.printme;
265+
target.critical = obslike.critical;
265266
resolutionQueue.push(target);
266267
}
267268
logger() << EOM;
@@ -333,11 +334,11 @@ namespace Gambit
333334
makeFunctorsModelCompatible();
334335

335336
graph_traits<MasterGraphType>::vertex_iterator vi, vi_end;
336-
const str formatString = "%-20s %-32s %-32s %-32s %-15s %-7i %-5i %-5i\n";
337+
const str formatString = "%-20s %-32s %-32s %-32s %-15s %-5i %-7i %-5i %-5i\n";
337338
logger() << LogTags::dependency_resolver << endl << "Vertices registered in masterGraph" << endl;
338339
logger() << "----------------------------------" << endl;
339340
logger() << boost::format(formatString)%
340-
"MODULE"% "FUNCTION"% "CAPABILITY"% "TYPE"% "PURPOSE"% "STATUS"% "#DEPs"% "#BE_REQs";
341+
"MODULE"% "FUNCTION"% "CAPABILITY"% "TYPE"% "PURPOSE"% "CRITICAL"% "STATUS"% "#DEPs"% "#BE_REQs";
341342
for (std::tie(vi, vi_end) = vertices(masterGraph); vi != vi_end; ++vi)
342343
{
343344
logger() << boost::format(formatString)%
@@ -346,6 +347,7 @@ namespace Gambit
346347
(*masterGraph[*vi]).capability()%
347348
(*masterGraph[*vi]).type()%
348349
(*masterGraph[*vi]).purpose()%
350+
(*masterGraph[*vi]).critical()%
349351
(*masterGraph[*vi]).status()%
350352
(*masterGraph[*vi]).dependencies().size()%
351353
(*masterGraph[*vi]).backendreqs().size();
@@ -707,6 +709,17 @@ namespace Gambit
707709
return none;
708710
}
709711

712+
/// Return whether a given functor is critical.
713+
bool DependencyResolver::getCritical(VertexID v)
714+
{
715+
for (const OutputVertex& ov : outputVertices)
716+
{
717+
if (ov.vertex == v) return ov.critical;
718+
}
719+
/// critical can safely be false if the functor does not correspond to an ObsLike entry in the ini file.
720+
return false;
721+
}
722+
710723
/// Tell functor that it invalidated the current point in model space (due to a large or NaN contribution to lnL)
711724
void DependencyResolver::invalidatePointAt(VertexID vertex, bool isnan)
712725
{
@@ -1569,7 +1582,8 @@ namespace Gambit
15691582
else // if output vertex
15701583
{
15711584
outVertex.vertex = fromVertex;
1572-
outVertex.purpose = entry.obslike->purpose;;
1585+
outVertex.purpose = entry.obslike->purpose;
1586+
outVertex.critical = entry.obslike->critical;
15731587
outputVertices.push_back(outVertex);
15741588
// Don't need subcaps during dry-run
15751589
if (not boundCore->show_runorder)

Core/src/likelihood_container.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ namespace Gambit
9191
// Set the ScanID
9292
set_scanID();
9393

94-
// Find subset of vertices that match requested purpose
94+
// Find subset of vertices that match requested purpose, or are critical observables
9595
auto all_vertices = dependencyResolver.getObsLikeOrder();
9696
for (auto it = all_vertices.begin(); it != all_vertices.end(); ++it)
9797
{
98-
if (dependencyResolver.getPurpose(*it) == purpose)
98+
if (dependencyResolver.getPurpose(*it) == purpose || dependencyResolver.getCritical(*it) == true)
9999
{
100100
return_types[*it] = dependencyResolver.checkTypeMatch(*it, purpose, allowed_types_for_purpose);
101101
target_vertices.push_back(std::move(*it));
@@ -279,6 +279,11 @@ namespace Gambit
279279
lnlike += *jt;
280280
}
281281
}
282+
else if (dependencyResolver.getCritical(*it) == true)
283+
{
284+
// Don't throw an error if the target vertex is a critical obslike,
285+
// but don't add it to the total LogLike
286+
}
282287
else core_error().raise(LOCAL_INFO, "Unexpected target functor type.");
283288

284289
// Print debug info

Core/src/yaml_parser.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ namespace YAML
212212
const std::string key = entry.first.as<std::string>();
213213
if (key == "purpose") rhs.purpose = entry.second.as<std::string>();
214214
else if (key == "capability") rhs.capability = entry.second.as<std::string>();
215+
else if (key == "critical") rhs.critical = entry.second.as<bool>();
215216
else if (key == "type") rhs.type = entry.second.as<std::string>();
216217
else if (key == "function") rhs.function = entry.second.as<std::string>();
217218
else if (key == "module") rhs.module = entry.second.as<std::string>();

Elements/include/gambit/Elements/functors.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ namespace Gambit
165165
virtual void setInUse(bool){};
166166
/// Setter for purpose (relevant only for next-to-output functors)
167167
void setPurpose(str);
168+
/// Setter for critical (relevant only for next-to-output functors)
169+
void setCritical(bool);
168170
/// Setter for vertex ID (used in printer system)
169171
void setVertexID(int);
170172
/// Set ID for timing 'vertex' (used in printer system)
@@ -197,6 +199,8 @@ namespace Gambit
197199
sspair quantity() const;
198200
/// Getter for purpose (relevant for output nodes, aka helper structures for the dep. resolution)
199201
str purpose() const;
202+
/// Getter for critical (relevant for output nodes, aka helper structures for the dep. resolution)
203+
bool critical() const;
200204
/// Getter for the citation key
201205
str citationKey() const;
202206
/// Getter for vertex ID
@@ -410,6 +414,8 @@ namespace Gambit
410414
str myOrigin;
411415
/// Purpose of the function (relevant for output and next-to-output functors)
412416
str myPurpose;
417+
/// critical flag of the function (relevant for output and next-to-output functors)
418+
bool myCritical;
413419
/// Citation key: BibTex key of the reference.
414420
str myCitationKey;
415421
/// Bound model functor claw, for checking relationships between models
@@ -600,7 +606,7 @@ namespace Gambit
600606
virtual std::set<sspair> model_conditional_backend_reqs_exact (str model);
601607

602608
/// Add and activate unconditional dependencies.
603-
void setDependency(str, str, void(*)(functor*, module_functor_common*), str purpose= "");
609+
void setDependency(str, str, void(*)(functor*, module_functor_common*), str purpose= "", bool critical=false);
604610

605611
/// Add conditional dependency-type pairs in advance of later conditions.
606612
void setConditionalDependency(str, str);

Elements/src/functors.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ namespace Gambit
104104
/// Setter for purpose (relevant only for next-to-output functors)
105105
void functor::setPurpose(str purpose) { myPurpose = purpose; }
106106

107+
/// Setter for critical flag (relevant only for next-to-output functors)
108+
void functor::setCritical(bool critical) { myCritical = critical; }
109+
107110
/// Setter for vertex ID (used in printer system)
108111
void functor::setVertexID(int ID) { myVertexID = ID; }
109112

@@ -145,6 +148,8 @@ namespace Gambit
145148
sspair functor::quantity() const { return std::make_pair(myCapability, myType); }
146149
/// Getter for purpose (relevant for output nodes, aka helper structures for the dep. resolution)
147150
str functor::purpose() const { return myPurpose; }
151+
/// Getter for critical (relevant for output nodes, aka helper structures for the dep. resolution)
152+
bool functor::critical() const { return myCritical; }
148153
/// Getter for citation key
149154
str functor::citationKey() const { return myCitationKey; }
150155
/// Getter for vertex ID
@@ -1166,12 +1171,13 @@ namespace Gambit
11661171
}
11671172

11681173
/// Add and activate unconditional dependencies.
1169-
void module_functor_common::setDependency(str dep, str dep_type, void(*resolver)(functor*, module_functor_common*), str purpose)
1174+
void module_functor_common::setDependency(str dep, str dep_type, void(*resolver)(functor*, module_functor_common*), str purpose, bool critical)
11701175
{
11711176
sspair key (dep, Utils::fix_type(dep_type));
11721177
myDependencies.insert(key);
11731178
dependency_map[key] = resolver;
11741179
this->myPurpose = purpose; // only relevant for output nodes
1180+
this->myCritical = critical; // only relevant for output nodes
11751181
}
11761182

11771183
/// Add conditional dependency-type pairs in advance of later conditions.
@@ -1529,6 +1535,8 @@ namespace Gambit
15291535
if (dependency_map.find(key) != dependency_map.end()) (*dependency_map[key])(dep_functor,this);
15301536
// propagate purpose from next to next-to-output nodes
15311537
dep_functor->setPurpose(this->myPurpose);
1538+
// propagate critical from next to next-to-output nodes
1539+
dep_functor->setCritical(this->myCritical);
15321540
// propagate this functor's dependees and subcaps on to the resolving functor
15331541
dep_functor->notifyOfDependee(this);
15341542
// save the pointer to the resolving functor to allow this functor to notify it of future dependees

Logs/src/logging.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ namespace Gambit
194194
//std::cout<<"Sorting tags..."<<std::endl;
195195
for(std::set<int>::iterator tag = mail.tags.begin(); tag != mail.tags.end(); ++tag)
196196
{
197-
// Debugging crap... to be deleted.
197+
// Debugging stuff... to be deleted.
198198
// std::cout<<"Sorting tag "<<tag2str()[*tag]<<std::endl;
199199
// std::cout<<"empty?"<<components().empty()<<std::endl;
200200
// for(std::set<int>::iterator tag2 = components().begin(); tag2 != components().end(); ++tag2)

0 commit comments

Comments
 (0)