bpp-core  2.1.0
bpp::AbstractParametrizable Class Reference

A partial implementation of the Parametrizable interface. More...

#include <Bpp/Numeric/AbstractParametrizable.h>

+ Inheritance diagram for bpp::AbstractParametrizable:
+ Collaboration diagram for bpp::AbstractParametrizable:

List of all members.

Public Member Functions

 AbstractParametrizable (const std::string &prefix)
virtual ~AbstractParametrizable ()
bool hasParameter (const std::string &name) const
 Tell if there is a parameter with specified name.
const ParameterListgetParameters () const
 Get all parameters available.
const ParametergetParameter (const std::string &name) const throw (ParameterNotFoundException)
 Get the parameter with specified name.
double getParameterValue (const std::string &name) const throw (ParameterNotFoundException)
 Get the value for parameter of name 'name'.
void setAllParametersValues (const ParameterList &parameters) throw (ParameterNotFoundException, ConstraintException)
 Set the parameters values to be equals to those of parameters.
void setParameterValue (const std::string &name, double value) throw (ParameterNotFoundException, ConstraintException)
 Set the value of parameter with name name to be equal to value.
void setParametersValues (const ParameterList &parameters) throw (ParameterNotFoundException, ConstraintException)
 Update the parameters from parameters.
bool matchParametersValues (const ParameterList &parameters) throw (ConstraintException)
 Update the parameters from parameters.
size_t getNumberOfParameters () const
 Get the number of parameters.
void setNamespace (const std::string &prefix)
 Set the namespace for the parameter names.
std::string getNamespace () const
std::string getParameterNameWithoutNamespace (const std::string &name) const
 Resolves a parameter name according to the current namespace.
virtual void fireParameterChanged (const ParameterList &parameters)=0
 Notify the class when one or several parameters have changed.
virtual Clonableclone () const =0
 Create a copy of this object and send a pointer to it.

Protected Member Functions

void addParameter_ (Parameter *parameter)
void addParameters_ (const ParameterList &parameters)
void deleteParameter_ (size_t index) throw (IndexOutOfBoundsException)
void resetParameters_ ()
ParametergetParameter_ (const std::string &name) throw (ParameterNotFoundException)
ParametergetParameterWithNamespace_ (const std::string &name) throw (ParameterNotFoundException)
const ParametergetParameterWithNamespace_ (const std::string &name) const throw (ParameterNotFoundException)
ParametergetParameter_ (size_t index) throw (IndexOutOfBoundsException)
const ParametergetParameter_ (size_t index) const throw (IndexOutOfBoundsException)
ParameterListgetParameters_ ()

Private Attributes

ParameterList parameters_
std::string prefix_

Detailed Description

A partial implementation of the Parametrizable interface.

Parameters are stored in a protected ParameterList object.

The abstract fireParameterChanged() method is provided so that the derived class know when a parameter has changed, and can be updated. All methods call the corresponding method in ParameterList and then call the fireParameterChanged() method.

Definition at line 62 of file AbstractParametrizable.h.


Constructor & Destructor Documentation

bpp::AbstractParametrizable::AbstractParametrizable ( const std::string &  prefix) [inline]

Definition at line 70 of file AbstractParametrizable.h.

Definition at line 72 of file AbstractParametrizable.h.


Member Function Documentation

