Mantid
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Mantid::CurveFitting::Constraints::BoundaryConstraint Class Reference

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>

Inheritance diagram for Mantid::CurveFitting::Constraints::BoundaryConstraint:
Mantid::API::IConstraint Mantid::API::ParameterReference

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 &paramName, const double lowerBound, bool isDefault=false)
 Constructor with lower boundary argument. More...
 
 BoundaryConstraint (API::IFunction *fun, const std::string &paramName, const double lowerBound, const double upperBound, bool isDefault=false)
 Constructor with boundary arguments. More...
 
 BoundaryConstraint (const std::string &paramName)
 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
IFunctiongetLocalFunction () 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...
 
IFunctionownerFunction () 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...
 

Detailed Description

A boundary constraint is designed to be used to set either upper or lower (or both) boundaries on a single parameter.

Author
Anders Markvardsen, ISIS, RAL
Date
13/11/2009

Definition at line 29 of file BoundaryConstraint.h.

Constructor & Destructor Documentation

◆ BoundaryConstraint() [1/4]

Mantid::CurveFitting::Constraints::BoundaryConstraint::BoundaryConstraint ( )

Default constructor.

Definition at line 29 of file BoundaryConstraint.cpp.

◆ BoundaryConstraint() [2/4]

Mantid::CurveFitting::Constraints::BoundaryConstraint::BoundaryConstraint ( const std::string &  paramName)

Constructor with no boundary arguments.

Parameters
paramName:: The parameter name

Definition at line 35 of file BoundaryConstraint.cpp.

References UNUSED_ARG.

◆ BoundaryConstraint() [3/4]

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.

Parameters
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().

◆ BoundaryConstraint() [4/4]

Mantid::CurveFitting::Constraints::BoundaryConstraint::BoundaryConstraint ( API::IFunction fun,
const std::string &  paramName,
const double  lowerBound,
bool  isDefault = false 
)

Member Function Documentation

◆ asString()

std::string Mantid::CurveFitting::Constraints::BoundaryConstraint::asString ( ) const
overridevirtual

◆ check()

double Mantid::CurveFitting::Constraints::BoundaryConstraint::check ( )
overridevirtual

◆ checkDeriv()

double Mantid::CurveFitting::Constraints::BoundaryConstraint::checkDeriv ( )
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.

◆ checkDeriv2()

double Mantid::CurveFitting::Constraints::BoundaryConstraint::checkDeriv2 ( )
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.

◆ clearBounds()

void Mantid::CurveFitting::Constraints::BoundaryConstraint::clearBounds ( )
inline

Clear both bounds (lower and upper) at the same time.

Definition at line 89 of file BoundaryConstraint.h.

Referenced by initialize().

◆ clearLower()

void Mantid::CurveFitting::Constraints::BoundaryConstraint::clearLower ( )
inline

Clear lower bound value.

Definition at line 72 of file BoundaryConstraint.h.

◆ clearUpper()

void Mantid::CurveFitting::Constraints::BoundaryConstraint::clearUpper ( )
inline

Clear upper bound value.

Definition at line 77 of file BoundaryConstraint.h.

◆ getPenaltyFactor()

double Mantid::CurveFitting::Constraints::BoundaryConstraint::getPenaltyFactor ( ) const
inlineoverridevirtual

get the penalty factor for the constraint

Implements Mantid::API::IConstraint.

Definition at line 50 of file BoundaryConstraint.h.

◆ hasLower()

bool Mantid::CurveFitting::Constraints::BoundaryConstraint::hasLower ( ) const
inline

Return if it has a lower bound.

Definition at line 53 of file BoundaryConstraint.h.

◆ hasUpper()

bool Mantid::CurveFitting::Constraints::BoundaryConstraint::hasUpper ( ) const
inline

Return if it has a lower bound.

Definition at line 55 of file BoundaryConstraint.h.

◆ initialize()

void Mantid::CurveFitting::Constraints::BoundaryConstraint::initialize ( API::IFunction fun,
const API::Expression expr,
bool  isDefault 
)
overridevirtual

Initialize the constraint from an expression.

Parameters
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().

◆ lower()

const double & Mantid::CurveFitting::Constraints::BoundaryConstraint::lower ( ) const
inline

Return the lower bound value.

Definition at line 57 of file BoundaryConstraint.h.

◆ setBounds()

void Mantid::CurveFitting::Constraints::BoundaryConstraint::setBounds ( const double &  lower,
const double &  upper 
)
inline

Set both bounds (lower and upper) at the same time.

Definition at line 83 of file BoundaryConstraint.h.

References lower, and upper.

◆ setLower()

void Mantid::CurveFitting::Constraints::BoundaryConstraint::setLower ( const double &  value)
inline

Set lower bound value.

Definition at line 62 of file BoundaryConstraint.h.

References value.

Referenced by initialize().

◆ setParamToSatisfyConstraint()

void Mantid::CurveFitting::Constraints::BoundaryConstraint::setParamToSatisfyConstraint ( )
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().

◆ setPenaltyFactor()

void Mantid::CurveFitting::Constraints::BoundaryConstraint::setPenaltyFactor ( const double &  c)
overridevirtual

implement IConstraint virtual functions

Set penalty factor.

Parameters
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().

◆ setUpper()

void Mantid::CurveFitting::Constraints::BoundaryConstraint::setUpper ( const double &  value)
inline

Set upper bound value.

Definition at line 67 of file BoundaryConstraint.h.

References value.

Referenced by initialize().

◆ upper()

const double & Mantid::CurveFitting::Constraints::BoundaryConstraint::upper ( ) const
inline

Return the upper bound value.

Definition at line 59 of file BoundaryConstraint.h.

Member Data Documentation

◆ m_hasLowerBound

bool Mantid::CurveFitting::Constraints::BoundaryConstraint::m_hasLowerBound
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().

◆ m_hasUpperBound

bool Mantid::CurveFitting::Constraints::BoundaryConstraint::m_hasUpperBound
private

has a upper bound set true/false

Definition at line 114 of file BoundaryConstraint.h.

Referenced by asString(), check(), checkDeriv(), checkDeriv2(), and setParamToSatisfyConstraint().

◆ m_lowerBound

double Mantid::CurveFitting::Constraints::BoundaryConstraint::m_lowerBound
private

the lower bound

Definition at line 116 of file BoundaryConstraint.h.

Referenced by asString(), check(), checkDeriv(), checkDeriv2(), and setParamToSatisfyConstraint().

◆ m_penaltyFactor

double Mantid::CurveFitting::Constraints::BoundaryConstraint::m_penaltyFactor
private

Penalty factor for the given boundary constraint.

Definition at line 106 of file BoundaryConstraint.h.

Referenced by asString(), check(), checkDeriv(), checkDeriv2(), and setPenaltyFactor().

◆ m_upperBound

double Mantid::CurveFitting::Constraints::BoundaryConstraint::m_upperBound
private

the upper bound

Definition at line 118 of file BoundaryConstraint.h.

Referenced by asString(), check(), checkDeriv(), checkDeriv2(), and setParamToSatisfyConstraint().


The documentation for this class was generated from the following files: