bpp-core3  3.0.0
bpp::LowMemoryRescaledHmmLikelihood Class Referenceabstract

A modified implementation of the RescaledHmmLikelihood implementation, with lower memory usage. More...

#include <Bpp/Numeric/Hmm/LowMemoryRescaledHmmLikelihood.h>

+ Inheritance diagram for bpp::LowMemoryRescaledHmmLikelihood:
+ Collaboration diagram for bpp::LowMemoryRescaledHmmLikelihood:

Public Member Functions

 LowMemoryRescaledHmmLikelihood (HmmStateAlphabet *hiddenAlphabet, HmmTransitionMatrix *transitionMatrix, HmmEmissionProbabilities *emissionProbabilities, const std::string &prefix, size_t maxSize=1000000)
 Build a new LowMemoryRescaledHmmLikelihood object. More...
 
 LowMemoryRescaledHmmLikelihood (const LowMemoryRescaledHmmLikelihood &lik)
 
LowMemoryRescaledHmmLikelihoodoperator= (const LowMemoryRescaledHmmLikelihood &lik)
 
virtual ~LowMemoryRescaledHmmLikelihood ()
 
LowMemoryRescaledHmmLikelihoodclone () const
 Create a copy of this object and send a pointer to it. More...
 
const HmmStateAlphabetgetHmmStateAlphabet () const
 
HmmStateAlphabetgetHmmStateAlphabet ()
 
const HmmTransitionMatrixgetHmmTransitionMatrix () const
 
HmmTransitionMatrixgetHmmTransitionMatrix ()
 
const HmmEmissionProbabilitiesgetHmmEmissionProbabilities () const
 
HmmEmissionProbabilitiesgetHmmEmissionProbabilities ()
 
void setBreakPoints (const std::vector< size_t > &breakPoints)
 
const std::vector< size_t > & getBreakPoints () const
 
void setParameters (const ParameterList &pl)
 Set the point where the function must be computed. More...
 
double getValue () const
 Get the value of the function at the current point. More...
 
double getLogLikelihood () const
 
void setNamespace (const std::string &nameSpace)
 Set the namespace for the parameter names. More...
 
void fireParameterChanged (const ParameterList &pl)
 Notify the class when one or several parameters have changed. More...
 
double getLikelihoodForASite (size_t site) const
 Get the likelihood for a site, and its derivatives. More...
 
Vdouble getLikelihoodForEachSite () const
 Get the likelihood for each site. More...
 
Vdouble getHiddenStatesPosteriorProbabilitiesForASite (size_t site) const
 
void getHiddenStatesPosteriorProbabilities (std::vector< std::vector< double > > &probs, bool append=false) const
 
void enableFirstOrderDerivatives (bool yn)
 Tell if derivatives must be computed. More...
 
bool enableFirstOrderDerivatives () const
 Tell if derivatives must be computed. More...
 
double getFirstOrderDerivative (const std::string &variable) const
 Get the derivative of the function at the current point. More...
 
double getDLogLikelihood () const
 
void enableSecondOrderDerivatives (bool yn)
 Tell if derivatives must be computed. More...
 
bool enableSecondOrderDerivatives () const
 Tell if derivatives must be computed. More...
 
double getSecondOrderDerivative (const std::string &variable) const
 Get the second order derivative of the function at the current point. More...
 
double getSecondOrderDerivative (const std::string &variable1, const std::string &variable2) const
 Get the value of the cross derivative of the function according to a given set of parameters. More...
 
double getD2LogLikelihood () const
 
virtual double d2f (const std::string &variable, const ParameterList &parameters)
 Get the value of the second order derivative of the function according to a given set of parameters. More...
 
virtual double d2f (const std::string &variable1, const std::string &variable2, const ParameterList &parameters)
 Get the value of the cross derivative of the function according to a given set of parameters. More...
 
virtual double df (const std::string &variable, const ParameterList &parameters)
 Get the value of the first derivative of the function according to a given set of parameters. More...
 
virtual double f (const ParameterList &parameters)
 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
 Get the parameter with specified name. More...
 
virtual double getParameterValue (const std::string &name) const =0
 Get the value for parameter of name 'name'. More...
 
virtual void setAllParametersValues (const ParameterList &parameters)=0
 Set the parameters values to be equals to those of parameters. More...
 
virtual void setParameterValue (const std::string &name, double value)=0
 Set the value of parameter with name name to be equal to value. More...
 
virtual void setParametersValues (const ParameterList &parameters)=0
 Update the parameters from parameters. More...
 
virtual bool matchParametersValues (const ParameterList &parameters)=0
 Update the parameters from parameters. More...
 
virtual size_t getNumberOfParameters () const =0
 Get the number of parameters. 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...
 
bool hasParameter (const std::string &name) const
 Tell if there is a parameter with specified name. More...
 
const ParameterListgetParameters () const
 Get all parameters available. More...
 
const ParametergetParameter (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 &parameters)
 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 &parameters)
 Update the parameters from parameters. More...
 
bool matchParametersValues (const ParameterList &parameters)
 Update the parameters from parameters. More...
 
size_t getNumberOfParameters () const
 Get the number of parameters. More...
 
std::string getNamespace () const
 
std::string getParameterNameWithoutNamespace (const std::string &name) const
 Resolves a parameter name according to the current namespace. More...
 

Protected Member Functions

void computeForward_ ()
 
void computeDLikelihood_ () const
 
void computeD2Likelihood_ () const
 
double getDLogLikelihoodForASite (size_t site) const
 
double getD2LogLikelihoodForASite (size_t site) const
 
virtual ParameterListgetParameters_ ()=0
 Get all parameters available. More...
 
const std::shared_ptr< Parameter > & getSharedParameter (size_t i) const
 
std::shared_ptr< Parameter > & getSharedParameter (size_t i)
 
virtual void addParameter_ (Parameter *parameter)
 
virtual void addParameters_ (const ParameterList &parameters)
 
virtual void shareParameter_ (const std::shared_ptr< Parameter > &parameter)
 
virtual void shareParameters_ (const ParameterList &parameters)
 
virtual void includeParameters_ (const ParameterList &parameters)
 
virtual void deleteParameter_ (size_t index)
 
virtual void deleteParameter_ (std::string &name)
 
virtual void deleteParameters_ (const std::vector< std::string > &names)
 
void resetParameters_ ()
 
ParametergetParameter_ (const std::string &name)
 
ParametergetParameter_ (size_t index)
 
const ParametergetParameter_ (size_t index) const
 
ParametergetParameterWithNamespace_ (const std::string &name)
 
const ParametergetParameterWithNamespace_ (const std::string &name) const
 
ParameterListgetParameters_ ()
 Get all parameters available. More...
 

Protected Attributes

double dLogLik_
 
std::string dVariable_
 
double d2LogLik_
 
std::string d2Variable_
 

Private Attributes

std::unique_ptr< HmmStateAlphabethiddenAlphabet_
 The alphabet describing the hidden states. More...
 
std::unique_ptr< HmmTransitionMatrixtransitionMatrix_
 
std::unique_ptr< HmmEmissionProbabilitiesemissionProbabilities_
 
std::vector< double > likelihood1_
 The likelihood array. More...
 
std::vector< double > likelihood2_
 
double logLik_
 
size_t maxSize_
 
std::vector< size_t > breakPoints_
 
size_t nbStates_
 
size_t nbSites_
 
ParameterList parameters_
 
std::string prefix_
 

Detailed Description

A modified implementation of the RescaledHmmLikelihood implementation, with lower memory usage.

This implementation is similar to the one used in the RescaledHmmLikelihood class, but does not store the full likelihood array. The benefit of it is a significantly reduced memory usage, allowing to compute likelihood for very large data sets.

The drawback is that this class can't compute posterior probabilities, neither derivatives of the likelihoods, and can hence only be used to compute likelihoods.

Definition at line 68 of file LowMemoryRescaledHmmLikelihood.h.

Constructor & Destructor Documentation

◆ LowMemoryRescaledHmmLikelihood() [1/2]

LowMemoryRescaledHmmLikelihood::LowMemoryRescaledHmmLikelihood ( HmmStateAlphabet hiddenAlphabet,
HmmTransitionMatrix transitionMatrix,
HmmEmissionProbabilities emissionProbabilities,
const std::string &  prefix,
size_t  maxSize = 1000000 
)

Build a new LowMemoryRescaledHmmLikelihood object.

Warning
the HmmTransitionMatrix and HmmEmissionProbabilities object passed as argument must be non-null and point toward the same HmmStateAlphabet instance. The three object will be copied if needed, and deleted when the hmm likelihood objet is deleted. You should secure a copy before if you don't want them to be destroyed with this object.
Parameters
hiddenAlphabetThe hidden states alphabet to use.
transitionMatrixThe transition matrix to use.
emissionProbabilitiesThe emission probabilities to use.
prefixA namespace for parameter names.
maxSizethe maximum size of the vector of scales. If this size is exceeded, then a temporary likelihood computation is made and stored, and the vector is reset. the size of the vector specify the memory usage of the class. A two low value can lead to numerical precision errors.

Definition at line 50 of file LowMemoryRescaledHmmLikelihood.cpp.

References bpp::AbstractParametrizable::addParameters_(), computeForward_(), emissionProbabilities_, bpp::HmmEmissionProbabilities::getHmmStateAlphabet(), bpp::HmmTransitionMatrix::getHmmStateAlphabet(), hiddenAlphabet_, likelihood1_, likelihood2_, nbSites_, nbStates_, and transitionMatrix_.

Referenced by clone().

◆ LowMemoryRescaledHmmLikelihood() [2/2]

bpp::LowMemoryRescaledHmmLikelihood::LowMemoryRescaledHmmLikelihood ( const LowMemoryRescaledHmmLikelihood lik)
inline

◆ ~LowMemoryRescaledHmmLikelihood()

virtual bpp::LowMemoryRescaledHmmLikelihood::~LowMemoryRescaledHmmLikelihood ( )
inlinevirtual

Definition at line 157 of file LowMemoryRescaledHmmLikelihood.h.

Member Function Documentation

◆ addParameter_()

virtual void bpp::AbstractParametrizable::addParameter_ ( Parameter parameter)
inlineprotectedvirtualinherited

◆ addParameters_()

◆ clone()

LowMemoryRescaledHmmLikelihood* bpp::LowMemoryRescaledHmmLikelihood::clone ( ) const
inlinevirtual

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

Returns
A pointer toward the copy object.

Implements bpp::HmmLikelihood.

Definition at line 159 of file LowMemoryRescaledHmmLikelihood.h.

References LowMemoryRescaledHmmLikelihood().

◆ computeD2Likelihood_()

void bpp::LowMemoryRescaledHmmLikelihood::computeD2Likelihood_ ( ) const
inlineprotectedvirtual

Implements bpp::HmmLikelihood.

Definition at line 221 of file LowMemoryRescaledHmmLikelihood.h.

◆ computeDLikelihood_()

void bpp::LowMemoryRescaledHmmLikelihood::computeDLikelihood_ ( ) const
inlineprotectedvirtual

Implements bpp::HmmLikelihood.

Definition at line 216 of file LowMemoryRescaledHmmLikelihood.h.

◆ computeForward_()

void LowMemoryRescaledHmmLikelihood::computeForward_ ( )
protected

◆ d2f() [1/2]

virtual double bpp::DerivableSecondOrder::d2f ( const std::string &  variable,
const ParameterList parameters 
)
inlinevirtualinherited

Get the value of the second order derivative of the function according to a given set of parameters.

Parameters
variableThe name of the $ x $ variable in $ \frac{\partial^2 f}{\partial x^2} $.
parametersThe parameter set to pass to the function.
Returns
The value of the function with the given parameter set.
Exceptions
ExceptionIf an error occured.

Definition at line 228 of file Functions.h.

References bpp::DerivableSecondOrder::getSecondOrderDerivative(), and bpp::Function::setParameters().

◆ d2f() [2/2]

virtual double bpp::DerivableSecondOrder::d2f ( const std::string &  variable1,
const std::string &  variable2,
const ParameterList parameters 
)
inlinevirtualinherited

Get the value of the cross derivative of the function according to a given set of parameters.

Parameters
variable1The name of the $ x $ variable in $ \frac{\partial^2 f}{\partial x \partial y} $.
variable2The name of the $ y $ variable in $ \frac{\partial^2 f}{\partial x \partial y} $.
parametersThe parameter set to pass to the function.
Returns
The value of the function with the given parameter set.
Exceptions
ExceptionIf an error occured.

Definition at line 255 of file Functions.h.

References bpp::DerivableSecondOrder::getSecondOrderDerivative(), and bpp::Function::setParameters().

◆ deleteParameter_() [1/2]

virtual void bpp::AbstractParametrizable::deleteParameter_ ( size_t  index)
inlineprotectedvirtualinherited

◆ deleteParameter_() [2/2]

virtual void bpp::AbstractParametrizable::deleteParameter_ ( std::string &  name)
inlineprotectedvirtualinherited

◆ deleteParameters_()

virtual void bpp::AbstractParametrizable::deleteParameters_ ( const std::vector< std::string > &  names)
inlineprotectedvirtualinherited

◆ df()

virtual double bpp::DerivableFirstOrder::df ( const std::string &  variable,
const ParameterList parameters 
)
inlinevirtualinherited

Get the value of the first derivative of the function according to a given set of parameters.

Parameters
variableThe name of the $ x $ variable in $ \frac{df}{dx} $.
parametersThe parameter set to pass to the function.
Returns
The value of the function with the given parameter set.
Exceptions
ExceptionIf an error occured.

Definition at line 173 of file Functions.h.

References bpp::DerivableFirstOrder::getFirstOrderDerivative(), and bpp::Function::setParameters().

◆ enableFirstOrderDerivatives() [1/2]

bool bpp::AbstractHmmLikelihood::enableFirstOrderDerivatives ( ) const
inlinevirtualinherited

Tell if derivatives must be computed.

Returns
yes/no

Implements bpp::DerivableFirstOrder.

Definition at line 162 of file HmmLikelihood.h.

◆ enableFirstOrderDerivatives() [2/2]

void bpp::AbstractHmmLikelihood::enableFirstOrderDerivatives ( bool  yn)
inlinevirtualinherited

Tell if derivatives must be computed.

Parameters
ynyes/no

Implements bpp::DerivableFirstOrder.

Definition at line 160 of file HmmLikelihood.h.

◆ enableSecondOrderDerivatives() [1/2]

bool bpp::AbstractHmmLikelihood::enableSecondOrderDerivatives ( ) const
inlinevirtualinherited

Tell if derivatives must be computed.

Returns
yes/no

Implements bpp::DerivableSecondOrder.

Definition at line 183 of file HmmLikelihood.h.

◆ enableSecondOrderDerivatives() [2/2]

void bpp::AbstractHmmLikelihood::enableSecondOrderDerivatives ( bool  yn)
inlinevirtualinherited

Tell if derivatives must be computed.

Parameters
ynyes/no

Implements bpp::DerivableSecondOrder.

Definition at line 181 of file HmmLikelihood.h.

◆ f()

◆ fireParameterChanged()

void LowMemoryRescaledHmmLikelihood::fireParameterChanged ( const ParameterList parameters)
virtual

Notify the class when one or several parameters have changed.

Parameters
parametersA ParameterList object with parameters that changed.

Reimplemented from bpp::AbstractParametrizable.

Definition at line 104 of file LowMemoryRescaledHmmLikelihood.cpp.

References computeForward_(), emissionProbabilities_, hiddenAlphabet_, and transitionMatrix_.

◆ getBreakPoints()

const std::vector<size_t>& bpp::LowMemoryRescaledHmmLikelihood::getBreakPoints ( ) const
inlinevirtual

Implements bpp::HmmLikelihood.

Definition at line 177 of file LowMemoryRescaledHmmLikelihood.h.

References breakPoints_.

◆ getD2LogLikelihood()

double bpp::AbstractHmmLikelihood::getD2LogLikelihood ( ) const
inlinevirtualinherited

Implements bpp::HmmLikelihood.

Definition at line 187 of file HmmLikelihood.h.

References bpp::AbstractHmmLikelihood::d2LogLik_.

◆ getD2LogLikelihoodForASite()

double bpp::LowMemoryRescaledHmmLikelihood::getD2LogLikelihoodForASite ( size_t  site) const
inlineprotectedvirtual

Implements bpp::HmmLikelihood.

Definition at line 232 of file LowMemoryRescaledHmmLikelihood.h.

◆ getDLogLikelihood()

double bpp::AbstractHmmLikelihood::getDLogLikelihood ( ) const
inlinevirtualinherited

Implements bpp::HmmLikelihood.

Definition at line 166 of file HmmLikelihood.h.

References bpp::AbstractHmmLikelihood::dLogLik_.

◆ getDLogLikelihoodForASite()

double bpp::LowMemoryRescaledHmmLikelihood::getDLogLikelihoodForASite ( size_t  site) const
inlineprotectedvirtual

Implements bpp::HmmLikelihood.

Definition at line 226 of file LowMemoryRescaledHmmLikelihood.h.

◆ getFirstOrderDerivative()

double AbstractHmmLikelihood::getFirstOrderDerivative ( const std::string &  variable) const
virtualinherited

Get the derivative of the function at the current point.

Parameters
variableThe name of the $ x $ variable in $ \frac{df}{dx} $.
Returns
The value of the function.
Exceptions
ExceptionIf no point is specified or if an error occured.

Implements bpp::DerivableFirstOrder.

Definition at line 70 of file HmmLikelihood.cpp.

References bpp::HmmEmissionProbabilities::computeDEmissionProbabilities(), bpp::HmmLikelihood::computeDLikelihood_(), bpp::AbstractHmmLikelihood::dLogLik_, bpp::AbstractHmmLikelihood::dVariable_, and bpp::HmmLikelihood::getHmmEmissionProbabilities().

Referenced by bpp::LogsumHmmLikelihood::computeD2Forward_().

◆ getHiddenStatesPosteriorProbabilities()

void bpp::LowMemoryRescaledHmmLikelihood::getHiddenStatesPosteriorProbabilities ( std::vector< std::vector< double > > &  probs,
bool  append = false 
) const
inlinevirtual

Implements bpp::HmmLikelihood.

Definition at line 208 of file LowMemoryRescaledHmmLikelihood.h.

◆ getHiddenStatesPosteriorProbabilitiesForASite()

Vdouble bpp::LowMemoryRescaledHmmLikelihood::getHiddenStatesPosteriorProbabilitiesForASite ( size_t  site) const
inlinevirtual

Implements bpp::HmmLikelihood.

Definition at line 203 of file LowMemoryRescaledHmmLikelihood.h.

◆ getHmmEmissionProbabilities() [1/2]

HmmEmissionProbabilities& bpp::LowMemoryRescaledHmmLikelihood::getHmmEmissionProbabilities ( )
inlinevirtual

Implements bpp::HmmLikelihood.

Definition at line 169 of file LowMemoryRescaledHmmLikelihood.h.

References emissionProbabilities_.

◆ getHmmEmissionProbabilities() [2/2]

const HmmEmissionProbabilities& bpp::LowMemoryRescaledHmmLikelihood::getHmmEmissionProbabilities ( ) const
inlinevirtual

Implements bpp::HmmLikelihood.

Definition at line 168 of file LowMemoryRescaledHmmLikelihood.h.

References emissionProbabilities_.

◆ getHmmStateAlphabet() [1/2]

HmmStateAlphabet& bpp::LowMemoryRescaledHmmLikelihood::getHmmStateAlphabet ( )
inlinevirtual

Implements bpp::HmmLikelihood.

Definition at line 163 of file LowMemoryRescaledHmmLikelihood.h.

References hiddenAlphabet_.

◆ getHmmStateAlphabet() [2/2]

const HmmStateAlphabet& bpp::LowMemoryRescaledHmmLikelihood::getHmmStateAlphabet ( ) const
inlinevirtual

Implements bpp::HmmLikelihood.

Definition at line 162 of file LowMemoryRescaledHmmLikelihood.h.

References hiddenAlphabet_.

◆ getHmmTransitionMatrix() [1/2]

HmmTransitionMatrix& bpp::LowMemoryRescaledHmmLikelihood::getHmmTransitionMatrix ( )
inlinevirtual

Implements bpp::HmmLikelihood.

Definition at line 166 of file LowMemoryRescaledHmmLikelihood.h.

References transitionMatrix_.

◆ getHmmTransitionMatrix() [2/2]

const HmmTransitionMatrix& bpp::LowMemoryRescaledHmmLikelihood::getHmmTransitionMatrix ( ) const
inlinevirtual

Implements bpp::HmmLikelihood.

Definition at line 165 of file LowMemoryRescaledHmmLikelihood.h.

References transitionMatrix_.

◆ getLikelihoodForASite()

double bpp::LowMemoryRescaledHmmLikelihood::getLikelihoodForASite ( size_t  site) const
inlinevirtual

Get the likelihood for a site, and its derivatives.

Parameters
siteThe site index to analyse.
Returns
The likelihood for site site.

Implements bpp::HmmLikelihood.

Definition at line 192 of file LowMemoryRescaledHmmLikelihood.h.

◆ getLikelihoodForEachSite()

Vdouble bpp::LowMemoryRescaledHmmLikelihood::getLikelihoodForEachSite ( ) const
inlinevirtual

Get the likelihood for each site.

Returns
A vector with all likelihoods for each site.

Implements bpp::HmmLikelihood.

Definition at line 198 of file LowMemoryRescaledHmmLikelihood.h.

◆ getLogLikelihood()

