bpp-phyl3  3.0.0
DecompositionReward.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #ifndef BPP_PHYL_MAPPING_DECOMPOSITIONREWARD_H
6 #define BPP_PHYL_MAPPING_DECOMPOSITIONREWARD_H
7 
8 
9 #include "DecompositionMethods.h"
10 #include "Reward.h"
11 
12 namespace bpp
13 {
29  public AbstractReward,
31 {
32 private:
34  mutable double currentLength_;
35 
36 public:
38  std::shared_ptr<const SubstitutionModelInterface> model,
39  std::shared_ptr<const AlphabetIndex1> alphIndex);
40 
42  const StateMapInterface& stateMap,
43  std::shared_ptr<const AlphabetIndex1> alphIndex);
44 
46  AbstractReward(dr),
48  rewards_(dr.rewards_),
50  {}
51 
53  {
56 
57  rewards_ = dr.rewards_;
59  return *this;
60  }
61 
62  virtual ~DecompositionReward() {}
63 
64  DecompositionReward* clone() const override { return new DecompositionReward(*this); }
65 
66 public:
67  double getReward(size_t initialState, size_t finalState, double length) const override;
68 
69  Matrix<double>* getAllRewards(double length) const override;
70 
71  void storeAllRewards(double length, Eigen::MatrixXd& mat) const override;
72 
80  void setSubstitutionModel(std::shared_ptr<const SubstitutionModelInterface> model) override;
81 
82 protected:
83  void initRewards_();
84 
85  void computeRewards_(double length) const;
86 
87  void alphabetIndexHasChanged() override;
88 
89 private:
90  void fillBMatrice_();
91 };
92 } // end of namespace bpp.
93 #endif // BPP_PHYL_MAPPING_DECOMPOSITIONREWARD_H
Basic implementation of the the Reward interface.
Definition: Reward.h:124
AbstractReward & operator=(const AbstractReward &ar)
Definition: Reward.h:137
Methods useful for analytical substitution count and rewards using the eigen decomposition method.
DecompositionMethods & operator=(const DecompositionMethods &dm)
Analytical reward using the eigen decomposition method.
DecompositionReward(const DecompositionReward &dr)
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.
DecompositionReward * clone() const override
DecompositionReward & operator=(const DecompositionReward &dr)
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...
Map the states of a given alphabet which have a model state.
Definition: StateMap.h:25
Defines the basic types of data flow nodes.