Mantid
Loading...
Searching...
No Matches
FunctionModel.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
15#include "MantidKernel/Logger.h"
17
18#include <algorithm>
19#include <utility>
20
21namespace {
22Mantid::Kernel::Logger g_log("FitFunction");
23}
24
26
27using namespace Mantid::API;
28
31 m_function = std::dynamic_pointer_cast<MultiDomainFunction>(fun);
32 if (m_function) {
34 return;
35 }
37 if (fun) {
38 auto const nf = m_numberDomains > 0 ? static_cast<int>(m_numberDomains) : 1;
40 for (int i = 0; i < nf; ++i) {
41 m_function->addFunction(fun->clone());
42 m_function->setDomainIndex(i, i);
43 }
44 }
45}
46
48 // It is important that this does not return a copy/clone of the function
49 return m_function;
50}
51
53 if (!m_function)
54 return m_function;
55
56 auto const numberOfFunctions = m_function->nFunctions();
57
58 if (numberOfFunctions > 1) {
59 if (m_currentDomainIndex < numberOfFunctions)
62
63 } else if (numberOfFunctions == 1) {
64 auto const function = m_function->getFunction(0)->clone();
65 auto const composite = std::dynamic_pointer_cast<CompositeFunction>(function);
66
67 if (composite && composite->nFunctions() == 1)
68 return composite->getFunction(0);
69 return function;
70 }
71 return IFunction_sptr();
72}
73
75 auto function = std::dynamic_pointer_cast<MultiDomainFunction>(m_function->clone());
76
77 auto const singleFun = m_function->getFunction(index);
78 for (auto paramIter = m_globalParameterNames.begin(); paramIter != m_globalParameterNames.end();) {
79 if (singleFun->hasParameter(*paramIter)) {
80 QStringList ties;
81 for (auto i = 0u; i < m_function->nFunctions(); ++i)
82 if (i != index)
83 ties << "f" + QString::number(i) + "." + QString::fromStdString(*paramIter);
84
85 ties << "f" + QString::number(index) + "." + QString::fromStdString(*paramIter);
86 function->addTies(ties.join("=").toStdString());
87 ++paramIter;
88 } else {
89 paramIter = m_globalParameterNames.erase(paramIter);
90 }
91 }
92 return function;
93}
94
96 if (!m_function || m_function->nFunctions() == 0)
97 return false;
98 return true;
99}
100
101void FunctionModel::addFunction(std::string const &prefix, std::string const &funStr) {
102 if (!hasFunction()) {
103 setFunctionString(funStr);
104 return;
105 }
106 auto newFun = FunctionFactory::Instance().createInitialized(funStr);
107 auto const nf = m_numberDomains > 0 ? static_cast<int>(m_numberDomains) : 1;
108 for (int i = 0; i < nf; ++i) {
109 auto fun = getSingleFunction(i);
110 auto parentFun = getFunctionWithPrefix(prefix, fun);
111 auto cf = std::dynamic_pointer_cast<CompositeFunction>(parentFun);
112 if (cf) {
113 cf->addFunction(newFun->clone());
114 } else if (i == 0 && prefix.empty()) {
115 setFunctionString(getFunctionString() + ";" + funStr);
116 break;
117 } else {
118 throw std::runtime_error("Function at " + prefix + " is not composite.");
119 }
120 }
121 m_function->checkFunction();
123}
124
125void FunctionModel::removeFunction(std::string const &functionIndex) {
126 std::string prefix;
127 int index;
128 std::tie(prefix, index) = splitFunctionPrefix(functionIndex);
129 if (prefix.empty() && index == -1) {
130 clear();
131 return;
132 }
133 auto const nf = m_numberDomains > 0 ? static_cast<int>(m_numberDomains) : 1;
134 for (int i = 0; i < nf; ++i) {
135 auto fun = getSingleFunction(i);
136 auto parentFun = getFunctionWithPrefix(prefix, fun);
137 auto cf = std::dynamic_pointer_cast<CompositeFunction>(parentFun);
138 if (!cf) {
139 throw std::runtime_error("Function at " + prefix + " is not composite.");
140 }
141 cf->removeFunction(index);
142 if (cf->nFunctions() == 1 && prefix.empty() && cf->name() == "CompositeFunction") {
143 m_function->replaceFunction(i, cf->getFunction(0));
144 m_function->checkFunction();
145 } else {
146 cf->checkFunction();
147 }
148 }
149 m_function->checkFunction();
151}
152
153void FunctionModel::setParameter(std::string const &parameterName, double value) {
154 if (isGlobal(parameterName))
155 setGlobalParameterValue(parameterName, value);
156 else
157 setLocalParameterValue(parameterName, static_cast<int>(m_currentDomainIndex), value);
158}
159
160void FunctionModel::setAttribute(std::string const &attrName, const IFunction::Attribute &value) {
161 auto fun = getCurrentFunction();
162 if (!fun) {
163 throw std::logic_error("Function is undefined.");
164 }
165 if (fun->hasAttribute(attrName)) {
166 fun->setAttribute(attrName, value);
167 }
168}
169
170void FunctionModel::setParameterError(std::string const &parameterName, double value) {
171 auto fun = getCurrentFunction();
172 auto const index = fun->parameterIndex(parameterName);
173 fun->setError(index, value);
174}
175
176double FunctionModel::getParameter(std::string const &parameterName) const {
177 auto const fun = getCurrentFunction();
178 return fun && fun->hasParameter(parameterName) ? fun->getParameter(parameterName) : 0.0;
179}
180
181IFunction::Attribute FunctionModel::getAttribute(std::string const &attrName) const {
182 auto const fun = getCurrentFunction();
183 return fun && fun->hasAttribute(attrName) ? fun->getAttribute(attrName) : IFunction::Attribute();
184}
185
186double FunctionModel::getParameterError(std::string const &parameterName) const {
187 auto fun = getCurrentFunction();
188 return fun && fun->hasParameter(parameterName) ? fun->getError(fun->parameterIndex(parameterName)) : 0.0;
189}
190
191std::string FunctionModel::getParameterDescription(std::string const &parameterName) const {
192 auto fun = getCurrentFunction();
193 return fun && fun->hasParameter(parameterName) ? fun->parameterDescription(fun->parameterIndex(parameterName)) : "";
194}
195
196bool FunctionModel::isParameterFixed(std::string const &parameterName) const {
197 return isLocalParameterFixed(parameterName, static_cast<int>(m_currentDomainIndex));
198}
199
200std::string FunctionModel::getParameterTie(std::string const &parameterName) const {
201 return getLocalParameterTie(parameterName, static_cast<int>(m_currentDomainIndex));
202}
203
204void FunctionModel::setParameterFixed(std::string const &parameterName, bool fixed) {
205 setLocalParameterFixed(parameterName, static_cast<int>(m_currentDomainIndex), fixed);
206}
207
208void FunctionModel::setParameterTie(std::string const &parameterName, std::string const &tie) {
209 setLocalParameterTie(parameterName, static_cast<int>(m_currentDomainIndex), tie);
210}
211
212std::vector<std::string> FunctionModel::getParameterNames() const {
213 if (hasFunction()) {
214 return getCurrentFunction()->getParameterNames();
215 }
216 return std::vector<std::string>{};
217}
218std::vector<std::string> FunctionModel::getAttributeNames() const {
219 if (hasFunction()) {
220 return getCurrentFunction()->getAttributeNames();
221 }
222 return std::vector<std::string>{};
223}
224
226 if (!checkIndex(index) || !hasFunction()) {
227 return IFunction_sptr();
228 }
229 return m_function->getFunction(index);
230}
231
235
237 if (nDomains < 0) {
238 throw std::runtime_error("Number of domains shouldn't be less than 0.");
239 }
240 auto const nd = static_cast<size_t>(nDomains);
241 if (nd == m_numberDomains) {
242 return;
243 }
244 if (!hasFunction()) {
245 m_numberDomains = nd;
246 } else {
247 auto const nfOld = m_numberDomains > 0 ? m_numberDomains : 1;
248 auto const lastIndex = nfOld - 1;
249 auto const nf = nd > 0 ? nd : 1;
250 if (nd > m_numberDomains) {
251 auto fun = m_function->getFunction(lastIndex);
252 for (size_t i = nfOld; i < nf; ++i) {
253 m_function->addFunction(fun->clone());
254 m_function->setDomainIndex(i, i);
255 }
256 } else {
257 for (size_t i = lastIndex; i >= nf; --i) {
258 m_function->removeFunction(i);
259 }
260 m_function->checkFunction();
261 m_function->clearDomainIndices();
262 for (size_t i = 0; i < m_function->nFunctions(); ++i) {
263 m_function->setDomainIndex(i, i);
264 }
265 }
266 m_numberDomains = nDomains;
267 }
270 }
271}
272
276void FunctionModel::setDatasets(const std::vector<std::string> &datasetNames) {
278 for (const auto &datasetName : datasetNames)
279 datasets.append(FunctionModelDataset(datasetName, FunctionModelSpectra("0")));
280
281 setDatasets(datasets);
282}
283
289 checkNumberOfDomains(datasets);
290 m_datasets = datasets;
291}
292
296void FunctionModel::addDatasets(const std::vector<std::string> &datasetNames) {
297 for (const auto &datasetName : datasetNames)
298 m_datasets.append(FunctionModelDataset(datasetName, FunctionModelSpectra("0")));
299
301}
302
307
308 // Sort in reverse order
309 using std::sort;
310 sort(indices.begin(), indices.end(), [](int a, int b) { return a > b; });
311 for (auto i = indices.constBegin(); i != indices.constEnd(); ++i)
312 m_datasets.erase(m_datasets.begin() + *i);
313
314 const auto nDomains = numberOfDomains(m_datasets);
315 setNumberDomains(nDomains);
316
317 auto currentIndex = currentDomainIndex();
318 if (currentIndex >= nDomains)
319 currentIndex = m_datasets.isEmpty() ? 0 : nDomains - 1;
320
321 setCurrentDomainIndex(currentIndex);
322}
323
327std::vector<std::string> FunctionModel::getDatasetNames() const {
328 std::vector<std::string> allDatasetNames;
329 for (const auto &dataset : m_datasets)
330 for (auto i = 0u; i < dataset.numberOfSpectra(); ++i) {
331 UNUSED_ARG(i);
332 allDatasetNames.emplace_back(dataset.datasetName());
333 }
334 return allDatasetNames;
335}
336
340std::vector<std::string> FunctionModel::getDatasetDomainNames() const {
341 std::vector<std::string> allDomainNames;
342 for (const auto &dataset : m_datasets) {
343 auto const domainNames = dataset.domainNames();
344 allDomainNames.insert(allDomainNames.end(), domainNames.cbegin(), domainNames.cend());
345 }
346 return allDomainNames;
347}
348
349int FunctionModel::getNumberDomains() const { return static_cast<int>(m_numberDomains); }
350
351int FunctionModel::currentDomainIndex() const { return static_cast<int>(m_currentDomainIndex); }
352
354 if (checkIndex(index)) {
355 m_currentDomainIndex = static_cast<size_t>(index);
356 }
357}
358
359double FunctionModel::getLocalParameterValue(std::string const &parameterName, int i) const {
360 return getSingleFunction(i)->getParameter(parameterName);
361}
362
363bool FunctionModel::isLocalParameterFixed(std::string const &parameterName, int i) const {
364 auto fun = getSingleFunction(i);
365 auto const parIndex = fun->parameterIndex(parameterName);
366 return fun->isFixed(parIndex);
367}
368
369std::string FunctionModel::getLocalParameterTie(std::string const &parameterName, int i) const {
370 auto fun = getSingleFunction(i);
371 auto const parIndex = fun->parameterIndex(parameterName);
372 auto const tie = fun->getTie(parIndex);
373 if (!tie)
374 return "";
375 auto const tieStr = QString::fromStdString(tie->asString());
376 auto const j = tieStr.indexOf('=');
377 return tieStr.mid(j + 1).toStdString();
378}
379
380std::string FunctionModel::getLocalParameterConstraint(std::string const &parameterName, int i) const {
381 auto fun = getSingleFunction(i);
382 auto const parIndex = fun->parameterIndex(parameterName);
383 auto const constraint = fun->getConstraint(parIndex);
384 auto const out = (!constraint) ? "" : constraint->asString();
385 return out;
386}
387
388void FunctionModel::setLocalParameterValue(std::string const &parameterName, int i, double value) {
389 auto function = getSingleFunction(i);
390 if (function && function->hasParameter(parameterName))
391 function->setParameter(parameterName, value);
392}
393
394void FunctionModel::setLocalParameterValue(std::string const &parameterName, int i, double value, double error) {
395 auto fun = getSingleFunction(i);
396 auto const parIndex = fun->parameterIndex(parameterName);
397 fun->setParameter(parIndex, value);
398 fun->setError(parIndex, error);
399}
400
401void FunctionModel::setLocalParameterFixed(std::string const &parameterName, int i, bool fixed) {
402 auto fun = getSingleFunction(i);
403 auto const parIndex = fun->parameterIndex(parameterName);
404 if (fixed) {
405 fun->fix(parIndex);
406 } else if (fun->isFixed(parIndex)) {
407 fun->unfix(parIndex);
408 }
409}
410
411void FunctionModel::setLocalParameterTie(std::string const &parameterName, int i, std::string const &tie) {
412 auto logError = [&parameterName](const std::string &msg) {
413 g_log.error() << "Tie " << parameterName << ": " << msg << '\n';
414 };
415 auto fun = getSingleFunction(i);
416 auto const name = parameterName;
417 if (tie.empty()) {
418 fun->removeTie(fun->parameterIndex(name));
419 } else {
420 auto const j = QString::fromStdString(tie).indexOf('=');
421 try {
422 fun->tie(name, QString::fromStdString(tie).mid(j + 1).toStdString());
423 } catch (const std::invalid_argument &e) {
424 logError(e.what());
425 } catch (const std::runtime_error &e) {
426 logError(e.what());
427 }
428 }
429}
430
431void FunctionModel::setLocalParameterConstraint(std::string const &parameterName, int i,
432 std::string const &constraint) {
433 auto const parts = splitConstraintString(constraint);
434 if (constraint != "" && parts.second.first == "" && parts.second.second == "") {
435 g_log.error("Constraint " + parameterName + ": " + constraint + " is not a valid constraint");
436 return;
437 }
438 std::string prefix, name;
439 std::tie(prefix, name) = splitParameterName(parameterName);
440 auto fun = getFunctionWithPrefix(prefix, getSingleFunction(i));
441 if (constraint.empty()) {
442 fun->removeConstraint(name);
443 } else {
444 auto newConstraint(QString::fromStdString(constraint));
445 newConstraint.replace(QString::fromStdString(parts.first), QString::fromStdString(name));
446 fun->addConstraints(newConstraint.toStdString());
447 }
448}
449
450void FunctionModel::setGlobalParameterValue(std::string const &parameterName, double value) {
451 if (isGlobal(parameterName))
452 for (auto i = 0; i < getNumberDomains(); ++i)
453 setLocalParameterValue(parameterName, i, value);
454}
455
456void FunctionModel::changeTie(std::string const &parameterName, std::string const &tie) {
457 try {
458 setLocalParameterTie(parameterName, static_cast<int>(m_currentDomainIndex), tie);
459 } catch (std::exception &) {
460 // the tie is probably being edited
461 }
462}
463
464void FunctionModel::addConstraint(std::string const &functionIndex, std::string const &constraint) {
465 auto fun = getFunctionWithPrefix(functionIndex, getCurrentFunction());
466 fun->addConstraints(constraint);
467}
468
469void FunctionModel::removeConstraint(std::string const &parameterName) {
470 getCurrentFunction()->removeConstraint(parameterName);
471}
472
473std::vector<std::string> FunctionModel::getGlobalParameters() const { return m_globalParameterNames; }
474
475void FunctionModel::setGlobal(std::string const &parameterName, bool on) {
476 if (parameterName.empty())
477 return;
478 if (!on) {
479 auto newEnd = std::remove(m_globalParameterNames.begin(), m_globalParameterNames.end(), parameterName);
480 if (newEnd != m_globalParameterNames.end()) {
482 }
483 } else if (std::find(m_globalParameterNames.cbegin(), m_globalParameterNames.cend(), parameterName) ==
484 m_globalParameterNames.cend()) {
485 m_globalParameterNames.emplace_back(parameterName);
486 }
487}
488
489void FunctionModel::setGlobalParameters(const std::vector<std::string> &globals) { m_globalParameterNames = globals; }
490
491std::vector<std::string> FunctionModel::getLocalParameters() const {
492 auto const parameterNames = getParameterNames();
493 std::vector<std::string> locals;
494 std::copy_if(parameterNames.cbegin(), parameterNames.cend(), std::back_inserter(locals),
495 [&](const std::string &parameterName) { return !isGlobal(parameterName); });
496 return locals;
497}
498
501 if (numberOfDomains(m_datasets) != static_cast<int>(m_numberDomains)) {
502 m_datasets.clear();
503 for (auto i = 0u; i < m_numberDomains; ++i)
505 }
506}
507
510 if (numberOfDomains(datasets) != static_cast<int>(m_numberDomains)) {
511 throw std::runtime_error("Number of dataset domains doesn't match the number of domains.");
512 }
513}
514
516 return std::accumulate(datasets.cbegin(), datasets.cend(), 0, [](int lhs, const auto &dataset) {
517 return lhs + static_cast<int>(dataset.numberOfSpectra());
518 });
519}
520
521bool FunctionModel::checkIndex(int const index) const {
522 auto const indexInRange = index == 0 || (index > 0 && index < getNumberDomains());
523 // If the domain index is out of range, this indicates a problem in the logic of our code.
524 // We want the index to be ignored in Release mode (i.e. for a user), but we want an exception
525 // when in Debug mode (i.e. to alert a dev of the logic issue).
526 assert(indexInRange);
527 return indexInRange;
528}
529
536
538 auto const nRows = paramTable.rowCount();
539 if (nRows == 0)
540 return;
541
542 auto const globalParameterNames = getGlobalParameters();
543 for (auto &&name : globalParameterNames) {
544 auto valueColumn = paramTable.getColumn(name);
545 auto errorColumn = paramTable.getColumn(name + "_Err");
546 setParameter(name, valueColumn->toDouble(0));
547 setParameterError(name, errorColumn->toDouble(0));
548 }
549
550 auto const localParameterNames = getLocalParameters();
551 for (auto &&name : localParameterNames) {
552 auto valueColumn = paramTable.getColumn(name);
553 auto errorColumn = paramTable.getColumn(name + "_Err");
554 if (nRows > 1) {
555 for (size_t i = 0; i < nRows; ++i) {
556 setLocalParameterValue(name, static_cast<int>(i), valueColumn->toDouble(i), errorColumn->toDouble(i));
557 }
558 } else {
559 auto const i = currentDomainIndex();
560 setLocalParameterValue(name, static_cast<int>(i), valueColumn->toDouble(0), errorColumn->toDouble(0));
561 }
562 }
563}
564
566 if (!hasFunction())
567 return;
568 if (m_function->nAttributes() != fun.nAttributes())
569 return;
570 for (const auto &name : fun.getAttributeNames()) {
571 m_function->setAttribute(name, fun.getAttribute(name));
572 }
573}
574
576 if (!hasFunction())
577 return;
578 auto currentFun = getCurrentFunction();
579 copyParametersAndErrors(fun, *currentFun);
580}
581
583 auto const fun = getCurrentFunction();
584 for (auto it = m_globalParameterNames.begin(); it != m_globalParameterNames.end();) {
585 if (!fun->hasParameter(*it)) {
586 it = m_globalParameterNames.erase(it);
587 } else {
588 ++it;
589 }
590 }
591}
592
594 auto n = fun->getNumberDomains();
595 if (n > 1) {
596 for (size_t index = 0; index < n; index++) {
597 setResolutionFromWorkspace(fun->getFunction(index));
598 }
599 } else {
600 if (fun->hasAttribute("f0.Workspace")) {
601 std::string wsName = fun->getAttribute("f0.Workspace").asString();
602 if (AnalysisDataService::Instance().doesExist(wsName)) {
603 const auto ws = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(wsName);
605 }
606 }
607 }
608}
609
611 auto inst = workspace->getInstrument();
612 auto analyser = inst->getStringParameter("analyser");
613 if (!analyser.empty()) {
614 auto comp = inst->getComponentByName(analyser[0]);
615 if (comp && comp->hasParameter("resolution")) {
616 auto params = comp->getNumberParameter("resolution", true);
617 for (const auto &param : fun->getParameterNames()) {
618 if (param.find("FWHM") != std::string::npos) {
619 fun->setParameter(param, params[0]);
620 }
621 }
622 }
623 }
624}
625
626bool FunctionModel::isGlobal(std::string const &parameterName) const {
627 auto const findIter = std::find(m_globalParameterNames.cbegin(), m_globalParameterNames.cend(), parameterName);
628 return findIter != m_globalParameterNames.cend();
629}
630
632 std::string foundName;
633 auto const fun = getCurrentFunction();
634 auto getA0 = [](IFunction const &f) -> std::string { return f.hasParameter("A0") ? "A0" : ""; };
635 auto const cf = std::dynamic_pointer_cast<CompositeFunction>(fun);
636 if (cf) {
637 if (fun->name() != "CompositeFunction")
638 return "";
639 for (size_t i = 0; i < cf->nFunctions(); ++i) {
640 foundName = getA0(*cf->getFunction(i));
641 if (!foundName.empty()) {
642 foundName.insert(0, "f" + std::to_string(i) + ".");
643 break;
644 }
645 }
646 } else {
647 foundName = getA0(*fun);
648 }
649 if (!foundName.empty()) {
650 fun->setParameter(foundName, value);
651 }
652 return foundName;
653}
654
655void FunctionModel::setResolution(const std::vector<std::pair<std::string, size_t>> &fitResolutions) {
656 (void)fitResolutions;
657}
658
659void FunctionModel::setQValues(const std::vector<double> &qValues) { (void)qValues; }
660
661} // namespace MantidQt::MantidWidgets
std::string name
Definition Run.cpp:60
double value
The value of the point.
Definition FitMW.cpp:51
double error
IPeaksWorkspace_sptr workspace
std::map< DeltaEMode::Type, std::string > index
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
Definition System.h:48
IFunction_sptr getFullFunction() const override
std::string setBackgroundA0(double value) override
IFunction_sptr getCurrentFunction() const override
void setAttribute(std::string const &attrName, const IFunction::Attribute &val)
std::vector< std::string > getDatasetDomainNames() const override
Returns names for the domains of each dataset.
IFunction_sptr getSingleFunction(int index) const override
void setResolutionFromWorkspace(const IFunction_sptr &fun)
double getParameter(std::string const &parameterName) const override
virtual void setGlobal(std::string const &parameterName, bool on) override
void changeTie(std::string const &parameterName, std::string const &tie) override
void addDatasets(const std::vector< std::string > &datasetNames)
Adds datasets based on their workspace names.
std::string getParameterTie(std::string const &parameterName) const
bool checkIndex(int const index) const
int numberOfDomains(const QList< FunctionModelDataset > &datasets) const
void setParameterFixed(std::string const &parameterName, bool fixed)
void setGlobalParameters(const std::vector< std::string > &globals) override
void removeDatasets(QList< int > &indices)
Removes datasets (i.e.
void addFunction(std::string const &prefix, std::string const &funStr) override
void setLocalParameterValue(std::string const &parameterName, int i, double value) override
double getLocalParameterValue(std::string const &parameterName, int i) const override
std::vector< std::string > getDatasetNames() const override
Returns the workspace names of the datasets.
void checkNumberOfDomains(const QList< FunctionModelDataset > &datasets) const
Check that the datasets supplied have the expected total number of domains.
void setQValues(const std::vector< double > &qValues) override
void checkDatasets()
Check that the number of domains is correct for m_datasets.
void updateParameters(const IFunction &fun) override
void removeConstraint(std::string const &parameterName) override
MultiDomainFunction_sptr m_function
std::vector< std::string > getLocalParameters() const override
bool isParameterFixed(std::string const &parameterName) const
std::string getLocalParameterConstraint(std::string const &parameterName, int i) const override
bool isGlobal(std::string const &parameterName) const override
IFunction_sptr getFitFunction() const override
IFunction_sptr getFitFunctionWithGlobals(std::size_t const &index) const
double getParameterError(std::string const &parameterName) const override
std::vector< std::string > m_globalParameterNames
void updateMultiDatasetAttributes(const IFunction &fun)
std::vector< std::string > getGlobalParameters() const override
void setParameterTie(std::string const &parameterName, std::string const &tie)
void removeFunction(std::string const &functionIndex) override
QList< FunctionModelDataset > m_datasets
void setLocalParameterConstraint(std::string const &parameterName, int i, std::string const &constraint) override
void addConstraint(std::string const &functionIndex, std::string const &constraint) override
std::string getLocalParameterTie(std::string const &parameterName, int i) const override
bool isLocalParameterFixed(std::string const &parameterName, int i) const override
std::vector< std::string > getParameterNames() const override
std::vector< std::string > getAttributeNames() const
void setDatasets(const std::vector< std::string > &datasetNames)
Sets the datasets based on their workspace names.
void setFunction(IFunction_sptr) override
void setLocalParameterFixed(std::string const &parameterName, int i, bool fixed) override
void setParameterError(std::string const &parameterName, double value) override
void setLocalParameterTie(std::string const &parameterName, int i, std::string const &tie) override
std::string getParameterDescription(std::string const &parameterName) const override
void setParameter(std::string const &parameterName, double value) override
void setResolution(const std::vector< std::pair< std::string, size_t > > &fitResolutions) override
void setGlobalParameterValue(std::string const &parameterName, double value) override
void updateMultiDatasetParameters(const IFunction &fun) override
IFunction::Attribute getAttribute(std::string const &attrName) const
static void copyParametersAndErrors(const IFunction &funFrom, IFunction &funTo)
void setFunctionString(std::string const &funStr)
Attribute is a non-fitting parameter.
Definition IFunction.h:285
This is an interface to a fitting function - a semi-abstarct class.
Definition IFunction.h:166
virtual Attribute getAttribute(const std::string &name) const
Return a value of attribute attName.
virtual std::vector< std::string > getAttributeNames() const
Returns a list of attribute names.
virtual size_t nAttributes() const
Returns the number of attributes associated with the function.
ITableWorkspace is an implementation of Workspace in which the data are organised in columns of same ...
virtual Column_sptr getColumn(const std::string &name)=0
Gets the shared pointer to a column by name.
virtual size_t rowCount() const =0
Number of rows in the workspace.
Base MatrixWorkspace Abstract Class.
A composite function defined on a CompositeDomain.
The Logger class is in charge of the publishing messages from the framework through various channels.
Definition Logger.h:51
void error(const std::string &msg)
Logs at error level.
Definition Logger.cpp:108
EXPORT_OPT_MANTIDQT_COMMON std::pair< std::string, std::pair< std::string, std::string > > splitConstraintString(const std::string &constraint)
Split a constraint definition into a parameter name and a pair of bounds, for example -1 < f0....
EXPORT_OPT_MANTIDQT_COMMON std::pair< std::string, int > splitFunctionPrefix(std::string const &prefix)
Split a function (eg f0.f3.f1.) into the parent prefix (f0.f3.) and the index of the child function (...
EXPORT_OPT_MANTIDQT_COMMON IFunction_sptr getFunctionWithPrefix(std::string const &prefix, const IFunction_sptr &fun)
Get a child function of a parent function whose parameters start with a given prefix.
EXPORT_OPT_MANTIDQT_COMMON std::pair< std::string, std::string > splitParameterName(std::string const &parameterName)
Split a qualified parameter name into function index and local parameter name.
std::shared_ptr< MultiDomainFunction > MultiDomainFunction_sptr
Shared pointer to Mantid::API::MultiDomainFunction.
Kernel::Logger g_log("ExperimentInfo")
static logger object
std::shared_ptr< IFunction > IFunction_sptr
shared pointer to the function base class
Definition IFunction.h:743
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
Kernel::Logger g_log("DetermineSpinStateOrder")
std::string to_string(const wide_integer< Bits, Signed > &n)