bpp-core3  3.0.0
bpp::DirectionFunction Class Referenceabstract

#include <Bpp/Numeric/Function/DirectionFunction.h>

+ Inheritance diagram for bpp::DirectionFunction:
+ Collaboration diagram for bpp::DirectionFunction:

Public Member Functions

 DirectionFunction (std::shared_ptr< FunctionInterface > function=nullptr)
 
 DirectionFunction (const DirectionFunction &df)
 
DirectionFunctionoperator= (const DirectionFunction &df)
 
virtual ~DirectionFunction ()
 
DirectionFunctionclone () const override
 Create a copy of this object and send a pointer to it. More...
 
void setParameters (const ParameterList &parameters) override
 Set the point where the function must be computed. More...
 
double getValue () const override
 Get the value of the function at the current point. More...
 
const ParameterListgetParameters () const override
 Get all parameters available. More...
 
void init (const ParameterList &p, const std::vector< double > &xi)
 
void autoParameter ()
 
void ignoreConstraints ()
 
void setConstraintPolicy (const std::string &constraintPolicy)
 
std::string getConstraintPolicy () const
 
void setMessageHandler (std::shared_ptr< OutputStream > messenger)
 
std::shared_ptr< FunctionInterfacegetFunction () const
 
ParameterList getFunctionParameters () const
 
size_t getNumberOfParameters () const override
 Get the number of parameters. More...
 
virtual double f (const ParameterList &parameters)
 Get the value of the function according to a given set of parameters. More...
 
virtual bool hasParameter (const std::string &name) const =0
 Tell if there is a parameter with specified name. More...
 
virtual const Parameterparameter (const std::string &name) const =0
 Get the parameter with specified name. More...
 
virtual double getParameterValue (const std::string &name) const =0
 Get the value for parameter of name 'name'. More...
 
virtual void setAllParametersValues (const ParameterList &parameters)=0
 Set the parameters values to be equals to those of parameters. More...
 
virtual void setParameterValue (const std::string &name, double value)=0
 Set the value of parameter with name name to be equal to value. More...
 
virtual void setParametersValues (const ParameterList &parameters)=0
 Update the parameters from parameters. More...
 
virtual bool matchParametersValues (const ParameterList &parameters)=0
 Update the parameters from parameters. More...
 
virtual void removeConstraint (const std::string &name)=0
 Remove the constraint associated with one parameter, if any. More...
 
virtual void setConstraint (const std::string &name, std::shared_ptr< ConstraintInterface > constraint)=0
 Set/Change the constraint associated with one parameter. More...
 
virtual void setNamespace (const std::string &prefix)=0
 Set the namespace for the parameter names. More...
 
virtual std::string getNamespace () const =0
 
virtual std::string getParameterNameWithoutNamespace (const std::string &name) const =0
 Resolves a parameter name according to the current namespace. More...
 
The Parametrizable interface.
bool hasParameter (const std::string &name) const override
 Tell if there is a parameter with specified name. More...
 
const Parameterparameter (const std::string &name) const override
 Get the parameter with specified name. More...
 
double getParameterValue (const std::string &name) const override
 Get the value for parameter of name 'name'. More...
 
void setAllParametersValues (const ParameterList &parameters) override
 Set the parameters values to be equals to those of parameters. More...
 
void setParameterValue (const std::string &name, double value) override
 Set the value of parameter with name name to be equal to value. More...
 
void setParametersValues (const ParameterList &parameters) override
 Update the parameters from parameters. More...
 
bool matchParametersValues (const ParameterList &parameters) override
 Update the parameters from parameters. More...
 
void removeConstraint (const std::string &name) override
 Remove the constraint associated with one parameter, if any. More...
 
void setConstraint (const std::string &name, std::shared_ptr< ConstraintInterface > constraint) override
 Set/Change the constraint associated with one parameter. More...
 
void setNamespace (const std::string &prefix) override
 Set the namespace for the parameter names. More...
 
std::string getNamespace () const override
 
std::string getParameterNameWithoutNamespace (const std::string &name) const override
 Resolves a parameter name according to the current namespace. More...
 

Protected Member Functions

ParameterListgetParameters_ () override
 Get all parameters available. More...
 

Protected Attributes

ParameterList parameters_
 
Parameter parameter_
 

Private Attributes

ParameterList params_
 
ParameterList p_
 
ParameterList xt_
 
std::vector< double > xi_
 
std::shared_ptr< FunctionInterfacefunction_
 
std::string constraintPolicy_
 
std::shared_ptr< OutputStreammessenger_
 

Detailed Description

Definition at line 17 of file DirectionFunction.h.

Constructor & Destructor Documentation

◆ DirectionFunction() [1/2]

bpp::DirectionFunction::DirectionFunction ( std::shared_ptr< FunctionInterface function = nullptr)
inline

Definition at line 29 of file DirectionFunction.h.

Referenced by clone().

◆ DirectionFunction() [2/2]

bpp::DirectionFunction::DirectionFunction ( const DirectionFunction df)
inline

Definition at line 34 of file DirectionFunction.h.

◆ ~DirectionFunction()

virtual bpp::DirectionFunction::~DirectionFunction ( )
inlinevirtual

Definition at line 51 of file DirectionFunction.h.

Member Function Documentation

◆ autoParameter()

void DirectionFunction::autoParameter ( )

Definition at line 58 of file DirectionFunction.cpp.

References bpp::AutoParameter::setMessageHandler().

Referenced by clone().

◆ clone()

DirectionFunction* bpp::DirectionFunction::clone ( ) const
inlineoverridevirtual

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

Returns
A pointer toward the copy object.

Implements bpp::Clonable.

Definition at line 53 of file DirectionFunction.h.

References autoParameter(), DirectionFunction(), getParameters(), getValue(), ignoreConstraints(), init(), and setParameters().

◆ f()

virtual double bpp::FunctionInterface::f ( const ParameterList parameters)
inlinevirtualinherited

Get the value of the function according to a given set of parameters.

Parameters
parametersThe parameter set to pass to the function.
Returns
The value of the function with the given parameter set.
Exceptions
ExceptionIf an error occured.

Reimplemented in bpp::InfinityFunctionWrapper, bpp::FunctionWrapper, and bpp::AbstractNumericalDerivative.

Definition at line 82 of file Functions.h.

References bpp::FunctionInterface::getValue(), and bpp::FunctionInterface::setParameters().

Referenced by bpp::NumTools::uniRoot().

◆ getConstraintPolicy()

std::string bpp::DirectionFunction::getConstraintPolicy ( ) const
inline

Definition at line 68 of file DirectionFunction.h.

References constraintPolicy_.

◆ getFunction()

std::shared_ptr<FunctionInterface> bpp::DirectionFunction::getFunction ( ) const
inline

Definition at line 71 of file DirectionFunction.h.

References function_.

◆ getFunctionParameters()

ParameterList bpp::DirectionFunction::getFunctionParameters ( ) const
inline
Returns
The set of parameters associated to the function, as specified by the init() method.

Definition at line 75 of file DirectionFunction.h.

References p_.

◆ getNamespace() [1/2]

virtual std::string bpp::Parametrizable::getNamespace ( ) const
pure virtualinherited
Returns
The current namespace used. This is an empty string if no namespace is currently defined.

Implemented in bpp::FunctionWrapper, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.

Referenced by bpp::Parametrizable::~Parametrizable().

◆ getNamespace() [2/2]

std::string bpp::ParametrizableAdapter::getNamespace ( ) const
inlineoverridevirtualinherited
Returns
The current namespace used. This is an empty string if no namespace is currently defined.

Implements bpp::Parametrizable.

Definition at line 204 of file Parametrizable.h.

◆ getNumberOfParameters()

size_t bpp::DirectionFunction::getNumberOfParameters ( ) const
inlineoverridevirtual

