BCModelManager.h
1 #ifndef __BCMODELMANAGER__H
2 #define __BCMODELMANAGER__H
3 
17 /*
18  * Copyright (C) 2007-2018, the BAT core developer team
19  * All rights reserved.
20  *
21  * For the licensing terms see doc/COPYING.
22  * For documentation see http://mpp.mpg.de/bat
23  */
24 
25 // ---------------------------------------------------------
26 
27 #include "BCDataSet.h"
28 #include "BCModel.h"
29 
30 #include <string>
31 
32 // ---------------------------------------------------------
33 
35 {
36 public:
37 
44 
47  BCModelManager(const BCModelManager& other);
48 
51  virtual ~BCModelManager();
52 
61 
63  friend void swap(BCModelManager& A, BCModelManager& B);
64 
72  unsigned int GetNModels()
73  { return fModels.size(); }
74 
79  BCModel* GetModel(unsigned index)
80  { return (index < fModels.size()) ? fModels[index] : 0; }
81 
86  { return fDataSet; };
87 
98  void SetDataSet(BCDataSet* dataset);
99 
102  void SetPrecision(BCEngineMCMC::Precision precision);
103 
107  void SetNIterationsMax(int niterations);
108 
113  void SetNIterationsMin(int niterations);
114 
117  void SetNIterationsPrecisionCheck(int niterations);
118 
122 
126 
130 
134  void SetRelativePrecision(double relprecision);
135 
138  void SetAbsolutePrecision(double absprecision);
139 
143  void SetNbins(unsigned int n);
144 
147  void SetNChains(unsigned int n);
148 
158  void AddModel(BCModel* model, double prior_probability = 0.);
159 
163  void Integrate();
164 
170  double BayesFactor(const unsigned int imodel1, const unsigned int imodel2) const;
171 
174  void FindMode();
175 
179  void MarginalizeAll();
180 
185  void WriteMarkovChain(bool flag);
186 
191  void WriteMarkovChainRun(bool flag);
192 
197  void WriteMarkovChainPreRun(bool flag);
198 
205  void WriteMarkovChain(const std::string& prefix, const std::string& option, bool flag_run = true, bool flag_prerun = true);
206 
209  void PrintModelComparisonSummary() const;
210 
213  void PrintSummary() const;
214 
217 private:
218 
221  std::vector<BCModel*> fModels;
222 
225  std::vector<double> fAPrioriProbability;
226 
229  std::vector<double> fAPosterioriProbability;
230 
233  BCDataSet* fDataSet;
234 
235 };
236 
237 // ---------------------------------------------------------
238 
239 #endif
void WriteMarkovChainRun(bool flag)
Turn on/off writing of Markov chain to root file during run for all models.
void FindMode()
Does the mode finding.
void SetAbsolutePrecision(double absprecision)
Set absolute precision of the numerical integation.
void SetRelativePrecision(double relprecision)
void SetOptimizationMethod(BCIntegrate::BCOptimizationMethod method)
BCDataSet * GetDataSet()
Returns the common data set.
void AddModel(BCModel *model, double prior_probability=0.)
Adds a model to the container.
A class representing a set of BCModels.
void SetIntegrationMethod(BCIntegrate::BCIntegrationMethod method)
The base class for all user-defined models.
Definition: BCModel.h:39
BCModel * GetModel(unsigned index)
Returns the BCModel at a certain index of this BCModelManager.
void SetNChains(unsigned int n)
Sets the number of Markov chains.
A class representing a set of data points.
Definition: BCDataSet.h:39
void PrintSummary() const
Prints a summary to the logs.
BCOptimizationMethod
An enumerator for the mode finding algorithm.
Definition: BCIntegrate.h:153
BCModelManager()
The default constructor.
void SetMarginalizationMethod(BCIntegrate::BCMarginalizationMethod method)
void SetPrecision(BCEngineMCMC::Precision precision)
Set the precision for the MCMC run.
void Integrate()
Calculates the normalization of the likelihood for each model in the container.
void SetNIterationsPrecisionCheck(int niterations)
BCIntegrationMethod
An enumerator for integration algorithms.
Definition: BCIntegrate.h:164
void SetNbins(unsigned int n)
BCModelManager & operator=(BCModelManager modelmanager)
The defaut assignment operator.
friend void swap(BCModelManager &A, BCModelManager &B)
swap
unsigned int GetNModels()
void SetNIterationsMax(int niterations)
Sets the maximum number of iterations for the Monte Carlo integration for all BCModels in this BCMode...
void PrintModelComparisonSummary() const
Prints a summary of the model comparison to the log.
void WriteMarkovChainPreRun(bool flag)
Turn on/off writing of Markov chain to root file during prerun for all models.
void MarginalizeAll()
Marginalize all probabilities wrt.
void SetDataSet(BCDataSet *dataset)
Sets the data set common to all BCModels in this BCModelManager.
void WriteMarkovChain(bool flag)
Turn on/off writing of Markov chains to root files for all models.
virtual ~BCModelManager()
The default destructor.
void SetNIterationsMin(int niterations)
Sets the minimum number of iterations for the Monte Carlo integration for all BCModels in this BCMode...
Precision
An enumerator for the status of a test.
Definition: BCEngineMCMC.h:65
double BayesFactor(const unsigned int imodel1, const unsigned int imodel2) const
Calculate Bayes factor for two models.
BCMarginalizationMethod
An enumerator for marginalization algorithms.
Definition: BCIntegrate.h:176