Mantid
Loading...
Searching...
No Matches
BoundaryConstraint.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 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//----------------------------------------------------------------------
13#include "MantidCurveFitting/DllConfig.h"
14
15namespace Mantid {
16namespace CurveFitting {
17namespace Constraints {
18//----------------------------------------------------------------------
19// Forward Declaration
20//----------------------------------------------------------------------
21
29class MANTID_CURVEFITTING_DLL BoundaryConstraint : public API::IConstraint {
30public:
33
35 BoundaryConstraint(const std::string &paramName);
36
38 BoundaryConstraint(API::IFunction *fun, const std::string &paramName, const double lowerBound,
39 const double upperBound, bool isDefault = false);
40
42 BoundaryConstraint(API::IFunction *fun, const std::string &paramName, const double lowerBound,
43 bool isDefault = false);
44
46 void initialize(API::IFunction *fun, const API::Expression &expr, bool isDefault) override;
47
49 void setPenaltyFactor(const double &c) override;
50 double getPenaltyFactor() const override { return m_penaltyFactor; }
51
53 bool hasLower() const { return m_hasLowerBound; }
55 bool hasUpper() const { return m_hasUpperBound; }
57 const double &lower() const { return m_lowerBound; }
59 const double &upper() const { return m_upperBound; }
60
62 void setLower(const double &value) {
63 m_hasLowerBound = true;
64 m_lowerBound = value;
65 }
67 void setUpper(const double &value) {
68 m_hasUpperBound = true;
69 m_upperBound = value;
70 }
72 void clearLower() {
73 m_hasLowerBound = false;
74 m_lowerBound = double();
75 }
77 void clearUpper() {
78 m_hasUpperBound = false;
79 m_upperBound = double();
80 }
81
83 void setBounds(const double &lower, const double &upper) {
84 setLower(lower);
85 setUpper(upper);
86 }
87
89 void clearBounds() {
90 clearLower();
91 clearUpper();
92 }
93
95 // std::string getParameterName() const { return m_parameterName; }
96
98 double check() override;
99 double checkDeriv() override;
100 double checkDeriv2() override;
101 void setParamToSatisfyConstraint() override;
102 std::string asString() const override;
103
104private:
107
109 // std::string m_parameterName;
110
119};
120
121} // namespace Constraints
122} // namespace CurveFitting
123} // namespace Mantid
double value
The value of the point.
Definition: FitMW.cpp:51
double lower
lower and upper bounds on the multiplier, if known
double upper
This class represents an expression made up of names, binary operators and brackets.
Definition: Expression.h:36
An interface to a constraint.
Definition: IConstraint.h:26
This is an interface to a fitting function - a semi-abstarct class.
Definition: IFunction.h:163
A boundary constraint is designed to be used to set either upper or lower (or both) boundaries on a s...
bool m_hasLowerBound
name of parameter you want to constraint
void setLower(const double &value)
Set lower bound value.
bool m_hasUpperBound
has a upper bound set true/false
double m_penaltyFactor
Penalty factor for the given boundary constraint.
const double & upper() const
Return the upper bound value.
void clearBounds()
Clear both bounds (lower and upper) at the same time.
double getPenaltyFactor() const override
get the penalty factor for the constraint
const double & lower() const
Return the lower bound value.
void setUpper(const double &value)
Set upper bound value.
bool hasLower() const
Return if it has a lower bound.
bool hasUpper() const
Return if it has a lower bound.
void setBounds(const double &lower, const double &upper)
Set both bounds (lower and upper) at the same time.
Helper class which provides the Collimation Length for SANS instruments.