Get the number of parameters.

See also
getNumberOfIndependentParameters If some parameters are aliased.
Returns
The number of parameters.

Implements bpp::Parametrizable.

Definition at line 77 of file DirectionFunction.h.

References getParameters_(), and bpp::ParameterList::size().

◆ getParameterNameWithoutNamespace() [1/2]

virtual std::string bpp::Parametrizable::getParameterNameWithoutNamespace ( const std::string &  name) const
pure virtualinherited

Resolves a parameter name according to the current namespace.

Returns
The parameter name without the namespace prefix, if any.

Implemented in bpp::FunctionWrapper, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.

Referenced by bpp::BppODiscreteDistributionFormat::readDiscreteDistribution(), bpp::BppOParametrizableFormat::write(), and bpp::Parametrizable::~Parametrizable().

◆ getParameterNameWithoutNamespace() [2/2]

std::string bpp::ParametrizableAdapter::getParameterNameWithoutNamespace ( const std::string &  name) const
inlineoverridevirtualinherited

Resolves a parameter name according to the current namespace.

Returns
The parameter name without the namespace prefix, if any.

Implements bpp::Parametrizable.

Definition at line 205 of file Parametrizable.h.

◆ getParameters()

const ParameterList & DirectionFunction::getParameters ( ) const
overridevirtual

Get all parameters available.

See also
getIndependentParameters if some parameters are aliased.
Returns
A list with all parameters available.

Implements bpp::Parametrizable.

Definition at line 33 of file DirectionFunction.cpp.

Referenced by clone().

◆ getParameters_()

ParameterList & DirectionFunction::getParameters_ ( )
overrideprotectedvirtual

Get all parameters available.

See also
getIndependentParameters if some parameters are aliased.
Returns
A list with all parameters available.

Implements bpp::Parametrizable.

Definition at line 38 of file DirectionFunction.cpp.

Referenced by getNumberOfParameters().

◆ getParameterValue() [1/2]

virtual double bpp::Parametrizable::getParameterValue ( const std::string &  name) const
pure virtualinherited

Get the value for parameter of name 'name'.

Parameters
nameThe name of the parameter.
Returns
the value of parameter name.

Implemented in bpp::FunctionWrapper, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.

Referenced by bpp::BppODiscreteDistributionFormat::readDiscreteDistribution(), and bpp::Parametrizable::~Parametrizable().

◆ getParameterValue() [2/2]

double bpp::ParametrizableAdapter::getParameterValue ( const std::string &  name) const
inlineoverridevirtualinherited

Get the value for parameter of name 'name'.

Parameters
nameThe name of the parameter.
Returns
the value of parameter name.

Implements bpp::Parametrizable.

Definition at line 195 of file Parametrizable.h.

◆ getValue()

double DirectionFunction::getValue ( ) const
overridevirtual

Get the value of the function at the current point.

Returns
The value of the function.
Exceptions
ExceptionIf no point is specified or if an error occured.

Implements bpp::FunctionInterface.

Definition at line 26 of file DirectionFunction.cpp.

Referenced by clone().

◆ hasParameter() [1/2]

virtual bool bpp::Parametrizable::hasParameter ( const std::string &  name) const
pure virtualinherited

Tell if there is a parameter with specified name.

Parameters
nameThe name of the parameter to look for.
Returns
y/n.

Implemented in bpp::FunctionWrapper, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.

Referenced by bpp::Parametrizable::~Parametrizable().

◆ hasParameter() [2/2]

bool bpp::ParametrizableAdapter::hasParameter ( const std::string &  name) const
inlineoverridevirtualinherited

Tell if there is a parameter with specified name.

Parameters
nameThe name of the parameter to look for.
Returns
y/n.

Implements bpp::Parametrizable.

Definition at line 192 of file Parametrizable.h.

References bpp::ParameterList::hasParameter().

◆ ignoreConstraints()

void DirectionFunction::ignoreConstraints ( )

