-
Notifications
You must be signed in to change notification settings - Fork 122
/
CalculateCostFunction.cpp
60 lines (47 loc) · 2.06 KB
/
CalculateCostFunction.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#include "MantidCurveFitting/Algorithms/CalculateCostFunction.h"
#include "MantidAPI/CostFunctionFactory.h"
#include "MantidCurveFitting/CostFunctions/CostFuncFitting.h"
#include "MantidKernel/ListValidator.h"
namespace Mantid {
namespace CurveFitting {
namespace Algorithms {
using namespace Kernel;
using namespace API;
// Register the algorithm into the AlgorithmFactory
DECLARE_ALGORITHM(CalculateCostFunction)
//----------------------------------------------------------------------------------------------
/// Algorithms name for identification. @see Algorithm::name
const std::string CalculateCostFunction::name() const { return "CalculateCostFunction"; }
/// Algorithm's version for identification. @see Algorithm::version
int CalculateCostFunction::version() const { return 1; }
/// Algorithm's summary for use in the GUI and help. @see Algorithm::summary
const std::string CalculateCostFunction::summary() const {
return "Calculate cost function for a function and a data set in a "
"workspace.";
}
//----------------------------------------------------------------------------------------------
/// Initialize the algorithm's properties.
void CalculateCostFunction::initConcrete() {
declareCostFunctionProperty();
declareProperty("Value", 0.0, "Output value of the cost function.", Direction::Output);
}
//----------------------------------------------------------------------------------------------
/// Execute the algorithm.
void CalculateCostFunction::execConcrete() {
if (!m_costFunction) {
m_costFunction = getCostFunctionInitialized();
}
// Get the result.
double value = m_costFunction->val();
// Store the result.
setProperty("Value", value);
}
} // namespace Algorithms
} // namespace CurveFitting
} // namespace Mantid