17 std::shared_ptr<const SubstitutionModelInterface> model,
18 std::shared_ptr<const AlphabetIndex1> alphIndex) :
21 rewards_(nbStates_, nbStates_),
25 if (
typeid(model->getAlphabet()) !=
typeid(
alphIndex_->getAlphabet()))
26 throw Exception(
"DecompositionReward (constructor): alphabets do not match between alphabet index and model.");
40 std::shared_ptr<const AlphabetIndex1> alphIndex) :
43 rewards_(nbStates_, nbStates_),
58 vector<int> supportedStates =
model_->getAlphabetStates();
89 throw Exception(
"DecompositionReward::getAllRewards: model not defined.");
106 throw Exception(
"DecompositionReward::storeAllRewards: model not defined.");
123 mat(Eigen::Index(j), Eigen::Index(k)) =
rewards_(j, k);
139 return rewards_(initialState, finalState);
145 std::shared_ptr<const SubstitutionModelInterface> model)
153 if (
typeid(model->getAlphabet()) !=
typeid(
alphIndex_->getAlphabet()))
154 throw Exception(
"DecompositionReward::setSubstitutionModel: alphabets do not match between alphabet index and model.");
176 throw Exception(
"DecompositionReward::AlphabetIndexHasChanged: alphabets do not match between alphbaet index and model.");
Basic implementation of the the Reward interface.
std::shared_ptr< const AlphabetIndex1 > alphIndex_
std::shared_ptr< const AlphabetIndex1 > getAlphabetIndex() const
Methods useful for analytical substitution count and rewards using the eigen decomposition method.
void computeExpectations(RowMatrix< double > &mapping, double length) const
void setSubstitutionModel(std::shared_ptr< const SubstitutionModelInterface > model)
Set the substitution model.
std::shared_ptr< const SubstitutionModelInterface > model_
std::vector< RowMatrix< double > > bMatrices_
computation matrices
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.
Matrix< double > * getAllRewards(double length) const override
Get the rewards on a branch, for each initial and final states, and given the branch length.
void computeRewards_(double length) const
DecompositionReward(std::shared_ptr< const SubstitutionModelInterface > model, std::shared_ptr< const AlphabetIndex1 > alphIndex)
void alphabetIndexHasChanged() override
void setSubstitutionModel(std::shared_ptr< const SubstitutionModelInterface > model) override
Set the substitution model.
RowMatrix< double > rewards_
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 leng...
void resize(size_t nRows, size_t nCols)
Map the states of a given alphabet which have a model state.
std::string toString(T t)
bool isinf(const double &d)
Defines the basic types of data flow nodes.