double bpp::LowMemoryRescaledHmmLikelihood::getLogLikelihood ( ) const
inlinevirtual

Implements bpp::HmmLikelihood.

Definition at line 186 of file LowMemoryRescaledHmmLikelihood.h.

References logLik_.

◆ getNamespace() [1/2]

std::string bpp::AbstractParametrizable::getNamespace ( ) const
inlinevirtualinherited

◆ getNamespace() [2/2]

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::ParametrizableAdapter, bpp::FunctionWrapper, and bpp::AbstractParametrizable.

Referenced by bpp::FunctionWrapper::getNamespace().

◆ getNumberOfParameters() [1/2]

size_t bpp::AbstractParametrizable::getNumberOfParameters ( ) const
inlinevirtualinherited

◆ getNumberOfParameters() [2/2]

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::ParametrizableAdapter, bpp::FunctionWrapper, bpp::DirectionFunction, and bpp::AbstractParametrizable.

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

◆ getParameter() [1/2]

const Parameter& bpp::AbstractParametrizable::getParameter ( const std::string &  name) const
inlinevirtualinherited

◆ getParameter() [2/2]

virtual const Parameter& bpp::Parametrizable::getParameter ( const std::string &  name) const
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::ParametrizableAdapter, bpp::FunctionWrapper, and bpp::AbstractParametrizable.

Referenced by bpp::FunctionWrapper::getParameter().

◆ getParameter_() [1/3]

◆ getParameter_() [2/3]

Parameter& bpp::AbstractParametrizable::getParameter_ ( size_t  index)
inlineprotectedinherited

◆ getParameter_() [3/3]

const Parameter& bpp::AbstractParametrizable::getParameter_ ( size_t  index) const
inlineprotectedinherited

◆ getParameterNameWithoutNamespace() [1/2]

std::string AbstractParametrizable::getParameterNameWithoutNamespace ( const std::string &  name) const
virtualinherited

◆ getParameterNameWithoutNamespace() [2/2]

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::ParametrizableAdapter, bpp::FunctionWrapper, and bpp::AbstractParametrizable.

Referenced by bpp::FunctionWrapper::getParameterNameWithoutNamespace(), and bpp::BppOParametrizableFormat::write().

◆ getParameters() [1/2]

const ParameterList& bpp::AbstractParametrizable::getParameters ( ) const
inlinevirtualinherited

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 bpp::AbstractParametrizable::parameters_.

Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::FullHmmTransitionMatrix::FullHmmTransitionMatrix(), bpp::MixtureOfDiscreteDistributions::MixtureOfDiscreteDistributions(), and bpp::ParametrizableCollection< N >::removeObject().

◆ getParameters() [2/2]

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

◆ getParameters_() [1/2]

ParameterList& bpp::AbstractParametrizable::getParameters_ ( )
inlineprotectedvirtualinherited

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

References bpp::AbstractParametrizable::parameters_.

Referenced by bpp::AbstractParameterAliasable::AbstractParameterAliasable(), bpp::AbstractParameterAliasable::aliasParameters(), and bpp::AbstractParameterAliasable::operator=().

◆ getParameters_() [2/2]

virtual ParameterList& bpp::Parametrizable::getParameters_ ( )
protectedpure virtualinherited

Get all parameters available.

See also
getIndependentParameters if some parameters are aliased.
Returns
A list with all parameters available.

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

Referenced by bpp::FunctionWrapper::getParameters_().

◆ getParameterValue() [1/2]

◆ getParameterValue() [2/2]

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

Referenced by bpp::FunctionWrapper::getParameterValue().

◆ getParameterWithNamespace_() [1/2]

Parameter& bpp::AbstractParametrizable::getParameterWithNamespace_ ( const std::string &  name)
inlineprotectedinherited
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 202 of file AbstractParametrizable.h.

References bpp::AbstractParametrizable::getParameter_().

◆ getParameterWithNamespace_() [2/2]

const Parameter& bpp::AbstractParametrizable::getParameterWithNamespace_ ( const std::string &  name) const
inlineprotectedinherited
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 211 of file AbstractParametrizable.h.

References bpp::AbstractParametrizable::getParameter().

◆ getSecondOrderDerivative() [1/2]

double AbstractHmmLikelihood::getSecondOrderDerivative ( const std::string &  variable) const
virtualinherited

Get the second order derivative of the function at the current point.

