16namespace CurveFitting {
17namespace CostFunctions {
19class CostFuncLeastSquares;
25namespace CurveFitting {
26namespace FuncMinimisers {
37 std::string
name()
const override {
return "FABADA"; }
41 bool iterate(
size_t iter)
override;
43 double costFunctionVal()
override;
45 void finalize()
override;
51 void boundApplication(
const size_t ¶meterIndex,
double &newValue,
double &step);
55 double gaussianStep(
const double &jump);
58 void tieApplication(
const size_t ¶meterIndex,
EigenVector &newParameters,
double &newValue);
61 void algorithmDisplacement(
const size_t ¶meterIndex,
const double &chi2New,
const EigenVector &newParameters);
63 void jumpUpdate(
const size_t ¶meterIndex);
66 void convergenceCheck();
68 void simAnnealingRefrigeration();
70 bool iterationContinuation();
74 void outputConvergedChains(
size_t convLength,
int nSteps);
76 void outputCostFunctionTable(
size_t convLength,
double mostProbableChi2);
78 double outputPDF(std::size_t
const &convLength, std::vector<std::vector<double>> &reducedChain);
79 void outputPDF(std::vector<double> &xValues, std::vector<double> &yValues,
80 std::vector<std::vector<double>> &reducedChain, std::size_t
const &convLength,
int const &pdfLength);
82 double getMostProbableChiSquared(std::size_t
const &convLength, std::vector<std::vector<double>> &reducedChain,
83 int const &pdfLength, std::vector<double> &xValues, std::vector<double> &yValues,
84 std::vector<double> &PDFYAxis,
double const &start,
double const &bin);
86 void setParameterXAndYValuesForPDF(std::vector<double> &xValues, std::vector<double> &yValues,
87 std::vector<std::vector<double>> &reducedChain, std::size_t
const &convLength,
88 int const &pdfLength);
90 void outputParameterTable(
const std::vector<double> &bestParameters,
const std::vector<double> &errorsLeft,
91 const std::vector<double> &errorsRight);
93 void calculateConvChainAndBestParameters(
size_t convLength,
int nSteps,
94 std::vector<std::vector<double>> &reducedChain,
95 std::vector<double> &bestParameters, std::vector<double> &errorLeft,
96 std::vector<double> &errorRight);
98 void initChainsAndParameters();
100 void initSimulatedAnnealing();
An interface for function minimizers.
void setDirty()
Set all dirty flags.
Cost function for least squares.
A wrapper around Eigen::Vector.
FABADA : Implements the FABADA Algorithm, based on a Adaptive Metropolis Algorithm extended with Gibb...
bool m_overexploration
Overexploration applied.
size_t m_nParams
Number of parameters of the FittingFunction (not necessarily the CostFunction)
size_t m_counter
The number of iterations done (restarted at each phase).
std::shared_ptr< CostFunctions::CostFuncLeastSquares > m_leastSquares
Pointer to the cost function. Must be the least squares.
std::vector< int > m_changes
The number of changes done on each parameter.
double m_tempStep
Temperature step between different Simulated Annealing phases.
std::vector< double > m_jump
The jump for each parameter.
size_t m_maxIter
Maximum number of iterations.
double m_temperature
Simulated Annealing temperature.
double m_chi2
The chi square result of previous iteration;.
size_t m_counterGlobal
The global number of iterations done.
std::string name() const override
Name of the minimizer.
std::vector< double > m_criteria
Convergence criteria for each parameter.
std::vector< size_t > m_numInactiveRegenerations
Number of consecutive regenerations without changes.
size_t m_simAnnealingItStep
Number of iterations between Simulated Annealing refrigeration points.
std::vector< std::vector< double > > m_chain
Markov chain.
size_t m_convPoint
The point when convergence has been reached.
std::vector< bool > m_parChanged
Bool that idicates if a varible has changed at some self iteration.
std::vector< bool > m_parConverged
Convergence of each parameter.
std::vector< int > m_changesOld
To track convergence through immobility.
size_t m_leftRefrPoints
The number of refrigeration points left.
size_t m_chainIterations
The number of chain iterations.
API::IFunction_sptr m_fitFunction
Pointer to the Fitting Function (IFunction) inside the cost function.
bool m_converged
Boolean that indicates global convergence.
EigenVector m_parameters
Parameters' values.
Used to access the setDirty() protected member.
void setDirtyInherited()
To inform the main class of changes through the IFunction.
std::shared_ptr< IFunction > IFunction_sptr
shared pointer to the function base class
std::shared_ptr< ICostFunction > ICostFunction_sptr
define a shared pointer to a cost function
Helper class which provides the Collimation Length for SANS instruments.