bpp-core3
3.0.0
|
A partial implementation of the Parametrizable interface. More...
#include <Bpp/Numeric/AbstractParametrizable.h>
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 |
Get the parameter with specified name. More... | |
const std::shared_ptr< Parameter > & | getSharedParameter (const std::string &name) const |
double | getParameterValue (const std::string &name) const |
Get the value for parameter of name 'name'. More... | |
void | setAllParametersValues (const ParameterList ¶meters) |
Set the parameters values to be equals to those of parameters. More... | |
void | setParameterValue (const std::string &name, double value) |
Set the value of parameter with name name to be equal to value. More... | |
void | setParametersValues (const ParameterList ¶meters) |
Update the parameters from parameters. More... | |
bool | matchParametersValues (const ParameterList ¶meters) |
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) |
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 | |
virtual void | addParameter_ (Parameter *parameter) |
virtual void | addParameters_ (const ParameterList ¶meters) |
virtual void | shareParameter_ (const std::shared_ptr< Parameter > ¶meter) |
virtual void | shareParameters_ (const ParameterList ¶meters) |
virtual void | includeParameters_ (const ParameterList ¶meters) |
virtual void | deleteParameter_ (size_t index) |
virtual void | deleteParameter_ (std::string &name) |
virtual void | deleteParameters_ (const std::vector< std::string > &names) |
void | resetParameters_ () |
Parameter & | getParameter_ (const std::string &name) |
Parameter & | getParameterWithNamespace_ (const std::string &name) |
const Parameter & | getParameterWithNamespace_ (const std::string &name) const |
Parameter & | getParameter_ (size_t index) |
const Parameter & | getParameter_ (size_t index) const |
ParameterList & | getParameters_ () |
Get all parameters available. More... | |
const std::shared_ptr< Parameter > & | getSharedParameter (size_t i) const |
std::shared_ptr< Parameter > & | getSharedParameter (size_t i) |
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.
|
inlineprotectedvirtual |
Reimplemented in bpp::AbstractParameterAliasable.
Definition at line 137 of file AbstractParametrizable.h.
References bpp::ParameterList::addParameter(), and parameters_.
Referenced by bpp::AbstractParameterAliasable::addParameter_(), bpp::AutoCorrelationTransitionMatrix::AutoCorrelationTransitionMatrix(), and bpp::TestFunction::TestFunction().
|
inlineprotectedvirtual |
Reimplemented in bpp::AbstractParameterAliasable.
Definition at line 143 of file AbstractParametrizable.h.
References bpp::ParameterList::addParameters(), and parameters_.
Referenced by bpp::AbstractParameterAliasable::addParameters_(), bpp::FullHmmTransitionMatrix::FullHmmTransitionMatrix(), bpp::LogsumHmmLikelihood::LogsumHmmLikelihood(), bpp::LowMemoryRescaledHmmLikelihood::LowMemoryRescaledHmmLikelihood(), and bpp::RescaledHmmLikelihood::RescaledHmmLikelihood().
|
pure virtualinherited |
Create a copy of this object and send a pointer to it.
Implemented in bpp::TransformedParameter, bpp::MultipleDiscreteDistribution, bpp::DiscreteDistribution, bpp::ParameterListener, bpp::BppNumberI, bpp::HmmLikelihood, bpp::HmmEmissionProbabilities, bpp::Optimizer, bpp::OptimizationStopCondition, bpp::DerivableSecondOrder, bpp::DerivableFirstOrder, bpp::AbstractNumericalDerivative, bpp::Constraint, bpp::OutputStream, bpp::PlaceboTransformedParameter, bpp::IntervalTransformedParameter, bpp::RTransformedParameter, bpp::Table< T >, bpp::PrincipalComponentAnalysis, bpp::DualityDiagram, bpp::CorrespondenceAnalysis, bpp::ContingencyTableTest, bpp::Range< T >, bpp::UniformDiscreteDistribution, bpp::TruncatedExponentialDiscreteDistribution, bpp::Simplex, bpp::SimpleDiscreteDistribution, bpp::MixtureOfDiscreteDistributions, bpp::InvariantMixedDiscreteDistribution, bpp::GaussianDiscreteDistribution, bpp::GammaDiscreteDistribution, bpp::ExponentialDiscreteDistribution, bpp::DirichletDiscreteDistribution, bpp::ConstantDistribution, bpp::BetaDiscreteDistribution, bpp::ParametrizableCollection< N >, bpp::ParameterList, bpp::Parameter, bpp::ParameterEvent, bpp::BppUnsignedInteger, bpp::BppInteger, bpp::BppDouble, bpp::Number< T >, bpp::Number< double >, bpp::Number< int >, bpp::Number< unsigned int >, bpp::BppNotANumber, bpp::LinearMatrix< Scalar >, bpp::ColMatrix< Scalar >, bpp::RowMatrix< Scalar >, bpp::RowMatrix< double >, bpp::RowMatrix< Real >, bpp::RescaledHmmLikelihood, bpp::LowMemoryRescaledHmmLikelihood, bpp::LogsumHmmLikelihood, bpp::FullHmmTransitionMatrix, bpp::AutoCorrelationTransitionMatrix, bpp::TwoPointsNumericalDerivative, bpp::ThreePointsNumericalDerivative, bpp::SimpleNewtonMultiDimensions, bpp::SimpleMultiDimensions, bpp::ReparametrizationDerivableSecondOrderWrapper, bpp::ReparametrizationDerivableFirstOrderWrapper, bpp::ReparametrizationFunctionWrapper, bpp::PowellMultiDimensions, bpp::PowellMultiDimensions::PMDStopCondition, bpp::FunctionStopCondition, bpp::ParametersStopCondition, bpp::NegativeOperator, bpp::MathOperator, bpp::FunctionOperator< F >, bpp::ConstantOperator, bpp::ComputationTree, bpp::BinaryOperator, bpp::NewtonOneDimension, bpp::NewtonBacktrackOneDimension, bpp::NewtonBacktrackOneDimension::NBODStopCondition, bpp::MetaOptimizer, bpp::MetaOptimizerInfos, bpp::GoldenSectionSearch, bpp::GoldenSectionSearch::GSSStopCondition, bpp::TestFunction, bpp::InfinityDerivableSecondOrderWrapper, bpp::InfinityDerivableFirstOrderWrapper, bpp::InfinityFunctionWrapper, bpp::FivePointsNumericalDerivative, bpp::DownhillSimplexMethod, bpp::DownhillSimplexMethod::DSMStopCondition, bpp::DirectionFunction, bpp::ConjugateGradientMultiDimensions, bpp::BrentOneDimension, bpp::BrentOneDimension::BODStopCondition, bpp::BfgsMultiDimensions, bpp::DataTable, bpp::IntervalConstraint, bpp::AutoParameter, bpp::AliasParameterListener, bpp::StdErr, bpp::StdOut, bpp::StlOutputStreamWrapper, bpp::StlOutputStream, bpp::NullOutputStream, bpp::RGBColor, bpp::Point2D< T >, bpp::Font, bpp::GlobalGraph, bpp::AssociationTreeGraphImplObserver< N, E, TreeGraphImpl >, bpp::AssociationGraphImplObserver< N, E, GraphImpl >, bpp::AssociationGraphImplObserver< N, E, DAGraphImpl >, bpp::AssociationGraphImplObserver< N, E, TreeGraphImpl >, bpp::AssociationDAGraphImplObserver< N, E, DAGraphImpl >, bpp::BppVector< T >, bpp::BppString, and bpp::BppBoolean.
Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::LogsumHmmLikelihood::LogsumHmmLikelihood(), and bpp::LogsumHmmLikelihood::operator=().
|
inlineprotectedvirtual |
Reimplemented in bpp::AbstractParameterAliasable.
Definition at line 163 of file AbstractParametrizable.h.
References bpp::ParameterList::deleteParameter(), parameters_, and bpp::ParameterList::size().
Referenced by bpp::AbstractParameterAliasable::deleteParameter_().
|
inlineprotectedvirtual |
Reimplemented in bpp::AbstractParameterAliasable.
Definition at line 170 of file AbstractParametrizable.h.
References bpp::ParameterList::deleteParameter(), and parameters_.
|
inlineprotectedvirtual |
Reimplemented in bpp::AbstractParameterAliasable.
Definition at line 175 of file AbstractParametrizable.h.
References bpp::ParameterList::deleteParameters(), and parameters_.
|
inlinevirtual |
Notify the class when one or several parameters have changed.
parameters | A ParameterList object with parameters that changed. |
Reimplemented in bpp::RescaledHmmLikelihood, bpp::LowMemoryRescaledHmmLikelihood, bpp::LogsumHmmLikelihood, bpp::UniformDiscreteDistribution, bpp::TruncatedExponentialDiscreteDistribution, bpp::Simplex, bpp::SimpleDiscreteDistribution, bpp::MixtureOfDiscreteDistributions, bpp::InvariantMixedDiscreteDistribution, bpp::GaussianDiscreteDistribution, bpp::GammaDiscreteDistribution, bpp::ExponentialDiscreteDistribution, bpp::DirichletDiscreteDistribution, bpp::ConstantDistribution, bpp::BetaDiscreteDistribution, bpp::ParametrizableCollection< N >, bpp::FullHmmTransitionMatrix, bpp::AutoCorrelationTransitionMatrix, bpp::ReparametrizationFunctionWrapper, and bpp::TestFunction.
Definition at line 134 of file AbstractParametrizable.h.
Referenced by bpp::BetaDiscreteDistribution::fireParameterChanged(), bpp::ConstantDistribution::fireParameterChanged(), bpp::DirichletDiscreteDistribution::fireParameterChanged(), bpp::ExponentialDiscreteDistribution::fireParameterChanged(), bpp::GammaDiscreteDistribution::fireParameterChanged(), bpp::GaussianDiscreteDistribution::fireParameterChanged(), bpp::InvariantMixedDiscreteDistribution::fireParameterChanged(), bpp::MixtureOfDiscreteDistributions::fireParameterChanged(), bpp::SimpleDiscreteDistribution::fireParameterChanged(), bpp::TruncatedExponentialDiscreteDistribution::fireParameterChanged(), matchParametersValues(), setAllParametersValues(), setParametersValues(), and setParameterValue().
|
inlinevirtual |
Implements bpp::Parametrizable.
Definition at line 125 of file AbstractParametrizable.h.
References prefix_.
Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::AbstractParameterAliasable::hasIndependentParameter(), bpp::MixtureOfDiscreteDistributions::MixtureOfDiscreteDistributions(), bpp::Simplex::setFrequencies(), bpp::AbstractParameterAliasable::setNamespace(), and bpp::BppODiscreteDistributionFormat::writeDiscreteDistribution().
|
inlinevirtual |
Get the number of parameters.
Implements bpp::Parametrizable.
Definition at line 121 of file AbstractParametrizable.h.
References parameters_, and bpp::ParameterList::size().
Referenced by bpp::AbstractParameterAliasable::AbstractParameterAliasable(), bpp::AbstractParameterAliasable::aliasParameters(), 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 bpp::ParameterList::getParameter(), parameters_, and prefix_.
Referenced by bpp::AbstractParameterAliasable::getAliasedParameters(), bpp::ReparametrizationDerivableFirstOrderWrapper::getFirstOrderDerivative(), bpp::AbstractParameterAliasable::getFromParameters(), getParameterValue(), getParameterWithNamespace_(), bpp::ReparametrizationDerivableSecondOrderWrapper::getSecondOrderDerivative(), 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 190 of file AbstractParametrizable.h.
References bpp::ParameterList::getParameter(), hasParameter(), parameters_, and prefix_.
Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::AbstractParameterAliasable::deleteParameter_(), getParameterWithNamespace_(), bpp::ConstantDistribution::restrictToConstraint(), bpp::InvariantMixedDiscreteDistribution::restrictToConstraint(), bpp::SimpleDiscreteDistribution::restrictToConstraint(), bpp::TruncatedExponentialDiscreteDistribution::restrictToConstraint(), and bpp::AbstractParameterAliasable::unaliasParameters().
|
inlineprotected |
Definition at line 216 of file AbstractParametrizable.h.
References parameters_, and bpp::ParameterList::size().
|
inlineprotected |
Definition at line 223 of file AbstractParametrizable.h.
References parameters_, and bpp::ParameterList::size().
|
virtual |
Resolves a parameter name according to the current namespace.
Implements bpp::Parametrizable.
Definition at line 65 of file AbstractParametrizable.cpp.
References bpp::TextTools::startsWith().
Referenced by bpp::AbstractParameterAliasable::AbstractParameterAliasable(), bpp::AbstractParameterAliasable::addParameter_(), bpp::AbstractParameterAliasable::addParameters_(), bpp::AbstractParameterAliasable::includeParameters_(), bpp::AbstractParameterAliasable::operator=(), and bpp::AbstractParameterAliasable::shareParameters_().
|
inlinevirtual |
Get all parameters available.
Implements bpp::Parametrizable.
Definition at line 77 of file AbstractParametrizable.h.
References parameters_.
Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::FullHmmTransitionMatrix::FullHmmTransitionMatrix(), bpp::MixtureOfDiscreteDistributions::MixtureOfDiscreteDistributions(), and bpp::ParametrizableCollection< N >::removeObject().
|
inlineprotectedvirtual |
Get all parameters available.
Implements bpp::Parametrizable.
Definition at line 231 of file AbstractParametrizable.h.
References parameters_.
Referenced by bpp::AbstractParameterAliasable::AbstractParameterAliasable(), bpp::AbstractParameterAliasable::aliasParameters(), 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 89 of file AbstractParametrizable.h.
References getParameter(), and bpp::Parameter::getValue().
Referenced by bpp::DirichletDiscreteDistribution::applyParameters(), bpp::AutoCorrelationTransitionMatrix::fireParameterChanged(), bpp::BetaDiscreteDistribution::fireParameterChanged(), bpp::ConstantDistribution::fireParameterChanged(), bpp::ExponentialDiscreteDistribution::fireParameterChanged(), bpp::GammaDiscreteDistribution::fireParameterChanged(), bpp::GaussianDiscreteDistribution::fireParameterChanged(), bpp::InvariantMixedDiscreteDistribution::fireParameterChanged(), bpp::MixtureOfDiscreteDistributions::fireParameterChanged(), bpp::SimpleDiscreteDistribution::fireParameterChanged(), bpp::Simplex::fireParameterChanged(), bpp::TruncatedExponentialDiscreteDistribution::fireParameterChanged(), bpp::BetaDiscreteDistribution::randC(), bpp::ExponentialDiscreteDistribution::randC(), bpp::GammaDiscreteDistribution::randC(), bpp::TruncatedExponentialDiscreteDistribution::randC(), 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 202 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 211 of file AbstractParametrizable.h.
References getParameter().
|
inline |
Definition at line 84 of file AbstractParametrizable.h.
References bpp::ParameterList::getSharedParameter(), parameters_, and prefix_.
Referenced by bpp::AbstractParameterAliasable::AbstractParameterAliasable(), bpp::AbstractParameterAliasable::addParameter_(), bpp::AbstractParameterAliasable::addParameters_(), bpp::AbstractParameterAliasable::includeParameters_(), bpp::AbstractParameterAliasable::operator=(), bpp::AbstractParameterAliasable::shareParameters_(), and bpp::AbstractParameterAliasable::unaliasParameters().
|
inlineprotected |
Definition at line 242 of file AbstractParametrizable.h.
References bpp::ParameterList::getSharedParameter(), and parameters_.
|
inlineprotected |
Definition at line 237 of file AbstractParametrizable.h.
References bpp::ParameterList::getSharedParameter(), and parameters_.
|
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 bpp::ParameterList::hasParameter(), parameters_, and prefix_.
Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::GammaDiscreteDistribution::fireParameterChanged(), getParameter_(), and bpp::AbstractParameterAliasable::unaliasParameters().
|
inlineprotectedvirtual |
Reimplemented in bpp::AbstractParameterAliasable.
Definition at line 158 of file AbstractParametrizable.h.
References bpp::ParameterList::includeParameters(), and parameters_.
Referenced by bpp::AbstractParameterAliasable::includeParameters_().
|
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 112 of file AbstractParametrizable.h.
References fireParameterChanged(), bpp::ParameterList::matchParametersValues(), parameters_, and bpp::ParameterList::shareSubList().
Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::Simplex::setFrequencies(), bpp::TestFunction::setParameters(), bpp::ReparametrizationFunctionWrapper::setParameters(), and bpp::FullHmmTransitionMatrix::setTransitionProbabilities().
|
inlineprotected |
Definition at line 180 of file AbstractParametrizable.h.
References parameters_, and bpp::ParameterList::reset().
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 94 of file AbstractParametrizable.h.
References fireParameterChanged(), parameters_, and bpp::ParameterList::setAllParametersValues().
|
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, bpp::InvariantMixedDiscreteDistribution, bpp::RescaledHmmLikelihood, bpp::LowMemoryRescaledHmmLikelihood, and bpp::LogsumHmmLikelihood.
Definition at line 47 of file AbstractParametrizable.cpp.
References bpp::TextTools::startsWith().
Referenced by bpp::LogsumHmmLikelihood::setNamespace(), bpp::LowMemoryRescaledHmmLikelihood::setNamespace(), bpp::RescaledHmmLikelihood::setNamespace(), and 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 106 of file AbstractParametrizable.h.
References fireParameterChanged(), parameters_, and bpp::ParameterList::setParametersValues().
Referenced by bpp::LogsumHmmLikelihood::setParameters(), bpp::LowMemoryRescaledHmmLikelihood::setParameters(), and bpp::RescaledHmmLikelihood::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 100 of file AbstractParametrizable.h.
References bpp::ParameterList::createSubList(), fireParameterChanged(), parameters_, prefix_, and bpp::ParameterList::setParameterValue().
|
inlineprotectedvirtual |
Reimplemented in bpp::AbstractParameterAliasable.
Definition at line 148 of file AbstractParametrizable.h.
References parameters_, and bpp::ParameterList::shareParameter().
Referenced by bpp::AbstractParameterAliasable::shareParameter_().
|
inlineprotectedvirtual |
Reimplemented in bpp::AbstractParameterAliasable.
Definition at line 153 of file AbstractParametrizable.h.
References parameters_, and bpp::ParameterList::shareParameters().
Referenced by bpp::AbstractParameterAliasable::shareParameters_().
|
private |
Definition at line 66 of file AbstractParametrizable.h.
Referenced by addParameter_(), addParameters_(), deleteParameter_(), deleteParameters_(), getNumberOfParameters(), getParameter(), getParameter_(), getParameters(), getParameters_(), getSharedParameter(), hasParameter(), includeParameters_(), matchParametersValues(), resetParameters_(), setAllParametersValues(), setParametersValues(), setParameterValue(), shareParameter_(), and shareParameters_().
|
private |
Definition at line 67 of file AbstractParametrizable.h.
Referenced by getNamespace(), getParameter(), getParameter_(), getSharedParameter(), hasParameter(), and setParameterValue().