gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-2191-ga4742ac
a Global And Modular Bsm Inference Tool
Gambit::Scanner::Function_Base< ret(args...)> Class Template Referenceabstract

Base function for the object that is upputed by "set_purpose". More...

#include <factory_defs.hpp>

Inheritance diagram for Gambit::Scanner::Function_Base< ret(args...)>:
Collaboration diagram for Gambit::Scanner::Function_Base< ret(args...)>:

Public Member Functions

 Function_Base (double offset=0.)
 
virtual ret main (const args &...)=0
 
virtual ~Function_Base ()
 
ret operator() (const args &... params)
 
void setPurpose (const std::string p)
 
void setPrinter (printer *p)
 
void setPrior (Priors::BasePrior *p)
 
printergetPrinter ()
 
printergetPrinter () const
 
Priors::BasePriorgetPrior ()
 
std::vector< std::string > getParameters ()
 
std::vector< std::string > getShownParameters ()
 
std::string getPurpose () const
 
int getRank () const
 
void setRank (int r)
 
double getPurposeOffset () const
 
void setPurposeOffset (double os)
 
unsigned long long int getPtID () const
 
void setPtID (unsigned long long int pID)
 
unsigned long long int getNextPtID () const
 
void tell_scanner_early_shutdown_in_progress ()
 Tell ScannerBit that we are aborting the scan and it should tell the scanner plugin to stop, and return control to the calling code. More...
 
void disable_external_shutdown ()
 Tells log-likelihood function (defined by driver code) not to use its own shutdown system (e.g the GAMBIT soft shutdown procedure) and instead to trust that the scanner plugin will safely terminate executions upon checking that shutdown is in progress (via the shutdown_in_progress flag set in plugin_info) More...
 
bool scanner_can_quit ()
 Check whether likelihood container is supposed to control early shutdown of scan. More...
 
void switch_to_alternate_min_LogL ()
 Tell log-likelihood function (defined by driver code) to switch to an alternate value for the minimum log-likelihood. More...
 
bool check_for_switch_to_alternate_min_LogL ()
 Checks if some process has triggered the 'switch_to_alternate_min_LogL' function. More...
 

Private Member Functions

virtual void deleter (Function_Base< ret(args...)> *in) const
 
virtual const std::type_info & type () const
 

Private Attributes

printermain_printer
 
Priors::BasePriorprior
 
std::string purpose
 
int myRealRank
 
double purpose_offset
 Variable to store some offset to be removed when printing out the return value of the function. More...
 
bool use_alternate_min_LogL
 Variable to store state of affairs regarding use of alternate min_LogL. More...
 
bool _scanner_can_quit
 Variable to specify whether the scanner plugin should control the shutdown process. More...
 

Friends

class Function_Deleter< ret(args...)>
 
class scan_ptr< ret(args...)>
 

Detailed Description

template<typename ret, typename... args>
class Gambit::Scanner::Function_Base< ret(args...)>

Base function for the object that is upputed by "set_purpose".

Definition at line 73 of file factory_defs.hpp.

Constructor & Destructor Documentation

◆ Function_Base()

template<typename ret , typename... args>
Gambit::Scanner::Function_Base< ret(args...)>::Function_Base ( double  offset = 0.)
inline

Definition at line 101 of file factory_defs.hpp.

References find_all_gambit_bits::args, Gambit::Scanner::Plugins::pluginInfo::check_alt_min_LogL_state(), Gambit::Scanner::Plugins::pluginInfo::clear_alt_min_LogL_state(), main(), and Gambit::Scanner::Plugins::plugin_info.

