Mantid
Loading...
Searching...
No Matches
IFunction.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2009 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 +
7#pragma once
8
9//----------------------------------------------------------------------
10// Includes
11//----------------------------------------------------------------------
12#include "MantidAPI/DllConfig.h"
16#include "MantidAPI/Jacobian.h"
19#include "MantidKernel/Matrix.h"
20#include "MantidKernel/Unit.h"
21
22#ifndef Q_MOC_RUN
23#include <boost/variant.hpp>
24#include <memory>
25#endif
26
27#include <string>
28#include <utility>
29
30#include <vector>
31
32#ifdef _WIN32
33#pragma warning(disable : 4250)
34#endif
35
36namespace Mantid {
37namespace Kernel {
38//----------------------------------------------------------------------
39// Forward declaration
40//----------------------------------------------------------------------
41class ProgressBase;
42} // namespace Kernel
43namespace API {
44class Workspace;
45class MatrixWorkspace;
46class FunctionHandler;
47
55template <class... Ts> struct AttributeLambdaVisitor : Ts... { using Ts::operator()...; };
56template <class... Ts> AttributeLambdaVisitor(Ts...) -> AttributeLambdaVisitor<Ts...>;
57
163class MANTID_API_DLL IFunction {
164public:
168 struct ValidationException : public std::runtime_error {
169 public:
170 ValidationException(const std::string &ErrorMsg) : std::runtime_error(ErrorMsg) {}
171 };
172
178 public:
179 ValidatorEvaluator(){}; // default constructor
180 template <typename T1> static void evaluate(T1 &inputData, Mantid::Kernel::IValidator_sptr validator) {
181 std::string error;
182
183 if (validator != nullptr) {
184 error = validator->isValid(inputData);
185 }
186
187 if (error != "") {
188 throw IFunction::ValidationException("Set Attribute Error: " + error);
189 }
190 }
191 };
192
200 template <typename T = void> class DLLExport AttributeVisitor : public boost::static_visitor<T> {
201 public:
203 virtual ~AttributeVisitor() = default;
205 T operator()(std::string &str) const { return apply(str); }
207 T operator()(double &d) const { return apply(d); }
209 T operator()(int &i) const { return apply(i); }
211 T operator()(bool &b) const { return apply(b); }
213 T operator()(std::vector<double> &v) const { return apply(v); }
214
215 protected:
217 virtual T apply(std::string &) const = 0;
219 virtual T apply(double &) const = 0;
221 virtual T apply(int &) const = 0;
223 virtual T apply(bool &) const = 0;
225 virtual T apply(std::vector<double> &) const = 0;
226
228 template <typename T1> void evaluateValidator(T1 &inputData) const {
229 if (m_validator != nullptr) {
230 ValidatorEvaluator::evaluate(inputData, m_validator);
231 }
232 }
233
236 };
237
241 template <typename T = void> class DLLExport ConstAttributeVisitor : public boost::static_visitor<T> {
242 public:
244 virtual ~ConstAttributeVisitor() = default;
246 T operator()(const std::string &str) const { return apply(str); }
248 T operator()(const double &d) const { return apply(d); }
250 T operator()(const int &i) const { return apply(i); }
252 T operator()(const bool &b) const { return apply(b); }
254 T operator()(const std::vector<double> &v) const { return apply(v); }
255
256 protected:
258 virtual T apply(const std::string &str) const = 0;
260 virtual T apply(const double &d) const = 0;
262 virtual T apply(const int &i) const = 0;
264 virtual T apply(const bool &i) const = 0;
266 virtual T apply(const std::vector<double> &) const = 0;
267
269 template <typename T1> void evaluateValidator(T1 &inputData) const {
270 if (m_validator != nullptr) {
271 ValidatorEvaluator::evaluate(inputData, m_validator);
272 }
273 }
274
277 };
278
282 class MANTID_API_DLL Attribute {
283 public:
285 explicit Attribute() : m_data(std::string()), m_quoteValue(false) {}
287 explicit Attribute(const std::string &str, bool quoteValue = false) : m_data(str), m_quoteValue(quoteValue) {}
289 explicit Attribute(const int &i) : m_data(i), m_quoteValue(false) {}
291 explicit Attribute(const double &d) : m_data(d), m_quoteValue(false) {}
293 explicit Attribute(const bool &b) : m_data(b), m_quoteValue(false) {}
295 explicit Attribute(const char *c) : m_data(std::string(c)), m_quoteValue(false) {}
297 explicit Attribute(const std::vector<double> &v) : m_data(v), m_quoteValue(false) {}
298
300 template <typename T> T apply(AttributeVisitor<T> &v) { return boost::apply_visitor(v, m_data); }
302 template <typename T> T apply(ConstAttributeVisitor<T> &v) const { return boost::apply_visitor(v, m_data); }
304 template <typename... Ts> void apply(AttributeLambdaVisitor<Ts...> &v) { boost::apply_visitor(v, m_data); }
305
307 void setValidator(const Kernel::IValidator_sptr &validator) const;
309 void evaluateValidator() const;
311 template <typename T> void evaluateValidator(T &inputData) const {
312 if (m_validator != nullptr) {
313 ValidatorEvaluator::evaluate(inputData, m_validator);
314 }
315 }
318
320 std::string type() const;
322 std::string value() const;
325 std::string asString() const;
328 std::string asQuotedString() const;
330 std::string asUnquotedString() const;
332 int asInt() const;
335 double asDouble() const;
337 bool asBool() const;
339 std::vector<double> asVector() const;
341 bool isEmpty() const;
342
344 void setString(const std::string &str);
346 void setDouble(const double &);
348 void setInt(const int &);
350 void setBool(const bool &);
352 void setVector(const std::vector<double> &);
353 // Set value
354 template <typename T> void setValue(const T &v) {
355 evaluateValidator(v);
356
357 m_data = v;
358 }
360 void fromString(const std::string &str);
361
362 private:
364 mutable boost::variant<std::string, int, double, bool, std::vector<double>> m_data;
366 bool m_quoteValue = false;
369 };
370
377 template <typename T = void> class DLLExport AttributeValidatorVisitor : public boost::static_visitor<T> {
378 public:
379 AttributeValidatorVisitor(const IFunction::Attribute *attrToValidate) : m_attrToValidate{attrToValidate} {}
380
382 T operator()(std::string &str) const { m_attrToValidate->evaluateValidator(str); }
384 T operator()(double &d) const { m_attrToValidate->evaluateValidator(d); }
386 T operator()(int &i) const { m_attrToValidate->evaluateValidator(i); }
388 T operator()(bool &b) const { m_attrToValidate->evaluateValidator(b); }
390 T operator()(std::vector<double> &v) const { m_attrToValidate->evaluateValidator(v); }
391
392 protected:
394 };
395
396 //---------------------------------------------------------//
398 IFunction();
400 virtual ~IFunction();
402 IFunction(const IFunction &) = delete;
404 IFunction &operator=(const IFunction &) = delete;
406 virtual std::string name() const = 0;
408 std::string asString() const;
410 virtual std::shared_ptr<IFunction> clone() const;
411
414 virtual void registerFunctionUsage(bool internal);
417 virtual void setWorkspace(std::shared_ptr<const Workspace> ws) { UNUSED_ARG(ws); }
419 virtual void setMatrixWorkspace(std::shared_ptr<const API::MatrixWorkspace> workspace, size_t wi, double startX,
420 double endX);
422 virtual void initialize() { this->init(); }
425 virtual int64_t estimateNoProgressCalls() const { return 1; }
426
428 void setProgressReporter(std::shared_ptr<Kernel::ProgressBase> reporter);
430 void reportProgress(const std::string &msg = "") const;
433 bool cancellationRequestReceived() const;
434
440 virtual const std::string category() const { return "General"; }
442 virtual const std::vector<std::string> categories() const;
445 virtual const std::string categorySeparator() const { return ";"; }
446
451 virtual void function(const FunctionDomain &domain, FunctionValues &values) const = 0;
453 virtual void functionDeriv(const FunctionDomain &domain, Jacobian &jacobian);
454
455 /* @name Callbacks to perform work at various points other than in the
456 * function */
458 virtual void iterationStarting() {}
460 virtual void iterationFinished() {}
461
465 virtual void setParameter(size_t, const double &value, bool explicitlySet = true) = 0;
467 virtual void setParameterDescription(size_t, const std::string &description) = 0;
469 virtual double getParameter(size_t i) const = 0;
471 virtual void setParameter(const std::string &name, const double &value, bool explicitlySet = true) = 0;
473 virtual void setParameterDescription(const std::string &name, const std::string &description) = 0;
475 virtual double getParameter(const std::string &name) const = 0;
477 virtual bool hasParameter(const std::string &name) const = 0;
479 virtual size_t nParams() const = 0;
481 virtual size_t parameterIndex(const std::string &name) const = 0;
483 virtual std::string parameterName(size_t i) const = 0;
485 virtual std::string parameterDescription(size_t i) const = 0;
487 virtual bool isExplicitlySet(size_t i) const = 0;
489 virtual double getError(size_t i) const = 0;
491 virtual double getError(const std::string &name) const = 0;
493 virtual void setError(size_t i, double err) = 0;
495 virtual void setError(const std::string &name, double err) = 0;
496
498 [[nodiscard]] bool isFixed(size_t i) const;
500 [[nodiscard]] bool isFixedByDefault(size_t i) const;
502 void fix(size_t i, bool isDefault = false);
504 void unfix(size_t i);
506 void fixParameter(const std::string &name, bool isDefault = false);
508 void unfixParameter(const std::string &name);
510 void fixAll(bool isDefault = false);
512 void unfixAll();
514 void unfixAllDefault();
516 void fixAllActive(bool isDefault = false);
517
520 virtual size_t getParameterIndex(const ParameterReference &ref) const = 0;
522 [[nodiscard]] std::vector<std::string> getParameterNames() const;
524
529 [[nodiscard]] virtual double activeParameter(size_t i) const;
532 virtual void setActiveParameter(size_t i, double value);
534 [[nodiscard]] virtual std::string nameOfActive(size_t i) const;
536 [[nodiscard]] virtual std::string descriptionOfActive(size_t i) const;
538 [[nodiscard]] bool isActive(size_t i) const;
540
544 virtual void tie(const std::string &parName, const std::string &expr, bool isDefault = false);
546 virtual void addTies(const std::string &ties, bool isDefault = false);
548 virtual void applyTies();
550 virtual void removeTie(const std::string &parName);
552 virtual void clearTies();
554 virtual bool removeTie(size_t i);
556 virtual ParameterTie *getTie(size_t i) const;
558 virtual bool ignoreTie(const ParameterTie &) const { return false; }
560 void sortTies();
562 [[nodiscard]] std::string writeTies() const;
564
568 virtual void addConstraints(const std::string &str, bool isDefault = false);
570 virtual void addConstraint(std::unique_ptr<IConstraint> ic);
572 [[nodiscard]] virtual IConstraint *getConstraint(size_t i) const;
574 virtual void removeConstraint(const std::string &parName);
575 virtual void setConstraintPenaltyFactor(const std::string &parName, const double &c);
577 [[nodiscard]] std::string writeConstraints() const;
579 virtual void clearConstraints();
581
585 [[nodiscard]] virtual size_t nAttributes() const;
587 [[nodiscard]] virtual std::vector<std::string> getAttributeNames() const;
589 [[nodiscard]] virtual std::string attributeName(size_t index) const;
591 [[nodiscard]] virtual Attribute getAttribute(const std::string &name) const;
593 virtual void setAttribute(const std::string &name, const Attribute &);
595 [[nodiscard]] virtual bool hasAttribute(const std::string &name) const;
597 template <typename T> void setAttributeValue(const std::string &attName, const T &value) {
598 // Since we can't know T and we would rather not create a universal setter
599 // copy and replace in-place
600 auto attr = getAttribute(attName);
601 attr.setValue(value);
602 setAttribute(attName, attr);
603 }
604 void setAttributeValue(const std::string &attName, const char *value);
605 void setAttributeValue(const std::string &attName, const std::string &value);
607
609 [[nodiscard]] virtual std::shared_ptr<IFunction> getFunction(size_t i) const;
611 [[nodiscard]] virtual std::size_t nFunctions() const { return 0; }
613 virtual void setUpForFit();
615 [[nodiscard]] virtual size_t getValuesSize(const FunctionDomain &domain) const;
617 [[nodiscard]] virtual size_t getNumberDomains() const;
619 [[nodiscard]] virtual std::vector<std::shared_ptr<IFunction>> createEquivalentFunctions() const;
621 void calNumericalDeriv(const FunctionDomain &domain, Jacobian &jacobian);
623 [[nodiscard]] double calculateStepSize(const double parameterValue) const;
625 void setCovarianceMatrix(const std::shared_ptr<Kernel::Matrix<double>> &covar);
627 std::shared_ptr<const Kernel::Matrix<double>> getCovarianceMatrix() const { return m_covar; }
629 void setReducedChiSquared(double chi2) { m_chiSquared = chi2; }
631 [[nodiscard]] double getReducedChiSquared() const { return m_chiSquared; }
632
634 void setParallel(bool on) { m_isParallel = on; }
636 [[nodiscard]] bool isParallel() const { return m_isParallel; }
637
639 void setHandler(std::unique_ptr<FunctionHandler> handler);
641 [[nodiscard]] FunctionHandler *getHandler() const { return m_handler.get(); }
642
649 enum ParameterStatus { Active, Fixed, FixedByDefault, Tied };
651 virtual void setParameterStatus(size_t i, ParameterStatus status) = 0;
653 [[nodiscard]] virtual ParameterStatus getParameterStatus(size_t i) const = 0;
654
658 enum class StepSizeMethod { DEFAULT, SQRT_EPSILON };
660 virtual void setStepSizeMethod(const StepSizeMethod method);
661
662protected:
664 virtual void init();
666 virtual void declareParameter(const std::string &name, double initValue = 0, const std::string &description = "") = 0;
667
669 [[nodiscard]] double convertValue(double value, Kernel::Unit_sptr &outUnit,
670 const std::shared_ptr<const MatrixWorkspace> &ws, size_t wsIndex) const;
671
672 void convertValue(std::vector<double> &values, Kernel::Unit_sptr &outUnit,
673 const std::shared_ptr<const MatrixWorkspace> &ws, size_t wsIndex) const;
674
676 virtual void declareAttributes() {}
678 virtual void declareParameters() {}
679
681 void declareAttribute(const std::string &name, const API::IFunction::Attribute &defaultValue);
683 void declareAttribute(const std::string &name, const API::IFunction::Attribute &defaultValue,
684 const Kernel::IValidator &validator);
686 void checkAttributeName(const std::string &name);
688 void storeAttributeValue(const std::string &name, const API::IFunction::Attribute &value);
690 void storeReadOnlyAttribute(const std::string &name, const API::IFunction::Attribute &value) const;
692 virtual void addTie(std::unique_ptr<ParameterTie> tie);
693 [[nodiscard]] bool hasOrderedTies() const;
694 void applyOrderedTies();
696 [[nodiscard]] virtual std::string writeToString(const std::string &parentLocalAttributesStr = "") const;
697
698 friend class ParameterTie;
699 friend class CompositeFunction;
701 friend class FunctionGenerator;
702
705
707 std::unique_ptr<FunctionHandler> m_handler;
708
710 std::shared_ptr<Kernel::ProgressBase> m_progReporter;
711
712private:
714 std::map<std::string, API::IFunction::Attribute> m_attrs;
716 std::shared_ptr<Kernel::Matrix<double>> m_covar;
720 std::vector<std::unique_ptr<ParameterTie>> m_ties;
722 std::vector<std::unique_ptr<IConstraint>> m_constraints;
724 std::vector<ParameterTie *> m_orderedTies;
726 bool m_isRegistered{false};
728 std::function<double(const double)> m_stepSizeFunction;
729};
730
732using IFunction_sptr = std::shared_ptr<IFunction>;
734using IFunction_const_sptr = std::shared_ptr<const IFunction>;
735
744public:
751 virtual ~FunctionHandler() = default;
753 virtual void init() = 0;
755 IFunction_sptr function() const { return m_fun; }
756
757protected:
759};
760
761} // namespace API
762} // namespace Mantid
Kernel::IValidator_sptr m_validator
Definition: IFunction.cpp:964
double value
The value of the point.
Definition: FitMW.cpp:51
double error
Definition: IndexPeaks.cpp:133
IPeaksWorkspace_sptr workspace
Definition: IndexPeaks.cpp:114
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
#define DLLExport
Definitions of the DLLImport compiler directives for MSVC.
Definition: System.h:53
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
Definition: System.h:64
const std::vector< Type > & m_data
Definition: TableColumn.h:417
A composite function is a function containing other functions.
Base class that represents the domain of a function.
FunctionGenerator is a partial implementation of IFunction that defines a function consisting of two ...
Classes inherited from FunctionHandler will handle the function.
Definition: IFunction.h:743
FunctionHandler & operator=(const FunctionHandler &)=delete
virtual ~FunctionHandler()=default
Virtual destructor.
IFunction_sptr function() const
Return the handled function.
Definition: IFunction.h:755
FunctionHandler(const FunctionHandler &)=delete
Delete copy constructor and copy assignment operator.
virtual void init()=0
abstract init method. It is called after setting handler to the function
IFunction_sptr m_fun
pointer to the handled function
Definition: IFunction.h:758
FunctionHandler(IFunction_sptr fun)
Constructor.
Definition: IFunction.h:746
A class to store values calculated by a function.
An interface to a constraint.
Definition: IConstraint.h:26
Atribute validator visitor class.
Definition: IFunction.h:377
T operator()(int &i) const
implements static_visitor's operator() for int
Definition: IFunction.h:386
T operator()(std::vector< double > &v) const
implements static_visitor's operator() for vector
Definition: IFunction.h:390
AttributeValidatorVisitor(const IFunction::Attribute *attrToValidate)
Definition: IFunction.h:379
const IFunction::Attribute * m_attrToValidate
Definition: IFunction.h:393
T operator()(double &d) const
implements static_visitor's operator() for double
Definition: IFunction.h:384
T operator()(std::string &str) const
implements static_visitor's operator() for std::string
Definition: IFunction.h:382
T operator()(bool &b) const
implements static_visitor's operator() for bool
Definition: IFunction.h:388
virtual T apply(bool &) const =0
Implement this method to access attribute as bool.
virtual ~AttributeVisitor()=default
Virtual destructor.
T operator()(bool &b) const
implements static_visitor's operator() for bool
Definition: IFunction.h:211
virtual T apply(int &) const =0
Implement this method to access attribute as int.
T operator()(double &d) const
implements static_visitor's operator() for double
Definition: IFunction.h:207
virtual T apply(std::vector< double > &) const =0
Implement this method to access attribute as vector.
void evaluateValidator(T1 &inputData) const
Evaluates the validator associated with attribute this visitor is to visit.
Definition: IFunction.h:228
T operator()(std::string &str) const
implements static_visitor's operator() for std::string
Definition: IFunction.h:205
virtual T apply(std::string &) const =0
Implement this method to access attribute as string.
T operator()(std::vector< double > &v) const
implements static_visitor's operator() for vector
Definition: IFunction.h:213
virtual T apply(double &) const =0
Implement this method to access attribute as double.
T operator()(int &i) const
implements static_visitor's operator() for int
Definition: IFunction.h:209
Attribute is a non-fitting parameter.
Definition: IFunction.h:282
Attribute(const bool &b)
Create bool attribute.
Definition: IFunction.h:293
Attribute(const int &i)
Create int attribute.
Definition: IFunction.h:289
Attribute(const double &d)
Create double attribute.
Definition: IFunction.h:291
Kernel::IValidator_sptr getValidator()
Return a clone of the attribute validator;.
Definition: IFunction.h:317
T apply(AttributeVisitor< T > &v)
Apply an attribute visitor.
Definition: IFunction.h:300
Attribute()
Create empty string attribute.
Definition: IFunction.h:285
void evaluateValidator(T &inputData) const
Evaluates the validator associated with this attribute with regards to input value....
Definition: IFunction.h:311
Kernel::IValidator_sptr m_validator
Associated Validator.
Definition: IFunction.h:368
boost::variant< std::string, int, double, bool, std::vector< double > > m_data
The data holder as boost variant.
Definition: IFunction.h:364
Attribute(const std::string &str, bool quoteValue=false)
Create string attribute.
Definition: IFunction.h:287
void apply(AttributeLambdaVisitor< Ts... > &v)
Apply a lambda visitor.
Definition: IFunction.h:304
Attribute(const char *c)
Create string attribute.
Definition: IFunction.h:295
T apply(ConstAttributeVisitor< T > &v) const
Apply a const attribute visitor.
Definition: IFunction.h:302
Attribute(const std::vector< double > &v)
Create vector attribute.
Definition: IFunction.h:297
Const version of AttributeVisitor.
Definition: IFunction.h:241
T operator()(const int &i) const
implements static_visitor's operator() for int
Definition: IFunction.h:250
virtual T apply(const double &d) const =0
Implement this mathod to access attribute as double.
virtual T apply(const std::string &str) const =0
Implement this mathod to access attribute as string.
T operator()(const double &d) const
implements static_visitor's operator() for double
Definition: IFunction.h:248
virtual T apply(const bool &i) const =0
Implement this mathod to access attribute as bool.
T operator()(const std::vector< double > &v) const
implements static_visitor's operator() for vector
Definition: IFunction.h:254
T operator()(const std::string &str) const
implements static_visitor's operator() for std::string
Definition: IFunction.h:246
T operator()(const bool &b) const
implements static_visitor's operator() for bool
Definition: IFunction.h:252
virtual ~ConstAttributeVisitor()=default
Virtual destructor.
void evaluateValidator(T1 &inputData) const
Evaluates the validator associated with attribute this visitor is to visit.
Definition: IFunction.h:269
virtual T apply(const int &i) const =0
Implement this mathod to access attribute as int.
virtual T apply(const std::vector< double > &) const =0
Implement this mathod to access attribute as vector.
This is an interface to a fitting function - a semi-abstarct class.
Definition: IFunction.h:163
virtual size_t nParams() const =0
Total number of parameters.
std::function< double(const double)> m_stepSizeFunction
The function used to calculate the step size.
Definition: IFunction.h:728
virtual void setParameterDescription(size_t, const std::string &description)=0
Set i-th parameter description.
virtual void setWorkspace(std::shared_ptr< const Workspace > ws)
Set the workspace.
Definition: IFunction.h:417
std::shared_ptr< const Kernel::Matrix< double > > getCovarianceMatrix() const
Get the covariance matrix.
Definition: IFunction.h:627
virtual double getParameter(size_t i) const =0
Get i-th parameter.
bool m_isParallel
Flag to hint that the function is being used in parallel computations.
Definition: IFunction.h:704
virtual void initialize()
Iinialize the function.
Definition: IFunction.h:422
virtual void iterationFinished()
Called at the end of an iteration.
Definition: IFunction.h:460
IFunction & operator=(const IFunction &)=delete
No copying.
ParameterStatus
Describe parameter status in relation to fitting: Active: Fit varies such parameter directly.
Definition: IFunction.h:649
FunctionHandler * getHandler() const
Return the handler.
Definition: IFunction.h:641
std::map< std::string, API::IFunction::Attribute > m_attrs
The declared attributes.
Definition: IFunction.h:714
double getReducedChiSquared() const
Get the reduced chi^2.
Definition: IFunction.h:631
virtual void declareAttributes()
Override to declare function attributes.
Definition: IFunction.h:676
virtual ParameterStatus getParameterStatus(size_t i) const =0
Get status of parameter.
virtual bool hasParameter(const std::string &name) const =0
Check if function has a parameter with this name.
virtual void setParameter(size_t, const double &value, bool explicitlySet=true)=0
Set i-th parameter.
virtual const std::string category() const
The categories the Fit function belong to.
Definition: IFunction.h:440
virtual int64_t estimateNoProgressCalls() const
Returns an estimate of the number of progress reports a single evaluation of the function will have.
Definition: IFunction.h:425
virtual const std::string categorySeparator() const
Function to return the sperator token for the category string.
Definition: IFunction.h:445
void setParallel(bool on)
Set the parallel hint.
Definition: IFunction.h:634
virtual void setParameterDescription(const std::string &name, const std::string &description)=0
Set description of parameter by name.
virtual size_t getParameterIndex(const ParameterReference &ref) const =0
Return parameter index from a parameter reference.
void setReducedChiSquared(double chi2)
Set the reduced chi^2.
Definition: IFunction.h:629
virtual void setError(size_t i, double err)=0
Set the fitting error for a parameter.
virtual std::string parameterDescription(size_t i) const =0
Returns the description of parameter i.
virtual void iterationStarting()
Called at the start of each iteration.
Definition: IFunction.h:458
std::vector< ParameterTie * > m_orderedTies
Ties ordered in order of correct application.
Definition: IFunction.h:724
virtual std::string parameterName(size_t i) const =0
Returns the name of parameter i.
virtual std::string name() const =0
Returns the function's name.
std::vector< std::unique_ptr< ParameterTie > > m_ties
Holds parameter ties.
Definition: IFunction.h:720
std::shared_ptr< Kernel::ProgressBase > m_progReporter
Pointer to the progress handler.
Definition: IFunction.h:710
bool isParallel() const
Get the parallel hint.
Definition: IFunction.h:636
std::vector< std::unique_ptr< IConstraint > > m_constraints
Holds the constraints added to function.
Definition: IFunction.h:722
virtual void setParameterStatus(size_t i, ParameterStatus status)=0
Change status of parameter.
virtual void function(const FunctionDomain &domain, FunctionValues &values) const =0
Evaluates the function for all arguments in the domain.
virtual size_t parameterIndex(const std::string &name) const =0
Returns the index of parameter name.
void setAttributeValue(const std::string &attName, const T &value)
Set an attribute value.
Definition: IFunction.h:597
virtual double getError(size_t i) const =0
Get the fitting error for a parameter.
virtual void declareParameters()
Override to declare function parameters.
Definition: IFunction.h:678
virtual bool ignoreTie(const ParameterTie &) const
Ignore a tie.
Definition: IFunction.h:558
virtual bool isExplicitlySet(size_t i) const =0
Checks if a parameter has been set explicitly.
virtual double getError(const std::string &name) const =0
Get the fitting error for a parameter by name.
std::unique_ptr< FunctionHandler > m_handler
Pointer to a function handler.
Definition: IFunction.h:707
virtual double getParameter(const std::string &name) const =0
Get parameter by name.
virtual void declareParameter(const std::string &name, double initValue=0, const std::string &description="")=0
Declare a new parameter.
virtual void setError(const std::string &name, double err)=0
Set the fitting error for a parameter by name.
virtual std::size_t nFunctions() const
Number of child functions.
Definition: IFunction.h:611
double m_chiSquared
The chi-squared of the last fit.
Definition: IFunction.h:718
StepSizeMethod
Describes the method in which the step size will be calculated: DEFAULT: Uses the traditional Mantid ...
Definition: IFunction.h:658
IFunction(const IFunction &)=delete
No copying.
virtual void setParameter(const std::string &name, const double &value, bool explicitlySet=true)=0
Set parameter by name.
std::shared_ptr< Kernel::Matrix< double > > m_covar
The covariance matrix of the fitting parameters.
Definition: IFunction.h:716
Represents the Jacobian in IFitFunction::functionDeriv.
Definition: Jacobian.h:22
A reference to a parameter in a function.
Ties fitting parameters.
Definition: ParameterTie.h:35
IValidator is the basic interface for all validators for properties.
Definition: IValidator.h:43
Numerical Matrix class.
Definition: Matrix.h:42
std::shared_ptr< IFunction > IFunction_sptr
shared pointer to the function base class
Definition: IFunction.h:732
std::shared_ptr< const IFunction > IFunction_const_sptr
shared pointer to the function base class (const version)
Definition: IFunction.h:734
std::shared_ptr< Unit > Unit_sptr
Shared pointer to the Unit base class.
Definition: Unit.h:229
std::shared_ptr< IValidator > IValidator_sptr
A shared_ptr to an IValidator.
Definition: IValidator.h:26
Helper class which provides the Collimation Length for SANS instruments.
STL namespace.
Attribute visitor structure supporting lambda expressions Example usage: AttributeLambdaVisitor{[](co...
Definition: IFunction.h:55
Simple Exception Struct to differentiate validation error from other exceptions.
Definition: IFunction.h:168
ValidationException(const std::string &ErrorMsg)
Definition: IFunction.h:170
Simple struct to constain function to evaluate attribute validators that is required in both attribut...
Definition: IFunction.h:177
static void evaluate(T1 &inputData, Mantid::Kernel::IValidator_sptr validator)
Definition: IFunction.h:180