Public Member Functions | Private Attributes | List of all members
ana::StanFitter::samplecounter_callback Class Reference
Inheritance diagram for ana::StanFitter::samplecounter_callback:
stan::callbacks::interrupt

Public Member Functions

 samplecounter_callback (std::size_t warmupSampleCount, std::size_t regularSampleCount)
 
void operator() ()
 

Private Attributes

std::unique_ptr< ana::ProgressfProgressWarmup
 
std::unique_ptr< ana::ProgressfProgressNormal
 
std::size_t fWarmupCounts
 
std::size_t fRegularCounts
 
std::size_t fCurrCount
 

Detailed Description

Definition at line 246 of file StanFitter.h.

Constructor & Destructor Documentation

ana::StanFitter::samplecounter_callback::samplecounter_callback ( std::size_t  warmupSampleCount,
std::size_t  regularSampleCount 
)
inline

Definition at line 249 of file StanFitter.h.

250  : fWarmupCounts(warmupSampleCount),
251  fRegularCounts(regularSampleCount),
252  fCurrCount(0)
253  {
254  }

Member Function Documentation

void ana::StanFitter::samplecounter_callback::operator() ( )
inlinevirtual

Callback function.

This function is called by the algorithms allowing the interfaces to break when necessary.

Reimplemented from stan::callbacks::interrupt.

Definition at line 256 of file StanFitter.h.

References art::to_string().

257  {
258  if (fWarmupCounts + fRegularCounts == 0)
259  return;
260 
262  fProgressWarmup = std::make_unique<ana::Progress>(
263  "Warming up MCMC sampler (" + std::to_string(fWarmupCounts) + " samples)");
264  if (fCurrCount >= fWarmupCounts)
265  {
266  if (fProgressWarmup)
267  fProgressWarmup->Done();
268 
269  if (!fProgressNormal)
270  fProgressNormal = std::make_unique<ana::Progress>(
271  "Sampling using MCMC (" + std::to_string(fRegularCounts) + " samples)");
272 
274  fProgressNormal->Done();
275  else
276  fProgressNormal->SetProgress(double(++fCurrCount - fWarmupCounts) / fRegularCounts);
277  }
278  else if (fWarmupCounts > 0)
279  fProgressWarmup->SetProgress(double(++fCurrCount) / fWarmupCounts);
280  }
std::unique_ptr< ana::Progress > fProgressWarmup
Definition: StanFitter.h:284
std::string to_string(ModuleType mt)
Definition: ModuleType.h:32
std::unique_ptr< ana::Progress > fProgressNormal
Definition: StanFitter.h:285

Member Data Documentation

std::size_t ana::StanFitter::samplecounter_callback::fCurrCount
private

Definition at line 288 of file StanFitter.h.

std::unique_ptr<ana::Progress> ana::StanFitter::samplecounter_callback::fProgressNormal
private

Definition at line 285 of file StanFitter.h.

std::unique_ptr<ana::Progress> ana::StanFitter::samplecounter_callback::fProgressWarmup
private

Definition at line 284 of file StanFitter.h.

std::size_t ana::StanFitter::samplecounter_callback::fRegularCounts
private

Definition at line 287 of file StanFitter.h.

std::size_t ana::StanFitter::samplecounter_callback::fWarmupCounts
private

Definition at line 286 of file StanFitter.h.


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