Definition at line 70 of file DirectionFunction.cpp.

Referenced by clone().

◆ init()

void DirectionFunction::init ( const ParameterList p,
const std::vector< double > &  xi 
)

◆ matchParametersValues() [1/2]

virtual bool bpp::Parametrizable::matchParametersValues ( const ParameterList parameters)
pure virtualinherited

Update the parameters from parameters.

Only common parameters with parameters will be updated.

Parameters
parametersA list of parameters.
Returns
True if at least one parameter value has been changed.
Exceptions
ConstraintExceptionIf a value in parameters does not match the constraint in the corresponding parameter in the list.

Implemented in bpp::InfinityFunctionWrapper, bpp::FunctionWrapper, bpp::AbstractNumericalDerivative, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.

Referenced by bpp::BppODiscreteDistributionFormat::initialize_(), bpp::TestFunction::setParameters(), and bpp::Parametrizable::~Parametrizable().

◆ matchParametersValues() [2/2]

bool bpp::ParametrizableAdapter::matchParametersValues ( const ParameterList parameters)
inlineoverridevirtualinherited

Update the parameters from parameters.

Only common parameters with parameters will be updated.

Parameters
parametersA list of parameters.
Returns
True if at least one parameter value has been changed.
Exceptions
ConstraintExceptionIf a value in parameters does not match the constraint in the corresponding parameter in the list.

Implements bpp::Parametrizable.

Definition at line 199 of file Parametrizable.h.

◆ operator=()

DirectionFunction& bpp::DirectionFunction::operator= ( const DirectionFunction df)
inline

Definition at line 38 of file DirectionFunction.h.

References constraintPolicy_, function_, messenger_, p_, params_, and xi_.

◆ parameter() [1/2]

virtual const Parameter& bpp::Parametrizable::parameter ( const std::string &  name) const
pure virtualinherited

Get the parameter with specified name.

Parameters
nameThe name of the parameter to look for.
Returns
The parameter with given name.
Exceptions
ParameterNotFoundExceptionif no parameter with this name is found.

Implemented in bpp::FunctionWrapper, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.

Referenced by bpp::TestFunction::getValue(), and bpp::Parametrizable::~Parametrizable().

◆ parameter() [2/2]

const Parameter& bpp::ParametrizableAdapter::parameter ( const std::string &  name) const
inlineoverridevirtualinherited

Get the parameter with specified name.

Parameters
nameThe name of the parameter to look for.
Returns
The parameter with given name.
Exceptions
ParameterNotFoundExceptionif no parameter with this name is found.

Implements bpp::Parametrizable.

Definition at line 194 of file Parametrizable.h.

◆ removeConstraint() [1/2]

virtual void bpp::Parametrizable::removeConstraint ( const std::string &  name)
pure virtualinherited

Remove the constraint associated with one parameter, if any.

Parameters
nameThe name of the parameter to look for.
Exceptions
ParameterNotFoundExceptionif no parameter with this name is found.

Implemented in bpp::FunctionWrapper, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.

Referenced by bpp::Parametrizable::~Parametrizable().

◆ removeConstraint() [2/2]

void bpp::ParametrizableAdapter::removeConstraint ( const std::string &  name)
inlineoverridevirtualinherited

Remove the constraint associated with one parameter, if any.

Parameters
nameThe name of the parameter to look for.
Exceptions
ParameterNotFoundExceptionif no parameter with this name is found.

Implements bpp::Parametrizable.

Definition at line 200 of file Parametrizable.h.

◆ setAllParametersValues() [1/2]

virtual void bpp::Parametrizable::setAllParametersValues ( const ParameterList parameters)
pure virtualinherited

Set the parameters values to be equals to those of parameters.

The list must contain exactly the same parameters (ie same names) than the parameters available.

Parameters
parametersA list with all parameters.
Exceptions
ParameterNotFoundExceptionIf a some parameter in the list is not in params.
ConstraintExceptionIf a value in parameters does not match the constraint in the corresponding parameter in the list.