Parameters
variableThe name of the $ x $ variable in $ \frac{\partial^2 f}{\partial x^2} $.
Returns
The value of the function.
Exceptions
ExceptionIf no point is specified or if an error occured.

Implements bpp::DerivableSecondOrder.

Definition at line 82 of file HmmLikelihood.cpp.

References bpp::HmmEmissionProbabilities::computeD2EmissionProbabilities(), bpp::HmmLikelihood::computeD2Likelihood_(), bpp::AbstractHmmLikelihood::d2LogLik_, bpp::AbstractHmmLikelihood::d2Variable_, and bpp::HmmLikelihood::getHmmEmissionProbabilities().

◆ getSecondOrderDerivative() [2/2]

double bpp::AbstractHmmLikelihood::getSecondOrderDerivative ( const std::string &  variable1,
const std::string &  variable2 
) const
inlinevirtualinherited

Get the value of the cross derivative of the function according to a given set of parameters.

Parameters
variable1The name of the $ x $ variable in $ \frac{\partial^2 f}{\partial x \partial y} $.
variable2The name of the $ y $ variable in $ \frac{\partial^2 f}{\partial x \partial y} $.
Returns
The value of the function with the given parameter set.
Exceptions
ExceptionIf an error occured.

Implements bpp::DerivableSecondOrder.

Definition at line 192 of file HmmLikelihood.h.

◆ getSharedParameter() [1/3]

◆ getSharedParameter() [2/3]

std::shared_ptr<Parameter>& bpp::AbstractParametrizable::getSharedParameter ( size_t  i)
inlineprotectedinherited

◆ getSharedParameter() [3/3]

const std::shared_ptr<Parameter>& bpp::AbstractParametrizable::getSharedParameter ( size_t  i) const
inlineprotectedinherited
Returns
The shared_ptr parameter at a given position.
Warning
No check is performed on the validity of the index given as input!

Definition at line 237 of file AbstractParametrizable.h.

References bpp::ParameterList::getSharedParameter(), and bpp::AbstractParametrizable::parameters_.

◆ getValue()

double bpp::LowMemoryRescaledHmmLikelihood::getValue ( ) const
inlinevirtual

Get the value of the function at the current point.

Returns
The value of the function.
Exceptions
ExceptionIf no point is specified or if an error occured.

Implements bpp::Function.

Definition at line 184 of file LowMemoryRescaledHmmLikelihood.h.

References logLik_.

◆ hasParameter() [1/2]

bool bpp::AbstractParametrizable::hasParameter ( const std::string &  name) const
inlinevirtualinherited

◆ hasParameter() [2/2]

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::ParametrizableAdapter, bpp::FunctionWrapper, and bpp::AbstractParametrizable.

Referenced by bpp::FunctionWrapper::hasParameter().

◆ includeParameters_()

virtual void bpp::AbstractParametrizable::includeParameters_ ( const ParameterList parameters)
inlineprotectedvirtualinherited

◆ matchParametersValues() [1/2]

bool bpp::AbstractParametrizable::matchParametersValues ( const ParameterList parameters)
inlinevirtualinherited

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

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

Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::Simplex::setFrequencies(), bpp::TestFunction::setParameters(), bpp::ReparametrizationFunctionWrapper::setParameters(), and bpp::FullHmmTransitionMatrix::setTransitionProbabilities().

◆ matchParametersValues() [2/2]

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

Referenced by bpp::InvariantMixedDiscreteDistribution::fireParameterChanged(), bpp::LogsumHmmLikelihood::fireParameterChanged(), bpp::BppODiscreteDistributionFormat::initialize_(), bpp::AbstractNumericalDerivative::matchParametersValues(), bpp::FunctionWrapper::matchParametersValues(), and bpp::InfinityFunctionWrapper::matchParametersValues().

◆ operator=()

◆ resetParameters_()

void bpp::AbstractParametrizable::resetParameters_ ( )
inlineprotectedinherited

◆ setAllParametersValues() [1/2]

void bpp::AbstractParametrizable::setAllParametersValues ( const ParameterList parameters)
inlinevirtualinherited

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

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

◆ setAllParametersValues() [2/2]

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

Referenced by bpp::AbstractNumericalDerivative::setAllParametersValues(), bpp::FunctionWrapper::setAllParametersValues(), and bpp::InfinityFunctionWrapper::setAllParametersValues().

◆ setBreakPoints()

void bpp::LowMemoryRescaledHmmLikelihood::setBreakPoints ( const std::vector< size_t > &  breakPoints)
inlinevirtual