void bpp::AbstractParametrizable::addParameter_ ( Parameter parameter) [inline, protected]
void bpp::AbstractParametrizable::addParameters_ ( const ParameterList parameters) [inline, protected]
virtual Clonable* bpp::Clonable::clone ( ) const [pure virtual, inherited]

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::StdErr, bpp::FunctionStopCondition, bpp::StdOut, bpp::LinearMatrix< Scalar >, bpp::PlaceboTransformedParameter, bpp::StlOutputStreamWrapper, bpp::ParametersStopCondition, bpp::ReparametrizationDerivableSecondOrderWrapper, bpp::IntervalTransformedParameter, bpp::MetaOptimizer, bpp::StlOutputStream, bpp::DerivableSecondOrder, bpp::Parameter, bpp::ReparametrizationDerivableFirstOrderWrapper, bpp::IntervalConstraint, bpp::RowMatrix< Scalar >, bpp::RowMatrix< double >, bpp::RowMatrix< Real >, bpp::LowMemoryRescaledHmmLikelihood, bpp::NullOutputStream, bpp::LogsumHmmLikelihood, bpp::Simplex, bpp::RTransformedParameter, bpp::RescaledHmmLikelihood, bpp::DerivableFirstOrder, bpp::Optimizer, bpp::DownhillSimplexMethod, bpp::AbstractNumericalDerivative, bpp::SimpleDiscreteDistribution, bpp::DirichletDiscreteDistribution, bpp::DualityDiagram, bpp::ReparametrizationFunctionWrapper, bpp::PrincipalComponentAnalysis, bpp::TruncatedExponentialDiscreteDistribution, bpp::DataTable, bpp::MetaOptimizerInfos, bpp::MixtureOfDiscreteDistributions, bpp::NewtonBacktrackOneDimension, bpp::AutoParameter, bpp::FivePointsNumericalDerivative, bpp::ParameterListener, bpp::ThreePointsNumericalDerivative, bpp::UNode, bpp::InvariantMixedDiscreteDistribution, bpp::AliasParameterListener, bpp::PowellMultiDimensions, bpp::Range< T >, bpp::OutputStream, bpp::BrentOneDimension, bpp::GammaDiscreteDistribution, bpp::GoldenSectionSearch, bpp::DirectionFunction, bpp::TwoPointsNumericalDerivative, bpp::BetaDiscreteDistribution, bpp::ExponentialDiscreteDistribution, bpp::BppVector< TYPE >, bpp::CorrespondenceAnalysis, bpp::Point2D< T >, bpp::Number< T >, bpp::BppString, bpp::BasicTNode, bpp::ParameterList, bpp::ContingencyTableTest, bpp::Font, bpp::BfgsMultiDimensions, bpp::BppBoolean, bpp::TNode, bpp::HmmLikelihood, bpp::GaussianDiscreteDistribution, bpp::NewtonBacktrackOneDimension::NBODStopCondition, bpp::OptimizationStopCondition, bpp::ParameterEvent, bpp::UniformDiscreteDistribution, 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::HmmEmissionProbabilities, bpp::Constraint, bpp::TransformedParameter, and bpp::NewtonOneDimension.

std::string bpp::AbstractParametrizable::getNamespace ( ) const [inline, virtual]
Returns:
The current namespace used. This is an empty string if no namespace is currently defined.

Implements bpp::Parametrizable.

Definition at line 124 of file AbstractParametrizable.h.

References prefix_.

Referenced by bpp::MixtureOfDiscreteDistributions::MixtureOfDiscreteDistributions(), bpp::Simplex::setFrequencies(), bpp::AbstractParameterAliasable::setNamespace(), and bpp::BppODiscreteDistributionFormat::write().

size_t bpp::AbstractParametrizable::getNumberOfParameters ( ) const [inline, virtual]
const Parameter& bpp::AbstractParametrizable::getParameter ( const std::string &  name) const throw (ParameterNotFoundException) [inline, virtual]

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 79 of file AbstractParametrizable.h.

References bpp::ParameterList::getParameter(), parameters_, and prefix_.

Referenced by bpp::ReparametrizationDerivableFirstOrderWrapper::getFirstOrderDerivative(), getParameterValue(), getParameterWithNamespace_(), bpp::ReparametrizationDerivableSecondOrderWrapper::getSecondOrderDerivative(), and bpp::TestFunction::getValue().

Parameter& bpp::AbstractParametrizable::getParameter_ ( size_t  index) throw (IndexOutOfBoundsException) [inline, protected]