Implemented in bpp::InfinityFunctionWrapper, bpp::FunctionWrapper, bpp::AbstractNumericalDerivative, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.

Referenced by bpp::Parametrizable::~Parametrizable().

◆ setAllParametersValues() [2/2]

void bpp::ParametrizableAdapter::setAllParametersValues ( const ParameterList parameters)
inlineoverridevirtualinherited

Set the parameters values to be equals to those of parameters.

The list must contain exactly the same parameters (ie same names) than the parameters available.

Parameters
parametersA list with all parameters.
Exceptions
ParameterNotFoundExceptionIf a some parameter in the list is not in params.
ConstraintExceptionIf a value in parameters does not match the constraint in the corresponding parameter in the list.

Implements bpp::Parametrizable.

Definition at line 196 of file Parametrizable.h.

◆ setConstraint() [1/2]

virtual void bpp::Parametrizable::setConstraint ( const std::string &  name,
std::shared_ptr< ConstraintInterface constraint 
)
pure virtualinherited

Set/Change the constraint associated with one parameter.

Parameters
nameThe name of the parameter to look for.
constraintA pointer to the constraint (may be null)
Exceptions
ParameterNotFoundExceptionif no parameter with this name is found.

Implemented in bpp::FunctionWrapper, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.

Referenced by bpp::Parametrizable::~Parametrizable().

◆ setConstraint() [2/2]

void bpp::ParametrizableAdapter::setConstraint ( const std::string &  name,
std::shared_ptr< ConstraintInterface constraint 
)
inlineoverridevirtualinherited

Set/Change the constraint associated with one parameter.

Parameters
nameThe name of the parameter to look for.
constraintA pointer to the constraint (may be null)
Exceptions
ParameterNotFoundExceptionif no parameter with this name is found.

Implements bpp::Parametrizable.

Definition at line 201 of file Parametrizable.h.

◆ setConstraintPolicy()

void bpp::DirectionFunction::setConstraintPolicy ( const std::string &  constraintPolicy)
inline

Definition at line 66 of file DirectionFunction.h.

◆ setMessageHandler()

void bpp::DirectionFunction::setMessageHandler ( std::shared_ptr< OutputStream messenger)
inline

Definition at line 70 of file DirectionFunction.h.

◆ setNamespace() [1/2]

virtual void bpp::Parametrizable::setNamespace ( const std::string &  prefix)
pure virtualinherited

Set the namespace for the parameter names.

Parameters
prefixThe 'namespace', that is a prefix to add to all parameter names. If parameter names are already prefixed, the new prefix will be used instead.

Implemented in bpp::FunctionWrapper, bpp::ParametrizableAdapter, bpp::LogsumHmmLikelihood, bpp::RescaledHmmLikelihood, bpp::LowMemoryRescaledHmmLikelihood, bpp::AbstractParameterAliasable, bpp::MixtureOfDiscreteDistributions, bpp::AbstractParametrizable, and bpp::InvariantMixedDiscreteDistribution.

Referenced by bpp::Parametrizable::~Parametrizable().

◆ setNamespace() [2/2]

void bpp::ParametrizableAdapter::setNamespace ( const std::string &  prefix)
inlineoverridevirtualinherited

Set the namespace for the parameter names.

Parameters
prefixThe 'namespace', that is a prefix to add to all parameter names. If parameter names are already prefixed, the new prefix will be used instead.

Implements bpp::Parametrizable.

Definition at line 203 of file Parametrizable.h.

◆ setParameters()

void DirectionFunction::setParameters ( const ParameterList parameters)
overridevirtual

Set the point where the function must be computed.

Parameters
parametersThe parameter set to pass to the function.

Implements bpp::FunctionInterface.

Definition at line 12 of file DirectionFunction.cpp.

References bpp::ParameterList::setParameters().

Referenced by clone().

◆ setParametersValues() [1/2]

