bpp-core  2.2.0
bpp::Function Class Referenceabstract

This is the function abstract class. More...

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

+ Inheritance diagram for bpp::Function:
+ Collaboration diagram for bpp::Function:

Public Member Functions

 Function ()
 
virtual ~Function ()
 
virtual void setParameters (const ParameterList &parameters)=0 throw (ParameterNotFoundException, ConstraintException, Exception)
 Set the point where the function must be computed. More...
 
virtual double getValue () const =0 throw (Exception)
 Get the value of the function at the current point. More...
 
virtual double f (const ParameterList &parameters) throw (Exception)
 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 ParameterListgetParameters () const =0
 Get all parameters available. More...
 
virtual const ParametergetParameter (const std::string &name) const =0 throw (ParameterNotFoundException)
 Get the parameter with specified name. More...
 
virtual double getParameterValue (const std::string &name) const =0 throw (ParameterNotFoundException)
 Get the value for parameter of name 'name'. More...
 
virtual void setAllParametersValues (const ParameterList &parameters)=0 throw (ParameterNotFoundException, ConstraintException)
 Set the parameters values to be equals to those of parameters. More...
 
virtual void setParameterValue (const std::string &name, double value)=0 throw (ParameterNotFoundException, ConstraintException)
 Set the value of parameter with name name to be equal to value. More...
 
virtual void setParametersValues (const ParameterList &parameters)=0 throw (ParameterNotFoundException, ConstraintException)
 Update the parameters from parameters. More...
 
virtual bool matchParametersValues (const ParameterList &parameters)=0 throw (ConstraintException)
 Update the parameters from parameters. More...
 
virtual size_t getNumberOfParameters () const =0
 Get the number of parameters. 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...
 
virtual Clonableclone () const =0
 Create a copy of this object and send a pointer to it. More...
 

Detailed Description

This is the function abstract class.

This class provides the interface for function objet and a default implementation of the f() function.

The f() function sends the value of the function according to a given set of parameters.

However for complexe function like likelihood for instance, computing the function value takes some time, and one do not want to perform several times the computation for an identical set of parameters. The setParameters() method hence allows to set the parameter value for which the function is to be computed, perform the computation and store the results. The getValue() methods send the result of the computation. One may hence access to the result of the computation by calling the getvalue() method without re-computating the function. The f(parameters) function is a shortcut for

setParameters(parameters);
return getValue();

for convinience.

See also
Parameter, ParameterList

Definition at line 86 of file Functions.h.

Constructor & Destructor Documentation

◆ Function()

bpp::Function::Function ( )
inline

Definition at line 90 of file Functions.h.

◆ ~Function()

virtual bpp::Function::~Function ( )
inlinevirtual

Definition at line 91 of file Functions.h.

Member Function Documentation

◆ clone()

virtual Clonable* bpp::Clonable::clone ( ) const
pure virtualinherited

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

Returns
A pointer toward the copy object.

Implemented in bpp::TestFunction, bpp::InfinityDerivableSecondOrderWrapper, bpp::InfinityDerivableFirstOrderWrapper, bpp::InfinityFunctionWrapper, bpp::LinearMatrix< Scalar >, bpp::StdErr, bpp::FunctionStopCondition, bpp::StdOut, bpp::PlaceboTransformedParameter, bpp::ColMatrix< Scalar >, bpp::StlOutputStreamWrapper, bpp::ParametersStopCondition, bpp::ReparametrizationDerivableSecondOrderWrapper, bpp::IntervalTransformedParameter, bpp::BppUnsignedInteger, bpp::MetaOptimizer, bpp::StlOutputStream, bpp::IntervalConstraint, bpp::DerivableSecondOrder, bpp::Parameter, bpp::RescaledHmmLikelihood, bpp::BppInteger, bpp::LogsumHmmLikelihood, bpp::ReparametrizationDerivableFirstOrderWrapper, bpp::RowMatrix< Scalar >, bpp::RowMatrix< double >, bpp::RowMatrix< Real >, bpp::BppDouble, bpp::LowMemoryRescaledHmmLikelihood, bpp::Simplex, bpp::NullOutputStream, bpp::RTransformedParameter, bpp::ParametrizableCollection< N >, bpp::DerivableFirstOrder, bpp::Optimizer, bpp::Number< T >, bpp::Number< double >, bpp::Number< int >, bpp::Number< unsigned int >, bpp::DownhillSimplexMethod, bpp::AbstractNumericalDerivative, bpp::SimpleDiscreteDistribution, bpp::ThreePointsNumericalDerivative, bpp::DirichletDiscreteDistribution, bpp::FivePointsNumericalDerivative, bpp::DualityDiagram, bpp::ReparametrizationFunctionWrapper, bpp::PrincipalComponentAnalysis, bpp::TruncatedExponentialDiscreteDistribution, bpp::MetaOptimizerInfos, bpp::MixtureOfDiscreteDistributions, bpp::NewtonBacktrackOneDimension, bpp::AutoParameter, bpp::DataTable, bpp::ParameterListener, bpp::UNode, bpp::InvariantMixedDiscreteDistribution, bpp::AliasParameterListener, bpp::PowellMultiDimensions, bpp::Range< T >, bpp::OutputStream, bpp::BrentOneDimension, bpp::TwoPointsNumericalDerivative, bpp::GammaDiscreteDistribution, bpp::GoldenSectionSearch, bpp::DirectionFunction, bpp::BetaDiscreteDistribution, bpp::ExponentialDiscreteDistribution, bpp::BppVector< TYPE >, bpp::CorrespondenceAnalysis, bpp::Point2D< T >, bpp::BppNotANumber, bpp::BppString, bpp::BasicTNode, bpp::HmmLikelihood, bpp::ParameterList, bpp::ContingencyTableTest, bpp::Font, bpp::BfgsMultiDimensions, bpp::FullHmmTransitionMatrix, bpp::BppBoolean, bpp::TNode, bpp::GaussianDiscreteDistribution, bpp::NewtonBacktrackOneDimension::NBODStopCondition, bpp::OptimizationStopCondition, bpp::ParameterEvent, bpp::UniformDiscreteDistribution, bpp::AutoCorrelationTransitionMatrix, bpp::ConstantDistribution, bpp::DiscreteDistribution, bpp::MultipleDiscreteDistribution, bpp::ConjugateGradientMultiDimensions, bpp::DownhillSimplexMethod::DSMStopCondition, bpp::RGBColor, bpp::BrentOneDimension::BODStopCondition, bpp::ONode, bpp::GoldenSectionSearch::GSSStopCondition, bpp::PowellMultiDimensions::PMDStopCondition, bpp::SimpleMultiDimensions, bpp::SimpleNewtonMultiDimensions, bpp::Constraint, bpp::HmmEmissionProbabilities, bpp::TransformedParameter, bpp::BppNumberI, and bpp::NewtonOneDimension.

