Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci_linux.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Gambit-light Linux CI on Wino
name: Gambit-light Linux CI

on:
push:
Expand Down
4 changes: 3 additions & 1 deletion Backends/include/gambit/Backends/backend_macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@ namespace Gambit
<< "which is supposed to contain the factory for class " << std::endl \
<< fixns(STRINGIFY(BARENAME) STRINGIFY(CONVERT_VARIADIC_ARG(ARGS)))<<", "<<std::endl\
<< "is missing or catastrophically broken." << std::endl \
<< "Fix or find that backend yo -- or don't use the type." << std::endl; \
<< "If running gambit with the -b flag, this backend is required to " << std::endl \
<< "run this yaml file or check what other backends are also required." << std::endl\
<< "Otherwise, fix or find that backend -- or don't use the type." << std::endl; \
backend_error().raise(LOCAL_INFO BOOST_PP_COMMA() err.str()); \
return NULL; \
} \
Expand Down
6 changes: 6 additions & 0 deletions Core/include/gambit/Core/depresolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ namespace Gambit
{
VertexID vertex;
str purpose;
bool critical;
};

/// Information in resolution queue
Expand All @@ -88,6 +89,7 @@ namespace Gambit
VertexID toVertex;
int dependency_type;
bool printme;
bool critical;
const Observable* obslike;
};

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

/// Returns whether a given functor is critical
/// True only if the functor corresponds to a critical ObsLike entry in the ini file.
bool getCritical(VertexID);

/// Tell functor that it invalidated the current point in model space (due to a large or NaN contribution to lnL)
void invalidatePointAt(VertexID, bool);

Expand Down
4 changes: 4 additions & 0 deletions Core/include/gambit/Core/observable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ namespace Gambit
/// Instruction to printer as to whether to write result to disk.
bool printme;

/// Allowed to invalidate a point.
bool critical;

/// Whether or not to log matches to the observable with functors.
bool log_matches;

Expand Down Expand Up @@ -100,6 +103,7 @@ namespace Gambit
functionChain(),
subcaps(),
printme(true),
critical(false),
log_matches(true),
include_all(false)
{}
Expand Down
22 changes: 18 additions & 4 deletions Core/src/depresolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,13 @@ namespace Gambit
for (const Observable& obslike : obslikes)
{
// Format output
logger() << LogTags::dependency_resolver << endl << obslike.capability << " (" << obslike.type << ") [" << obslike.purpose << "]";
logger() << LogTags::dependency_resolver << endl << obslike.capability << " (" << obslike.type << ") [" << obslike.purpose << "] critical:" << obslike.critical << "";
QueueEntry target;
target.quantity.first = obslike.capability;
target.quantity.second = obslike.type;
target.obslike = &obslike;
target.printme = obslike.printme;
target.critical = obslike.critical;
resolutionQueue.push(target);
}
logger() << EOM;
Expand Down Expand Up @@ -333,11 +334,11 @@ namespace Gambit
makeFunctorsModelCompatible();

graph_traits<MasterGraphType>::vertex_iterator vi, vi_end;
const str formatString = "%-20s %-32s %-32s %-32s %-15s %-7i %-5i %-5i\n";
const str formatString = "%-20s %-32s %-32s %-32s %-15s %-5i %-7i %-5i %-5i\n";
logger() << LogTags::dependency_resolver << endl << "Vertices registered in masterGraph" << endl;
logger() << "----------------------------------" << endl;
logger() << boost::format(formatString)%
"MODULE"% "FUNCTION"% "CAPABILITY"% "TYPE"% "PURPOSE"% "STATUS"% "#DEPs"% "#BE_REQs";
"MODULE"% "FUNCTION"% "CAPABILITY"% "TYPE"% "PURPOSE"% "CRITICAL"% "STATUS"% "#DEPs"% "#BE_REQs";
for (std::tie(vi, vi_end) = vertices(masterGraph); vi != vi_end; ++vi)
{
logger() << boost::format(formatString)%
Expand All @@ -346,6 +347,7 @@ namespace Gambit
(*masterGraph[*vi]).capability()%
(*masterGraph[*vi]).type()%
(*masterGraph[*vi]).purpose()%
(*masterGraph[*vi]).critical()%
(*masterGraph[*vi]).status()%
(*masterGraph[*vi]).dependencies().size()%
(*masterGraph[*vi]).backendreqs().size();
Expand Down Expand Up @@ -707,6 +709,17 @@ namespace Gambit
return none;
}

