bpp-core3
3.0.0
|
This class is designed to facilitate the manipulation of parameters. More...
#include <Bpp/Numeric/Parameter.h>
Public Member Functions | |
Parameter () | |
Default contructor. Creates a parameter with no name, no constraint, and a value of 0. More... | |
Parameter (const std::string &name, double value, std::shared_ptr< Constraint > constraint=0, double precision=0) | |
Build a new parameter. More... | |
Parameter (const std::string &name, double value, std::shared_ptr< Constraint > constraint, bool precision)=delete | |
Parameter (const Parameter ¶m) | |
Copy constructor. More... | |
Parameter & | operator= (const Parameter ¶m) |
Assignment operator. More... | |
virtual | ~Parameter () |
Parameter * | clone () const |
Create a copy of this object and send a pointer to it. More... | |
virtual void | setName (const std::string &name) |
Set the name of this parameter. More... | |
virtual void | setValue (double value) |
Set the value of this parameter. More... | |
void | setPrecision (double precision) |
Set the precision of this parameter. More... | |
virtual const std::string & | getName () const |
Get the name of this parameter. More... | |
virtual double | getValue () const |
Get the value of this parameter. More... | |
virtual double | getPrecision () const |
Get the precision of this parameter. More... | |
virtual const std::shared_ptr< Constraint > | getConstraint () const |
Return the constraint associated to this parameter if there is one. More... | |
virtual std::shared_ptr< Constraint > | getConstraint () |
Return the constraint associated to this parameter if there is one. More... | |
virtual bool | hasConstraint () const |
Tells if this parameter has a constraint. More... | |
virtual std::shared_ptr< Constraint > | removeConstraint () |
Remove the constraint associated to this parameter. More... | |
virtual void | setConstraint (std::shared_ptr< Constraint > constraint) |
Set a constraint to this parameter. More... | |
virtual void | addParameterListener (ParameterListener *listener, bool attachListener=true) |
Add a new listener to this parameter. More... | |
virtual void | removeParameterListener (const std::string &listenerId) |
Remove all listeners with a given id from this parameter. More... | |
virtual bool | hasParameterListener (const std::string &listenerId) |
Tell is there is a listener with a given id from this parameter. More... | |
Static Public Attributes | |
static const std::shared_ptr< IntervalConstraint > | R_PLUS |
static const std::shared_ptr< IntervalConstraint > | R_PLUS_STAR |
static const std::shared_ptr< IntervalConstraint > | R_MINUS |
static const std::shared_ptr< IntervalConstraint > | R_MINUS_STAR |
static const std::shared_ptr< IntervalConstraint > | PROP_CONSTRAINT_IN |
static const std::shared_ptr< IntervalConstraint > | PROP_CONSTRAINT_EX |
Protected Member Functions | |
void | fireParameterNameChanged (ParameterEvent &event) |
void | fireParameterValueChanged (ParameterEvent &event) |
void | fireParameterConstraintChanged (ParameterEvent &event) |
Protected Attributes | |
std::string | name_ |
double | value_ |
double | precision_ |
std::shared_ptr< Constraint > | constraint_ |
std::vector< ParameterListener * > | listeners_ |
std::vector< bool > | listenerAttach_ |
This class is designed to facilitate the manipulation of parameters.
A parameter object contains a value stored as a double. It also contains a name and optionaly a constraint. Constraint objects allows to apply restriction on the value of the parameter, for instance positive number, or a particular interval and so on.
Definition at line 133 of file Parameter.h.
|
inline |
Default contructor. Creates a parameter with no name, no constraint, and a value of 0.
Definition at line 150 of file Parameter.h.
Referenced by clone().
Parameter::Parameter | ( | const std::string & | name, |
double | value, | ||
std::shared_ptr< Constraint > | constraint = 0 , |
||
double | precision = 0 |
||
) |
Build a new parameter.
name | The parameter name. |
value | The parameter value. |
constraint | An optional pointer toward a constraint Object. The constraint will be copied and attached to this instance. |
precision | An optional parameter precision (default 0) |
ConstraintException | If the parameter value does not match the contraint. |
Constructors:
Definition at line 59 of file Parameter.cpp.
References setPrecision(), and setValue().
|
delete |
Parameter::Parameter | ( | const Parameter & | param | ) |
Copy constructor.
Definition at line 66 of file Parameter.cpp.
References listenerAttach_, and listeners_.
|
virtual |
Destructor:
Definition at line 99 of file Parameter.cpp.
References listenerAttach_, and listeners_.
|
inlinevirtual |
Add a new listener to this parameter.
listener | The listener to add. |
attachListener | Tell if the parameter will own this listener. If so, deep copies will be made when cloning the parameter, and the listener will be destroyed upon destruction of the parameter or upon removal. Alternatively, only superficial copies will be made, and the listener will persist if the parameter is destroyed. |
Definition at line 278 of file Parameter.h.
References listenerAttach_, and listeners_.
Referenced by bpp::AbstractParameterAliasable::aliasParameters().
|
inlinevirtual |
Create a copy of this object and send a pointer to it.
Implements bpp::Clonable.
Reimplemented in bpp::TransformedParameter, bpp::PlaceboTransformedParameter, bpp::IntervalTransformedParameter, and bpp::RTransformedParameter.
Definition at line 177 of file Parameter.h.
References Parameter().
Referenced by bpp::ParameterList::addParameter(), bpp::AbstractParameterAliasable::aliasParameters(), bpp::ParameterList::getCommonParametersWith(), and bpp::ParameterList::setParameter().
|
inlineprotected |
Definition at line 316 of file Parameter.h.
References listeners_.
|
inlineprotected |
|
inlineprotected |
|
inlinevirtual |
Return the constraint associated to this parameter if there is one.
Definition at line 242 of file Parameter.h.
References constraint_.
|
inlinevirtual |
Return the constraint associated to this parameter if there is one.
Definition at line 233 of file Parameter.h.
References constraint_.
Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::ReparametrizationFunctionWrapper::init_(), bpp::ParameterList::matchParametersValues(), bpp::AliasParameterListener::parameterConstraintChanged(), bpp::ParameterList::setParametersValues(), and bpp::ParameterList::testParametersValues().
|
inlinevirtual |
Get the name of this parameter.
Definition at line 211 of file Parameter.h.
References name_.
Referenced by bpp::ParameterList::addParameter(), bpp::AbstractParameterAliasable::addParameter_(), bpp::AbstractParameterAliasable::deleteParameter_(), bpp::ParameterList::getCommonParametersWith(), bpp::ParametersStopCondition::getCurrentTolerance(), bpp::NumCalcApplicationTools::getDefaultValue(), bpp::ParameterList::getParameter(), bpp::ParameterList::getParameterValue(), bpp::ParameterList::hasParameter(), bpp::ReparametrizationFunctionWrapper::init_(), bpp::ParametersStopCondition::isToleranceReached(), bpp::AliasParameterListener::parameterConstraintChanged(), bpp::AliasParameterListener::parameterValueChanged(), and bpp::FullHmmTransitionMatrix::setTransitionProbabilities().
|
inlinevirtual |
Get the precision of this parameter.
Definition at line 225 of file Parameter.h.
References precision_.
|
inlinevirtual |
Get the value of this parameter.
Definition at line 218 of file Parameter.h.
References value_.
Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::ParametersStopCondition::getCurrentTolerance(), bpp::NumCalcApplicationTools::getDefaultValue(), bpp::RTransformedParameter::getFirstOrderDerivative(), bpp::IntervalTransformedParameter::getFirstOrderDerivative(), bpp::RTransformedParameter::getOriginalValue(), bpp::IntervalTransformedParameter::getOriginalValue(), bpp::PlaceboTransformedParameter::getOriginalValue(), bpp::AbstractParametrizable::getParameterValue(), bpp::ParameterList::getParameterValue(), bpp::RTransformedParameter::getSecondOrderDerivative(), bpp::IntervalTransformedParameter::getSecondOrderDerivative(), bpp::TestFunction::getValue(), bpp::ReparametrizationFunctionWrapper::init_(), bpp::ParametersStopCondition::isToleranceReached(), bpp::ParameterList::matchParametersValues(), bpp::ParameterList::setAllParametersValues(), bpp::ParameterList::setParametersValues(), and bpp::ParameterList::testParametersValues().
|
inlinevirtual |
Tells if this parameter has a constraint.
Definition at line 249 of file Parameter.h.
References constraint_.
Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::ParameterList::matchParametersValues(), bpp::ParameterList::setParametersValues(), and bpp::ParameterList::testParametersValues().
|
virtual |
Tell is there is a listener with a given id from this parameter.
listenerId | The id of listener to remove. |
Definition at line 165 of file Parameter.cpp.
References listeners_.
Assignment operator.
Definition at line 81 of file Parameter.cpp.
References constraint_, listenerAttach_, listeners_, name_, precision_, and value_.
Referenced by bpp::AutoParameter::operator=().
|
virtual |
Remove the constraint associated to this parameter.
Warning! The contraint objet is not deleted.
Definition at line 140 of file Parameter.cpp.
References constraint_.
Referenced by bpp::SimpleDiscreteDistribution::restrictToConstraint().
|
virtual |
Remove all listeners with a given id from this parameter.
listenerId | The id of listener to remove. |
Definition at line 149 of file Parameter.cpp.
References listenerAttach_, and listeners_.
Referenced by bpp::AbstractParameterAliasable::unaliasParameters().
|
virtual |
Set a constraint to this parameter.
constraint | a pointer to the constraint (may be null) |
Definition at line 131 of file Parameter.cpp.
References constraint_, and value_.
Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::AliasParameterListener::parameterConstraintChanged(), bpp::ConstantDistribution::restrictToConstraint(), bpp::SimpleDiscreteDistribution::restrictToConstraint(), and bpp::TruncatedExponentialDiscreteDistribution::restrictToConstraint().
|
inlinevirtual |
Set the name of this parameter.
name | the new parameter name. |
Definition at line 185 of file Parameter.h.
References fireParameterNameChanged(), and name_.
Referenced by bpp::ParametrizableCollection< N >::addObject(), and bpp::FullHmmTransitionMatrix::setTransitionProbabilities().
void Parameter::setPrecision | ( | double | precision | ) |
Set the precision of this parameter.
precision | the new parameter precision. |
Precision:
Definition at line 124 of file Parameter.cpp.
References precision_.
Referenced by Parameter().
|
virtual |
Set the value of this parameter.
value | the new parameter value. |
Value:
Reimplemented in bpp::AutoParameter.
Definition at line 110 of file Parameter.cpp.
References constraint_, fireParameterValueChanged(), precision_, and value_.
Referenced by bpp::BrentOneDimension::doInit(), bpp::GoldenSectionSearch::doInit(), bpp::BrentOneDimension::doStep(), bpp::GoldenSectionSearch::doStep(), bpp::NewtonBacktrackOneDimension::doStep(), bpp::ReparametrizationFunctionWrapper::fireParameterChanged(), bpp::ParameterList::matchParametersValues(), Parameter(), bpp::AliasParameterListener::parameterValueChanged(), bpp::ParameterList::setAllParametersValues(), bpp::RTransformedParameter::setOriginalValue(), bpp::IntervalTransformedParameter::setOriginalValue(), bpp::PlaceboTransformedParameter::setOriginalValue(), bpp::ParameterList::setParametersValues(), bpp::ParameterList::setParameterValue(), and bpp::AutoParameter::setValue().
|
protected |
Definition at line 140 of file Parameter.h.
Referenced by getConstraint(), hasConstraint(), operator=(), removeConstraint(), setConstraint(), bpp::AutoParameter::setValue(), and setValue().
|
protected |
Definition at line 142 of file Parameter.h.
Referenced by addParameterListener(), operator=(), Parameter(), removeParameterListener(), and ~Parameter().
|
protected |
Definition at line 141 of file Parameter.h.
Referenced by addParameterListener(), fireParameterConstraintChanged(), fireParameterNameChanged(), fireParameterValueChanged(), hasParameterListener(), operator=(), Parameter(), removeParameterListener(), and ~Parameter().
|
protected |
Definition at line 137 of file Parameter.h.
Referenced by getName(), operator=(), setName(), and bpp::AutoParameter::setValue().
|
protected |
Definition at line 139 of file Parameter.h.
Referenced by getPrecision(), operator=(), setPrecision(), and setValue().
|
static |
Definition at line 330 of file Parameter.h.
Referenced by bpp::AutoCorrelationTransitionMatrix::AutoCorrelationTransitionMatrix(), and bpp::Simplex::Simplex().
|
static |
|
static |
Definition at line 327 of file Parameter.h.
|
static |
Definition at line 328 of file Parameter.h.
|
static |
Definition at line 325 of file Parameter.h.
Referenced by bpp::ExponentialDiscreteDistribution::ExponentialDiscreteDistribution(), and bpp::TruncatedExponentialDiscreteDistribution::TruncatedExponentialDiscreteDistribution().
|
static |
Definition at line 326 of file Parameter.h.
Referenced by bpp::GaussianDiscreteDistribution::GaussianDiscreteDistribution().
|
protected |
Definition at line 138 of file Parameter.h.
Referenced by getValue(), operator=(), setConstraint(), and setValue().