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 override |
Tell if there is a parameter with specified name. More... | |
const ParameterList & | getParameters () const override |
Get all parameters available. More... | |
const Parameter & | parameter (const std::string &name) const override |
Get the parameter with specified name. More... | |
const std::shared_ptr< Parameter > & | getParameter (const std::string &name) const |
double | getParameterValue (const std::string &name) const override |
Get the value for parameter of name 'name'. More... | |
void | setAllParametersValues (const ParameterList ¶meters) 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 ¶meters) override |
Update the parameters from parameters. More... | |
bool | matchParametersValues (const ParameterList ¶meters) 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... | |
size_t | getNumberOfParameters () const override |
Get the number of parameters. 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... | |
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_ () override |
Get all parameters available. More... | |
const std::shared_ptr< Parameter > & | getParameter (size_t i) const |
std::shared_ptr< Parameter > & | getParameter (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 26 of file AbstractParametrizable.h.
|
inline |
Definition at line 34 of file AbstractParametrizable.h.
|
inlinevirtual |
Definition at line 36 of file AbstractParametrizable.h.
|
inlineprotectedvirtual |
Reimplemented in bpp::AbstractParameterAliasable.
Definition at line 111 of file AbstractParametrizable.h.
References bpp::ParameterList::addParameter().
Referenced by bpp::AbstractParameterAliasable::addParameter_(), and bpp::AutoCorrelationTransitionMatrix::AutoCorrelationTransitionMatrix().
|
inlineprotectedvirtual |
Reimplemented in bpp::AbstractParameterAliasable.
Definition at line 117 of file AbstractParametrizable.h.
References bpp::ParameterList::addParameters().
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::TestFunction, bpp::InfinityDerivableSecondOrderWrapper, bpp::InfinityDerivableFirstOrderWrapper, bpp::InfinityFunctionWrapper, bpp::LinearMatrix< Scalar >, bpp::AssociationGraphImplObserver< N, E, GraphImpl >, bpp::AssociationGraphImplObserver< N, E, DAGraphImpl >, bpp::AssociationGraphImplObserver< N, E, TreeGraphImpl >, bpp::StdErr, bpp::FunctionStopCondition, bpp::ColMatrix< Scalar >, bpp::PlaceboTransformedParameter, bpp::StdOut, bpp::GlobalGraph, bpp::ParametersStopCondition, bpp::StlOutputStreamWrapper, bpp::ReparametrizationDerivableSecondOrderWrapper, bpp::IntervalTransformedParameter, bpp::MetaOptimizer, bpp::IntervalConstraint, bpp::BppUnsignedInteger, bpp::StlOutputStream, bpp::SecondOrderDerivable, bpp::LogsumHmmLikelihood, bpp::RescaledHmmLikelihood, bpp::ReparametrizationDerivableFirstOrderWrapper, bpp::BppInteger, bpp::RowMatrix< Scalar >, bpp::RowMatrix< double >, bpp::RowMatrix< Real >, bpp::Parameter, bpp::Simplex, bpp::LowMemoryRescaledHmmLikelihood, bpp::Table< T >, bpp::AbstractNumericalDerivative, bpp::BppDouble, bpp::RTransformedParameter, bpp::NullOutputStream, bpp::ParametrizableCollection< N >, bpp::FirstOrderDerivable, bpp::OptimizerInterface, bpp::AssociationTreeGraphImplObserver< N, E, TreeGraphImpl >, bpp::AssociationDAGraphImplObserver< N, E, DAGraphImpl >, bpp::ThreePointsNumericalDerivative, bpp::DirichletDiscreteDistribution, bpp::SimpleDiscreteDistribution, bpp::DownhillSimplexMethod, bpp::Number< T >, bpp::Number< double >, bpp::Number< int >, bpp::Number< unsigned int >, bpp::FivePointsNumericalDerivative, bpp::ReparametrizationFunctionWrapper, bpp::DataTable, bpp::PrincipalComponentAnalysis, bpp::DualityDiagram, bpp::TruncatedExponentialDiscreteDistribution, bpp::MetaOptimizerInfos, bpp::BrentOneDimension, bpp::NewtonBacktrackOneDimension, bpp::FunctionOperator< F >, bpp::AutoParameter, bpp::GammaDiscreteDistribution, bpp::MixtureOfDiscreteDistributions, bpp::AliasParameterListener, bpp::Range< T >, bpp::PowellMultiDimensions, bpp::InvariantMixedDiscreteDistribution, bpp::TwoPointsNumericalDerivative, bpp::ParameterListener, bpp::OutputStream, bpp::GoldenSectionSearch, bpp::DirectionFunction, bpp::Point2D< T >, bpp::BetaDiscreteDistribution, bpp::ExponentialDiscreteDistribution, bpp::ParameterList, bpp::CorrespondenceAnalysis, bpp::HmmLikelihood, bpp::GaussianDiscreteDistribution, bpp::BfgsMultiDimensions, bpp::NewtonBacktrackOneDimension::NBODStopCondition, bpp::FullHmmTransitionMatrix, bpp::BppNotANumber, bpp::UniformDiscreteDistribution, bpp::ContingencyTableTest, bpp::Font, bpp::ConstantDistribution, bpp::DiscreteDistributionInterface, bpp::MultipleDiscreteDistribution, bpp::DownhillSimplexMethod::DSMStopCondition, bpp::MathOperator, bpp::BrentOneDimension::BODStopCondition, bpp::ConjugateGradientMultiDimensions, bpp::OptimizationStopCondition, bpp::AutoCorrelationTransitionMatrix, bpp::ParameterEvent, bpp::ComputationTree, bpp::GoldenSectionSearch::GSSStopCondition, bpp::PowellMultiDimensions::PMDStopCondition, bpp::ConstraintInterface, bpp::HmmStateAlphabet, bpp::RGBColor, bpp::SimpleMultiDimensions, bpp::SimpleNewtonMultiDimensions, bpp::HmmEmissionProbabilities, bpp::BinaryOperator, bpp::BppVector< T >, bpp::TransformedParameter, bpp::BppString, bpp::ConstantOperator, bpp::NegativeOperator, bpp::HmmTransitionMatrix, bpp::BppNumberI, bpp::BppBoolean, and bpp::NewtonOneDimension.
Referenced by bpp::FirstOrderDerivable::~FirstOrderDerivable(), and bpp::SecondOrderDerivable::~SecondOrderDerivable().
|
inlineprotectedvirtual |
Reimplemented in bpp::AbstractParameterAliasable.
Definition at line 137 of file AbstractParametrizable.h.
References bpp::ParameterList::deleteParameter(), and bpp::ParameterList::size().
Referenced by bpp::AbstractParameterAliasable::deleteParameter_().
|
inlineprotectedvirtual |
Reimplemented in bpp::AbstractParameterAliasable.
Definition at line 144 of file AbstractParametrizable.h.
References bpp::ParameterList::deleteParameter().
|
inlineprotectedvirtual |
Reimplemented in bpp::AbstractParameterAliasable.
Definition at line 149 of file AbstractParametrizable.h.
References bpp::ParameterList::deleteParameters().
|
inlinevirtual |
Notify the class when one or several parameters have changed.
parameters | A ParameterList object with parameters that changed. |
Reimplemented in bpp::TestFunction, bpp::OrderedSimplex, bpp::LogsumHmmLikelihood, bpp::RescaledHmmLikelihood, bpp::LowMemoryRescaledHmmLikelihood, bpp::Simplex, bpp::ParametrizableCollection< N >, bpp::ReparametrizationFunctionWrapper, bpp::MixtureOfDiscreteDistributions, bpp::SimpleDiscreteDistribution, bpp::DirichletDiscreteDistribution, bpp::FullHmmTransitionMatrix, bpp::TruncatedExponentialDiscreteDistribution, bpp::AutoCorrelationTransitionMatrix, bpp::GammaDiscreteDistribution, bpp::InvariantMixedDiscreteDistribution, bpp::BetaDiscreteDistribution, bpp::ExponentialDiscreteDistribution, bpp::GaussianDiscreteDistribution, bpp::UniformDiscreteDistribution, and bpp::ConstantDistribution.
Definition at line 108 of file AbstractParametrizable.h.
Referenced by bpp::ConstantDistribution::fireParameterChanged(), bpp::GaussianDiscreteDistribution::fireParameterChanged(), bpp::ExponentialDiscreteDistribution::fireParameterChanged(), bpp::BetaDiscreteDistribution::fireParameterChanged(), bpp::InvariantMixedDiscreteDistribution::fireParameterChanged(), bpp::GammaDiscreteDistribution::fireParameterChanged(), bpp::TruncatedExponentialDiscreteDistribution::fireParameterChanged(), bpp::DirichletDiscreteDistribution::fireParameterChanged(), bpp::SimpleDiscreteDistribution::fireParameterChanged(), bpp::MixtureOfDiscreteDistributions::fireParameterChanged(), matchParametersValues(), setAllParametersValues(), setParametersValues(), and setParameterValue().
|
inlineoverridevirtual |
Implements bpp::Parametrizable.
Definition at line 99 of file AbstractParametrizable.h.
References getParameterNameWithoutNamespace(), and prefix_.
Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::MixtureOfDiscreteDistributions::MixtureOfDiscreteDistributions(), bpp::Simplex::setFrequencies(), and bpp::AbstractParameterAliasable::setNamespace().
|
inlineoverridevirtual |
Get the number of parameters.
Implements bpp::Parametrizable.
Definition at line 95 of file AbstractParametrizable.h.
References setNamespace(), 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().
|
inline |
Definition at line 48 of file AbstractParametrizable.h.
References bpp::ParameterList::getParameter().
Referenced by bpp::AbstractParameterAliasable::AbstractParameterAliasable(), bpp::AbstractParameterAliasable::operator=(), and bpp::AbstractParameterAliasable::unaliasParameters().
|
inlineprotected |
Definition at line 211 of file AbstractParametrizable.h.
References bpp::ParameterList::getParameter().
|
inlineprotected |
Definition at line 216 of file AbstractParametrizable.h.
References bpp::ParameterList::getParameter().
|
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 hasParameter(), and bpp::ParameterList::parameter().
Referenced by bpp::AbstractParameterAliasable::aliasParameters(), getParameterWithNamespace_(), removeConstraint(), bpp::ConstantDistribution::restrictToConstraint(), bpp::TruncatedExponentialDiscreteDistribution::restrictToConstraint(), bpp::SimpleDiscreteDistribution::restrictToConstraint(), bpp::InvariantMixedDiscreteDistribution::restrictToConstraint(), setConstraint(), and bpp::AbstractParameterAliasable::unaliasParameters().
|
inlineprotected |
Definition at line 190 of file AbstractParametrizable.h.
References bpp::ParameterList::size().
|
inlineprotected |
Definition at line 197 of file AbstractParametrizable.h.
References bpp::ParameterList::size().
|
overridevirtual |
Resolves a parameter name according to the current namespace.
Implements bpp::Parametrizable.
Definition at line 28 of file AbstractParametrizable.cpp.
References bpp::TextTools::startsWith().
Referenced by bpp::AbstractParameterAliasable::AbstractParameterAliasable(), getNamespace(), and bpp::AbstractParameterAliasable::operator=().
|
inlineoverridevirtual |
Get all parameters available.
Implements bpp::Parametrizable.
Definition at line 41 of file AbstractParametrizable.h.
References parameters_.
Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::FullHmmTransitionMatrix::FullHmmTransitionMatrix(), bpp::MixtureOfDiscreteDistributions::MixtureOfDiscreteDistributions(), and bpp::ParametrizableCollection< N >::removeObject().
|
inlineoverrideprotectedvirtual |
Get all parameters available.
Implements bpp::Parametrizable.
Definition at line 205 of file AbstractParametrizable.h.
References parameters_.
Referenced by bpp::AbstractParameterAliasable::AbstractParameterAliasable(), bpp::AbstractParameterAliasable::aliasParameters(), and bpp::AbstractParameterAliasable::operator=().
|
inlineoverridevirtual |
Get the value for parameter of name 'name'.
name | The name of the parameter. |
Implements bpp::Parametrizable.
Definition at line 53 of file AbstractParametrizable.h.
References bpp::Parameter::getValue(), and parameter().
Referenced by bpp::DirichletDiscreteDistribution::applyParameters(), bpp::ConstantDistribution::fireParameterChanged(), bpp::GaussianDiscreteDistribution::fireParameterChanged(), bpp::BetaDiscreteDistribution::fireParameterChanged(), bpp::ExponentialDiscreteDistribution::fireParameterChanged(), bpp::InvariantMixedDiscreteDistribution::fireParameterChanged(), bpp::GammaDiscreteDistribution::fireParameterChanged(), bpp::AutoCorrelationTransitionMatrix::fireParameterChanged(), bpp::TruncatedExponentialDiscreteDistribution::fireParameterChanged(), bpp::SimpleDiscreteDistribution::fireParameterChanged(), bpp::MixtureOfDiscreteDistributions::fireParameterChanged(), bpp::Simplex::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 176 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 185 of file AbstractParametrizable.h.
References parameter().
|
inlineoverridevirtual |
Tell if there is a parameter with specified name.
name | The name of the parameter to look for. |
Implements bpp::Parametrizable.
Definition at line 39 of file AbstractParametrizable.h.
References bpp::ParameterList::hasParameter().
Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::GammaDiscreteDistribution::fireParameterChanged(), getParameter_(), and bpp::AbstractParameterAliasable::unaliasParameters().
|
inlineprotectedvirtual |
Reimplemented in bpp::AbstractParameterAliasable.
Definition at line 132 of file AbstractParametrizable.h.
References bpp::ParameterList::includeParameters().
Referenced by bpp::AbstractParameterAliasable::includeParameters_().
|
inlineoverridevirtual |
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 76 of file AbstractParametrizable.h.
References fireParameterChanged(), bpp::ParameterList::matchParametersValues(), and bpp::ParameterList::shareSubList().
Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::Simplex::setFrequencies(), bpp::ReparametrizationFunctionWrapper::setParameters(), and bpp::FullHmmTransitionMatrix::setTransitionProbabilities().
|
inlineoverridevirtual |
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 43 of file AbstractParametrizable.h.
References bpp::ParameterList::parameter().
Referenced by bpp::AbstractParameterAliasable::getAliasedParameters(), bpp::ReparametrizationDerivableFirstOrderWrapper::getFirstOrderDerivative(), bpp::AbstractParameterAliasable::getFromParameters(), getParameterValue(), getParameterWithNamespace_(), and bpp::ReparametrizationDerivableSecondOrderWrapper::getSecondOrderDerivative().
|
inlineoverridevirtual |
Remove the constraint associated with one parameter, if any.
name | The name of the parameter to look for. |
ParameterNotFoundException | if no parameter with this name is found. |
Implements bpp::Parametrizable.
Definition at line 85 of file AbstractParametrizable.h.
References getParameter_(), and bpp::Parameter::removeConstraint().
|
inlineprotected |
Definition at line 154 of file AbstractParametrizable.h.
References bpp::ParameterList::reset().
Referenced by bpp::AbstractParameterAliasable::resetParameters_().
|
inlineoverridevirtual |
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 58 of file AbstractParametrizable.h.
References fireParameterChanged(), and bpp::ParameterList::setAllParametersValues().
|
inlineoverridevirtual |
Set/Change the constraint associated with one parameter.
name | The name of the parameter to look for. |
constraint | A pointer to the constraint (may be null) |
ParameterNotFoundException | if no parameter with this name is found. |
Implements bpp::Parametrizable.
Definition at line 90 of file AbstractParametrizable.h.
References getParameter_(), and bpp::Parameter::setConstraint().
Referenced by bpp::SimpleDiscreteDistribution::restrictToConstraint().
|
overridevirtual |
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::LogsumHmmLikelihood, bpp::RescaledHmmLikelihood, bpp::LowMemoryRescaledHmmLikelihood, bpp::MixtureOfDiscreteDistributions, and bpp::InvariantMixedDiscreteDistribution.
Definition at line 10 of file AbstractParametrizable.cpp.
References bpp::TextTools::startsWith().
Referenced by getNumberOfParameters(), bpp::AbstractParameterAliasable::setNamespace(), bpp::LowMemoryRescaledHmmLikelihood::setNamespace(), bpp::LogsumHmmLikelihood::setNamespace(), and bpp::RescaledHmmLikelihood::setNamespace().
|
inlineoverridevirtual |
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 70 of file AbstractParametrizable.h.
References fireParameterChanged(), and bpp::ParameterList::setParametersValues().
Referenced by bpp::LowMemoryRescaledHmmLikelihood::setParameters(), bpp::RescaledHmmLikelihood::setParameters(), and bpp::LogsumHmmLikelihood::setParameters().
|
inlineoverridevirtual |
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 64 of file AbstractParametrizable.h.
References bpp::ParameterList::createSubList(), fireParameterChanged(), and bpp::ParameterList::setParameterValue().
|
inlineprotectedvirtual |
Reimplemented in bpp::AbstractParameterAliasable.
Definition at line 122 of file AbstractParametrizable.h.
References bpp::ParameterList::shareParameter().
Referenced by bpp::AbstractParameterAliasable::shareParameter_().
|
inlineprotectedvirtual |
Reimplemented in bpp::AbstractParameterAliasable.
Definition at line 127 of file AbstractParametrizable.h.
References bpp::ParameterList::shareParameters().
Referenced by bpp::AbstractParameterAliasable::shareParameters_().
|
private |
Definition at line 30 of file AbstractParametrizable.h.
Referenced by getParameters(), and getParameters_().
|
private |
Definition at line 31 of file AbstractParametrizable.h.
Referenced by getNamespace().