Mantid
|
A boundary constraint is designed to be used to set either upper or lower (or both) boundaries on a single parameter. More...
#include <BoundaryConstraint.h>
Public Member Functions | |
std::string | asString () const override |
Return the string that can be used in this->initialize() to recreate this constraint. More... | |
BoundaryConstraint () | |
Default constructor. More... | |
BoundaryConstraint (API::IFunction *fun, const std::string ¶mName, const double lowerBound, bool isDefault=false) | |
Constructor with lower boundary argument. More... | |
BoundaryConstraint (API::IFunction *fun, const std::string ¶mName, const double lowerBound, const double upperBound, bool isDefault=false) | |
Constructor with boundary arguments. More... | |
BoundaryConstraint (const std::string ¶mName) | |
Constructor with no boundary arguments. More... | |
double | check () override |
Get parameter name. More... | |
double | checkDeriv () override |
Returns the derivative of the penalty for each active parameter. More... | |
double | checkDeriv2 () override |
Returns the derivative of the penalty for each active parameter. More... | |
void | clearBounds () |
Clear both bounds (lower and upper) at the same time. More... | |
void | clearLower () |
Clear lower bound value. More... | |
void | clearUpper () |
Clear upper bound value. More... | |
double | getPenaltyFactor () const override |
get the penalty factor for the constraint More... | |
bool | hasLower () const |
Return if it has a lower bound. More... | |
bool | hasUpper () const |
Return if it has a lower bound. More... | |
void | initialize (API::IFunction *fun, const API::Expression &expr, bool isDefault) override |
Initialize the constraint from an expression. More... | |
const double & | lower () const |
Return the lower bound value. More... | |
void | setBounds (const double &lower, const double &upper) |
Set both bounds (lower and upper) at the same time. More... | |
void | setLower (const double &value) |
Set lower bound value. More... | |
void | setParamToSatisfyConstraint () override |
Set the parameters of IFitFunction to satisfy constraint. More... | |
void | setPenaltyFactor (const double &c) override |
implement IConstraint virtual functions More... | |
void | setUpper (const double &value) |
Set upper bound value. More... | |
const double & | upper () const |
Return the upper bound value. More... | |
virtual std::string | asString () const =0 |
Return the string that can be used in this->initialize() to recreate this constraint. More... | |
virtual double | check ()=0 |
Returns a penalty number which is bigger than or equal to zero If zero it means that the constraint is not penalized. More... | |
virtual double | checkDeriv ()=0 |
Returns the derivative of the penalty for each active parameter. More... | |
virtual double | checkDeriv2 ()=0 |
Returns the derivative of the penalty for each active parameter. More... | |
virtual double | getPenaltyFactor () const =0 |
get the penalty factor for the constraint More... | |
virtual void | initialize (IFunction *fun, const Expression &expr, bool isDefault=false)=0 |
Initialize the constraint from an expression. More... | |
virtual void | setParamToSatisfyConstraint ()=0 |
Set the parameters of IFitFunction to satisfy constraint. More... | |
virtual void | setPenaltyFactor (const double &c)=0 |
set the penalty factor for the constraint Set panelty factor. More... | |
Public Member Functions inherited from Mantid::API::ParameterReference | |
IFunction * | getLocalFunction () const |
Return pointer to the local function. More... | |
std::size_t | getLocalIndex () const |
Return parameter index in the local function. More... | |
double | getParameter () const |
Get the value of the parameter. More... | |
bool | isDefault () const |
Returns the default value flag. More... | |
bool | isParameterOf (const IFunction *fun) const |
Find out if this refers to a parameter of a function: direct or via composite function member. More... | |
IFunction * | ownerFunction () const |
std::size_t | parameterIndex () const |
Return parameter index in the owning function. More... | |
std::string | parameterName () const |
Return parameter name in the owning function. More... | |
ParameterReference () | |
Default constructor. More... | |
ParameterReference (IFunction *fun, std::size_t index, bool isDefault=false) | |
Constructor. More... | |
void | setParameter (const double &value, bool isExplicitlySet=true) |
Set the parameter. More... | |
virtual | ~ParameterReference ()=default |
Private Attributes | |
bool | m_hasLowerBound |
name of parameter you want to constraint More... | |
bool | m_hasUpperBound |
has a upper bound set true/false More... | |
double | m_lowerBound |
the lower bound More... | |
double | m_penaltyFactor |
Penalty factor for the given boundary constraint. More... | |
double | m_upperBound |
the upper bound More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from Mantid::API::IConstraint | |
static double | getDefaultPenaltyFactor () |
Return the value for default fitting penalties. More... | |
Protected Member Functions inherited from Mantid::API::ParameterReference | |
void | reset (IFunction *fun, std::size_t index, bool isDefault=false) |
Reset the reference. More... | |
Static Protected Attributes inherited from Mantid::API::IConstraint | |
static constexpr double | m_defaultPenaltyFactor = 1000 |
default penalty factor for constraints More... | |
A boundary constraint is designed to be used to set either upper or lower (or both) boundaries on a single parameter.
Definition at line 29 of file BoundaryConstraint.h.
Mantid::CurveFitting::Constraints::BoundaryConstraint::BoundaryConstraint | ( | ) |
Default constructor.
Definition at line 29 of file BoundaryConstraint.cpp.
Mantid::CurveFitting::Constraints::BoundaryConstraint::BoundaryConstraint | ( | const std::string & | paramName | ) |
Constructor with no boundary arguments.
paramName | :: The parameter name |
Definition at line 35 of file BoundaryConstraint.cpp.
References UNUSED_ARG.
Mantid::CurveFitting::Constraints::BoundaryConstraint::BoundaryConstraint | ( | API::IFunction * | fun, |
const std::string & | paramName, | ||
const double | lowerBound, | ||
const double | upperBound, | ||
bool | isDefault = false |
||
) |
Constructor with boundary arguments.
fun | :: The function |
paramName | :: The parameter name |
lowerBound | :: The lower bound |
upperBound | :: The upper bound |
isDefault | :: Flag to mark as default the value of an object associated with this reference: a tie or a constraint. |
Definition at line 49 of file BoundaryConstraint.cpp.
References Mantid::API::ParameterReference::isDefault(), Mantid::API::IFunction::parameterIndex(), and Mantid::API::ParameterReference::reset().
Mantid::CurveFitting::Constraints::BoundaryConstraint::BoundaryConstraint | ( | API::IFunction * | fun, |
const std::string & | paramName, | ||
const double | lowerBound, | ||
bool | isDefault = false |
||
) |
Constructor with lower boundary argument.
Definition at line 56 of file BoundaryConstraint.cpp.
References Mantid::API::ParameterReference::isDefault(), Mantid::API::IFunction::parameterIndex(), and Mantid::API::ParameterReference::reset().
|
overridevirtual |
Return the string that can be used in this->initialize() to recreate this constraint.
Implements Mantid::API::IConstraint.
Definition at line 240 of file BoundaryConstraint.cpp.
References Mantid::API::IConstraint::getDefaultPenaltyFactor(), m_hasLowerBound, m_hasUpperBound, m_lowerBound, m_penaltyFactor, m_upperBound, and Mantid::API::ParameterReference::parameterName().
|
overridevirtual |
Get parameter name.
overwrite IConstraint base class methods
Implements Mantid::API::IConstraint.
Definition at line 166 of file BoundaryConstraint.cpp.
References Mantid::API::g_log, Mantid::API::ParameterReference::getParameter(), m_hasLowerBound, m_hasUpperBound, m_lowerBound, m_penaltyFactor, m_upperBound, Mantid::API::ParameterReference::parameterName(), and Mantid::Kernel::Logger::warning().
|
overridevirtual |
Returns the derivative of the penalty for each active parameter.
Implements Mantid::API::IConstraint.
Definition at line 192 of file BoundaryConstraint.cpp.
References Mantid::API::ParameterReference::getParameter(), m_hasLowerBound, m_hasUpperBound, m_lowerBound, m_penaltyFactor, and m_upperBound.
|
overridevirtual |
Returns the derivative of the penalty for each active parameter.
Implements Mantid::API::IConstraint.
Definition at line 218 of file BoundaryConstraint.cpp.
References Mantid::API::ParameterReference::getParameter(), m_hasLowerBound, m_hasUpperBound, m_lowerBound, m_penaltyFactor, and m_upperBound.
|
inline |
Clear both bounds (lower and upper) at the same time.
Definition at line 89 of file BoundaryConstraint.h.
Referenced by initialize().
|
inline |
Clear lower bound value.
Definition at line 72 of file BoundaryConstraint.h.
|
inline |
Clear upper bound value.
Definition at line 77 of file BoundaryConstraint.h.
|
inlineoverridevirtual |
get the penalty factor for the constraint
Implements Mantid::API::IConstraint.
Definition at line 50 of file BoundaryConstraint.h.
|
inline |
Return if it has a lower bound.
Definition at line 53 of file BoundaryConstraint.h.
|
inline |
Return if it has a lower bound.
Definition at line 55 of file BoundaryConstraint.h.
|
overridevirtual |
Initialize the constraint from an expression.
fun | :: The function |
expr | :: The initializing expression which must look like this: " 10 < Sigma < 20 " or " Sigma > 20 " |
isDefault | :: Flag to mark as default the value of an object associated with this reference: a tie or a constraint. |
Implements Mantid::API::IConstraint.
Definition at line 72 of file BoundaryConstraint.cpp.
References clearBounds(), Mantid::Geometry::d, Mantid::Kernel::Logger::error(), Mantid::API::g_log, Mantid::API::ParameterReference::isDefault(), Mantid::API::Expression::name(), Mantid::API::IFunction::name(), Mantid::API::Expression::operator_name(), Mantid::API::IFunction::parameterIndex(), Mantid::API::ParameterReference::reset(), setLower(), setUpper(), Mantid::API::Expression::size(), and Mantid::API::Expression::str().
|
inline |
Return the lower bound value.
Definition at line 57 of file BoundaryConstraint.h.
|
inline |
Set both bounds (lower and upper) at the same time.
Definition at line 83 of file BoundaryConstraint.h.
|
inline |
Set lower bound value.
Definition at line 62 of file BoundaryConstraint.h.
References value.
Referenced by initialize().
|
overridevirtual |
Set the parameters of IFitFunction to satisfy constraint.
For example for a BoundaryConstraint this if param value less than lower boundary it is set to that value and vice versa for if the param value is larger than the upper boundary value.
Implements Mantid::API::IConstraint.
Definition at line 150 of file BoundaryConstraint.cpp.
References Mantid::API::g_log, Mantid::API::ParameterReference::getParameter(), m_hasLowerBound, m_hasUpperBound, m_lowerBound, m_upperBound, Mantid::API::ParameterReference::parameterName(), Mantid::API::ParameterReference::setParameter(), and Mantid::Kernel::Logger::warning().
|
overridevirtual |
implement IConstraint virtual functions
Set penalty factor.
c | :: penalty factor |
Implements Mantid::API::IConstraint.
Definition at line 140 of file BoundaryConstraint.cpp.
References Mantid::API::g_log, m_penaltyFactor, and Mantid::Kernel::Logger::warning().
|
inline |
Set upper bound value.
Definition at line 67 of file BoundaryConstraint.h.
References value.
Referenced by initialize().
|
inline |
Return the upper bound value.
Definition at line 59 of file BoundaryConstraint.h.
|
private |
name of parameter you want to constraint
has a lower bound set true/false
Definition at line 112 of file BoundaryConstraint.h.
Referenced by asString(), check(), checkDeriv(), checkDeriv2(), and setParamToSatisfyConstraint().
|
private |
has a upper bound set true/false
Definition at line 114 of file BoundaryConstraint.h.
Referenced by asString(), check(), checkDeriv(), checkDeriv2(), and setParamToSatisfyConstraint().
|
private |
the lower bound
Definition at line 116 of file BoundaryConstraint.h.
Referenced by asString(), check(), checkDeriv(), checkDeriv2(), and setParamToSatisfyConstraint().
|
private |
Penalty factor for the given boundary constraint.
Definition at line 106 of file BoundaryConstraint.h.
Referenced by asString(), check(), checkDeriv(), checkDeriv2(), and setPenaltyFactor().
|
private |
the upper bound
Definition at line 118 of file BoundaryConstraint.h.
Referenced by asString(), check(), checkDeriv(), checkDeriv2(), and setParamToSatisfyConstraint().