bpp-phyl3 3.0.0
Simplex_DF.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_SIMPLEX_DF_H
6#define BPP_PHYL_LIKELIHOOD_DATAFLOW_SIMPLEX_DF_H
7
8#include <Bpp/Exceptions.h>
12#include <functional>
13#include <unordered_map>
14
15#include "Definitions.h"
16
17namespace bpp
18{
19class Simplex;
20
35class ConfiguredSimplex : public Value<const Simplex*>,
37{
38 // private:
39
40 // const Context& context_;
41
42public:
44 using Target = Simplex;
45
46 ConfiguredSimplex (const Context& context, NodeRefVec&& deps, std::unique_ptr<Simplex>&& simplex);
48
50 {
51 throw bpp::Exception("ConfiguredSimplex clone should not happen.");
52 }
53
54 std::string description () const final;
55 std::string debugInfo () const final;
56 std::string color() const final
57 {
58 return "blue";
59 }
60
61 bool compareAdditionalArguments (const Node_DF& other) const;
62
63 std::size_t hashAdditionalArguments () const;
64
67
68 NodeRef recreate (Context& c, NodeRefVec&& deps) final;
69
70 const ConfiguredParameter& getConfiguredParameter(const std::string& name)
71 {
72 return static_cast<const ConfiguredParameter&>(parameter(name));
73 }
74
75private:
76 void compute ()
77 {
78 simplex_->matchParametersValues(getParameters());
79 }
80
81
82 std::unique_ptr<Simplex> simplex_;
83};
84
92class FrequenciesFromSimplex : public Value<Eigen::RowVectorXd>
93{
94public:
96 using T = Eigen::RowVectorXd;
97
98 // static ValueRef<T> create (Context & c, NodeRefVec && deps, const Dimension<T> & dim);
100
101 std::string debugInfo () const final;
102
103 std::string color() const final
104 {
105 return "blue";
106 }
107
108 bool compareAdditionalArguments (const Node_DF& other) const final;
109
110 NodeRef derive (Context& c, const Node_DF& node) final;
111 NodeRef recreate (Context& c, NodeRefVec&& deps) final;
112
113private:
114 void compute () final;
115
117
118public:
119 static std::shared_ptr<Self> create (Context& c, NodeRefVec&& deps);
120};
121} // namespace bpp
122#endif // BPP_PHYL_LIKELIHOOD_DATAFLOW_SIMPLEX_DF_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 Frequencies Set configured with parameter values.
Definition: Simplex_DF.h:37
ConfiguredSimplex * clone() const
Definition: Simplex_DF.h:49
std::string description() const final
Node pretty name (default = type name).
Definition: Simplex_DF.cpp:29
void compute()
Computation implementation.
Definition: Simplex_DF.h:76
std::unique_ptr< Simplex > simplex_
Definition: Simplex_DF.h:82
bool compareAdditionalArguments(const Node_DF &other) const
Compare node-specific configuration to another.
Definition: Simplex_DF.cpp:39
std::string debugInfo() const final
Node debug info (default = ""): user defined detailed info for DF graph debug.
Definition: Simplex_DF.cpp:31
std::string color() const final
Definition: Simplex_DF.h:56
NumericalDerivativeConfiguration config
Configuration for numerical derivation of computation nodes using this Simplex.
Definition: Simplex_DF.h:66
const ConfiguredParameter & getConfiguredParameter(const std::string &name)
Definition: Simplex_DF.h:70
std::size_t hashAdditionalArguments() const
Return the hash of node-specific configuration.
Definition: Simplex_DF.cpp:54
ConfiguredSimplex(const Context &context, NodeRefVec &&deps, std::unique_ptr< Simplex > &&simplex)
Definition: Simplex_DF.cpp:16
NodeRef recreate(Context &c, NodeRefVec &&deps) final
Recreate the node with different dependencies.
Definition: Simplex_DF.cpp:60
Context for dataflow node construction.
Definition: DataFlow.h:527
NodeRef derive(Context &c, const Node_DF &node) final
Returns a node computing d(this_node_expression)/d(node_expression).
Definition: Simplex_DF.cpp:87
Eigen::RowVectorXd T
Definition: Simplex_DF.h:96
std::string color() const final
Definition: Simplex_DF.h:103
static std::shared_ptr< Self > create(Context &c, NodeRefVec &&deps)
void compute() final
Computation implementation.
Definition: Simplex_DF.cpp:107
FrequenciesFromSimplex(NodeRefVec &&deps, const Dimension< T > &dim)
Definition: Simplex_DF.cpp:71
bool compareAdditionalArguments(const Node_DF &other) const final
Compare node-specific configuration to another.
Definition: Simplex_DF.cpp:82
NodeRef recreate(Context &c, NodeRefVec &&deps) final
Recreate the node with different dependencies.
Definition: Simplex_DF.cpp:102
Dimension< T > targetDimension_
Definition: Simplex_DF.h:116
std::string debugInfo() const final
Node debug info (default = ""): user defined detailed info for DF graph debug.
Definition: Simplex_DF.cpp:75
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.