102  {
103  #ifdef WITH_MPI
104  GMPI::Comm world;
105  myRealRank = world.Get_rank();
106  #endif
107  // Check if we should be using the alternative min_LogL from the very beginning
108  // (for example if we are resuming from a run where we already switched to this)
109  if (Gambit::Scanner::Plugins::plugin_info.resume_mode())
110  {
112  }
113  else
114  {
115  // New scan; delete any old persistence file
116  // But only do this if we are process 0, otherwise I think race conditions can occur.
117  // (TODO do we need to ensure a sync here in case other processes than 0 get too far ahead?)
119  }
120  }
bool _scanner_can_quit
Variable to specify whether the scanner plugin should control the shutdown process.
bool use_alternate_min_LogL
Variable to store state of affairs regarding use of alternate min_LogL.
void clear_alt_min_LogL_state() const
Delete the persistence file if it exists (e.g. when starting a new run)
bool check_alt_min_LogL_state() const
Check persistence file to see if we should be using the alternative min_LogL value.
EXPORT_SYMBOLS pluginInfo plugin_info
Access Functor for plugin info.
double purpose_offset
Variable to store some offset to be removed when printing out the return value of the function...
Here is the call graph for this function:

◆ ~Function_Base()

template<typename ret , typename... args>
virtual Gambit::Scanner::Function_Base< ret(args...)>::~Function_Base ( )
inlinevirtual

Definition at line 123 of file factory_defs.hpp.

123 {}

Member Function Documentation

◆ check_for_switch_to_alternate_min_LogL()

template<typename ret , typename... args>
bool Gambit::Scanner::Function_Base< ret(args...)>::check_for_switch_to_alternate_min_LogL ( )
inline

Checks if some process has triggered the 'switch_to_alternate_min_LogL' function.

Definition at line 186 of file factory_defs.hpp.

References find_all_gambit_bits::args, Gambit::Scanner::Plugins::pluginInfo::check_alt_min_LogL_state(), and Gambit::Scanner::Plugins::plugin_info.

187  {
188  if(not use_alternate_min_LogL)
189  {
190  #ifdef WITH_MPI
191  GMPI::Comm& myComm(Gambit::Scanner::Plugins::plugin_info.scanComm());
192  static const int TAG = Gambit::Scanner::Plugins::plugin_info.MIN_LOGL_MSG;
193  if(myComm.Iprobe(MPI_ANY_SOURCE, TAG))
194  {
195  int nullmsg;
196  MPI_Status msg_status;
197  myComm.Recv(&nullmsg, 1, MPI_ANY_SOURCE, TAG, &msg_status); // Recv the message to delete it.
198  use_alternate_min_LogL = true;
199  }
200  #endif
201  }
202  // If we didn't decide to switch yet, check for the existence of
203  // the persistence file. This is not necessary for proper functioning
204  // of this system, but it allows users to manually create the persistence file
205  // as a 'hack' to force the likelihood to switch to the alternate min LogL
206  // value.
207  if(not use_alternate_min_LogL)
208  {
210  }
211  return use_alternate_min_LogL;
212  }
bool use_alternate_min_LogL
Variable to store state of affairs regarding use of alternate min_LogL.
bool check_alt_min_LogL_state() const
Check persistence file to see if we should be using the alternative min_LogL value.
EXPORT_SYMBOLS pluginInfo plugin_info
Access Functor for plugin info.
Here is the call graph for this function:

◆ deleter()

template<typename ret , typename... args>
virtual void Gambit::Scanner::Function_Base< ret(args...)>::deleter ( Function_Base< ret(args...)> *  in) const
inlineprivatevirtual

Definition at line 93 of file factory_defs.hpp.

94  {
95  delete in;
96  }

◆ disable_external_shutdown()

template<typename ret , typename... args>
void Gambit::Scanner::Function_Base< ret(args...)>::disable_external_shutdown ( )
inline

Tells log-likelihood function (defined by driver code) not to use its own shutdown system (e.g the GAMBIT soft shutdown procedure) and instead to trust that the scanner plugin will safely terminate executions upon checking that shutdown is in progress (via the shutdown_in_progress flag set in plugin_info)

Definition at line 165 of file factory_defs.hpp.

