likelihood_container.cpp
Go to the documentation of this file.
44 Likelihood_Container::Likelihood_Container(const std::map<str, primary_model_functor *> &functorMap, 50 min_valid_lnlike (iniFile.getValueOrDef<double>(0.9*std::numeric_limits<double>::lowest(), "likelihood", "model_invalid_for_lnlike_below")), 51 alt_min_valid_lnlike (iniFile.getValueOrDef<double>(0.5*min_valid_lnlike, "likelihood", "model_invalid_for_lnlike_below_alt")), 52 active_min_valid_lnlike (min_valid_lnlike), // can be switched to the alternate value by the scanner 54 disable_print_for_lnlike_below (iniFile.getValueOrDef<double>(min_valid_lnlike, "likelihood", "disable_print_for_lnlike_below")), 68 debug (iniFile.getValueOrDef<bool>(false, "debug") or iniFile.getValueOrDef<bool>(false, "likelihood", "debug")) 71 // Set the list of valid return types of functions that can be used for 'purpose' by this container class. 72 const std::vector<str> allowed_types_for_purpose = initVector<str>("double", "std::vector<double>", "float", "std::vector<float>"); 90 void Likelihood_Container::setParameters (const std::unordered_map<std::string, double> ¶meterMap) 101 // Iterate over the parameters, setting their values in the primary_model_parameters functors from the parameterMap. 109 err << "Error! Failed to set parameter '"<<key<<"' following prior transformation! The parameter could not be found in the map returned by the prior. This probably means that the prior you are using contains a bug." << std::endl; 126 exception::set_parameters("\n\nYAML-ready parameter values at failed point:\n"+parstream.str()); 136 logger() << LogTags::core << "\nBeginning computations for parameter point:\n" << parstream.str() << EOM; 139 //logger() << LogTags::core << "\nBeginning computations for parameter point:\n" << parstream.str() << EOM; 152 // Check for signals from the scanner to switch to an alternate minimum log likelihood value. TODO: could let scanner plugin set the actual value? 159 logger() << "Switched to using alt_min_valid_lnlike ("<<alt_min_valid_lnlike<<") instead of original value ("<<min_valid_lnlike<<")" << EOM; 168 logger() << "Informed scanner that early shutdown is in progress and it should secure all its output files if possible." << EOM; 174 // If the scanner does not have a built-in mechanism for halting the scan early, then we will assume 177 lnlike = alt_min_valid_lnlike; // Always use this larger value to avoid scanner deadlocks (e.g. MultiNest refuses to progress without a likelihood above its minimum threshold) 178 point_invalidated = true; // Will prevent this likelihood value from being flagged as 'valid' by the printer 179 logger() << "Shutdown in progess! The scanner is not flagged as being able to shut itself down, so are managing the shutdown from the likelihood container side. Returning min_valid_lnlike to ScannerBit instead of computing likelihood." << EOM; 183 // If the shutdown has been triggered but the quit flag is present, then we let the likelihood evaluation proceed as normal. 187 // Set the values of the parameter point in the PrimaryParameters functor, and log them to cout and/or the logs if desired. 190 // Logger debug output; things labelled 'LogTags::debug' only get logged if the logger::debug or master debug flags are true, not if only 'likelihood::debug' is true. 191 logger() << LogTags::core << LogTags::debug << "Number of target vertices to calculate: " << target_vertices.size() << endl 204 str likelihood_tag = "ikelihood contribution from " + dependencyResolver.get_functor(*it)->origin() 217 // Switch depending on whether the functor returns floats or doubles and a single likelihood or a vector of them. 260 // If we've dropped below the likelihood corresponding to effective zero already, skip the rest of the vertices. 267 // Catch points that are invalid, either due to low like or pathology. Skip the rest of the vertices if a point is invalid. 270 logger() << LogTags::core << "Point invalidated by " << e.thrower()->origin() << "::" << e.thrower()->name() << ": " << e.message() << "Invalidation code " << e.invalidcode << EOM; 286 // If none of the likelihood calculations have invalidated the point, calculate the additional auxiliary observables. 289 if (debug) logger() << LogTags::core << "Completed likelihoods. Calculating additional observables." << EOM; 306 << "::" << e.thrower()->name() << ": " << e.message() << "Invalidation code " << e.invalidcode << EOM; 311 // If the point is invalid and print_invalid_points = false disable the printer, otherwise print vertices 314 // If the likelihood is below the limit given in disable_print_for_lnlike_below, disable the printer 358 // Disable the printer so that it doesn't try to output the min_valid_lnlike as a valid likelihood value. ScannerBit will re-enable it when needed again. void print(T const &in, const std::string &label, const int vertexID, const uint rank, const ulong pointID) Definition: basebaseprinter.hpp:139 DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry double Definition: ColliderBit_LEP_rollcall.hpp:183 const str totallooptime_label Definition: likelihood_container.hpp:90 std::chrono::time_point< std::chrono::system_clock > previous_startL Global record of time that last likelihood evaluation began, for computing true total iteration time... Definition: likelihood_container.hpp:83 DRes::DependencyResolver & dependencyResolver Bound dependency resolver object. Definition: likelihood_container.hpp:53 const IniParser::ObservableType * getIniEntry(VertexID) Definition: depresolver.cpp:731 bool printTiming() Getter for print_timing flag (used by LikelihoodContainer) Definition: depresolver.cpp:686 std::vector< DRes::VertexID > aux_vertices Graph vertices corresponding to additional functors not in ObsLike part of yaml file. Definition: likelihood_container.hpp:50 Helper functions for dealing with POSIX signals. STL namespace. const int totalloopID Definition: likelihood_container.hpp:95 EXPORT_SYMBOLS int get_main_param_id(const std::string &) Returns unique positive parameter id; just a thin wrapper for get_param_id. Definition: printer_id_tools.cpp:85 str origin() const Getter for the wrapped function's origin (module or backend name) Definition: functors.cpp:121 functor * get_functor(VertexID) Get the functor corresponding to a single VertexID. Definition: depresolver.cpp:689 void attempt_soft_shutdown() Perform soft shutdown if processes can be synchronised. Definition: signal_handling.cpp:284 std::string message() Retrieve the message that this exception was raised with. Definition: exceptions.cpp:374 double main(std::unordered_map< std::string, double > &in) Evaluate total likelihood function. Definition: likelihood_container.cpp:145 std::vector< DRes::VertexID > target_vertices Graph vertices corresponding to functors in the ObsLike section of yaml file. Definition: likelihood_container.hpp:47 std::vector< VertexID > getObsLikeOrder() Retrieve the order in which target vertices are to be evaluated. Definition: depresolver.cpp:580 functor * thrower() Retrieve pointer to the functor that threw the invalid point exception. Definition: exceptions.cpp:410 GAMBIT signal handling functions. Definition: log_tags.hpp:38 std::chrono::time_point< std::chrono::system_clock > previous_endL Global record of time that last likelihood evaluation ended, for computing intra-iteration overhead t... Definition: likelihood_container.hpp:85 Definition: log_tags.hpp:35 double active_min_valid_lnlike Active value for the minimum log likelihood (one of the above two values, whichever is currently in-u... Definition: likelihood_container.hpp:71 const str interlooptime_label Definition: likelihood_container.hpp:89 std::map< DRes::VertexID, str > return_types Map of return types of target functors. Definition: likelihood_container.hpp:80 EXPORT_SYMBOLS SignalData & signaldata() Retrieve global instance of signal handler options struct. Definition: signal_handling.cpp:633 int getRank() Retrieve/Set MPI rank (setting is useful for e.g. the postprocessor to re-print points from other ran... Definition: basebaseprinter.hpp:98 const Logging::endofmessage EOM Explicit const instance of the end of message struct in Gambit namespace. Definition: logger.hpp:100 EXPORT_SYMBOLS Logging::LogMaster & logger() Function to retrieve a reference to the Gambit global log object. Definition: logger.cpp:95 double alt_min_valid_lnlike Alternate value for the minimum log likelihood (scanner can trigger a switch to this in special circu... Definition: likelihood_container.hpp:68 const int interloopID Definition: likelihood_container.hpp:94 Likelihood container declarations. double disable_print_for_lnlike_below Disable printing for points with log likelihood below some value. Definition: likelihood_container.hpp:77 double min_valid_lnlike Primary value of the log likelihood at which a point is considered so unlikely that it can be ruled o... Definition: likelihood_container.hpp:65 A simple C++ wrapper for the MPI C bindings. std::map< str, primary_model_functor * > functorMap Map of parameter names to values. Definition: likelihood_container.hpp:62 Definition: log_tags.hpp:47 Likelihood_Container(const std::map< str, primary_model_functor *> &functorMap, DRes::DependencyResolver &dependencyResolver, IniParser::IniFile &iniFile, const str &purpose, Printers::BaseBasePrinter &printer) Constructor. Definition: likelihood_container.cpp:44 void invalidatePointAt(VertexID, bool) Definition: depresolver.cpp:718 str checkTypeMatch(VertexID, const str &, const std::vector< str > &) Ensure that the type of a given vertex is equivalent to at least one of a provided list... Definition: depresolver.cpp:700 void setParameters(const std::unordered_map< std::string, double > &) Do the prior transformation and populate the parameter map. Definition: likelihood_container.cpp:90 bool print_invalid_points Switch to print or not print invalid points to the output file. Definition: likelihood_container.hpp:74 |