bpp-phyl3  3.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TransitionMatrix.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_LIKELIHOOD_DATAFLOW_TRANSITIONMATRIX_H
6 #define BPP_PHYL_LIKELIHOOD_DATAFLOW_TRANSITIONMATRIX_H
7 
8 #include <Bpp/Exceptions.h>
12 #include <functional>
13 #include <unordered_map>
14 
15 #include "Definitions.h"
16 
17 namespace bpp
18 {
26 class ConfiguredTransitionMatrix : public Value<const HmmTransitionMatrix*>,
28 {
29  // private:
30  // Context& context_;
31 
32 public:
35 
36  ConfiguredTransitionMatrix (Context& context, NodeRefVec&& deps, std::unique_ptr<HmmTransitionMatrix>&& hmm);
38 
40  {
41  throw bpp::Exception("ConfiguredTransitionMatrix clone should not happen.");
42  }
43 
44  std::string description () const final;
45  std::string debugInfo () const final;
46 
47  std::string color () const final
48  {
49  return "green";
50  }
51 
52  bool compareAdditionalArguments (const Node_DF& other) const;
53 
54  std::size_t hashAdditionalArguments () const;
55 
58 
59  NodeRef recreate (Context& c, NodeRefVec&& deps) final;
60 
61  const ConfiguredParameter& getConfiguredParameter(const std::string& name) const
62  {
63  return static_cast<const ConfiguredParameter&>(parameter(name));
64  }
65 
66 private:
67  void compute ()
68  {
69  hmm_->matchParametersValues(getParameters());
70  }
71 
72  std::unique_ptr<HmmTransitionMatrix> hmm_;
73 };
74 
82 class EquilibriumFrequenciesFromTransitionMatrix : public Value<Eigen::VectorXd>
83 {
84 public:
87  using T = Eigen::VectorXd;
88 
90 
91  std::string debugInfo () const final;
92 
93  bool compareAdditionalArguments (const Node_DF& other) const;
94 
95  NodeRef derive (Context& c, const Node_DF& node) final;
96  NodeRef recreate (Context& c, NodeRefVec&& deps) final;
97 
98  std::string color () const final
99  {
100  return "#ffff66";
101  }
102 
103 private:
104  void compute () final;
105 
107 };
108 
116 {
117 public:
120  using T = Eigen::MatrixXd;
121 
122 private:
124 
125 public:
128 
129  std::string debugInfo () const final;
130 
131  bool compareAdditionalArguments (const Node_DF& other) const;
132 
133  NodeRef derive (Context& c, const Node_DF& node) final;
134  NodeRef recreate (Context& c, NodeRefVec&& deps) final;
135 
136  std::string color () const final
137  {
138  return "#aaff00";
139  }
140 
141  std::string description () const final
142  {
143  return "TransitionMatrix";
144  }
145 
146  std::string shape() const
147  {
148  return "octagon";
149  }
150 
151 private:
152  void compute () final;
153 };
154 } // namespace bpp
155 #endif // BPP_PHYL_LIKELIHOOD_DATAFLOW_TRANSITIONMATRIX_H
const Parameter & parameter(const std::string &name) const override
const ParameterList & getParameters() const override
Data flow node representing a parameter.
Definition: Parameter.h:27
Data flow node representing a TransitionMatrix configured with parameter values.
NumericalDerivativeConfiguration config
Configuration for numerical derivation of computation nodes using this TransitionMatrix.
std::string description() const final
Node pretty name (default = type name).
void compute()
Computation implementation.
ConfiguredTransitionMatrix(Context &context, NodeRefVec &&deps, std::unique_ptr< HmmTransitionMatrix > &&hmm)
std::string color() const final
bool compareAdditionalArguments(const Node_DF &other) const
Compare node-specific configuration to another.
std::string debugInfo() const final
Node debug info (default = ""): user defined detailed info for DF graph debug.
NodeRef recreate(Context &c, NodeRefVec &&deps) final
Recreate the node with different dependencies.
std::unique_ptr< HmmTransitionMatrix > hmm_
ConfiguredTransitionMatrix * clone() const
const ConfiguredParameter & getConfiguredParameter(const std::string &name) const
std::size_t hashAdditionalArguments() const
Return the hash of node-specific configuration.
Context for dataflow node construction.
Definition: DataFlow.h:527
std::string debugInfo() const final
Node debug info (default = ""): user defined detailed info for DF graph debug.
void compute() final
Computation implementation.
bool compareAdditionalArguments(const Node_DF &other) const
Compare node-specific configuration to another.
EquilibriumFrequenciesFromTransitionMatrix(NodeRefVec &&deps, const Dimension< T > &dim)
NodeRef derive(Context &c, const Node_DF &node) final
Returns a node computing d(this_node_expression)/d(node_expression).
NodeRef recreate(Context &c, NodeRefVec &&deps) final
Recreate the node with different dependencies.
Base dataflow Node class.
Definition: DataFlow.h:152
std::string description() const final
Node pretty name (default = type name).
Abstract Node storing a value of type T.
Definition: DataFlow.h:352
Defines the basic types of data flow nodes.
std::vector< NodeRef > NodeRefVec
Alias for a dependency vector (of NodeRef).
Definition: DataFlow.h:81
std::shared_ptr< Node_DF > NodeRef
Definition: DataFlow.h:78
Store a dimension for type T.
Configuration for a numerical derivation: what delta to use, and type of derivation.