bpp-phyl3
3.0.0
|
Analytical reward using the eigen decomposition method. More...
#include <Bpp/Phyl/Mapping/DecompositionReward.h>
Public Member Functions | |
DecompositionReward (std::shared_ptr< const SubstitutionModelInterface > model, std::shared_ptr< const AlphabetIndex1 > alphIndex) | |
DecompositionReward (const StateMapInterface &stateMap, std::shared_ptr< const AlphabetIndex1 > alphIndex) | |
DecompositionReward (const DecompositionReward &dr) | |
DecompositionReward & | operator= (const DecompositionReward &dr) |
virtual | ~DecompositionReward () |
DecompositionReward * | clone () const override |
double | getReward (size_t initialState, size_t finalState, double length) const override |
Get the reward of susbstitutions on a branch, given the initial and final states, and the branch length. More... | |
Matrix< double > * | getAllRewards (double length) const override |
Get the rewards on a branch, for each initial and final states, and given the branch length. More... | |
void | storeAllRewards (double length, Eigen::MatrixXd &mat) const override |
Store the rewards on a branch, for each initial and final states, and given the branch length. More... | |
void | setSubstitutionModel (std::shared_ptr< const SubstitutionModelInterface > model) override |
Set the substitution model. More... | |
bool | hasAlphabetIndex () const |
void | setAlphabetIndex (std::shared_ptr< const AlphabetIndex1 > alphIndex) |
attribution of an AlphabetIndex1 More... | |
std::shared_ptr< const AlphabetIndex1 > | getAlphabetIndex () const |
const AlphabetIndex1 & | alphabetIndex () const |
virtual std::shared_ptr< const Alphabet > | getAlphabet () const |
Short cut function, equivalent to getSubstitutionRegister()->getAlphabet(). More... | |
virtual size_t | getNumberOfStates () const |
Short cut function, equivalent to getSubstitutionRegister()->getAlphabet()->getSize(). More... | |
Protected Member Functions | |
void | initRewards_ () |
void | computeRewards_ (double length) const |
void | alphabetIndexHasChanged () override |
void | initStates_ () |
void | initBMatrices_ () |
void | computeProducts_ () |
void | computeExpectations (RowMatrix< double > &mapping, double length) const |
void | computeExpectations (std::vector< RowMatrix< double >> &mappings, double length) const |
void | jFunction_ (const std::vector< double > &lambda, double t, RowMatrix< double > &result) const |
Compute the integral part of the computation. More... | |
void | jFunction_ (const std::vector< double > &lambda, const std::vector< double > &ilambda, double t, RowMatrix< double > &result, RowMatrix< double > &iresult) const |
Compute the integral part of the computation, in complex numbers. More... | |
Protected Attributes | |
std::shared_ptr< const AlphabetIndex1 > | alphIndex_ |
std::shared_ptr< const SubstitutionModelInterface > | model_ |
size_t | nbStates_ |
size_t | nbTypes_ |
RowMatrix< double > | jMat_ |
RowMatrix< double > | jIMat_ |
ColMatrix< double > | rightEigenVectors_ |
Real and imaginary eigenvectors, for non-reversible computation. More... | |
ColMatrix< double > | rightIEigenVectors_ |
RowMatrix< double > | leftEigenVectors_ |
RowMatrix< double > | leftIEigenVectors_ |
std::vector< RowMatrix< double > > | bMatrices_ |
computation matrices More... | |
std::vector< RowMatrix< double > > | insideProducts_ |
std::vector< RowMatrix< double > > | insideIProducts_ |
Private Member Functions | |
void | fillBMatrice_ () |
Private Attributes | |
RowMatrix< double > | rewards_ |
double | currentLength_ |
Analytical reward using the eigen decomposition method.
The codes is adapted from the original R code by Paula Tataru and Asger Hobolth to the formula in the article of Minin & Suchard.
Minin, V.N. and Suchard, M.A., Fast, accurate and simulation-free stochastic mapping Philosophical Transactions of the Royal Society B 2008 363:3985-95.
Only reversible models are supported for now.
Definition at line 28 of file DecompositionReward.h.
DecompositionReward::DecompositionReward | ( | std::shared_ptr< const SubstitutionModelInterface > | model, |
std::shared_ptr< const AlphabetIndex1 > | alphIndex | ||
) |
Definition at line 16 of file DecompositionReward.cpp.
References bpp::AbstractReward::alphIndex_, bpp::DecompositionMethods::computeProducts_(), fillBMatrice_(), bpp::DecompositionMethods::initBMatrices_(), and initRewards_().
Referenced by clone().
DecompositionReward::DecompositionReward | ( | const StateMapInterface & | stateMap, |
std::shared_ptr< const AlphabetIndex1 > | alphIndex | ||
) |
Definition at line 38 of file DecompositionReward.cpp.
|
inline |
Definition at line 45 of file DecompositionReward.h.
|
inlinevirtual |
Definition at line 62 of file DecompositionReward.h.
|
inlineinherited |
Definition at line 161 of file Reward.h.
References bpp::AbstractReward::alphIndex_.
|
overrideprotectedvirtual |
Implements bpp::AbstractReward.
Definition at line 169 of file DecompositionReward.cpp.
References bpp::AbstractReward::alphIndex_, bpp::DecompositionMethods::computeProducts_(), computeRewards_(), currentLength_, fillBMatrice_(), and bpp::DecompositionMethods::model_.
|
inlineoverridevirtual |
Implements bpp::Reward.
Definition at line 64 of file DecompositionReward.h.
References DecompositionReward().
|
protectedinherited |
Definition at line 166 of file DecompositionMethods.cpp.
References bpp::MatrixTools::hadamardMult(), bpp::DecompositionMethods::insideIProducts_, bpp::DecompositionMethods::insideProducts_, bpp::DecompositionMethods::jFunction_(), bpp::DecompositionMethods::jIMat_, bpp::DecompositionMethods::jMat_, bpp::DecompositionMethods::leftEigenVectors_, bpp::DecompositionMethods::leftIEigenVectors_, bpp::DecompositionMethods::model_, bpp::MatrixTools::mult(), bpp::DecompositionMethods::nbStates_, bpp::DecompositionMethods::rightEigenVectors_, and bpp::DecompositionMethods::rightIEigenVectors_.
Referenced by bpp::DecompositionSubstitutionCount::computeCounts_(), and computeRewards_().
|
protectedinherited |
Definition at line 196 of file DecompositionMethods.cpp.
References bpp::MatrixTools::hadamardMult(), bpp::DecompositionMethods::insideIProducts_, bpp::DecompositionMethods::insideProducts_, bpp::DecompositionMethods::jFunction_(), bpp::DecompositionMethods::jIMat_, bpp::DecompositionMethods::jMat_, bpp::DecompositionMethods::leftEigenVectors_, bpp::DecompositionMethods::leftIEigenVectors_, bpp::DecompositionMethods::model_, bpp::MatrixTools::mult(), bpp::DecompositionMethods::nbStates_, bpp::DecompositionMethods::nbTypes_, bpp::DecompositionMethods::rightEigenVectors_, and bpp::DecompositionMethods::rightIEigenVectors_.
|
protectedinherited |
Definition at line 91 of file DecompositionMethods.cpp.
References bpp::DecompositionMethods::bMatrices_, bpp::DecompositionMethods::insideIProducts_, bpp::DecompositionMethods::insideProducts_, bpp::DecompositionMethods::leftEigenVectors_, bpp::DecompositionMethods::leftIEigenVectors_, bpp::DecompositionMethods::model_, bpp::MatrixTools::mult(), bpp::DecompositionMethods::nbStates_, bpp::DecompositionMethods::nbTypes_, bpp::DecompositionMethods::rightEigenVectors_, and bpp::DecompositionMethods::rightIEigenVectors_.
Referenced by alphabetIndexHasChanged(), DecompositionReward(), bpp::DecompositionSubstitutionCount::DecompositionSubstitutionCount(), bpp::DecompositionSubstitutionCount::distancesHaveChanged(), setSubstitutionModel(), bpp::DecompositionSubstitutionCount::setSubstitutionModel(), and bpp::DecompositionSubstitutionCount::substitutionRegisterHasChanged().
|
protected |
Definition at line 67 of file DecompositionReward.cpp.
References bpp::DecompositionMethods::computeExpectations(), bpp::numeric::isinf(), bpp::DecompositionMethods::model_, bpp::DecompositionMethods::nbStates_, and rewards_.
Referenced by alphabetIndexHasChanged(), getAllRewards(), getReward(), setSubstitutionModel(), and storeAllRewards().
|
private |
Definition at line 56 of file DecompositionReward.cpp.
References bpp::DecompositionMethods::bMatrices_, bpp::AbstractReward::getAlphabetIndex(), bpp::DecompositionMethods::model_, and bpp::DecompositionMethods::nbStates_.
Referenced by alphabetIndexHasChanged(), DecompositionReward(), and setSubstitutionModel().
|
overridevirtual |
Get the rewards on a branch, for each initial and final states, and given the branch length.
length | The length of the branch. |
Implements bpp::Reward.
Definition at line 86 of file DecompositionReward.cpp.
References computeRewards_(), currentLength_, bpp::DecompositionMethods::model_, rewards_, and bpp::TextTools::toString().
|
inlinevirtualinherited |
Short cut function, equivalent to getSubstitutionRegister()->getAlphabet().
Definition at line 65 of file Reward.h.
References bpp::Reward::getAlphabetIndex().
Referenced by bpp::Reward::getNumberOfStates().
|
inlinevirtualinherited |
Implements bpp::Reward.
Definition at line 159 of file Reward.h.
References bpp::AbstractReward::alphIndex_.
Referenced by fillBMatrice_().
|
inlinevirtualinherited |
Short cut function, equivalent to getSubstitutionRegister()->getAlphabet()->getSize().
Definition at line 75 of file Reward.h.
References bpp::Reward::getAlphabet().
|
overridevirtual |
Get the reward of susbstitutions on a branch, given the initial and final states, and the branch length.
initialState | The initial state. |
finalState | The final state. |
length | The length of the branch. |
Implements bpp::Reward.
Definition at line 130 of file DecompositionReward.cpp.
References computeRewards_(), currentLength_, rewards_, and bpp::TextTools::toString().
|
inlinevirtualinherited |
Implements bpp::Reward.
Definition at line 146 of file Reward.h.
References bpp::AbstractReward::alphIndex_.
|
protectedinherited |
Definition at line 306 of file DecompositionMethods.cpp.
References bpp::DecompositionMethods::bMatrices_, bpp::DecompositionMethods::insideProducts_, bpp::DecompositionMethods::nbStates_, and bpp::DecompositionMethods::nbTypes_.
Referenced by bpp::DecompositionMethods::DecompositionMethods(), DecompositionReward(), bpp::DecompositionSubstitutionCount::DecompositionSubstitutionCount(), bpp::DecompositionMethods::initStates_(), bpp::DecompositionMethods::setSubstitutionModel(), and bpp::DecompositionSubstitutionCount::substitutionRegisterHasChanged().
|
protected |
Definition at line 49 of file DecompositionReward.cpp.
References bpp::DecompositionMethods::nbStates_, RowMatrix< double >::resize(), and rewards_.
Referenced by DecompositionReward(), and setSubstitutionModel().
|
protectedinherited |
Definition at line 233 of file DecompositionMethods.cpp.
References bpp::DecompositionMethods::initBMatrices_(), bpp::DecompositionMethods::jMat_, bpp::DecompositionMethods::nbStates_, and RowMatrix< double >::resize().
Referenced by bpp::DecompositionSubstitutionCount::substitutionRegisterHasChanged().
|
protectedinherited |
Compute the integral part of the computation, in complex numbers.
Definition at line 135 of file DecompositionMethods.cpp.
References bpp::abs(), bpp::VectorTools::cos(), bpp::VectorTools::exp(), bpp::DecompositionMethods::nbStates_, bpp::VectorTools::sin(), and bpp::NumConstants::TINY().
|
protectedinherited |
Compute the integral part of the computation.
Definition at line 117 of file DecompositionMethods.cpp.
References bpp::abs(), bpp::VectorTools::exp(), bpp::DecompositionMethods::nbStates_, and bpp::NumConstants::TINY().
Referenced by bpp::DecompositionMethods::computeExpectations().
|
inline |
Definition at line 52 of file DecompositionReward.h.
References currentLength_, bpp::AbstractReward::operator=(), bpp::DecompositionMethods::operator=(), and rewards_.
|
inlinevirtualinherited |
attribution of an AlphabetIndex1
alphIndex | pointer to a AlphabetIndex1 |
Implements bpp::Reward.
Definition at line 153 of file Reward.h.
References bpp::AbstractReward::alphabetIndexHasChanged(), and bpp::AbstractReward::alphIndex_.
|
overridevirtual |
Set the substitution model.
model | A pointer toward the substitution model to use. Only reversible models are currently supported. Setting a non-reversible model will throw an exception. |
Implements bpp::Reward.
Definition at line 144 of file DecompositionReward.cpp.
References bpp::AbstractReward::alphIndex_, bpp::DecompositionMethods::computeProducts_(), computeRewards_(), currentLength_, fillBMatrice_(), initRewards_(), and bpp::DecompositionMethods::setSubstitutionModel().
|
overridevirtual |
Store the rewards on a branch, for each initial and final states, and given the branch length.
length | The length of the branch. |
mat | A matrix to store all rewards for each initial and final states. |
Implements bpp::Reward.
Definition at line 103 of file DecompositionReward.cpp.
References computeRewards_(), currentLength_, bpp::DecompositionMethods::model_, bpp::DecompositionMethods::nbStates_, rewards_, and bpp::TextTools::toString().
|
protectedinherited |
Definition at line 126 of file Reward.h.
Referenced by bpp::AbstractReward::alphabetIndex(), alphabetIndexHasChanged(), DecompositionReward(), bpp::AbstractReward::getAlphabetIndex(), bpp::AbstractReward::hasAlphabetIndex(), bpp::AbstractReward::operator=(), bpp::AbstractReward::setAlphabetIndex(), and setSubstitutionModel().
|
protectedinherited |
computation matrices
Definition at line 44 of file DecompositionMethods.h.
Referenced by bpp::DecompositionMethods::computeProducts_(), fillBMatrice_(), bpp::DecompositionSubstitutionCount::fillBMatrices_(), bpp::DecompositionMethods::initBMatrices_(), bpp::DecompositionMethods::operator=(), and bpp::DecompositionSubstitutionCount::setDistanceBMatrices_().
|
mutableprivate |
Definition at line 34 of file DecompositionReward.h.
Referenced by alphabetIndexHasChanged(), getAllRewards(), getReward(), operator=(), setSubstitutionModel(), and storeAllRewards().
|
protectedinherited |
Definition at line 44 of file DecompositionMethods.h.
Referenced by bpp::DecompositionMethods::computeExpectations(), bpp::DecompositionMethods::computeProducts_(), bpp::DecompositionMethods::operator=(), and bpp::DecompositionMethods::setSubstitutionModel().
|
protectedinherited |
Definition at line 44 of file DecompositionMethods.h.
Referenced by bpp::DecompositionMethods::computeExpectations(), bpp::DecompositionMethods::computeProducts_(), bpp::DecompositionMethods::initBMatrices_(), and bpp::DecompositionMethods::operator=().
|
protectedinherited |
Definition at line 32 of file DecompositionMethods.h.
Referenced by bpp::DecompositionMethods::computeExpectations(), bpp::DecompositionMethods::operator=(), and bpp::DecompositionMethods::setSubstitutionModel().
|
mutableprotectedinherited |
Definition at line 32 of file DecompositionMethods.h.
Referenced by bpp::DecompositionMethods::computeExpectations(), bpp::DecompositionMethods::initStates_(), bpp::DecompositionMethods::operator=(), and bpp::DecompositionMethods::setSubstitutionModel().
|
protectedinherited |
Definition at line 39 of file DecompositionMethods.h.
Referenced by bpp::DecompositionMethods::computeExpectations(), bpp::DecompositionMethods::computeProducts_(), bpp::DecompositionMethods::operator=(), and bpp::DecompositionMethods::setSubstitutionModel().
|
protectedinherited |
Definition at line 39 of file DecompositionMethods.h.
Referenced by bpp::DecompositionMethods::computeExpectations(), bpp::DecompositionMethods::computeProducts_(), bpp::DecompositionMethods::operator=(), and bpp::DecompositionMethods::setSubstitutionModel().
|
protectedinherited |
Definition at line 29 of file DecompositionMethods.h.
Referenced by alphabetIndexHasChanged(), bpp::DecompositionSubstitutionCount::computeCounts_(), bpp::DecompositionMethods::computeExpectations(), bpp::DecompositionMethods::computeProducts_(), computeRewards_(), bpp::DecompositionSubstitutionCount::distancesHaveChanged(), fillBMatrice_(), bpp::DecompositionSubstitutionCount::fillBMatrices_(), bpp::DecompositionSubstitutionCount::getAllNumbersOfSubstitutions(), getAllRewards(), bpp::DecompositionSubstitutionCount::getNumberOfSubstitutions(), bpp::DecompositionSubstitutionCount::getNumberOfSubstitutionsPerType(), bpp::DecompositionMethods::operator=(), bpp::DecompositionSubstitutionCount::setDistanceBMatrices_(), bpp::DecompositionMethods::setSubstitutionModel(), bpp::DecompositionSubstitutionCount::storeAllNumbersOfSubstitutions(), storeAllRewards(), bpp::DecompositionSubstitutionCount::substitutionRegisterHasChanged(), and bpp::DecompositionSubstitutionCount::weightsHaveChanged().
|
protectedinherited |
Definition at line 30 of file DecompositionMethods.h.
Referenced by bpp::DecompositionSubstitutionCount::computeCounts_(), bpp::DecompositionMethods::computeExpectations(), bpp::DecompositionMethods::computeProducts_(), computeRewards_(), fillBMatrice_(), bpp::DecompositionSubstitutionCount::fillBMatrices_(), bpp::DecompositionMethods::initBMatrices_(), bpp::DecompositionSubstitutionCount::initCounts_(), initRewards_(), bpp::DecompositionMethods::initStates_(), bpp::DecompositionMethods::jFunction_(), bpp::DecompositionMethods::operator=(), bpp::DecompositionSubstitutionCount::setDistanceBMatrices_(), bpp::DecompositionMethods::setSubstitutionModel(), bpp::DecompositionSubstitutionCount::storeAllNumbersOfSubstitutions(), and storeAllRewards().
|
protectedinherited |
Definition at line 31 of file DecompositionMethods.h.
Referenced by bpp::DecompositionSubstitutionCount::computeCounts_(), bpp::DecompositionMethods::computeExpectations(), bpp::DecompositionMethods::computeProducts_(), bpp::DecompositionMethods::initBMatrices_(), bpp::DecompositionMethods::operator=(), and bpp::DecompositionMethods::setSubstitutionModel().
|
mutableprivate |
Definition at line 33 of file DecompositionReward.h.
Referenced by computeRewards_(), getAllRewards(), getReward(), initRewards_(), operator=(), and storeAllRewards().
|
protectedinherited |
Real and imaginary eigenvectors, for non-reversible computation.
Definition at line 38 of file DecompositionMethods.h.
Referenced by bpp::DecompositionMethods::computeExpectations(), bpp::DecompositionMethods::computeProducts_(), bpp::DecompositionMethods::operator=(), and bpp::DecompositionMethods::setSubstitutionModel().
|
protectedinherited |
Definition at line 38 of file DecompositionMethods.h.
Referenced by bpp::DecompositionMethods::computeExpectations(), bpp::DecompositionMethods::computeProducts_(), bpp::DecompositionMethods::operator=(), and bpp::DecompositionMethods::setSubstitutionModel().