Mantid
Loading...
Searching...
No Matches
CalculateCostFunction.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 +
8
12
14
15using namespace Kernel;
16using namespace API;
17
18// Register the algorithm into the AlgorithmFactory
19DECLARE_ALGORITHM(CalculateCostFunction)
20
21//----------------------------------------------------------------------------------------------
22
23
24const std::string CalculateCostFunction::name() const { return "CalculateCostFunction"; }
25
27int CalculateCostFunction::version() const { return 1; }
28
30const std::string CalculateCostFunction::summary() const {
31 return "Calculate cost function for a function and a data set in a "
32 "workspace.";
33}
34
35//----------------------------------------------------------------------------------------------
37void CalculateCostFunction::initConcrete() {
39 declareProperty("Value", 0.0, "Output value of the cost function.", Direction::Output);
40}
41
42//----------------------------------------------------------------------------------------------
44void CalculateCostFunction::execConcrete() {
45
46 if (!m_costFunction) {
48 }
49
50 // Get the result.
51 double value = m_costFunction->val();
52 // Store the result.
53 setProperty("Value", value);
54}
55
56} // namespace Mantid::CurveFitting::Algorithms
#define DECLARE_ALGORITHM(classname)
Definition: Algorithm.h:576
double value
The value of the point.
Definition: FitMW.cpp:51
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
Definition: Algorithm.cpp:1913
Calculate cost function for a function and a data set in a workspace.
std::shared_ptr< CostFunctions::CostFuncFitting > m_costFunction
Cache for the cost function.
void declareCostFunctionProperty()
Declare a "CostFunction" property.
std::shared_ptr< CostFunctions::CostFuncFitting > getCostFunctionInitialized() const
Create a cost function from the "CostFunction" property and make it ready for evaluation.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
STL namespace.
@ Output
An output workspace.
Definition: Property.h:54