![]() |
MaCh3 2.2.1
Reference Guide
|
Class PSO, consist of a vector of object Class Particle and global best Takes in the size (number of particle) and number of iteration functions includes: finding global best, updating velocity, actual minimisation function. More...
#include <Fitters/PSO.h>
Public Member Functions | |
PSO (manager *const fitMan) | |
constructor | |
virtual | ~PSO () |
Destructor. | |
particle * | get_best_particle () |
void | set_best_particle (particle *n) |
std::vector< std::vector< double > > | bisection (const std::vector< double > &position, const double minimum, const double range, const double precision) |
std::vector< std::vector< double > > | calc_uncertainty (const std::vector< double > &position, const double minimum) |
void | init () |
void | uncertainty_check (const std::vector< double > &previous_pos) |
void | run () |
void | WriteOutput () |
void | RunMCMC () override |
Actual implementation of PSO Fit algorithm. | |
double | CalcChi2 (const double *x) |
Chi2 calculation over all included samples and syst objects. | |
double | rastriginFunc (const double *x) |
Evaluates the Rastrigin function for a given parameter values. | |
double | swarmIterate () |
std::vector< double > | vector_multiply (std::vector< double > velocity, const double mul) |
std::vector< double > | vector_add (const std::vector< double > &v1, const std::vector< double > &v2) |
std::vector< double > | vector_subtract (const std::vector< double > &v1, const std::vector< double > &v2) |
std::vector< double > | three_vector_addition (std::vector< double > vec1, const std::vector< double > &vec2, const std::vector< double > &vec3) |
std::vector< double > | four_vector_addition (std::vector< double > vec1, const std::vector< double > &vec2, const std::vector< double > &vec3, const std::vector< double > &vec4) |
double | CalcChi (std::vector< double > x) |
std::string | GetName () const |
Get name of class. | |
![]() | |
LikelihoodFit (manager *const fitMan) | |
Constructor. | |
virtual | ~LikelihoodFit () |
Destructor. | |
virtual double | CalcChi2 (const double *x) |
Chi2 calculation over all included samples and syst objects. | |
int | GetNPars () |
Get total number of params, this sums over all covariance objects. | |
virtual void | RunMCMC ()=0 |
Implementation of fitting algorithm. | |
virtual std::string | GetName () const |
Get name of class. | |
![]() | |
FitterBase (manager *const fitMan) | |
Constructor. | |
virtual | ~FitterBase () |
Destructor for the FitterBase class. | |
void | AddSampleHandler (SampleHandlerBase *sample) |
This function adds a sample PDF object to the analysis framework. The sample PDF object will be utilized in fitting procedures or likelihood scans. | |
void | AddSystObj (ParameterHandlerBase *cov) |
This function adds a Covariance object to the analysis framework. The Covariance object will be utilized in fitting procedures or likelihood scans. | |
virtual void | RunMCMC ()=0 |
The specific fitting algorithm implemented in this function depends on the derived class. It could be Markov Chain Monte Carlo (MCMC), MinuitFit, or another algorithm. | |
void | DragRace (const int NLaps=100) |
Calculates the required time for each sample or covariance object in a drag race simulation. Inspired by Dan's feature. | |
void | RunLLHScan () |
Perform a 1D likelihood scan. | |
void | GetStepScaleBasedOnLLHScan () |
LLH scan is good first estimate of step scale. | |
void | Run2DLLHScan () |
Perform a 2D likelihood scan. | |
void | RunSigmaVar () |
Perform a 2D and 1D sigma var for all samples. | |
virtual void | StartFromPreviousFit (const std::string &FitName) |
Allow to start from previous fit/chain. | |
virtual std::string | GetName () const |
Get name of class. | |
Private Attributes | |
particle * | best_particle |
double | fBestValue |
std::vector< double > | prior |
std::vector< bool > | fixed |
std::vector< double > | ranges_max |
std::vector< double > | ranges_min |
std::vector< particle * > | system |
double | fInertia |
double | fOne |
double | fTwo |
double | fConvergence |
int | fIterations |
double | fConstriction |
std::vector< std::vector< double > > | uncertainties |
int | fParticles |
std::vector< double * > | paramlist |
double | vel [kMaxParticles] |
double * | par |
int | fDim |
Static Private Attributes | |
static constexpr const int | kMaxParticles = 10000 |
Additional Inherited Members | |
![]() | |
void | PrepareFit () |
prepare output and perform sanity checks | |
![]() | |
void | ProcessMCMC () |
Process MCMC output. | |
void | PrepareOutput () |
Prepare the output file. | |
void | SaveOutput () |
Save output and close files. | |
void | SanitiseInputs () |
Remove obsolete memory and make other checks before fit starts. | |
void | SaveSettings () |
Save the settings that the MCMC was run with. | |
bool | GetScaneRange (std::map< std::string, std::vector< double > > &scanRanges) |
YSP: Set up a mapping to store parameters with user-specified ranges, suggested by D. Barrow. | |
bool | CheckSkipParameter (const std::vector< std::string > &SkipVector, const std::string &ParamName) const |
KS: Check whether we want to skip parameter using skip vector. | |
![]() | |
int | NPars |
Number of all parameters from all covariances. | |
int | NParsPCA |
Number of all parameters from all covariances in PCA base. | |
bool | fMirroring |
Flag telling if mirroring is used or not. | |
![]() | |
manager * | fitMan |
The manager. | |
unsigned int | step |
current state | |
double | logLCurr |
current likelihood | |
double | logLProp |
proposed likelihood | |
double | accProb |
current acceptance prob | |
int | accCount |
counts accepted steps | |
int | stepStart |
step start if restarting | |
std::vector< double > | sample_llh |
store the llh breakdowns | |
std::vector< double > | syst_llh |
systematic llh breakdowns | |
std::vector< SampleHandlerBase * > | samples |
Sample holder. | |
unsigned int | TotalNSamples |
Total number of samples used. | |
std::vector< ParameterHandlerBase * > | systematics |
Systematic holder. | |
std::unique_ptr< TStopwatch > | clock |
tells global time how long fit took | |
std::unique_ptr< TStopwatch > | stepClock |
tells how long single step/fit iteration took | |
double | stepTime |
Time of single step. | |
std::unique_ptr< TRandom3 > | random |
Random number. | |
TFile * | outputFile |
Output. | |
TDirectory * | CovFolder |
Output cov folder. | |
TDirectory * | SampleFolder |
Output sample folder. | |
TTree * | outTree |
Output tree with posteriors. | |
int | auto_save |
auto save every N steps | |
bool | fTestLikelihood |
Necessary for some fitting algorithms like PSO. | |
bool | FileSaved |
Checks if file saved not repeat some operations. | |
bool | SettingsSaved |
Checks if setting saved not repeat some operations. | |
bool | OutputPrepared |
Checks if output prepared not repeat some operations. | |
Class PSO, consist of a vector of object Class Particle and global best Takes in the size (number of particle) and number of iteration functions includes: finding global best, updating velocity, actual minimisation function.
PSO::PSO | ( | manager *const | fitMan | ) |
constructor
Definition at line 6 of file PSO.cpp.
std::vector< std::vector< double > > PSO::bisection | ( | const std::vector< double > & | position, |
const double | minimum, | ||
const double | range, | ||
const double | precision | ||
) |
Definition at line 151 of file PSO.cpp.
std::vector< std::vector< double > > PSO::calc_uncertainty | ( | const std::vector< double > & | position, |
const double | minimum | ||
) |
Definition at line 236 of file PSO.cpp.
|
inline |
Definition at line 139 of file PSO.h.
|
virtual |
Chi2 calculation over all included samples and syst objects.
Reimplemented from LikelihoodFit.
Definition at line 530 of file PSO.cpp.
|
inline |
|
inline |
|
inlinevirtual |
Get name of class.
Reimplemented from LikelihoodFit.
Definition at line 144 of file PSO.h.
void PSO::init | ( | ) |
Definition at line 50 of file PSO.cpp.
double PSO::rastriginFunc | ( | const double * | x | ) |
Evaluates the Rastrigin function for a given parameter values.
Definition at line 540 of file PSO.cpp.
void PSO::run | ( | ) |
Definition at line 398 of file PSO.cpp.
|
overridevirtual |
Actual implementation of PSO Fit algorithm.
Implements LikelihoodFit.
Definition at line 25 of file PSO.cpp.
|
inline |
double PSO::swarmIterate | ( | ) |
Definition at line 338 of file PSO.cpp.
|
inline |
void PSO::uncertainty_check | ( | const std::vector< double > & | previous_pos | ) |
Definition at line 300 of file PSO.cpp.
|
inline |
|
inline |
Definition at line 105 of file PSO.h.
|
inline |
void PSO::WriteOutput | ( | ) |
Definition at line 443 of file PSO.cpp.
|
staticconstexprprivate |
|
private |