bpp-core3  3.0.0
bpp::RTransformedParameter Class Reference

Parameter transformation from ] b, +inf [ or ] -inf, b [ to ]-inf, + inf [. More...

#include <Bpp/Numeric/TransformedParameter.h>

+ Inheritance diagram for bpp::RTransformedParameter:
+ Collaboration diagram for bpp::RTransformedParameter:

Public Member Functions

 RTransformedParameter (const std::string &name, double value, double bound=0, bool positive=true, double scale=1)
 Build a new RTransformedParameter, with given bound and scale. More...
 
RTransformedParameterclone () const
 Create a copy of this object and send a pointer to it. More...
 
void setOriginalValue (double value)
 Set the value of the parameter using the orignal coordinate system. More...
 
double getOriginalValue () const
 
double getFirstOrderDerivative () const
 
double getSecondOrderDerivative () const
 
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< ConstraintgetConstraint () const
 Return the constraint associated to this parameter if there is one. More...
 
virtual std::shared_ptr< ConstraintgetConstraint ()
 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< ConstraintremoveConstraint ()
 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< IntervalConstraintR_PLUS
 
static const std::shared_ptr< IntervalConstraintR_PLUS_STAR
 
static const std::shared_ptr< IntervalConstraintR_MINUS
 
static const std::shared_ptr< IntervalConstraintR_MINUS_STAR
 
static const std::shared_ptr< IntervalConstraintPROP_CONSTRAINT_IN
 
static const std::shared_ptr< IntervalConstraintPROP_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< Constraintconstraint_
 
std::vector< ParameterListener * > listeners_
 
std::vector< bool > listenerAttach_
 

Private Attributes

double scale_
 
double bound_
 
bool positive_
 

Detailed Description

Parameter transformation from ] b, +inf [ or ] -inf, b [ to ]-inf, + inf [.

The equation of the tranformation is

\[ x' = \begin{cases} \log(a\cdot(x-b)) & \text{if $x < b+1$},\\ a(x-1-b) & \text{if $a \geq b+1$}. \end{cases} \]

for a transformation from ] b, +inf [ to ]-inf, + inf [. The 'b' parameter is the lower bound and 'a' is a scaling factor set to 1 by default. For a transformation from ] -inf, b [, the transformation is then

\[ x' = \begin{cases} -\log(-a\cdot(x-b)) & \text{if $x < b-1$},\\ -a(x-1-b) & \text{if $a \geq b-1$}. \end{cases} \]

Definition at line 117 of file TransformedParameter.h.

Constructor & Destructor Documentation

◆ RTransformedParameter()

bpp::RTransformedParameter::RTransformedParameter ( const std::string &  name,
double  value,
double  bound = 0,
bool  positive = true,
double  scale = 1 
)
inline

Build a new RTransformedParameter, with given bound and scale.

Parameters
namethe name of the parameter.
valuethe value of th eparameter, in orginal coordinates.
boundthe inerval bound to use.
positivetell if the original interval is positive or negative.
scalethe scaling factor.

Definition at line 135 of file TransformedParameter.h.

References setOriginalValue().

Referenced by clone().

Member Function Documentation

◆ addParameterListener()

virtual void bpp::Parameter::addParameterListener ( ParameterListener listener,
bool  attachListener = true 
)
inlinevirtualinherited

Add a new listener to this parameter.

Parameters
listenerThe listener to add.
attachListenerTell 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 bpp::Parameter::listenerAttach_, and bpp::Parameter::listeners_.

Referenced by bpp::AbstractParameterAliasable::aliasParameters().

◆ clone()

RTransformedParameter* bpp::RTransformedParameter::clone ( ) const
inlinevirtual

Create a copy of this object and send a pointer to it.

Returns
A pointer toward the copy object.

Implements bpp::TransformedParameter.

Definition at line 144 of file TransformedParameter.h.

References RTransformedParameter().

◆ fireParameterConstraintChanged()

void bpp::Parameter::fireParameterConstraintChanged ( ParameterEvent event)
inlineprotectedinherited

Definition at line 316 of file Parameter.h.

References bpp::Parameter::listeners_.

◆ fireParameterNameChanged()

void bpp::Parameter::fireParameterNameChanged ( ParameterEvent event)
inlineprotectedinherited

Definition at line 300 of file Parameter.h.

References bpp::Parameter::listeners_.

Referenced by bpp::Parameter::setName().

◆ fireParameterValueChanged()

void bpp::Parameter::fireParameterValueChanged ( ParameterEvent event)
inlineprotectedinherited

Definition at line 308 of file Parameter.h.

References bpp::Parameter::listeners_.

Referenced by bpp::Parameter::setValue().

◆ getConstraint() [1/2]

virtual std::shared_ptr<Constraint> bpp::Parameter::getConstraint ( )
inlinevirtualinherited

Return the constraint associated to this parameter if there is one.

Returns
A shared pointer toward the constraint, or NULL if there is no constraint.

Definition at line 242 of file Parameter.h.

References bpp::Parameter::constraint_.

◆ getConstraint() [2/2]

virtual const std::shared_ptr<Constraint> bpp::Parameter::getConstraint ( ) const
inlinevirtualinherited

Return the constraint associated to this parameter if there is one.

Returns
A shared pointer toward the constraint, or NULL if there is no constraint.

Definition at line 233 of file Parameter.h.

References bpp::Parameter::constraint_.

Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::ReparametrizationFunctionWrapper::init_(), bpp::ParameterList::matchParametersValues(), bpp::AliasParameterListener::parameterConstraintChanged(), bpp::ParameterList::setParametersValues(), and bpp::ParameterList::testParametersValues().

◆ getFirstOrderDerivative()

double bpp::RTransformedParameter::getFirstOrderDerivative ( ) const
inlinevirtual
Returns
The first order derivative of the transformation at the original point.
Exceptions
NotImplementedExceptionif the transformation does not support derivation or if the derivation was not implemented.

Implements bpp::TransformedParameter.

Definition at line 166 of file TransformedParameter.h.

References bpp::Parameter::getValue(), positive_, and scale_.

◆ getName()

◆ getOriginalValue()

double bpp::RTransformedParameter::getOriginalValue ( ) const
inlinevirtual
Returns
The current value of the parameter in orignal coordinates.

Implements bpp::TransformedParameter.

Definition at line 156 of file TransformedParameter.h.

References bound_, bpp::Parameter::getValue(), positive_, and scale_.

◆ getPrecision()

virtual double bpp::Parameter::getPrecision ( ) const
inlinevirtualinherited

Get the precision of this parameter.

Returns
The precision value.

Definition at line 225 of file Parameter.h.

References bpp::Parameter::precision_.

◆ getSecondOrderDerivative()

double bpp::RTransformedParameter::getSecondOrderDerivative ( ) const
inlinevirtual
Returns
The second order derivative of the transformation at the original point.
Exceptions
NotImplementedExceptionif the transformation does not support derivation or if the derivation was not implemented.

Implements bpp::TransformedParameter.

Definition at line 176 of file TransformedParameter.h.

References bpp::Parameter::getValue(), positive_, and scale_.

◆ getValue()

◆ hasConstraint()

virtual bool bpp::Parameter::hasConstraint ( ) const
inlinevirtualinherited

Tells if this parameter has a constraint.

Returns
True if this parameter has a contraint.

Definition at line 249 of file Parameter.h.

References bpp::Parameter::constraint_.

Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::ParameterList::matchParametersValues(), bpp::ParameterList::setParametersValues(), and bpp::ParameterList::testParametersValues().

◆ hasParameterListener()

bool Parameter::hasParameterListener ( const std::string &  listenerId)
virtualinherited

Tell is there is a listener with a given id from this parameter.

Parameters
listenerIdThe id of listener to remove.
Returns
True if at list one listener with the given id was found.

Definition at line 165 of file Parameter.cpp.

References bpp::Parameter::listeners_.

◆ removeConstraint()

std::shared_ptr< Constraint > Parameter::removeConstraint ( )
virtualinherited

Remove the constraint associated to this parameter.

Warning! The contraint objet is not deleted.

Returns
A pointer toward the formerly used contraint.

Definition at line 140 of file Parameter.cpp.

References bpp::Parameter::constraint_.

Referenced by bpp::SimpleDiscreteDistribution::restrictToConstraint().

◆ removeParameterListener()

void Parameter::removeParameterListener ( const std::string &  listenerId)
virtualinherited

Remove all listeners with a given id from this parameter.

Parameters
listenerIdThe id of listener to remove.

Definition at line 149 of file Parameter.cpp.

References bpp::Parameter::listenerAttach_, and bpp::Parameter::listeners_.

Referenced by bpp::AbstractParameterAliasable::unaliasParameters().

◆ setConstraint()

void Parameter::setConstraint ( std::shared_ptr< Constraint constraint)
virtualinherited

◆ setName()

virtual void bpp::Parameter::setName ( const std::string &  name)
inlinevirtualinherited

Set the name of this parameter.

Parameters
namethe new parameter name.

Definition at line 185 of file Parameter.h.

References bpp::Parameter::fireParameterNameChanged(), and bpp::Parameter::name_.

Referenced by bpp::ParametrizableCollection< N >::addObject(), and bpp::FullHmmTransitionMatrix::setTransitionProbabilities().

◆ setOriginalValue()

void bpp::RTransformedParameter::setOriginalValue ( double  value)
inlinevirtual

Set the value of the parameter using the orignal coordinate system.

Parameters
valueParameter value in original coordinates.
Exceptions
ConstraintExceptionif the value is not correct.

Implements bpp::TransformedParameter.

Definition at line 147 of file TransformedParameter.h.

References bound_, positive_, scale_, and bpp::Parameter::setValue().

Referenced by RTransformedParameter().

◆ setPrecision()

void Parameter::setPrecision ( double  precision)
inherited

Set the precision of this parameter.

Parameters
precisionthe new parameter precision.

Precision:

Definition at line 124 of file Parameter.cpp.

References bpp::Parameter::precision_.

Referenced by bpp::Parameter::Parameter().

◆ setValue()

Member Data Documentation

◆ bound_

double bpp::RTransformedParameter::bound_
private

Definition at line 122 of file TransformedParameter.h.

Referenced by getOriginalValue(), and setOriginalValue().

◆ constraint_

◆ listenerAttach_

std::vector<bool> bpp::Parameter::listenerAttach_
protectedinherited

◆ listeners_

◆ name_

std::string bpp::Parameter::name_
protectedinherited

◆ positive_

bool bpp::RTransformedParameter::positive_
private

◆ precision_

double bpp::Parameter::precision_
protectedinherited

◆ PROP_CONSTRAINT_EX

const std::shared_ptr< IntervalConstraint > Parameter::PROP_CONSTRAINT_EX
staticinherited

◆ PROP_CONSTRAINT_IN

◆ R_MINUS

const std::shared_ptr< IntervalConstraint > Parameter::R_MINUS
staticinherited

Definition at line 327 of file Parameter.h.

◆ R_MINUS_STAR

const std::shared_ptr< IntervalConstraint > Parameter::R_MINUS_STAR
staticinherited

Definition at line 328 of file Parameter.h.

◆ R_PLUS

◆ R_PLUS_STAR

const std::shared_ptr< IntervalConstraint > Parameter::R_PLUS_STAR
staticinherited

◆ scale_

double bpp::RTransformedParameter::scale_
private

◆ value_

double bpp::Parameter::value_
protectedinherited

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