/// Return whether a given functor is critical.
bool DependencyResolver::getCritical(VertexID v)
{
for (const OutputVertex& ov : outputVertices)
{
if (ov.vertex == v) return ov.critical;
}
/// critical can safely be false if the functor does not correspond to an ObsLike entry in the ini file.
return false;
}

/// Tell functor that it invalidated the current point in model space (due to a large or NaN contribution to lnL)
void DependencyResolver::invalidatePointAt(VertexID vertex, bool isnan)
{
Expand Down Expand Up @@ -1569,7 +1582,8 @@ namespace Gambit
else // if output vertex
{
outVertex.vertex = fromVertex;
outVertex.purpose = entry.obslike->purpose;;
outVertex.purpose = entry.obslike->purpose;
outVertex.critical = entry.obslike->critical;
outputVertices.push_back(outVertex);
// Don't need subcaps during dry-run
if (not boundCore->show_runorder)
Expand Down
9 changes: 7 additions & 2 deletions Core/src/likelihood_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ namespace Gambit
// Set the ScanID
set_scanID();

// Find subset of vertices that match requested purpose
// Find subset of vertices that match requested purpose, or are critical observables
auto all_vertices = dependencyResolver.getObsLikeOrder();
for (auto it = all_vertices.begin(); it != all_vertices.end(); ++it)
{
if (dependencyResolver.getPurpose(*it) == purpose)
if (dependencyResolver.getPurpose(*it) == purpose || dependencyResolver.getCritical(*it) == true)
{
return_types[*it] = dependencyResolver.checkTypeMatch(*it, purpose, allowed_types_for_purpose);
target_vertices.push_back(std::move(*it));
Expand Down Expand Up @@ -279,6 +279,11 @@ namespace Gambit
lnlike += *jt;
}
}
else if (dependencyResolver.getCritical(*it) == true)
{
// Don't throw an error if the target vertex is a critical obslike,
// but don't add it to the total LogLike
}
else core_error().raise(LOCAL_INFO, "Unexpected target functor type.");

// Print debug info
Expand Down
1 change: 1 addition & 0 deletions Core/src/yaml_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ namespace YAML
const std::string key = entry.first.as<std::string>();
if (key == "purpose") rhs.purpose = entry.second.as<std::string>();
else if (key == "capability") rhs.capability = entry.second.as<std::string>();
else if (key == "critical") rhs.critical = entry.second.as<bool>();
else if (key == "type") rhs.type = entry.second.as<std::string>();
else if (key == "function") rhs.function = entry.second.as<std::string>();
else if (key == "module") rhs.module = entry.second.as<std::string>();
Expand Down
8 changes: 7 additions & 1 deletion Elements/include/gambit/Elements/functors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ namespace Gambit
virtual void setInUse(bool){};
/// Setter for purpose (relevant only for next-to-output functors)
void setPurpose(str);
/// Setter for critical (relevant only for next-to-output functors)
void setCritical(bool);
/// Setter for vertex ID (used in printer system)
void setVertexID(int);
/// Set ID for timing 'vertex' (used in printer system)
Expand Down Expand Up @@ -197,6 +199,8 @@ namespace Gambit
sspair quantity() const;
/// Getter for purpose (relevant for output nodes, aka helper structures for the dep. resolution)
str purpose() const;
/// Getter for critical (relevant for output nodes, aka helper structures for the dep. resolution)
bool critical() const;
/// Getter for the citation key
str citationKey() const;
/// Getter for vertex ID
Expand Down Expand Up @@ -410,6 +414,8 @@ namespace Gambit
str myOrigin;
/// Purpose of the function (relevant for output and next-to-output functors)
str myPurpose;
/// critical flag of the function (relevant for output and next-to-output functors)
bool myCritical;
/// Citation key: BibTex key of the reference.
str myCitationKey;
/// Bound model functor claw, for checking relationships between models
Expand Down Expand Up @@ -600,7 +606,7 @@ namespace Gambit
virtual std::set<sspair> model_conditional_backend_reqs_exact (str model);

/// Add and activate unconditional dependencies.
void setDependency(str, str, void(*)(functor*, module_functor_common*), str purpose= "");
void setDependency(str, str, void(*)(functor*, module_functor_common*), str purpose= "", bool critical=false);

/// Add conditional dependency-type pairs in advance of later conditions.
void setConditionalDependency(str, str);
Expand Down
10 changes: 9 additions & 1 deletion Elements/src/functors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ namespace Gambit
/// Setter for purpose (relevant only for next-to-output functors)
void functor::setPurpose(str purpose) { myPurpose = purpose; }

/// Setter for critical flag (relevant only for next-to-output functors)
void functor::setCritical(bool critical) { myCritical = critical; }

/// Setter for vertex ID (used in printer system)
void functor::setVertexID(int ID) { myVertexID = ID; }

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

/// Add and activate unconditional dependencies.
void module_functor_common::setDependency(str dep, str dep_type, void(*resolver)(functor*, module_functor_common*), str purpose)
void module_functor_common::setDependency(str dep, str dep_type, void(*resolver)(functor*, module_functor_common*), str purpose, bool critical)
{
sspair key (dep, Utils::fix_type(dep_type));
myDependencies.insert(key);
dependency_map[key] = resolver;
this->myPurpose = purpose; // only relevant for output nodes
this->myCritical = critical; // only relevant for output nodes
}

/// Add conditional dependency-type pairs in advance of later conditions.
Expand Down Expand Up @@ -1529,6 +1535,8 @@ namespace Gambit
if (dependency_map.find(key) != dependency_map.end()) (*dependency_map[key])(dep_functor,this);
// propagate purpose from next to next-to-output nodes
dep_functor->setPurpose(this->myPurpose);
// propagate critical from next to next-to-output nodes
dep_functor->setCritical(this->myCritical);
// propagate this functor's dependees and subcaps on to the resolving functor
dep_functor->notifyOfDependee(this);
// save the pointer to the resolving functor to allow this functor to notify it of future dependees
Expand Down
2 changes: 1 addition & 1 deletion Logs/src/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ namespace Gambit
//std::cout<<"Sorting tags..."<<std::endl;
for(std::set<int>::iterator tag = mail.tags.begin(); tag != mail.tags.end(); ++tag)
{
// Debugging crap... to be deleted.
// Debugging stuff... to be deleted.
// std::cout<<"Sorting tag "<<tag2str()[*tag]<<std::endl;
// std::cout<<"empty?"<<components().empty()<<std::endl;
// for(std::set<int>::iterator tag2 = components().begin(); tag2 != components().end(); ++tag2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/// HDF5 databases.
///
/// Currently I am using the C++ bindings for
/// HDF5, however they are a bit crap and it may
/// HDF5, however they not great and it may
/// be better to just write our own.
///
/// *********************************************
Expand Down
2 changes: 1 addition & 1 deletion Printers/src/printers/hdf5printer/hdf5tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/// HDF5 databases.
///
/// Currently I am using the C++ bindings for
/// HDF5, however they are a bit crap and it may
/// HDF5, however they not great and it may
/// be better to just write our own.
///
/// *********************************************
Expand Down
2 changes: 1 addition & 1 deletion ScannerBit/include/gambit/ScannerBit/plugin_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ namespace Gambit
template <typename... args>
auto operator()(args&... params) -> typename find_variadic_type <void (args...), T...>::ret_type
{
static_assert(find_variadic_type <void (args...), T...>::value, "\n\033[00;31;1mPlugin Interface: Entered argument types do not match any of the plugin mains' argument types.\033[00m\n");
static_assert(find_variadic_type <void (args...), T...>::value, "\n\u001B[00;31;1mPlugin Interface: Entered argument types do not match any of the plugin mains' argument types.\u001B[00m\n");
return Plugin_Main_Interface_Base<typename find_variadic_type <void (args...), T...>::func_type>::operator()(params...);
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// GAMBIT: Global and Modular BSM Inference Tool
// *********************************************
/// \file
///
/// ScannerBit interface to Diver 1.0.5
///
/// Header file
///
/// *********************************************
///
/// Authors (add name and date if you modify):
///
/// \author Pat Scott
/// (p.scott@imperial.ac.uk)
/// \date 2019 Dec
///
/// *********************************************

#ifndef __diver_hpp__
#define __diver_hpp__

#include "gambit/ScannerBit/scanner_plugin.hpp"

// C++ prototype of the main run_de function for Diver.
extern "C" void cdiver(double (*)(double[], const int, int&, bool&, const bool, void*&), int, const double[], const double[],
const char[], int, int, const int[], bool, const int, const int, int, int, const double[], double,
double, bool, bool, int, bool, bool, double, int, bool, bool, double(*)(const double[], const int, void*&),
double, double, int, bool, bool, int, bool, int, double, int, void*&, int);

namespace Gambit
{

namespace Diver_1_0_5
{

/// Structure for passing likelihood and printer data through Diver to the objective function.
struct diverScanData
{
Scanner::like_ptr likelihood_function;
Scanner::printer_interface* printer;
};

/// Function to be minimised by Diver
double objective(double params[], const int param_dim, int &fcall, bool &quit, const bool validvector, void*& context);

}

}

#endif // #defined __diver_hpp__
Loading
Loading