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 (
const 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;
836 g_log.
notice() <<
"[DBx436] Starting Chi^2 = " << startchisq <<
", Power-Fit is " << powerfit <<
'\n';
840 double final_chi2 = DBL_MAX;
843 map<string, pair<double, double>> paramvaluemap2, paramvaluemap3;
845 string minimizer =
"Simplex";
847 string fitstatussimplex;
849 bool fitgood1 =
doFitFunction(function, dataws, wsindex, minimizer, numiters, chi2simplex, fitstatussimplex);
854 chi2simplex = DBL_MAX;
857 minimizer =
"Levenberg-MarquardtMD";
861 bool fitgood2 =
doFitFunction(function, dataws, wsindex, minimizer, numiters, chi2lv2, fitstatuslv2);
868 map<string, Parameter> tempparmap;
872 bool fitgood3 =
doFitFunction(function, dataws, wsindex, minimizer, numiters, chi2lv1, fitstatuslv1);
879 g_log.
notice() <<
"Fit Result: Chi2s: Simplex = " << chi2simplex <<
", "
880 <<
"Levenberg 1 = " << chi2lv2 <<
", Levenberg 2 = " << chi2lv1 <<
'\n';
882 if (fitgood1 || fitgood2 || fitgood3) {
884 if (fitgood1 && chi2simplex <= chi2lv2 && chi2simplex <= chi2lv1) {
885 final_chi2 = chi2simplex;
887 }
else if (fitgood2 && chi2lv2 <= chi2lv1) {
889 final_chi2 = chi2lv2;
890 }
else if (fitgood3) {
891 final_chi2 = chi2lv1;
894 throw runtime_error(
"This situation is impossible to happen!");
899 string minimizer =
"Levenberg-MarquardtMD";
902 bool fitgood =
doFitFunction(function, dataws, wsindex, minimizer, numiters, final_chi2, fitstatus);
907 g_log.
warning() <<
"Fit by " << minimizer <<
" failed. Reason: " << fitstatus <<
"\n";
919 int wsindex,
const string &minimizer,
int numiters,
double &chi2,
923 outss <<
"Fit function: " <<
m_positionFunc->asString() <<
"\nData To Fit: \n";
924 for (
size_t i = 0; i < dataws->x(0).size(); ++i)
925 outss << dataws->x(wsindex)[i] <<
"\t\t" << dataws->y(wsindex)[i] <<
"\t\t" << dataws->e(wsindex)[i] <<
"\n";
930 fitalg->initialize();
932 fitalg->setProperty(
"Function", function);
933 fitalg->setProperty(
"InputWorkspace", dataws);
934 fitalg->setProperty(
"WorkspaceIndex", wsindex);
935 fitalg->setProperty(
"Minimizer", minimizer);
936 fitalg->setProperty(
"CostFunction",
"Least squares");
937 fitalg->setProperty(
"MaxIterations", numiters);
938 fitalg->setProperty(
"CalcErrors",
true);
941 bool successfulfit = fitalg->execute();
942 if (!fitalg->isExecuted() || !successfulfit) {
944 g_log.
warning(
"Fitting to instrument geometry function failed. ");
946 fitstatus =
"Minimizer throws exception.";
951 chi2 = fitalg->getProperty(
"OutputChi2overDoF");
952 string tempfitstatus = fitalg->getProperty(
"OutputStatus");
953 fitstatus = tempfitstatus;
955 bool goodfit = fitstatus ==
"success";
958 dbss <<
"Fit Result (GSL): Chi^2 = " << chi2 <<
"; Fit Status = " << fitstatus <<
", Return Bool = " << goodfit
960 vector<string> funcparnames = function->getParameterNames();
961 for (
size_t i = 0; i < funcparnames.size(); ++i)
962 dbss << funcparnames[i] <<
" = " << setw(20) << function->getParameter(funcparnames[i]) <<
" +/- "
963 << function->getError(i) <<
"\n";
973 double startchi2,
double finalchi2) {
975 auto tablews = std::make_shared<TableWorkspace>();
977 tablews->addColumn(
"str",
"Name");
978 tablews->addColumn(
"double",
"Value");
979 tablews->addColumn(
"str",
"FitOrTie");
980 tablews->addColumn(
"double",
"Min");
981 tablews->addColumn(
"double",
"Max");
982 tablews->addColumn(
"double",
"StepSize");
983 tablews->addColumn(
"double",
"Error");
990 map<string, Parameter>::iterator pariter;
991 for (pariter = parameters.begin(); pariter != parameters.end(); ++pariter) {
992 const Parameter ¶m = pariter->second;
993 TableRow newrow = tablews->appendRow();
1018 auto pariter = parameters.find(parname);
1019 if (pariter != parameters.end()) {
1020 parameters[parname].curvalue = parvalue;
1023 newparameter.
name = parname;
1025 parameters.emplace(parname, newparameter);
1041 outws->getAxis(0)->setUnit(
"dSpacing");
1043 auto tAxis = std::make_unique<TextAxis>(outws->getNumberHistograms());
1044 tAxis->setLabel(0,
"Data");
1045 tAxis->setLabel(1,
"Model");
1046 tAxis->setLabel(2,
"DiffDM");
1047 tAxis->setLabel(3,
"Start");
1048 tAxis->setLabel(4,
"DiffDS");
1049 tAxis->setLabel(5,
"Zdiff");
1050 outws->replaceAxis(1, std::move(tAxis));
1058 for (
size_t iws = 0; iws < outws->getNumberHistograms(); ++iws) {
1059 outws->mutableX(iws) = domain.
toVector();
1065 outws->mutableY(1) = funcvalues.
toVector();
1066 outws->mutableY(2) = dataY - funcvalues.
toVector();
1067 outws->mutableY(3) = rawvalues.
toVector();
1068 outws->mutableY(4) = dataY - rawvalues.
toVector();
1072 outws->mutableY(5) = zscore;
1081 map<string, Parameter> params) {
1083 vector<string> funparamnames = function->getParameterNames();
1087 msgss <<
"Set Instrument Function Parameter : \n";
1089 for (
const auto &parname : funparamnames) {
1090 auto paramiter = params.find(parname);
1092 if (paramiter != params.end()) {
1095 function->setParameter(parname, param.
curvalue);
1097 msgss << setw(10) << parname <<
" = " << param.
curvalue <<
'\n';
1101 errss <<
"Peak profile parameter " << parname <<
" is not found in input parameters. ";
1103 throw runtime_error(errss.str());
1152 map<string, Parameter> params) {
1154 vector<string> funparamnames =
m_positionFunc->getParameterNames();
1157 std::map<std::string, Parameter>::iterator paramiter;
1158 for (
size_t i = 0; i < funparamnames.size(); ++i) {
1159 string parname = funparamnames[i];
1160 paramiter = params.find(parname);
1162 if (paramiter != params.end()) {
1164 const Parameter ¶m = paramiter->second;
1169 double lowerbound = param.
minvalue;
1170 double upperbound = param.
maxvalue;
1171 if (lowerbound >= -DBL_MAX * 0.1 || upperbound <= DBL_MAX * 0.1) {
1174 std::make_unique<Constraints::BoundaryConstraint>(function.get(), parname, lowerbound, upperbound,
false);
1175 function->addConstraint(std::move(bc));
1184 errss <<
"Peak profile parameter " << parname <<
" is not found in input parameters. ";
1186 throw runtime_error(errss.str());
1190 g_log.
notice() <<
"Fit function:\n" << function->asString() <<
"\n";
1204 map<string, Parameter>::const_iterator miter;
1205 for (miter = source.begin(); miter != source.end(); ++miter) {
1206 string parname = miter->first;
1210 target.emplace(parname, newparam);
1221 if (source.size() != target.size())
1222 throw runtime_error(
"Source and Target should have the same size.");
1225 for (
auto miter = source.begin(); miter != source.end(); ++miter) {
1226 string parname = miter->first;
1228 double paramvalue = param.
curvalue;
1230 auto titer = target.find(parname);
1231 if (titer == target.end())
1232 throw runtime_error(
"Source and target should have exactly the same keys.");
1234 titer->second.curvalue = paramvalue;
1244 for (
size_t i = 0; i < strvec.size(); ++i)
1245 lookupdict.emplace(strvec[i], i);
1252 map<string, size_t>::iterator fiter;
1253 fiter = lookupdict.find(key);
1257 if (fiter == lookupdict.end()) {
1262 returnvalue =
static_cast<int>(fiter->second);
1272 parvaluemap.clear();
1274 vector<string> parnames = function->getParameterNames();
1275 for (
size_t i = 0; i < parnames.size(); ++i) {
1276 string &parname = parnames[i];
1277 double parvalue = function->getParameter(i);
1278 double parerror = function->getError(i);
1279 parvaluemap.emplace(parname, make_pair(parvalue, parerror));
1289 map<string, Parameter> ¶mmap) {
1290 vector<string> parnames = function->getParameterNames();
1292 for (
auto &parname : parnames) {
1293 map<string, pair<double, double>>::iterator miter;
1294 miter = parvaluemap.find(parname);
1296 if (miter != parvaluemap.end()) {
1297 double parvalue = miter->second.first;
1300 function->setParameter(parname, parvalue);
1303 auto pariter = parammap.find(parname);
1304 if (pariter != parammap.end()) {
1306 pariter->second.curvalue = parvalue;
1307 pariter->second.fiterror = miter->second.second;
#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.
const 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
void duplicateParameters(const std::map< std::string, Parameter > &source, std::map< std::string, Parameter > &target)
Copy parameters from source to target.
double calculateFunctionChiSquare(const std::vector< double > &modelY, const std::vector< double > &dataY, const std::vector< double > &dataE)
Calculate Chi^2.
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 storeFunctionParameterValue(const API::IFunction_sptr &function, std::map< std::string, std::pair< double, double > > &parvaluemap)
Store function parameter values to a map.
void copyParametersValues(const std::map< std::string, Parameter > &source, std::map< std::string, Parameter > &target)
Copy parameters values from source to target.
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.