Definition at line 188 of file AbstractParametrizable.h.

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

const Parameter& bpp::AbstractParametrizable::getParameter_ ( size_t  index) const throw (IndexOutOfBoundsException) [inline, protected]

Definition at line 194 of file AbstractParametrizable.h.

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

std::string AbstractParametrizable::getParameterNameWithoutNamespace ( const std::string &  name) const [virtual]

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 63 of file AbstractParametrizable.cpp.

References bpp::TextTools::startsWith().

const ParameterList& bpp::AbstractParametrizable::getParameters ( ) const [inline, virtual]

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 77 of file AbstractParametrizable.h.

References parameters_.

Referenced by bpp::AbstractParameterAliasable::fireParameterChanged(), and bpp::MixtureOfDiscreteDistributions::MixtureOfDiscreteDistributions().

Parameter& bpp::AbstractParametrizable::getParameterWithNamespace_ ( const std::string &  name) throw (ParameterNotFoundException) [inline, protected]
Parameters:
nameThe name of the parameter, including its namespace.
Returns:
A reference toward the corresponding parameter.
Exceptions:
ParameterNotFoundExceptionIf no parameter with that name is found in the list.

Definition at line 174 of file AbstractParametrizable.h.

References getParameter_().

const Parameter& bpp::AbstractParametrizable::getParameterWithNamespace_ ( const std::string &  name) const throw (ParameterNotFoundException) [inline, protected]
Parameters:
nameThe name of the parameter, including its namespace.
Returns:
A reference toward the corresponding parameter.
Exceptions:
ParameterNotFoundExceptionIf no parameter with that name is found in the list.

Definition at line 183 of file AbstractParametrizable.h.

References getParameter().

bool bpp::AbstractParametrizable::hasParameter ( const std::string &  name) const [inline, virtual]

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 75 of file AbstractParametrizable.h.

References bpp::ParameterList::hasParameter(), parameters_, and prefix_.

Referenced by bpp::ConstantDistribution::fireParameterChanged().

bool bpp::AbstractParametrizable::matchParametersValues ( const ParameterList parameters) throw (ConstraintException) [inline, virtual]

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 111 of file AbstractParametrizable.h.

References fireParameterChanged(), bpp::ParameterList::matchParametersValues(), and parameters_.

Referenced by bpp::Simplex::setFrequencies(), bpp::ReparametrizationFunctionWrapper::setParameters(), and bpp::TestFunction::setParameters().

void bpp::AbstractParametrizable::resetParameters_ ( ) [inline, protected]

Reimplemented in bpp::AbstractParameterAliasable.

Definition at line 154 of file AbstractParametrizable.h.

References parameters_, and bpp::ParameterList::reset().

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 90 of file AbstractParametrizable.h.

References fireParameterChanged(), parameters_, and bpp::ParameterList::setAllParametersValues().

void AbstractParametrizable::setNamespace ( const std::string &  prefix) [virtual]

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.

Reimplemented in bpp::AbstractParameterAliasable, bpp::MixtureOfDiscreteDistributions, and bpp::InvariantMixedDiscreteDistribution.

Definition at line 45 of file AbstractParametrizable.cpp.

References bpp::TextTools::startsWith().

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 104 of file AbstractParametrizable.h.

References fireParameterChanged(), parameters_, and bpp::ParameterList::setParametersValues().

Referenced by bpp::RescaledHmmLikelihood::setParameters(), bpp::LogsumHmmLikelihood::setParameters(), and bpp::LowMemoryRescaledHmmLikelihood::setParameters().

void bpp::AbstractParametrizable::setParameterValue ( const std::string &  name,
double  value 
) throw (ParameterNotFoundException, ConstraintException) [inline, virtual]

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 97 of file AbstractParametrizable.h.

References fireParameterChanged(), parameters_, prefix_, bpp::ParameterList::setParameterValue(), and bpp::ParameterList::subList().


Member Data Documentation


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Friends