Implements bpp::HmmLikelihood.

Definition at line 171 of file LowMemoryRescaledHmmLikelihood.h.

References breakPoints_, and computeForward_().

◆ setNamespace()

void LowMemoryRescaledHmmLikelihood::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.

Reimplemented from bpp::AbstractParametrizable.

Definition at line 95 of file LowMemoryRescaledHmmLikelihood.cpp.

References emissionProbabilities_, hiddenAlphabet_, bpp::AbstractParametrizable::setNamespace(), and transitionMatrix_.

◆ setParameters()

void bpp::LowMemoryRescaledHmmLikelihood::setParameters ( const ParameterList parameters)
inlinevirtual

Set the point where the function must be computed.

Parameters
parametersThe parameter set to pass to the function.

Implements bpp::Function.

Definition at line 179 of file LowMemoryRescaledHmmLikelihood.h.

References bpp::AbstractParametrizable::setParametersValues().

◆ setParametersValues() [1/2]

void bpp::AbstractParametrizable::setParametersValues ( const ParameterList parameters)
inlinevirtualinherited

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

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

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

◆ setParametersValues() [2/2]

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

Referenced by bpp::LogsumHmmLikelihood::fireParameterChanged(), bpp::AbstractNumericalDerivative::setParametersValues(), bpp::FunctionWrapper::setParametersValues(), and bpp::InfinityFunctionWrapper::setParametersValues().

◆ setParameterValue() [1/2]

void bpp::AbstractParametrizable::setParameterValue ( const std::string &  name,
double  value 
)
inlinevirtualinherited

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

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

◆ setParameterValue() [2/2]

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

Referenced by bpp::AbstractNumericalDerivative::setParameterValue(), bpp::FunctionWrapper::setParameterValue(), and bpp::InfinityFunctionWrapper::setParameterValue().

◆ shareParameter_()

virtual void bpp::AbstractParametrizable::shareParameter_ ( const std::shared_ptr< Parameter > &  parameter)
inlineprotectedvirtualinherited

◆ shareParameters_()

virtual void bpp::AbstractParametrizable::shareParameters_ ( const ParameterList parameters)
inlineprotectedvirtualinherited

Member Data Documentation

◆ breakPoints_

std::vector<size_t> bpp::LowMemoryRescaledHmmLikelihood::breakPoints_
private

◆ d2LogLik_

◆ d2Variable_

◆ dLogLik_

◆ dVariable_

std::string bpp::AbstractHmmLikelihood::dVariable_
mutableprotectedinherited

◆ emissionProbabilities_

std::unique_ptr<HmmEmissionProbabilities> bpp::LowMemoryRescaledHmmLikelihood::emissionProbabilities_
private

◆ hiddenAlphabet_

std::unique_ptr<HmmStateAlphabet> bpp::LowMemoryRescaledHmmLikelihood::hiddenAlphabet_
private

The alphabet describing the hidden states.

Definition at line 76 of file LowMemoryRescaledHmmLikelihood.h.

Referenced by fireParameterChanged(), getHmmStateAlphabet(), LowMemoryRescaledHmmLikelihood(), operator=(), and setNamespace().

◆ likelihood1_

std::vector<double> bpp::LowMemoryRescaledHmmLikelihood::likelihood1_
private

The likelihood array.

Here we use two arrays for the i and i-1 positions

Definition at line 85 of file LowMemoryRescaledHmmLikelihood.h.

Referenced by computeForward_(), LowMemoryRescaledHmmLikelihood(), and operator=().

◆ likelihood2_

std::vector<double> bpp::LowMemoryRescaledHmmLikelihood::likelihood2_
private

◆ logLik_

double bpp::LowMemoryRescaledHmmLikelihood::logLik_
private

◆ maxSize_

size_t bpp::LowMemoryRescaledHmmLikelihood::maxSize_
private

Definition at line 88 of file LowMemoryRescaledHmmLikelihood.h.

Referenced by computeForward_(), and operator=().

◆ nbSites_

size_t bpp::LowMemoryRescaledHmmLikelihood::nbSites_
private

◆ nbStates_

size_t bpp::LowMemoryRescaledHmmLikelihood::nbStates_
private

◆ parameters_

◆ prefix_

◆ transitionMatrix_

std::unique_ptr<HmmTransitionMatrix> bpp::LowMemoryRescaledHmmLikelihood::transitionMatrix_
private

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