◆ f()

◆ getNamespace()

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::FunctionWrapper::getNamespace().

◆ getNumberOfParameters()

virtual size_t bpp::Parametrizable::getNumberOfParameters ( ) const
pure virtualinherited

Get the number of parameters.

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

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

Referenced by bpp::FunctionWrapper::getNumberOfParameters(), and bpp::BppODiscreteDistributionFormat::write().

◆ getParameter()

virtual const Parameter& bpp::Parametrizable::getParameter ( const std::string &  name) const
throw (ParameterNotFoundException
)
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::FunctionWrapper::getParameter().

◆ getParameterNameWithoutNamespace()

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::FunctionWrapper::getParameterNameWithoutNamespace(), bpp::BppODiscreteDistributionFormat::read(), and bpp::BppOParametrizableFormat::write().

◆ getParameters()

virtual const ParameterList& bpp::Parametrizable::getParameters ( ) const
pure virtualinherited

◆ getParameterValue()

virtual double bpp::Parametrizable::getParameterValue ( const std::string &  name) const
throw (ParameterNotFoundException
)
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::FunctionWrapper::getParameterValue(), and bpp::BppODiscreteDistributionFormat::read().

◆ getValue()

◆ hasParameter()

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::FunctionWrapper::hasParameter().

◆ matchParametersValues()

virtual bool bpp::Parametrizable::matchParametersValues ( const ParameterList parameters)
throw (ConstraintException
)
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::InvariantMixedDiscreteDistribution::fireParameterChanged(), bpp::AbstractNumericalDerivative::matchParametersValues(), bpp::FunctionWrapper::matchParametersValues(), and bpp::InfinityFunctionWrapper::matchParametersValues().

◆ setAllParametersValues()

virtual void bpp::Parametrizable::setAllParametersValues ( const ParameterList parameters)
throw (ParameterNotFoundException,
ConstraintException
)
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::AbstractNumericalDerivative::setAllParametersValues(), bpp::FunctionWrapper::setAllParametersValues(), and bpp::InfinityFunctionWrapper::setAllParametersValues().

◆ setNamespace()

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::AbstractParameterAliasable, bpp::MixtureOfDiscreteDistributions, bpp::AbstractParametrizable, and bpp::InvariantMixedDiscreteDistribution.

Referenced by bpp::InvariantMixedDiscreteDistribution::InvariantMixedDiscreteDistribution(), bpp::InvariantMixedDiscreteDistribution::setNamespace(), and bpp::FunctionWrapper::setNamespace().

◆ setParameters()

◆ setParametersValues()

virtual void bpp::Parametrizable::setParametersValues ( const ParameterList parameters)
throw (ParameterNotFoundException,
ConstraintException
)
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::AbstractNumericalDerivative::setParametersValues(), bpp::FunctionWrapper::setParametersValues(), and bpp::InfinityFunctionWrapper::setParametersValues().

◆ setParameterValue()

virtual void bpp::Parametrizable::setParameterValue ( const std::string &  name,
double  value 
)
throw (ParameterNotFoundException,
ConstraintException
)
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::AbstractNumericalDerivative::setParameterValue(), bpp::FunctionWrapper::setParameterValue(), and bpp::InfinityFunctionWrapper::setParameterValue().


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