33 : m_dataWS(), m_wsIndex(-1), m_paramTable(), m_fitMode(MONTECARLO), m_stdMode(
CONSTANT), m_numWalkSteps(-1),
34 m_randomSeed(-1), m_profileParameters(), m_positionFunc(), m_dampingFactor(0.), m_bestChiSq(0.),
35 m_bestChiSqStep(-1), m_bestChiSqGroup(-1) {}
44 "Data workspace containing workspace positions in TOF agains dSpacing.");
47 declareProperty(
"WorkspaceIndex", 0,
"Workspace Index of the peak positions in PeakPositionWorkspace.");
52 "Output data workspace containing refined workspace positions in TOF "
58 "INput tableWorkspace containg instrument's parameters.");
63 "Output tableworkspace containing instrument's fitted parameters. ");
66 vector<string> algoptions{
"OneStepFit",
"MonteCarlo"};
67 auto validator = std::make_shared<Kernel::StringListValidator>(algoptions);
68 declareProperty(
"RefinementAlgorithm",
"MonteCarlo", validator,
"Algorithm to refine the instrument parameters.");
71 declareProperty(
"RandomWalkSteps", 10000,
"Number of Monte Carlo random walk steps. ");
74 declareProperty(
"MonteCarloRandomSeed", 0,
"Random seed for Monte Carlo simulation. ");
77 vector<string> stdoptions{
"ConstantValue",
"UseInputValue"};
78 auto listvalidator = std::make_shared<Kernel::StringListValidator>(stdoptions);
80 "Algorithm to calculate the standard error of peak positions.");
84 "Damping factor for (1) minimizer 'Damped "
85 "Gauss-Newton'. (2) Monte Carlo. ");
88 declareProperty(
"AnnealingTemperature", 1.0,
"Starting annealing temperature.");
91 declareProperty(
"MonteCarloIterations", 100,
"Number of iterations in Monte Carlo random walk.");
108 m_positionFunc = std::make_shared<ThermalNeutronDtoTOFFunction>();
124 double finalchi2 = DBL_MAX;
128 g_log.
notice(
"Fit by non Monte Carlo algorithm. ");
140 throw runtime_error(
"Unsupported fit mode.");
146 setProperty(
"OutputInstrumentParameterWorkspace", fitparamtable);
149 setProperty(
"OutputPeakPositionWorkspace", outdataws);
162 if (m_wsIndex < 0 || m_wsIndex >=
static_cast<int>(
m_dataWS->getNumberHistograms())) {
163 throw runtime_error(
"Input workspace index is out of range.");
170 string fitmode =
getProperty(
"RefinementAlgorithm");
171 if (fitmode ==
"OneStepFit")
173 else if (fitmode ==
"MonteCarlo")
177 throw runtime_error(
"Input RefinementAlgorithm is not supported.");
182 if (stdmode ==
"ConstantValue")
184 else if (stdmode ==
"UseInputValue")
188 throw runtime_error(
"Input StandardError (mode) is not supported.");
194 throw runtime_error(
"Monte Carlo walk steps cannot be less or equal to 0. ");
214 map<string, Parameter> ¶mmap) {
216 std::vector<std::string> colnames = tablews->getColumnNames();
217 map<string, size_t> colnamedict;
227 if (iname < 0 || ivalue < 0 || ifit < 0)
228 throw runtime_error(
"TableWorkspace does not have column Name, Value and/or Fit.");
231 size_t numrows = tablews->rowCount();
232 for (
size_t irow = 0; irow < numrows; ++irow) {
233 string parname = tablews->cell<
string>(irow, iname);
234 double parvalue = tablews->cell<
double>(irow, ivalue);
235 string fitq = tablews->cell<
string>(irow, ifit);
239 minvalue = tablews->cell<
double>(irow, imin);
245 maxvalue = tablews->cell<
double>(irow, imax);
251 stepsize = tablews->cell<
double>(irow, istep);
256 newpar.
name = parname;
265 if (fitq[0] ==
'F' || fitq[0] ==
'f')
270 parammap.emplace(parname, newpar);
285 bool powerfit =
false;
290 sumss <<
"Non-Monte Carlo Results: Best Chi^2 = " << chi2;
305 sumss <<
"Monte Carlo Results: Best Chi^2 = " << chisq <<
" @ Step " <<
m_bestChiSqStep <<
", Group "
323 vector<double> vecY(numpts, 0.0);
326 vector<vector<string>> mcgroups;
329 int randomseed =
getProperty(
"MonteCarloRandomSeed");
332 double temperature =
getProperty(
"AnnealingTemperature");
333 if (temperature < 1.0E-10)
334 throw runtime_error(
"Annealing temperature is too low.");
336 int maxiterations =
getProperty(
"MonteCarloIterations");
337 if (maxiterations <= 0)
338 throw runtime_error(
"Max iteration cannot be 0 or less.");
341 map<string, Parameter> parammap;
344 map<string, Parameter> bestresult;
354 g_log.
notice() <<
"[DBx510] Starting Chi^2 = " << chisq0 <<
" (homemade) " << chisq0x <<
" (Levenber-marquadt)\n";
360 double chisqx = chisq0;
361 int numrecentacceptance = 0;
362 int numrecentsteps = 0;
364 map<string, Parameter> propparammap;
367 for (
int istep = 0; istep < maxiterations; ++istep) {
368 for (
int igroup = 0; igroup < static_cast<int>(mcgroups.size()); ++igroup) {
396 if (acceptpropvalues) {
404 ++numrecentacceptance;
409 if (numrecentsteps >= 10) {
410 double acceptratio =
static_cast<double>(numrecentacceptance) /
static_cast<double>(numrecentsteps);
411 if (acceptratio < 0.2) {
414 }
else if (acceptratio >= 0.8) {
420 numrecentacceptance = 0;
437 bool restoremcresult =
false;
439 map<string, Parameter> nullmap;
441 if (fitchisq > chisqf) {
443 restoremcresult =
true;
449 restoremcresult =
true;
452 g_log.
warning() <<
"[DBx545] Restore MC Result = " << restoremcresult <<
'\n';
454 if (restoremcresult) {
461 map<string, Parameter> emptymap;
463 g_log.
notice() <<
"Best Chi^2 (L-V) = " << chisqfx <<
", (homemade) = " << chisqf0 <<
'\n';
465 <<
", Number of parameters = " <<
m_positionFunc->getParameterNames().size() <<
'\n';
479 map<string, Parameter> &curparammap,
480 map<string, Parameter> &newparammap,
double currchisq) {
481 for (
const auto ¶mname : mcgroup) {
483 double randomnumber = 2 *
static_cast<double>(rand()) /
static_cast<double>(RAND_MAX) - 1.0;
486 Parameter param = curparammap[paramname];
490 g_log.
debug() <<
"Parameter " << paramname <<
" Step Size = " << stepsize <<
" From " << param.
mcA0 <<
", "
496 newvalue = param.
curvalue + stepsize;
546 newvalue =
fabs(newvalue);
550 newparammap[paramname].curvalue = newvalue;
557 }
else if (stepsize < 0) {
568 g_log.
debug() <<
"[DBx257] " << paramname <<
"\t"
569 <<
"Proposed value = " << setw(15) << newvalue <<
" (orig = " << param.
curvalue
570 <<
", step = " << stepsize <<
"), totRwp = " << currchisq <<
'\n';
584 if (newchisq < curchisq) {
589 double dice =
static_cast<double>(rand()) /
static_cast<double>(RAND_MAX);
590 double bar = exp(-(newchisq - curchisq) / (curchisq * temperature));
601 int igroup, map<string, Parameter> &bestparammap)
606 bool recordparameter =
false;
613 recordparameter =
true;
617 if (bestparammap.empty()) {
620 }
else if (recordparameter) {
645 vector<vector<string>> &mcgroups) {
646 stringstream dboutss;
647 dboutss <<
"Monte Carlo minimizer refines: ";
651 vector<string> geomparams;
659 mcgroups.emplace_back(geomparams);
661 dboutss <<
"Geometry parameters: ";
662 for (
auto &geomparam : geomparams)
663 dboutss << geomparam <<
"\t\t";
669 parammap[
"Width"].mcA0 = 0.0;
670 parammap[
"Width"].mcA1 = 1.0;
671 parammap[
"Width"].nonnegative =
true;
673 parammap[
"Tcross"].mcA0 = 0.0;
674 parammap[
"Tcross"].mcA1 = 1.0;
675 parammap[
"Tcross"].nonnegative =
true;
677 parammap[
"Zero"].mcA0 = 5.0;
678 parammap[
"Zero"].mcA1 = 0.0;
679 parammap[
"Zero"].nonnegative =
false;
681 parammap[
"Zerot"].mcA0 = 5.0;
682 parammap[
"Zerot"].mcA1 = 0.0;
683 parammap[
"Zerot"].nonnegative =
false;
685 parammap[
"Dtt1"].mcA0 = 5.0;
686 parammap[
"Dtt1"].mcA1 = 0.0;
687 parammap[
"Dtt1"].nonnegative =
true;
689 parammap[
"Dtt1t"].mcA0 = 5.0;
690 parammap[
"Dtt1t"].mcA1 = 0.0;
691 parammap[
"Dtt1t"].nonnegative =
true;
693 parammap[
"Dtt2t"].mcA0 = 0.1;
694 parammap[
"Dtt2t"].mcA1 = 1.0;
695 parammap[
"Dtt2t"].nonnegative =
false;
698 map<string, Parameter>::iterator mapiter;
699 for (mapiter = parammap.begin(); mapiter != parammap.end(); ++mapiter) {
700 mapiter->second.movedirection = 1;
701 mapiter->second.sumstepsize = 0.0;
702 mapiter->second.numpositivemove = 0;
703 mapiter->second.numnegativemove = 0;
704 mapiter->second.numnomove = 0;
705 mapiter->second.maxabsstepsize = -0.0;
719 map<string, Parameter> parammap) {
720 map<string, Parameter>::iterator pariter;
721 pariter = parammap.find(parname);
722 if (pariter == parammap.end()) {
724 errss <<
"Parameter " << parname <<
" does not exisit Le Bail function parameters. ";
726 throw runtime_error(errss.str());
729 if (pariter->second.fit)
730 parnamesforMC.emplace_back(parname);
741 vector<double> &vecY) {
743 if (!parammap.empty())
749 if (vecY.size() != vecX.size())
750 throw runtime_error(
"vecY must be initialized with proper size!");
764 const vector<double> &dataE) {
766 if (modelY.size() != dataY.size() || dataY.size() != dataE.size())
767 throw runtime_error(
"Input model, data and error have different size.");
771 size_t numpts = modelY.size();
772 for (
size_t i = 0; i < numpts; ++i) {
773 if (dataE[i] > 1.0E-5) {
774 double temp = (modelY[i] - dataY[i]) / dataE[i];
775 chisq += temp * temp;
788 vector<string> parnames = function->getParameterNames();
789 vector<bool> vecFix(parnames.size(),
false);
791 for (
size_t i = 0; i < parnames.size(); ++i) {
792 bool fixed = !function->isActive(i);
801 const std::string minimizer =
"Levenberg-MarquardtMD";
802 bool fitOK =
doFitFunction(function, dataws, wsindex, minimizer, 0, chi2, fitstatus);
805 g_log.
warning() <<
"Fit by " << minimizer <<
" with 0 iterations failed, with reason: " << fitstatus <<
"\n";
809 for (
size_t i = 0; i < parnames.size(); ++i) {
829 int wsindex,
bool powerfit) {
831 map<string, pair<double, double>> start_paramvaluemap, paramvaluemap1, paramvaluemap2, paramvaluemap3;
836 g_log.
notice() <<
"[DBx436] Starting Chi^2 = " << startchisq <<
", Power-Fit is " << powerfit <<
'\n';
840 double final_chi2 = DBL_MAX;
844 string minimizer =
"Simplex";
846 string fitstatussimplex;
848 bool fitgood1 =
doFitFunction(function, dataws, wsindex, minimizer, numiters, chi2simplex, fitstatussimplex);
853 chi2simplex = DBL_MAX;
856 minimizer =
"Levenberg-MarquardtMD";
860 bool fitgood2 =
doFitFunction(function, dataws, wsindex, minimizer, numiters, chi2lv2, fitstatuslv2);
867 map<string, Parameter> tempparmap;
871 bool fitgood3 =
doFitFunction(function, dataws, wsindex, minimizer, numiters, chi2lv1, fitstatuslv1);
878 g_log.
notice() <<
"Fit Result: Chi2s: Simplex = " << chi2simplex <<
", "
879 <<
"Levenberg 1 = " << chi2lv2 <<
", Levenberg 2 = " << chi2lv1 <<
'\n';
881 if (fitgood1 || fitgood2 || fitgood3) {
883 if (fitgood1 && chi2simplex <= chi2lv2 && chi2simplex <= chi2lv1) {
884 final_chi2 = chi2simplex;
886 }
else if (fitgood2 && chi2lv2 <= chi2lv1) {
888 final_chi2 = chi2lv2;
889 }
else if (fitgood3) {
890 final_chi2 = chi2lv1;
893 throw runtime_error(
"This situation is impossible to happen!");
898 string minimizer =
"Levenberg-MarquardtMD";
901 bool fitgood =
doFitFunction(function, dataws, wsindex, minimizer, numiters, final_chi2, fitstatus);
906 g_log.
warning() <<
"Fit by " << minimizer <<
" failed. Reason: " << fitstatus <<
"\n";
918 int wsindex,
const string &minimizer,
int numiters,
double &chi2,
922 outss <<
"Fit function: " <<
m_positionFunc->asString() <<
"\nData To Fit: \n";
923 for (
size_t i = 0; i < dataws->x(0).size(); ++i)
924 outss << dataws->x(wsindex)[i] <<
"\t\t" << dataws->y(wsindex)[i] <<
"\t\t" << dataws->e(wsindex)[i] <<
"\n";
929 fitalg->initialize();
931 fitalg->setProperty(
"Function", function);
932 fitalg->setProperty(
"InputWorkspace", dataws);
933 fitalg->setProperty(
"WorkspaceIndex", wsindex);
934 fitalg->setProperty(
"Minimizer", minimizer);
935 fitalg->setProperty(
"CostFunction",
"Least squares");
936 fitalg->setProperty(
"MaxIterations", numiters);
937 fitalg->setProperty(
"CalcErrors",
true);
940 bool successfulfit = fitalg->execute();
941 if (!fitalg->isExecuted() || !successfulfit) {
943 g_log.
warning(
"Fitting to instrument geometry function failed. ");
945 fitstatus =
"Minimizer throws exception.";
950 chi2 = fitalg->getProperty(
"OutputChi2overDoF");
951 string tempfitstatus = fitalg->getProperty(
"OutputStatus");
952 fitstatus = tempfitstatus;
954 bool goodfit = fitstatus ==
"success";
957 dbss <<
"Fit Result (GSL): Chi^2 = " << chi2 <<
"; Fit Status = " << fitstatus <<
", Return Bool = " << goodfit
959 vector<string> funcparnames = function->getParameterNames();
960 for (
size_t i = 0; i < funcparnames.size(); ++i)
961 dbss << funcparnames[i] <<
" = " << setw(20) << function->getParameter(funcparnames[i]) <<
" +/- "
962 << function->getError(i) <<
"\n";
972 double startchi2,
double finalchi2) {
974 auto tablews = std::make_shared<TableWorkspace>();
976 tablews->addColumn(
"str",
"Name");
977 tablews->addColumn(
"double",
"Value");
978 tablews->addColumn(
"str",
"FitOrTie");
979 tablews->addColumn(
"double",
"Min");
980 tablews->addColumn(
"double",
"Max");
981 tablews->addColumn(
"double",
"StepSize");
982 tablews->addColumn(
"double",
"Error");
989 map<string, Parameter>::iterator pariter;
990 for (pariter = parameters.begin(); pariter != parameters.end(); ++pariter) {
992 TableRow newrow = tablews->appendRow();
1017 auto pariter = parameters.find(parname);
1018 if (pariter != parameters.end()) {
1019 parameters[parname].curvalue = parvalue;
1022 newparameter.
name = parname;
1024 parameters.emplace(parname, newparameter);
1040 outws->getAxis(0)->setUnit(
"dSpacing");
1042 auto tAxis = std::make_unique<TextAxis>(outws->getNumberHistograms());
1043 tAxis->setLabel(0,
"Data");
1044 tAxis->setLabel(1,
"Model");
1045 tAxis->setLabel(2,
"DiffDM");
1046 tAxis->setLabel(3,
"Start");
1047 tAxis->setLabel(4,
"DiffDS");
1048 tAxis->setLabel(5,
"Zdiff");
1049 outws->replaceAxis(1, std::move(tAxis));
1057 for (
size_t iws = 0; iws < outws->getNumberHistograms(); ++iws) {
1058 outws->mutableX(iws) = domain.
toVector();
1064 outws->mutableY(1) = funcvalues.
toVector();
1065 outws->mutableY(2) = dataY - funcvalues.
toVector();
1066 outws->mutableY(3) = rawvalues.
toVector();
1067 outws->mutableY(4) = dataY - rawvalues.
toVector();
1071 outws->mutableY(5) = zscore;
1080 map<string, Parameter> params) {
1082 vector<string> funparamnames = function->getParameterNames();
1086 msgss <<
"Set Instrument Function Parameter : \n";
1088 for (
const auto &parname : funparamnames) {
1089 auto paramiter = params.find(parname);
1091 if (paramiter != params.end()) {
1094 function->setParameter(parname, param.
curvalue);
1096 msgss << setw(10) << parname <<
" = " << param.
curvalue <<
'\n';
1100 errss <<
"Peak profile parameter " << parname <<
" is not found in input parameters. ";
1102 throw runtime_error(errss.str());
1151 map<string, Parameter> params) {
1153 vector<string> funparamnames =
m_positionFunc->getParameterNames();
1156 std::map<std::string, Parameter>::iterator paramiter;
1157 for (
size_t i = 0; i < funparamnames.size(); ++i) {
1158 string parname = funparamnames[i];
1159 paramiter = params.find(parname);
1161 if (paramiter != params.end()) {
1168 double lowerbound = param.
minvalue;
1169 double upperbound = param.
maxvalue;
1170 if (lowerbound >= -DBL_MAX * 0.1 || upperbound <= DBL_MAX * 0.1) {
1173 std::make_unique<Constraints::BoundaryConstraint>(function.get(), parname, lowerbound, upperbound,
false);
1174 function->addConstraint(std::move(bc));
1183 errss <<
"Peak profile parameter " << parname <<
" is not found in input parameters. ";
1185 throw runtime_error(errss.str());
1189 g_log.
notice() <<
"Fit function:\n" << function->asString() <<
"\n";
1203 map<string, Parameter>::iterator miter;
1204 for (miter = source.begin(); miter != source.end(); ++miter) {
1205 string parname = miter->first;
1209 target.emplace(parname, newparam);
1220 if (source.size() != target.size())
1221 throw runtime_error(
"Source and Target should have the same size.");
1224 map<string, Parameter>::iterator miter;
1225 map<string, Parameter>::iterator titer;
1226 for (miter = source.begin(); miter != source.end(); ++miter) {
1227 string parname = miter->first;
1229 double paramvalue = param.
curvalue;
1231 titer = target.find(parname);
1232 if (titer == target.end())
1233 throw runtime_error(
"Source and target should have exactly the same keys.");
1235 titer->second.curvalue = paramvalue;
1245 for (
size_t i = 0; i < strvec.size(); ++i)
1246 lookupdict.emplace(strvec[i], i);
1253 map<string, size_t>::iterator fiter;
1254 fiter = lookupdict.find(key);
1258 if (fiter == lookupdict.end()) {
1263 returnvalue =
static_cast<int>(fiter->second);
1273 parvaluemap.clear();
1275 vector<string> parnames = function->getParameterNames();
1276 for (
size_t i = 0; i < parnames.size(); ++i) {
1277 string &parname = parnames[i];
1278 double parvalue = function->getParameter(i);
1279 double parerror = function->getError(i);
1280 parvaluemap.emplace(parname, make_pair(parvalue, parerror));
1290 map<string, Parameter> ¶mmap) {
1291 vector<string> parnames = function->getParameterNames();
1293 for (
auto &parname : parnames) {
1294 map<string, pair<double, double>>::iterator miter;
1295 miter = parvaluemap.find(parname);
1297 if (miter != parvaluemap.end()) {
1298 double parvalue = miter->second.first;
1299 double parerror = miter->second.second;
1302 function->setParameter(parname, parvalue);
1305 auto pariter = parammap.find(parname);
1306 if (pariter != parammap.end()) {
1308 pariter->second.curvalue = parvalue;
1309 pariter->second.fiterror = parerror;
#define DECLARE_ALGORITHM(classname)
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
virtual std::shared_ptr< Algorithm > createChildAlgorithm(const std::string &name, const double startProgress=-1., const double endProgress=-1., const bool enableLogging=true, const int &version=-1)
Create a Child Algorithm.
Implements FunctionDomain1D with its own storage in form of a std::vector.
std::vector< double > toVector() const
Convert to a vector.
A class to store values calculated by a function.
std::vector< double > toVector() const
Return the calculated values as a vector.
TableRow represents a row in a TableWorkspace.
A property class for workspaces.
RefinePowderInstrumentParameters3 :
double fitFunction(const API::IFunction_sptr &function, const DataObjects::Workspace2D_sptr &dataws, int wsindex, bool powerfit)
Fit function by non MC minimzer(s)
double calculateFunction(const std::map< std::string, Parameter > ¶mmap, std::vector< double > &vecY)
Implement parameter values, calculate function and its chi square.
enum Mantid::CurveFitting::Algorithms::RefinePowderInstrumentParameters3::@3 m_fitMode
Fit mode.
double execFitParametersMC()
Refine instrument parameters by Monte Carlo/simulated annealing method.
void addParameterToMCMinimize(std::vector< std::string > &parnamesforMC, const std::string &parname, std::map< std::string, Parameter > parammap)
Add parameter (to a vector of string/name) for MC random walk.
double calculateFunctionError(const API::IFunction_sptr &function, const DataObjects::Workspace2D_sptr &dataws, int wsindex)
Calculate Chi^2 of the a function with all parameters are fixed.
int m_randomSeed
Random seed.
void bookKeepMCResult(std::map< std::string, Parameter > parammap, double chisq, int istep, int igroup, std::map< std::string, Parameter > &bestparammap)
Book keep the best fitting result.
double m_dampingFactor
Damping factor.
int m_numWalkSteps
Monte Carlo random walk steps.
DataObjects::TableWorkspace_sptr genOutputProfileTable(std::map< std::string, Parameter > parameters, double startchi2, double finalchi2)
Construct an output TableWorkspace for refined peak profile parameters.
double m_bestChiSq
Book keep for MC.
DataObjects::Workspace2D_sptr genOutputWorkspace(const API::FunctionDomain1DVector &domain, const API::FunctionValues &rawvalues)
Construct output.
void parseTableWorkspaces()
Parse TableWorkspaces.
Functions::ThermalNeutronDtoTOFFunction_sptr m_positionFunc
My function for peak positions.
void setFunctionParameterValues(const API::IFunction_sptr &function, std::map< std::string, Parameter > params)
Set parameter values to function from Parameter map.
double doSimulatedAnnealing(std::map< std::string, Parameter > inparammap)
Do MC/simulated annealing to refine parameters.
bool doFitFunction(const API::IFunction_sptr &function, const DataObjects::Workspace2D_sptr &dataws, int wsindex, const std::string &minimizer, int numiters, double &chi2, std::string &fitstatus)
Fit function (single step)
double execFitParametersNonMC()
Fit instrument parameters by non Monte Carlo algorithm.
enum Mantid::CurveFitting::Algorithms::RefinePowderInstrumentParameters3::@4 m_stdMode
Standard error mode.
DataObjects::Workspace2D_sptr m_dataWS
Data workspace containg peak positions.
void parseTableWorkspace(const DataObjects::TableWorkspace_sptr &tablews, std::map< std::string, Parameter > ¶mmap)
Parse table workspace to a map of Parameters.
void setupRandomWalkStrategy(std::map< std::string, Parameter > ¶mmap, std::vector< std::vector< std::string > > &mcgroups)
Set up Monte Carlo random walk strategy.
int m_wsIndex
Workspace index of the peak positions.
void proposeNewValues(const std::vector< std::string > &mcgroup, std::map< std::string, Parameter > &curparammap, std::map< std::string, Parameter > &newparammap, double currchisq)
Propose new parameters.
DataObjects::TableWorkspace_sptr m_paramTable
TableWorkspace containing peak parameters value and fit information.
void exec() override
Implement abstract Algorithm methods.
void processInputProperties()
Process input properties.
std::map< std::string, Parameter > m_profileParameters
Data structure (map of Parameters) to hold parameters.
void addOrReplace(std::map< std::string, Parameter > ¶meters, const std::string &parname, double parvalue)
Add a parameter to parameter map.
void init() override
Implement abstract Algorithm methods.
void setFunctionParameterFitSetups(const API::IFunction_sptr &function, std::map< std::string, Parameter > params)
Set parameter fitting setup (boundary, fix or unfix) to function from Parameter map.
bool acceptOrDenyChange(double curchisq, double newchisq, double temperature)
Determine whether the proposed value should be accepted or denied.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void debug(const std::string &msg)
Logs at debug level.
void notice(const std::string &msg)
Logs at notice level.
void error(const std::string &msg)
Logs at error level.
void warning(const std::string &msg)
Logs at warning level.
void information(const std::string &msg)
Logs at information level.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
std::shared_ptr< IFunction > IFunction_sptr
shared pointer to the function base class
double calculateFunctionChiSquare(const std::vector< double > &modelY, const std::vector< double > &dataY, const std::vector< double > &dataE)
Calculate Chi^2.
void duplicateParameters(std::map< std::string, Parameter > source, std::map< std::string, Parameter > &target)
Copy parameters from source to target.
void convertToDict(std::vector< std::string > strvec, std::map< std::string, size_t > &lookupdict)
Convert a vector to a lookup map (dictionary)
int getStringIndex(std::map< std::string, size_t > lookupdict, const std::string &key)
Get the index from lookup dictionary (map)
void restoreFunctionParameterValue(std::map< std::string, std::pair< double, double > > parvaluemap, const API::IFunction_sptr &function, std::map< std::string, Parameter > ¶mmap)
Restore function parameter values to a map.
void copyParametersValues(std::map< std::string, Parameter > source, std::map< std::string, Parameter > &target)
Copy parameters values from source to target.
void storeFunctionParameterValue(const API::IFunction_sptr &function, std::map< std::string, std::pair< double, double > > &parvaluemap)
Store function parameter values to a map.
std::shared_ptr< Workspace2D > Workspace2D_sptr
shared pointer to Mantid::DataObjects::Workspace2D
std::shared_ptr< TableWorkspace > TableWorkspace_sptr
shared pointer to Mantid::DataObjects::TableWorkspace
std::unique_ptr< T > create(const P &parent, const IndexArg &indexArg, const HistArg &histArg)
This is the create() method that all the other create() methods call.
std::vector< double > getZscore(const std::vector< TYPE > &data)
Return the Z score values for a dataset.
LeBailFit : Algorithm to do Le Bail Fit.
@ Input
An input workspace.
@ Output
An output workspace.