bpp-phyl3 3.0.0
FrequencySet.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_FREQUENCYSET_H
6#define BPP_PHYL_LIKELIHOOD_DATAFLOW_FREQUENCYSET_H
7
8#include <Bpp/Exceptions.h>
13#include <functional>
14#include <unordered_map>
15
16#include "Definitions.h"
17
18namespace bpp
19{
20class FrequencySetInterface;
21
37 public Value<const FrequencySetInterface*>,
39{
40 // private:
41
42 // const Context& context_;
43
44public:
47
48 ConfiguredFrequencySet (const Context& context, NodeRefVec&& deps, std::unique_ptr<FrequencySetInterface>&& freqset);
49
51
53 {
54 throw bpp::Exception("ConfiguredFrequencySet clone should not happen.");
55 }
56
57 std::string description () const final;
58 std::string debugInfo () const final;
59 std::string color() const final
60 {
61 return "#ffff00";
62 }
63
64 bool compareAdditionalArguments (const Node_DF& other) const;
65
66 std::size_t hashAdditionalArguments () const;
67
70
71 NodeRef recreate (Context& c, NodeRefVec&& deps) final;
72
73 const ConfiguredParameter& getConfiguredParameter(const std::string& name)
74 {
75 return static_cast<const ConfiguredParameter&>(parameter(name));
76 }
77
78private:
79 void compute ()
80 {
81 freqset_->matchParametersValues(getParameters());
82 }
83
84
85 std::unique_ptr<FrequencySetInterface> freqset_;
86};
87
95class FrequenciesFromFrequencySet : public Value<Eigen::RowVectorXd>
96{
97public:
99 using T = Eigen::RowVectorXd;
100
101 // static ValueRef<T> create (Context & c, NodeRefVec && deps, const Dimension<T> & dim);
103
104 std::string debugInfo () const final;
105
106 bool compareAdditionalArguments (const Node_DF& other) const final;
107
108 NodeRef derive (Context& c, const Node_DF& node) final;
109 NodeRef recreate (Context& c, NodeRefVec&& deps) final;
110
111 std::string color() const final
112 {
113 return "#ffff66";
114 }
115
116private:
117 void compute () final;
118
120};
121} // namespace bpp
122#endif // BPP_PHYL_LIKELIHOOD_DATAFLOW_FREQUENCYSET_H
const Parameter & parameter(const std::string &name) const override
const ParameterList & getParameters() const override
Data flow node representing a Frequencies Set configured with parameter values.
Definition: FrequencySet.h:39
std::string color() const final
Definition: FrequencySet.h:59
const ConfiguredParameter & getConfiguredParameter(const std::string &name)
Definition: FrequencySet.h:73
bool compareAdditionalArguments(const Node_DF &other) const
Compare node-specific configuration to another.
ConfiguredFrequencySet(const Context &context, NodeRefVec &&deps, std::unique_ptr< FrequencySetInterface > &&freqset)
ConfiguredFrequencySet * clone() const
Definition: FrequencySet.h:52
NumericalDerivativeConfiguration config
Configuration for numerical derivation of computation nodes using this FrequencySet.
Definition: FrequencySet.h:69
NodeRef recreate(Context &c, NodeRefVec &&deps) final
Recreate the node with different dependencies.
std::string debugInfo() const final
Node debug info (default = ""): user defined detailed info for DF graph debug.
void compute()
Computation implementation.
Definition: FrequencySet.h:79
std::size_t hashAdditionalArguments() const
Return the hash of node-specific configuration.
std::string description() const final
Node pretty name (default = type name).
std::unique_ptr< FrequencySetInterface > freqset_
Definition: FrequencySet.h:85
Data flow node representing a parameter.
Definition: Parameter.h:27
Context for dataflow node construction.
Definition: DataFlow.h:527
void compute() final
Computation implementation.
std::string color() const final
Definition: FrequencySet.h:111
FrequenciesFromFrequencySet(NodeRefVec &&deps, const Dimension< T > &dim)
std::string debugInfo() const final
Node debug info (default = ""): user defined detailed info for DF graph debug.
bool compareAdditionalArguments(const Node_DF &other) const final
Compare node-specific configuration to another.
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.
Parametrize a set of state frequencies.
Definition: FrequencySet.h:29
Base dataflow Node class.
Definition: DataFlow.h:152
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.