virtual void bpp::Parametrizable::setParametersValues ( const ParameterList parameters)
pure virtualinherited

Update the parameters from parameters.

parameters must be a subset of all parameters available.

Parameters
parametersA list containing all parameters to update.
Exceptions
ParameterNotFoundExceptionIf a some parameter in params is not in the list.
ConstraintExceptionIf a value in parameters does not match the constraint in the corresponding parameter in the list.

Implemented in bpp::InfinityFunctionWrapper, bpp::FunctionWrapper, bpp::AbstractNumericalDerivative, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.

Referenced by bpp::Parametrizable::~Parametrizable().

◆ setParametersValues() [2/2]

void bpp::ParametrizableAdapter::setParametersValues ( const ParameterList parameters)
inlineoverridevirtualinherited

Update the parameters from parameters.

parameters must be a subset of all parameters available.

Parameters
parametersA list containing all parameters to update.
Exceptions
ParameterNotFoundExceptionIf a some parameter in params is not in the list.
ConstraintExceptionIf a value in parameters does not match the constraint in the corresponding parameter in the list.

Implements bpp::Parametrizable.

Definition at line 198 of file Parametrizable.h.

◆ setParameterValue() [1/2]

virtual void bpp::Parametrizable::setParameterValue ( const std::string &  name,
double  value 
)
pure virtualinherited

Set the value of parameter with name name to be equal to value.

Parameters
namethe name of the parameter to set.
valueThe value of the parameter.
Exceptions
ParameterNotFoundExceptionIf no parameter in the list has the name name.
ConstraintExceptionIf value does not match the constraint associated to parameter name.

Implemented in bpp::InfinityFunctionWrapper, bpp::FunctionWrapper, bpp::AbstractNumericalDerivative, bpp::ParametrizableAdapter, and bpp::AbstractParametrizable.

Referenced by bpp::Parametrizable::~Parametrizable().

◆ setParameterValue() [2/2]

void bpp::ParametrizableAdapter::setParameterValue ( const std::string &  name,
double  value 
)
inlineoverridevirtualinherited

Set the value of parameter with name name to be equal to value.

Parameters
namethe name of the parameter to set.
valueThe value of the parameter.
Exceptions
ParameterNotFoundExceptionIf no parameter in the list has the name name.
ConstraintExceptionIf value does not match the constraint associated to parameter name.

Implements bpp::Parametrizable.

Definition at line 197 of file Parametrizable.h.

Member Data Documentation

◆ constraintPolicy_

std::string bpp::DirectionFunction::constraintPolicy_
private

Definition at line 25 of file DirectionFunction.h.

Referenced by getConstraintPolicy(), and operator=().

◆ function_

std::shared_ptr<FunctionInterface> bpp::DirectionFunction::function_
private

Definition at line 24 of file DirectionFunction.h.

Referenced by getFunction(), and operator=().

◆ messenger_

std::shared_ptr<OutputStream> bpp::DirectionFunction::messenger_
private

Definition at line 26 of file DirectionFunction.h.

Referenced by operator=().

◆ p_

ParameterList bpp::DirectionFunction::p_
mutableprivate

Definition at line 22 of file DirectionFunction.h.

Referenced by getFunctionParameters(), and operator=().

◆ parameter_

Parameter bpp::ParametrizableAdapter::parameter_
protectedinherited

Definition at line 180 of file Parametrizable.h.

◆ parameters_

ParameterList bpp::ParametrizableAdapter::parameters_
protectedinherited

Definition at line 179 of file Parametrizable.h.

◆ params_

ParameterList bpp::DirectionFunction::params_
mutableprivate

Definition at line 22 of file DirectionFunction.h.

Referenced by operator=().

◆ xi_

std::vector<double> bpp::DirectionFunction::xi_
private

Definition at line 23 of file DirectionFunction.h.

Referenced by operator=().

◆ xt_

ParameterList bpp::DirectionFunction::xt_
mutableprivate

Definition at line 22 of file DirectionFunction.h.


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