165 { _scanner_can_quit = true; }
bool _scanner_can_quit
Variable to specify whether the scanner plugin should control the shutdown process.

◆ getNextPtID()

template<typename ret , typename... args>
unsigned long long int Gambit::Scanner::Function_Base< ret(args...)>::getNextPtID ( ) const
inline

Definition at line 153 of file factory_defs.hpp.

153 {return getPtID()+1;} // Needed if PtID required by plugin *before* operator() is called. See e.g. GreAT plugin.
unsigned long long int getPtID() const

◆ getParameters()

template<typename ret , typename... args>
std::vector<std::string> Gambit::Scanner::Function_Base< ret(args...)>::getParameters ( )
inline

Definition at line 144 of file factory_defs.hpp.

References Gambit::Priors::BasePrior::getParameters().

144 {return prior->getParameters();}
std::vector< std::string > getParameters() const
Definition: base_prior.hpp:83
Here is the call graph for this function:

◆ getPrinter() [1/2]

template<typename ret , typename... args>
printer& Gambit::Scanner::Function_Base< ret(args...)>::getPrinter ( )
inline

Definition at line 141 of file factory_defs.hpp.

◆ getPrinter() [2/2]

template<typename ret , typename... args>
printer& Gambit::Scanner::Function_Base< ret(args...)>::getPrinter ( ) const
inline

Definition at line 142 of file factory_defs.hpp.

142 {return *main_printer;} // Need a const version as well.

◆ getPrior()

template<typename ret , typename... args>
Priors::BasePrior& Gambit::Scanner::Function_Base< ret(args...)>::getPrior ( )
inline

Definition at line 143 of file factory_defs.hpp.

143 {return *prior;}

◆ getPtID()

template<typename ret , typename... args>
unsigned long long int Gambit::Scanner::Function_Base< ret(args...)>::getPtID ( ) const
inline

Definition at line 151 of file factory_defs.hpp.

References Gambit::Printers::get_point_id().

EXPORT_SYMBOLS unsigned long long int & get_point_id()
Returns unigue pointid;.
Here is the call graph for this function:

◆ getPurpose()

template<typename ret , typename... args>
std::string Gambit::Scanner::Function_Base< ret(args...)>::getPurpose ( ) const
inline

Definition at line 146 of file factory_defs.hpp.

◆ getPurposeOffset()

template<typename ret , typename... args>
double Gambit::Scanner::Function_Base< ret(args...)>::getPurposeOffset ( ) const
inline

Definition at line 149 of file factory_defs.hpp.

149 { return purpose_offset; }
double purpose_offset
Variable to store some offset to be removed when printing out the return value of the function...

◆ getRank()

template<typename ret , typename... args>
int Gambit::Scanner::Function_Base< ret(args...)>::getRank ( ) const
inline

Definition at line 147 of file factory_defs.hpp.

