|
bpp-core
2.1.0
|
A partial implementation of the Parametrizable interface. More...
#include <Bpp/Numeric/AbstractParametrizable.h>
Inheritance diagram for bpp::AbstractParametrizable:
Collaboration diagram for bpp::AbstractParametrizable: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. More... | |
| const ParameterList & | getParameters () const |
| Get all parameters available. More... | |
| const Parameter & | getParameter (const std::string &name) const throw (ParameterNotFoundException) |
| Get the parameter with specified name. More... | |
| double | getParameterValue (const std::string &name) const throw (ParameterNotFoundException) |
| Get the value for parameter of name 'name'. More... | |
| void | setAllParametersValues (const ParameterList ¶meters) throw (ParameterNotFoundException, ConstraintException) |
| Set the parameters values to be equals to those of parameters. More... | |
| void | setParameterValue (const std::string &name, double value) throw (ParameterNotFoundException, ConstraintException) |
| Set the value of parameter with name name to be equal to value. More... | |
| void | setParametersValues (const ParameterList ¶meters) throw (ParameterNotFoundException, ConstraintException) |
| Update the parameters from parameters. More... | |
| bool | matchParametersValues (const ParameterList ¶meters) throw (ConstraintException) |
| Update the parameters from parameters. More... | |
| size_t | getNumberOfParameters () const |
| Get the number of parameters. More... | |
| void | setNamespace (const std::string &prefix) |
| Set the namespace for the parameter names. More... | |
| std::string | getNamespace () const |
| std::string | getParameterNameWithoutNamespace (const std::string &name) const |
| Resolves a parameter name according to the current namespace. More... | |
| virtual void | fireParameterChanged (const ParameterList ¶meters)=0 |
| Notify the class when one or several parameters have changed. More... | |
| virtual Clonable * | clone () const =0 |
| Create a copy of this object and send a pointer to it. More... | |
Protected Member Functions | |
| void | addParameter_ (Parameter *parameter) |
| void | addParameters_ (const ParameterList ¶meters) |
| void | deleteParameter_ (size_t index) throw (IndexOutOfBoundsException) |
| void | resetParameters_ () |
| Parameter & | getParameter_ (const std::string &name) throw (ParameterNotFoundException) |
| Parameter & | getParameterWithNamespace_ (const std::string &name) throw (ParameterNotFoundException) |
| const Parameter & | getParameterWithNamespace_ (const std::string &name) const throw (ParameterNotFoundException) |
| Parameter & | getParameter_ (size_t index) throw (IndexOutOfBoundsException) |
| const Parameter & | getParameter_ (size_t index) const throw (IndexOutOfBoundsException) |
| ParameterList & | getParameters_ () |
Private Attributes | |
| ParameterList | parameters_ |
| std::string | prefix_ |
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.
|
inline |
Definition at line 70 of file AbstractParametrizable.h.
|
inlinevirtual |
Definition at line 72 of file AbstractParametrizable.h.
|
inlineprotected |
Definition at line 136 of file AbstractParametrizable.h.
References parameters_.
Referenced by bpp::AbstractParameterAliasable::addParameter_(), bpp::TestFunction::TestFunction(), and bpp::TestFunction::TestFunction().
|
inlineprotected |
Definition at line 142 of file AbstractParametrizable.h.
References parameters_.
Referenced by bpp::AbstractParameterAliasable::addParameters_().
|
pure virtualinherited |
Create a copy of this object and send a pointer to it.
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::PowellMultiDimensions, bpp::Range< T >, bpp::OutputStream, bpp::AliasParameterListener, 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::DiscreteDistribution, bpp::MultipleDiscreteDistribution, bpp::ConstantDistribution, 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.
|
inlineprotected |
Definition at line 147 of file AbstractParametrizable.h.
References parameters_, parameters_, and parameters_.
Referenced by bpp::AbstractParameterAliasable::deleteParameter_().
|
pure virtual |
Notify the class when one or several parameters have changed.
| parameters | A ParameterList object with parameters that changed. |
Implemented in bpp::TestFunction, bpp::LowMemoryRescaledHmmLikelihood, bpp::LogsumHmmLikelihood, bpp::AbstractParameterAliasable, bpp::RescaledHmmLikelihood, bpp::Simplex, bpp::MixtureOfDiscreteDistributions, bpp::ReparametrizationFunctionWrapper, bpp::SimpleDiscreteDistribution, bpp::DirichletDiscreteDistribution, bpp::TruncatedExponentialDiscreteDistribution, bpp::InvariantMixedDiscreteDistribution, bpp::BetaDiscreteDistribution, bpp::ExponentialDiscreteDistribution, bpp::GammaDiscreteDistribution, bpp::GaussianDiscreteDistribution, bpp::UniformDiscreteDistribution, and bpp::ConstantDistribution.
Referenced by matchParametersValues(), setAllParametersValues(), setParametersValues(), and setParameterValue().
|
inlinevirtual |
Implements bpp::Parametrizable.
Definition at line 124 of file AbstractParametrizable.h.
References prefix_.
Referenced by bpp::MixtureOfDiscreteDistributions::MixtureOfDiscreteDistributions(), bpp::Simplex::setFrequencies(), bpp::Simplex::setFrequencies(), bpp::AbstractParameterAliasable::setNamespace(), bpp::AbstractParameterAliasable::setNamespace(), bpp::AbstractParameterAliasable::setNamespace(), bpp::AbstractParameterAliasable::setNamespace(), bpp::BppODiscreteDistributionFormat::write(), bpp::BppODiscreteDistributionFormat::write(), and bpp::BppODiscreteDistributionFormat::write().
|
inlinevirtual |
Get the number of parameters.
Implements bpp::Parametrizable.
Definition at line 120 of file AbstractParametrizable.h.
References parameters_.
Referenced by bpp::AbstractParameterAliasable::AbstractParameterAliasable(), bpp::SimpleDiscreteDistribution::fireParameterChanged(), bpp::AbstractParameterAliasable::operator=(), bpp::ConstantDistribution::restrictToConstraint(), and bpp::SimpleDiscreteDistribution::restrictToConstraint().
|
inlinevirtual |
Get the parameter with specified name.
| name | The name of the parameter to look for. |
| ParameterNotFoundException | if no parameter with this name is found. |
Implements bpp::Parametrizable.
Definition at line 79 of file AbstractParametrizable.h.
References parameters_.
Referenced by bpp::ReparametrizationDerivableFirstOrderWrapper::getFirstOrderDerivative(), getParameterValue(), getParameterWithNamespace_(), bpp::ReparametrizationDerivableSecondOrderWrapper::getSecondOrderDerivative(), bpp::ReparametrizationDerivableSecondOrderWrapper::getSecondOrderDerivative(), bpp::ReparametrizationDerivableSecondOrderWrapper::getSecondOrderDerivative(), bpp::ReparametrizationDerivableSecondOrderWrapper::getSecondOrderDerivative(), bpp::TestFunction::getValue(), and bpp::TestFunction::getValue().
|
inlineprotected |
| name | The name of the parameter. |
| ParameterNotFoundException | If no parameter with that name is found in the list. |
Definition at line 164 of file AbstractParametrizable.h.
References parameters_.
Referenced by bpp::AbstractParameterAliasable::deleteParameter_(), getParameterWithNamespace_(), bpp::ConstantDistribution::restrictToConstraint(), bpp::ConstantDistribution::restrictToConstraint(), bpp::TruncatedExponentialDiscreteDistribution::restrictToConstraint(), bpp::InvariantMixedDiscreteDistribution::restrictToConstraint(), bpp::SimpleDiscreteDistribution::restrictToConstraint(), bpp::SimpleDiscreteDistribution::restrictToConstraint(), and bpp::SimpleDiscreteDistribution::restrictToConstraint().
|
inlineprotected |
Definition at line 188 of file AbstractParametrizable.h.
References parameters_, parameters_, and parameters_.
|
inlineprotected |
Definition at line 194 of file AbstractParametrizable.h.
References parameters_, parameters_, and parameters_.
|
virtual |
Resolves a parameter name according to the current namespace.
Implements bpp::Parametrizable.
Definition at line 63 of file AbstractParametrizable.cpp.
References bpp::TextTools::startsWith().
|
inlinevirtual |
Get 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().
|
inlineprotected |
Definition at line 201 of file AbstractParametrizable.h.
References parameters_.
Referenced by bpp::AbstractParameterAliasable::AbstractParameterAliasable(), bpp::AbstractParameterAliasable::AbstractParameterAliasable(), bpp::AbstractParameterAliasable::AbstractParameterAliasable(), bpp::AbstractParameterAliasable::AbstractParameterAliasable(), bpp::AbstractParameterAliasable::operator=(), bpp::AbstractParameterAliasable::operator=(), bpp::AbstractParameterAliasable::operator=(), and bpp::AbstractParameterAliasable::operator=().
|
inlinevirtual |
Get the value for parameter of name 'name'.
| name | The name of the parameter. |
Implements bpp::Parametrizable.
Definition at line 84 of file AbstractParametrizable.h.
References getParameter(), and bpp::Parameter::getValue().
Referenced by bpp::DirichletDiscreteDistribution::applyParameters(), bpp::ConstantDistribution::fireParameterChanged(), bpp::GaussianDiscreteDistribution::fireParameterChanged(), bpp::GaussianDiscreteDistribution::fireParameterChanged(), bpp::ExponentialDiscreteDistribution::fireParameterChanged(), bpp::GammaDiscreteDistribution::fireParameterChanged(), bpp::GammaDiscreteDistribution::fireParameterChanged(), bpp::BetaDiscreteDistribution::fireParameterChanged(), bpp::BetaDiscreteDistribution::fireParameterChanged(), bpp::InvariantMixedDiscreteDistribution::fireParameterChanged(), bpp::TruncatedExponentialDiscreteDistribution::fireParameterChanged(), bpp::TruncatedExponentialDiscreteDistribution::fireParameterChanged(), bpp::SimpleDiscreteDistribution::fireParameterChanged(), bpp::SimpleDiscreteDistribution::fireParameterChanged(), bpp::SimpleDiscreteDistribution::fireParameterChanged(), bpp::SimpleDiscreteDistribution::fireParameterChanged(), bpp::MixtureOfDiscreteDistributions::fireParameterChanged(), bpp::MixtureOfDiscreteDistributions::fireParameterChanged(), bpp::Simplex::fireParameterChanged(), bpp::Simplex::fireParameterChanged(), bpp::ExponentialDiscreteDistribution::randC(), bpp::GammaDiscreteDistribution::randC(), bpp::GammaDiscreteDistribution::randC(), bpp::ExponentialDiscreteDistribution::randC(), bpp::GammaDiscreteDistribution::randC(), bpp::GammaDiscreteDistribution::randC(), bpp::BetaDiscreteDistribution::randC(), bpp::BetaDiscreteDistribution::randC(), bpp::BetaDiscreteDistribution::randC(), bpp::BetaDiscreteDistribution::randC(), bpp::TruncatedExponentialDiscreteDistribution::randC(), bpp::TruncatedExponentialDiscreteDistribution::randC(), bpp::ConstantDistribution::restrictToConstraint(), and bpp::ConstantDistribution::restrictToConstraint().
|
inlineprotected |
| name | The name of the parameter, including its namespace. |
| ParameterNotFoundException | If no parameter with that name is found in the list. |
Definition at line 174 of file AbstractParametrizable.h.
References getParameter_().
|
inlineprotected |
| name | The name of the parameter, including its namespace. |
| ParameterNotFoundException | If no parameter with that name is found in the list. |
Definition at line 183 of file AbstractParametrizable.h.
References getParameter().
|
inlinevirtual |
Tell if there is a parameter with specified name.
| name | The name of the parameter to look for. |
Implements bpp::Parametrizable.
Definition at line 75 of file AbstractParametrizable.h.
References parameters_.
Referenced by bpp::ConstantDistribution::fireParameterChanged().
|
inlinevirtual |
Update the parameters from parameters.
Only common parameters with parameters will be updated.
| parameters | A list of parameters. |
| ConstraintException | If 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(), and parameters_.
Referenced by bpp::Simplex::setFrequencies(), bpp::ReparametrizationFunctionWrapper::setParameters(), and bpp::TestFunction::setParameters().
|
inlineprotected |
Definition at line 154 of file AbstractParametrizable.h.
References parameters_.
Referenced by bpp::AbstractParameterAliasable::resetParameters_().
|
inlinevirtual |
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 | A list with all parameters. |
| ParameterNotFoundException | If a some parameter in the list is not in params. |
| ConstraintException | If 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(), and parameters_.
|
virtual |
Set the namespace for the parameter names.
| prefix | The '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::MixtureOfDiscreteDistributions, and bpp::InvariantMixedDiscreteDistribution.
Definition at line 45 of file AbstractParametrizable.cpp.
References bpp::TextTools::startsWith().
Referenced by bpp::AbstractParameterAliasable::setNamespace().
|
inlinevirtual |
Update the parameters from parameters.
parameters must be a subset of all parameters available.
| parameters | A list containing all parameters to update. |
| ParameterNotFoundException | If a some parameter in params is not in the list. |
| ConstraintException | If 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(), and parameters_.
Referenced by bpp::RescaledHmmLikelihood::setParameters(), bpp::LogsumHmmLikelihood::setParameters(), and bpp::LowMemoryRescaledHmmLikelihood::setParameters().
|
inlinevirtual |
Set the value of parameter with name name to be equal to value.
| name | the name of the parameter to set. |
| value | The value of the parameter. |
| ParameterNotFoundException | If no parameter in the list has the name name. |
| ConstraintException | If value does not match the constraint associated to parameter name. |
Implements bpp::Parametrizable.
Definition at line 97 of file AbstractParametrizable.h.
References fireParameterChanged(), and parameters_.
|
private |
Definition at line 66 of file AbstractParametrizable.h.
Referenced by addParameter_(), addParameters_(), deleteParameter_(), deleteParameter_(), deleteParameter_(), getNumberOfParameters(), getParameter(), getParameter_(), getParameter_(), getParameter_(), getParameter_(), getParameter_(), getParameter_(), getParameter_(), getParameters(), getParameters_(), hasParameter(), matchParametersValues(), resetParameters_(), setAllParametersValues(), setParametersValues(), setParameterValue(), and setParameterValue().
|
private |
Definition at line 67 of file AbstractParametrizable.h.
Referenced by getNamespace(), getParameter(), getParameter_(), hasParameter(), setParameterValue(), and setParameterValue().