5 #ifndef BPP_PHYL_LIKELIHOOD_DATAFLOW_PARAMETER_H
6 #define BPP_PHYL_LIKELIHOOD_DATAFLOW_PARAMETER_H
13 #include <unordered_map>
26 public Value<Parameter*>
40 checkNthDependencyIsValue<double>(
typeid (
Self), deps, 0);
41 return cachedAs<Self>(c, std::make_shared<Self>(c, std::move(deps), param));
48 return cachedAs<Self>(c, std::make_shared<Self>(c, std::move(deps), param));
55 checkNthDependencyIsValue<double>(
typeid (
Self), deps, 0);
57 self->resetDependencies_(std::move(deps));
59 return cachedAs<Self>(c,
self);
79 std::string
color ()
const override;
141 checkDependencyRangeIsValue<double>(
typeid (
Self), deps, 0, 2);
144 auto& delta = deps[1];
145 auto* paramAsShiftParameter =
dynamic_cast<ShiftParameter*
>(¶m);
147 if (paramAsShiftParameter !=
nullptr && paramAsShiftParameter->dependency (1) == delta)
151 return Self::create (c, std::move(deps), p2, n + paramAsShiftParameter->getN ());
158 return std::dynamic_pointer_cast<ConfiguredParameter>(paramAsConf->shared_from_this());
164 return cachedAs<ConfiguredParameter>(c, std::make_shared<Self>(c, std::move(deps), param, n));
181 if (name.substr(0, 5) ==
"BrLen")
197 const auto* derived =
dynamic_cast<const Self*
>(&other);
198 return derived !=
nullptr &&
n_ == derived->n_;
208 throw Exception(
"ShiftParameter setValue should not be called");
223 std::size_t seed = 0;
234 auto dx = this->
dependency (0)->derive (c, node);
235 auto ddelta = this->
dependency (1)->derive (c, node);
255 const auto& x = accessValueConstCast<double>(*this->
dependency (0));
256 const auto& delta = accessValueConstCast<double>(*this->
dependency (1));
257 double r =
n_ * delta + x;
290 return "ValueFrom(" +
dependency(0)->description() +
")";
293 std::string
color ()
const;
static std::shared_ptr< Self > create(Context &c, const Dimension< T > &dim)
Build a new ConstantOne node of the given dimension.
static std::shared_ptr< Self > create(Context &c, const Dimension< T > &dim)
Build a new ConstantZero node of the given dimension.
Context for dataflow node construction.
Base dataflow Node class.
const NodeRef & dependency(std::size_t i) const noexcept
static std::shared_ptr< Self > create(Context &, Args &&... args)
Build a new NumericMutable node with T(args...) value.
virtual void setValue(double value)
virtual double getValue() const
virtual std::shared_ptr< const ConstraintInterface > getConstraint() const
virtual const std::string & getName() const
virtual bool hasConstraint() const
shift param value = n * delta + x.
NodeRef derive(Context &c, const Node_DF &node) final
Returns a node computing d(this_node_expression)/d(node_expression).
static std::shared_ptr< ConfiguredParameter > create(Context &c, NodeRefVec &&deps, Parameter ¶m, const int n)
Build a new ShiftDelta node with the given output dimensions and shift number.
std::string debugInfo() const override
Node debug info (default = ""): user defined detailed info for DF graph debug.
std::string description() const override
Node pretty name (default = type name).
void setValue(double v) override
double getValue() const override
Raw value access (const).
ShiftParameter(const Context &context, NodeRefVec &&deps, Parameter &¶meter, int n)
std::size_t hashAdditionalArguments() const final
Return the hash of node-specific configuration.
ShiftParameter(const Context &context, NodeRefVec &&deps, const Parameter ¶meter, int n)
void compute() final
Computation implementation.
bool compareAdditionalArguments(const Node_DF &other) const final
Compare node-specific configuration to another.
std::string color() const override
NodeRef recreate(Context &c, NodeRefVec &&deps) final
Recreate the node with different dependencies.
Abstract Node storing a value of type T.
const Parameter * & accessValueConst() const noexcept
Raw value access (const).
const Parameter * & targetValue()
Access value, recompute if needed.
Parameter * & accessValueMutable() noexcept
Defines the basic types of data flow nodes.
void checkDependenciesNotNull(const std::type_info &contextNodeType, const NodeRefVec &deps)
Checks that all dependencies are not null, throws if not.
std::string to_string(const NoDimension &)
std::vector< NodeRef > NodeRefVec
Alias for a dependency vector (of NodeRef).
void checkDependencyVectorSize(const std::type_info &contextNodeType, const NodeRefVec &deps, std::size_t expectedSize)
void combineHash(std::size_t &seed, const T &t)
Combine hashable value to a hash, from Boost library.
std::shared_ptr< Node_DF > NodeRef