147 {return getPrinter().getRank();} // Printer controls the 'virtual' rank. Lets us re-print data from a point originally generated by another rank.
int getRank()
Retrieve/Set MPI rank (setting is useful for e.g. the postprocessor to re-print points from other ran...

◆ getShownParameters()

template<typename ret , typename... args>
std::vector<std::string> Gambit::Scanner::Function_Base< ret(args...)>::getShownParameters ( )
inline

Definition at line 145 of file factory_defs.hpp.

References Gambit::Priors::BasePrior::getShownParameters().

145 {return prior->getShownParameters();}
virtual std::vector< std::string > getShownParameters() const
Definition: base_prior.hpp:75
Here is the call graph for this function:

◆ main()

template<typename ret , typename... args>
virtual ret Gambit::Scanner::Function_Base< ret(args...)>::main ( const args &  ...)
pure virtual

◆ operator()()

template<typename ret , typename... args>
ret Gambit::Scanner::Function_Base< ret(args...)>::operator() ( const args &...  params)
inline

Definition at line 125 of file factory_defs.hpp.

References Gambit::Printers::auto_increment(), Gambit::Printers::get_point_id(), main(), Gambit::Scanner::Plugins::plugin_info, and Gambit::Scanner::Plugins::pluginInfo::set_calculating().

126  {
128  if(Gambit::Printers::auto_increment()) // This is slightly hacky, but I need to be able to disable the auto-incrementing in the post-processor scanner. Need to manually set the point ID.
129  {
131  }
132  ret ret_val = main(params...);
134 
135  return ret_val;
136  }
EXPORT_SYMBOLS bool & auto_increment()
Global flag to indicate if auto-incrementing of the PointID by the likelihood container is allowed...
EXPORT_SYMBOLS unsigned long long int & get_point_id()
Returns unigue pointid;.
virtual ret main(const args &...)=0
EXPORT_SYMBOLS pluginInfo plugin_info
Access Functor for plugin info.
Here is the call graph for this function:

◆ scanner_can_quit()

template<typename ret , typename... args>
bool Gambit::Scanner::Function_Base< ret(args...)>::scanner_can_quit ( )
inline

Check whether likelihood container is supposed to control early shutdown of scan.

Definition at line 168 of file factory_defs.hpp.

168 { return _scanner_can_quit; }
bool _scanner_can_quit
Variable to specify whether the scanner plugin should control the shutdown process.

◆ setPrinter()

template<typename ret , typename... args>
void Gambit::Scanner::Function_Base< ret(args...)>::setPrinter ( printer p)
inline

Definition at line 139 of file factory_defs.hpp.

◆ setPrior()

template<typename ret , typename... args>
void Gambit::Scanner::Function_Base< ret(args...)>::setPrior ( Priors::BasePrior p)
inline

Definition at line 140 of file factory_defs.hpp.

140 {prior = p;}

◆ setPtID()

template<typename ret , typename... args>
void Gambit::Scanner::Function_Base< ret(args...)>::setPtID ( unsigned long long int  pID)
inline

Definition at line 152 of file factory_defs.hpp.

References Gambit::Printers::get_point_id().

152 {Gambit::Printers::get_point_id() = pID;} // Needed by postprocessor; should not use otherwise.
EXPORT_SYMBOLS unsigned long long int & get_point_id()
Returns unigue pointid;.
Here is the call graph for this function:

◆ setPurpose()

template<typename ret , typename... args>
void Gambit::Scanner::Function_Base< ret(args...)>::setPurpose ( const std::string  p)
inline

Definition at line 138 of file factory_defs.hpp.

◆ setPurposeOffset()

template<typename ret , typename... args>
void Gambit::Scanner::Function_Base< ret(args...)>::setPurposeOffset ( double  os)
inline

Definition at line 150 of file factory_defs.hpp.

150 { purpose_offset = os; }
double purpose_offset
Variable to store some offset to be removed when printing out the return value of the function...

◆ setRank()

template<typename ret , typename... args>
void Gambit::Scanner::Function_Base< ret(args...)>::setRank ( int  r)
inline

Definition at line 148 of file factory_defs.hpp.

148 {getPrinter().setRank(r);} // Needed by postprocessor to adjust 'virtual' rank; generally should not use otherwise.
START_MODEL dNur_CMB r

◆ switch_to_alternate_min_LogL()

template<typename ret , typename... args>
void Gambit::Scanner::Function_Base< ret(args...)>::switch_to_alternate_min_LogL ( )
inline

Tell log-likelihood function (defined by driver code) to switch to an alternate value for the minimum log-likelihood.

Called by e.g. MultiNest scanner plugin.

Definition at line 172 of file factory_defs.hpp.

References Gambit::Scanner::Plugins::plugin_info, and Gambit::Scanner::Plugins::pluginInfo::save_alt_min_LogL_state().

173  {
174  use_alternate_min_LogL = true;
175  #ifdef WITH_MPI
176  GMPI::Comm& myComm(Gambit::Scanner::Plugins::plugin_info.scanComm());
177  static const int TAG = Gambit::Scanner::Plugins::plugin_info.MIN_LOGL_MSG;
178  MPI_Request req_null = MPI_REQUEST_NULL;
179  int nullmsg = 0; // Don't need message content, the message itself is the signal.
180  myComm.IsendToAll(&nullmsg, 1, TAG, &req_null);
181  #endif
182  Gambit::Scanner::Plugins::plugin_info.save_alt_min_LogL_state(); // Write a file to disk so that upon startup we can check if the alternate min LogL is supposed to be used.
183  }
void save_alt_min_LogL_state() const
Save persistence file to record that the alternative min_LogL value is in use for this scan...
bool use_alternate_min_LogL
Variable to store state of affairs regarding use of alternate min_LogL.
EXPORT_SYMBOLS pluginInfo plugin_info
Access Functor for plugin info.
Here is the call graph for this function:

◆ tell_scanner_early_shutdown_in_progress()

template<typename ret , typename... args>
void Gambit::Scanner::Function_Base< ret(args...)>::tell_scanner_early_shutdown_in_progress ( )
inline

Tell ScannerBit that we are aborting the scan and it should tell the scanner plugin to stop, and return control to the calling code.

Definition at line 156 of file factory_defs.hpp.

References Gambit::Scanner::Plugins::plugin_info, and Gambit::Scanner::Plugins::pluginInfo::set_early_shutdown_in_progress().

157  {
159  }
EXPORT_SYMBOLS pluginInfo plugin_info
Access Functor for plugin info.
Here is the call graph for this function:

◆ type()

template<typename ret , typename... args>
virtual const std::type_info& Gambit::Scanner::Function_Base< ret(args...)>::type ( ) const
inlineprivatevirtual

Definition at line 98 of file factory_defs.hpp.

References find_all_gambit_bits::args.

98 {return typeid(ret (args...));}

Friends And Related Function Documentation

◆ Function_Deleter< ret(args...)>

template<typename ret , typename... args>
friend class Function_Deleter< ret(args...)>
friend

Definition at line 76 of file factory_defs.hpp.

◆ scan_ptr< ret(args...)>

template<typename ret , typename... args>
friend class scan_ptr< ret(args...)>
friend

Definition at line 77 of file factory_defs.hpp.

Member Data Documentation

◆ _scanner_can_quit

template<typename ret , typename... args>
bool Gambit::Scanner::Function_Base< ret(args...)>::_scanner_can_quit
private

Variable to specify whether the scanner plugin should control the shutdown process.

Definition at line 91 of file factory_defs.hpp.

◆ main_printer

template<typename ret , typename... args>
printer* Gambit::Scanner::Function_Base< ret(args...)>::main_printer
private

Definition at line 79 of file factory_defs.hpp.

◆ myRealRank

template<typename ret , typename... args>
int Gambit::Scanner::Function_Base< ret(args...)>::myRealRank
private

Definition at line 82 of file factory_defs.hpp.

◆ prior

template<typename ret , typename... args>
Priors::BasePrior* Gambit::Scanner::Function_Base< ret(args...)>::prior
private

Definition at line 80 of file factory_defs.hpp.

◆ purpose

template<typename ret , typename... args>
std::string Gambit::Scanner::Function_Base< ret(args...)>::purpose
private

Definition at line 81 of file factory_defs.hpp.

◆ purpose_offset

template<typename ret , typename... args>
double Gambit::Scanner::Function_Base< ret(args...)>::purpose_offset
private

Variable to store some offset to be removed when printing out the return value of the function.

Definition at line 85 of file factory_defs.hpp.

◆ use_alternate_min_LogL

template<typename ret , typename... args>
bool Gambit::Scanner::Function_Base< ret(args...)>::use_alternate_min_LogL
private

Variable to store state of affairs regarding use of alternate min_LogL.

Definition at line 88 of file factory_defs.hpp.


The documentation for this class was generated from the following file: