bpp-core
2.2.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, Constraint *constraint, bool attachConstraint, double precision=0) throw (ConstraintException) | |
Build a new parameter. More... | |
Parameter (const std::string &name, double value, const Constraint *constraint=0, double precision=0) throw (ConstraintException) | |
Build a new parameter. More... | |
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) throw (ConstraintException) |
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 Constraint * | getConstraint () const |
Return the constraint associated to this parameter if there is one. More... | |
virtual 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 const Constraint * | removeConstraint () |
Remove the constraint associated to this parameter. More... | |
virtual void | setConstraint (Constraint *constraint, bool attach=false) |
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 IntervalConstraint | R_PLUS |
static const IntervalConstraint | R_PLUS_STAR |
static const IntervalConstraint | R_MINUS |
static const IntervalConstraint | R_MINUS_STAR |
static const IntervalConstraint | PROP_CONSTRAINT_IN |
static const IntervalConstraint | PROP_CONSTRAINT_EX |
Protected Member Functions | |
void | fireParameterNameChanged (ParameterEvent &event) |
void | fireParameterValueChanged (ParameterEvent &event) |
Protected Attributes | |
std::string | name_ |
double | value_ |
double | precision_ |
Constraint * | constraint_ |
bool | attach_ |
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 135 of file Parameter.h.
|
inline |
Default contructor. Creates a parameter with no name, no constraint, and a value of 0.
Definition at line 152 of file Parameter.h.
Referenced by clone().
Parameter::Parameter | ( | const std::string & | name, |
double | value, | ||
Constraint * | constraint, | ||
bool | attachConstraint, | ||
double | precision = 0 |
||
) | |||
throw | ( | ConstraintException | |
) |
Build a new parameter.
name | The parameter name. |
value | The parameter value. |
constraint | A pointer toward a constraint Object. |
attachConstraint | Tell if the constraint must be attached to this parameter, or shared |
precision | An optional parameter precision (default 0) between different objects (the default behavior, for backward compatibility). If the first case, the constraint object will be destroyed when the parameter is destroyed, and duplicated when the parameter is copied. |
ConstraintException | If the parameter value does not match the contraint. |
Constructors:
Definition at line 57 of file Parameter.cpp.
Parameter::Parameter | ( | const std::string & | name, |
double | value, | ||
const Constraint * | constraint = 0 , |
||
double | precision = 0 |
||
) | |||
throw | ( | ConstraintException | |
) |
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. |
Definition at line 66 of file Parameter.cpp.
Parameter::Parameter | ( | const Parameter & | param | ) |
Copy constructor.
Definition at line 75 of file Parameter.cpp.
References attach_, bpp::Constraint::clone(), constraint_, listenerAttach_, and listeners_.
|
virtual |
Destructor:
Definition at line 113 of file Parameter.cpp.
References attach_, constraint_, 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 298 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::PlaceboTransformedParameter, bpp::IntervalTransformedParameter, bpp::RTransformedParameter, and bpp::TransformedParameter.
Definition at line 199 of file Parameter.h.
References Parameter().
Referenced by bpp::AbstractParameterAliasable::addParameter_(), bpp::AbstractParameterAliasable::aliasParameters(), and bpp::ParameterList::getCommonParametersWith().
|
inlineprotected |
|
inlineprotected |
Definition at line 325 of file Parameter.h.
References listeners_.
|
inlinevirtual |
Return the constraint associated to this parameter if there is one.
Definition at line 255 of file Parameter.h.
References constraint_.
Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::ReparametrizationFunctionWrapper::init_(), bpp::ParameterList::matchParametersValues(), bpp::ParameterList::setParametersValues(), and bpp::ParameterList::testParametersValues().
|
inlinevirtual |
Return the constraint associated to this parameter if there is one.
Definition at line 262 of file Parameter.h.
References constraint_.
|
inlinevirtual |
Get the name of this parameter.
Definition at line 234 of file Parameter.h.
References name_.
Referenced by bpp::ParameterList::deleteParameter(), bpp::AbstractParameterAliasable::deleteParameter_(), bpp::FullHmmTransitionMatrix::FullHmmTransitionMatrix(), 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::parameterValueChanged(), and bpp::FullHmmTransitionMatrix::setTransitionProbabilities().
|
inlinevirtual |
Get the precision of this parameter.
Definition at line 248 of file Parameter.h.
References precision_.
|
inlinevirtual |
Get the value of this parameter.
Definition at line 241 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 269 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 187 of file Parameter.cpp.
References listeners_.
Assignment operator.
Definition at line 93 of file Parameter.cpp.
References attach_, bpp::Constraint::clone(), 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 163 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 172 of file Parameter.cpp.
References listenerAttach_, and listeners_.
|
virtual |
Set a constraint to this parameter.
constraint | a pointer to the constraint (may be null) |
attach | says if the constraint is attached to the Parameter (default: false). |
Definition at line 143 of file Parameter.cpp.
References attach_, constraint_, bpp::Constraint::isCorrect(), and value_.
Referenced by bpp::ConstantDistribution::restrictToConstraint(), bpp::TruncatedExponentialDiscreteDistribution::restrictToConstraint(), and bpp::SimpleDiscreteDistribution::restrictToConstraint().
|
inlinevirtual |
Set the name of this parameter.
name | the new parameter name. |
Definition at line 208 of file Parameter.h.
References fireParameterNameChanged(), and name_.
Referenced by bpp::ParametrizableCollection< N >::addObject(), bpp::FullHmmTransitionMatrix::FullHmmTransitionMatrix(), and bpp::FullHmmTransitionMatrix::setTransitionProbabilities().
void Parameter::setPrecision | ( | double | precision | ) |
Set the precision of this parameter.
precision | the new parameter precision. |
Precision:
Definition at line 136 of file Parameter.cpp.
References precision_.
|
virtual |
Set the value of this parameter.
value | the new parameter value. |
Value:
Reimplemented in bpp::AutoParameter.
Definition at line 123 of file Parameter.cpp.
Referenced by bpp::NewtonBacktrackOneDimension::doStep(), bpp::GoldenSectionSearch::doStep(), bpp::BrentOneDimension::doStep(), bpp::ReparametrizationFunctionWrapper::fireParameterChanged(), bpp::ParameterList::matchParametersValues(), 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 143 of file Parameter.h.
Referenced by operator=(), Parameter(), setConstraint(), and ~Parameter().
|
protected |
Definition at line 142 of file Parameter.h.
Referenced by getConstraint(), hasConstraint(), operator=(), Parameter(), removeConstraint(), setConstraint(), and ~Parameter().
|
protected |
Definition at line 145 of file Parameter.h.
Referenced by addParameterListener(), operator=(), Parameter(), removeParameterListener(), and ~Parameter().
|
protected |
Definition at line 144 of file Parameter.h.
Referenced by addParameterListener(), fireParameterNameChanged(), fireParameterValueChanged(), hasParameterListener(), operator=(), Parameter(), removeParameterListener(), and ~Parameter().
|
protected |
Definition at line 139 of file Parameter.h.
Referenced by getName(), operator=(), and setName().
|
protected |
Definition at line 141 of file Parameter.h.
Referenced by getPrecision(), operator=(), and setPrecision().
|
static |
Definition at line 337 of file Parameter.h.
Referenced by bpp::AutoCorrelationTransitionMatrix::AutoCorrelationTransitionMatrix(), and bpp::Simplex::Simplex().
|
static |
|
static |
Definition at line 334 of file Parameter.h.
|
static |
Definition at line 335 of file Parameter.h.
|
static |
Definition at line 332 of file Parameter.h.
Referenced by bpp::ExponentialDiscreteDistribution::ExponentialDiscreteDistribution(), and bpp::TruncatedExponentialDiscreteDistribution::TruncatedExponentialDiscreteDistribution().
|
static |
Definition at line 333 of file Parameter.h.
Referenced by bpp::GaussianDiscreteDistribution::GaussianDiscreteDistribution().
|
protected |
Definition at line 140 of file Parameter.h.
Referenced by getValue(), operator=(), and setConstraint().