bpp-phyl3
3.0.0
|
Data flow node representing a parameter. More...
#include <Bpp/Phyl/Likelihood/DataFlow/Parameter.h>
Public Types | |
using | Self = ConfiguredParameter |
using | Target = Parameter |
Public Member Functions | |
ConfiguredParameter (const ConfiguredParameter ¶m) | |
ConfiguredParameter (const Context &context, NodeRefVec &&deps, const Parameter ¶meter) | |
ConfiguredParameter (const Context &context, NodeRefVec &&deps, Parameter &¶meter) | |
ConfiguredParameter * | clone () const override |
~ConfiguredParameter () | |
std::string | description () const override |
Node pretty name (default = type name). More... | |
std::string | color () const override |
std::string | debugInfo () const override |
Node debug info (default = ""): user defined detailed info for DF graph debug. More... | |
void | setValue (double v) override |
double | getValue () const override |
bool | compareAdditionalArguments (const Node_DF &other) const override |
Compare node-specific configuration to another. More... | |
std::size_t | hashAdditionalArguments () const override |
Return the hash of node-specific configuration. More... | |
NodeRef | derive (Context &c, const Node_DF &node) override |
Returns a node computing d(this_node_expression)/d(node_expression). More... | |
NodeRef | recreate (Context &c, NodeRefVec &&deps) override |
Recreate the node with different dependencies. More... | |
NodeRef | recreate (Context &c) |
virtual void | setName (const std::string &name) |
void | setPrecision (double precision) |
virtual const std::string & | getName () const |
virtual double | getPrecision () const |
virtual std::shared_ptr< const ConstraintInterface > | getConstraint () const |
virtual std::shared_ptr< ConstraintInterface > | getConstraint () |
virtual const ConstraintInterface & | constraint () const |
virtual ConstraintInterface & | constraint () |
virtual bool | hasConstraint () const |
virtual std::shared_ptr< ConstraintInterface > | removeConstraint () |
virtual void | setConstraint (std::shared_ptr< ConstraintInterface > constraint) |
virtual void | addParameterListener (std::shared_ptr< ParameterListener > listener) |
virtual void | removeParameterListener (const std::string &listenerId) |
virtual bool | hasParameterListener (const std::string &listenerId) |
const Parameter * & | targetValue () |
Access value, recompute if needed. More... | |
const Parameter * & | accessValueConst () const noexcept |
Raw value access (const). More... | |
ValueRef< Parameter * > | deriveAsValue (Context &c, const Node_DF &node) |
void | modify (Callable &&modifier, bool makeValid) |
General case for modification of the T object. More... | |
bool | isValid () const noexcept |
std::size_t | nbDependentNodes () const noexcept |
Number of dependent nodes (ie nodes that depend on this) More... | |
const std::vector< Node_DF * > & | dependentNodes () const noexcept |
std::size_t | nbDependencies () const noexcept |
Number of dependencies (ie nodes we depend on) More... | |
const NodeRefVec & | dependencies () const noexcept |
const NodeRef & | dependency (std::size_t i) const noexcept |
virtual std::string | shape () const |
virtual bool | hasNumericalProperty (NumericalProperty prop) const |
Test if the node has the given numerical property. More... | |
void | computeRecursively () |
Compute this node value, recomputing dependencies (transitively) as needed. More... | |
Static Public Member Functions | |
static std::shared_ptr< Self > | create (Context &c, NodeRefVec &&deps, const Parameter ¶m) |
Build a new ConfiguredParameter node. More... | |
static std::shared_ptr< Self > | create (Context &c, const Parameter ¶m) |
static std::shared_ptr< Self > | resetDependencies (Context &c, std::shared_ptr< Self > self, NodeRefVec &&deps) |
Static Public Attributes | |
static const std::shared_ptr< IntervalConstraint > | R_PLUS |
static const std::shared_ptr< IntervalConstraint > | R_PLUS_STAR |
static const std::shared_ptr< IntervalConstraint > | R_MINUS |
static const std::shared_ptr< IntervalConstraint > | R_MINUS_STAR |
static const std::shared_ptr< IntervalConstraint > | PROP_CONSTRAINT_IN |
static const std::shared_ptr< IntervalConstraint > | PROP_CONSTRAINT_EX |
Protected Member Functions | |
void | fireParameterNameChanged (ParameterEvent &event) |
void | fireParameterValueChanged (ParameterEvent &event) |
void | fireParameterConstraintChanged (ParameterEvent &event) |
Parameter * & | accessValueMutable () noexcept |
void | invalidateRecursively () noexcept |
Invalidate (transitively) dependent nodes from this one. More... | |
void | makeInvalid () noexcept |
void | makeValid () noexcept |
void | resetDependencies_ (NodeRefVec &&dependenciesArg) |
Protected Attributes | |
std::string | name_ |
double | value_ |
double | precision_ |
std::shared_ptr< ConstraintInterface > | constraint_ |
std::vector< std::shared_ptr< ParameterListener > > | listeners_ |
Private Member Functions | |
void | compute () override |
Computation implementation. More... | |
void | registerNode (Node_DF *n) |
void | unregisterNode (const Node_DF *n) |
Private Attributes | |
const Context & | context_ |
NodeRefVec | dependencyNodes_ {} |
std::vector< Node_DF * > | dependentNodes_ {} |
bool | isValid_ {false} |
Data flow node representing a parameter.
This class wraps a bpp::Parameter as a data flow node.
It depends on a Value<double> node.
Definition at line 25 of file Parameter.h.
Definition at line 32 of file Parameter.h.
Definition at line 33 of file Parameter.h.
|
inline |
bpp::ConfiguredParameter::ConfiguredParameter | ( | const Context & | context, |
NodeRefVec && | deps, | ||
const Parameter & | parameter | ||
) |
Definition at line 17 of file Parameter.cpp.
bpp::ConfiguredParameter::ConfiguredParameter | ( | const Context & | context, |
NodeRefVec && | deps, | ||
Parameter && | parameter | ||
) |
Definition at line 21 of file Parameter.cpp.
|
default |
|
inlinenoexceptinherited |
Raw value access (const).
Value is not guaranteed to be valid (no recomputation).
Definition at line 385 of file DataFlow.h.
|
inlineprotectednoexceptinherited |
Raw value access (mutable). Should only be used by subclasses to implement compute().
Definition at line 416 of file DataFlow.h.
|
inlineoverridevirtual |
Reimplemented from bpp::Parameter.
Definition at line 71 of file Parameter.h.
References ConfiguredParameter().
|
overridevirtual |
Reimplemented from bpp::Node_DF.
Reimplemented in bpp::ShiftParameter.
Definition at line 37 of file Parameter.cpp.
References bpp::Parameter::getName().
|
overridevirtual |
Compare node-specific configuration to another.
Required by Context for merging. It must compare everything in the node configuration except its type and dependencies. See DataFlowNumeric for examples. The default returns false, so nodes are considered different and not merged.
Reimplemented from bpp::Node_DF.
Reimplemented in bpp::ShiftParameter.
Definition at line 49 of file Parameter.cpp.
References bpp::Parameter::getName().
|
overrideprivatevirtual |
Computation implementation.
This functions is defined by derived classes. It should compute the new node value from dependency node values. When called, dependency node are guaranteed to have valid values.
This function is private to prevent use for invalid dependencies. Higher level functions like computeRecursively call it while ensuring dependency validity.
Compute has access to dependencies as a NodeRefVec (base Node_DF classes only). The recommended usage is to check dependency types at Node construction. Then use static_cast to access derived classes efficiently from the NodeRefVec. See DataFlowNumeric.h for examples.
Implements bpp::Node_DF.
Reimplemented in bpp::ShiftParameter.
Definition at line 88 of file Parameter.cpp.
References bpp::Node_DF::dependency(), bpp::Parameter::getValue(), and bpp::Parameter::setValue().
|
inherited |
Compute this node value, recomputing dependencies (transitively) as needed.
Not thread safe !
Definition at line 183 of file DataFlow.cpp.
References bpp::Node_DF::isValid().
Referenced by bpp::Value< T >::targetValue().
|
inlinestatic |
Definition at line 44 of file Parameter.h.
References bpp::NumericMutable< T >::create(), and bpp::Parameter::getValue().
|
inlinestatic |
Build a new ConfiguredParameter node.
Definition at line 36 of file Parameter.h.
References bpp::checkDependenciesNotNull(), and bpp::checkDependencyVectorSize().
Referenced by bpp::AbstractPhyloLikelihoodSet::addPhyloLikelihood(), bpp::AlignedPhyloLikelihoodMixture::AlignedPhyloLikelihoodMixture(), bpp::CollectionNodes::CollectionNodes(), bpp::ShiftParameter::create(), bpp::ConfiguredParametrizable::createConfigured(), bpp::HmmLikelihood_DF::HmmLikelihood_DF(), bpp::LikelihoodCalculationSingleProcess::makeProcessNodes_(), bpp::MixtureProcessPhyloLikelihood::MixtureProcessPhyloLikelihood(), bpp::ProcessTree::ProcessTree(), recreate(), and bpp::LikelihoodCalculationSingleProcess::setClockLike().
|
overridevirtual |
Node debug info (default = ""): user defined detailed info for DF graph debug.
Reimplemented from bpp::Node_DF.
Reimplemented in bpp::ShiftParameter.
Definition at line 32 of file Parameter.cpp.
Referenced by bpp::ShiftParameter::debugInfo().
|
inlinenoexceptinherited |
Definition at line 183 of file DataFlow.h.
References bpp::Node_DF::dependencyNodes_.
Referenced by bpp::CWiseAdd< R, ReductionOf< T > >::compute(), bpp::CombineDeltaShifted< T >::compute(), bpp::CWiseMul< R, ReductionOf< T > >::compute(), bpp::ConfiguredDistribution::ConfiguredDistribution(), bpp::ConfiguredFrequencySet::ConfiguredFrequencySet(), bpp::ConfiguredModel::ConfiguredModel(), bpp::ConfiguredSimplex::ConfiguredSimplex(), bpp::ConfiguredTransitionMatrix::ConfiguredTransitionMatrix(), bpp::CWiseMul< R, std::tuple< T0, T1 > >::derive(), and bpp::CWiseMul< R, ReductionOf< T > >::derive().
|
inlinenoexceptinherited |
Definition at line 185 of file DataFlow.h.
References bpp::Node_DF::dependencyNodes_.
Referenced by bpp::BackwardHmmLikelihood_DF::BackwardHmmLikelihood_DF(), bpp::ForwardHmmLikelihood_DF::build(), bpp::ValueFromConfiguredParameter::color(), bpp::CWiseFill< R, T >::compute(), bpp::CWiseApply< R, T, F >::compute(), bpp::CWiseAdd< R, std::tuple< T0, T1 > >::compute(), bpp::CWiseAdd< R, T >::compute(), bpp::CWiseMul< R, std::tuple< T0, T1 > >::compute(), bpp::CWiseDiv< R, std::tuple< T0, T1 > >::compute(), bpp::SumOfLogarithms< F >::compute(), bpp::CombineDeltaShifted< T >::compute(), bpp::CWiseSub< R, std::tuple< T0, T1 > >::compute(), bpp::CWiseMean< R, ReductionOf< T >, ReductionOf< P > >::compute(), bpp::CWiseMean< R, ReductionOf< T >, P >::compute(), bpp::CWiseNegate< T >::compute(), bpp::CWiseInverse< T >::compute(), bpp::CWiseLog< T >::compute(), bpp::CWiseExp< T >::compute(), bpp::CWiseConstantPow< T >::compute(), bpp::ScalarProduct< R, T0, T1 >::compute(), bpp::LogSumExp< R, T0, T1 >::compute(), bpp::MatrixProduct< R, T0, T1 >::compute(), bpp::ShiftDelta< T >::compute(), bpp::Convert< R, F >::compute(), bpp::Identity< R >::compute(), bpp::ProbabilitiesFromDiscreteDistribution::compute(), bpp::ProbabilityFromDiscreteDistribution::compute(), bpp::CategoryFromDiscreteDistribution::compute(), bpp::FrequenciesFromFrequencySet::compute(), bpp::EquilibriumFrequenciesFromModel::compute(), bpp::TransitionMatrixFromModel::compute(), bpp::TransitionFunctionFromModel::compute(), bpp::ProbabilitiesFromMixedModel::compute(), bpp::ProbabilityFromMixedModel::compute(), bpp::ShiftParameter::compute(), bpp::ValueFromConfiguredParameter::compute(), bpp::FrequenciesFromSimplex::compute(), bpp::EquilibriumFrequenciesFromTransitionMatrix::compute(), bpp::TransitionMatrixFromTransitionMatrix::compute(), bpp::CWisePattern< R >::compute(), bpp::CWiseMatching< R, ReductionOf< T > >::compute(), bpp::CWiseCompound< R, ReductionOf< T > >::compute(), compute(), bpp::CombineDeltaShifted< T >::create(), bpp::TransitionMatrixFromModel::debugInfo(), bpp::TransitionFunctionFromModel::debugInfo(), bpp::ValueFromConfiguredParameter::debugInfo(), bpp::CondLikelihood::debugInfo(), bpp::CWiseFill< R, T >::derive(), bpp::CWisePattern< R >::derive(), bpp::CWiseMatching< R, ReductionOf< T > >::derive(), bpp::CWiseCompound< R, ReductionOf< T > >::derive(), bpp::CWiseApply< R, T, F >::derive(), bpp::CWiseAdd< R, std::tuple< T0, T1 > >::derive(), bpp::CWiseSub< R, std::tuple< T0, T1 > >::derive(), bpp::CWiseAdd< R, ReductionOf< T > >::derive(), bpp::CWiseAdd< R, T >::derive(), bpp::CWiseMean< R, ReductionOf< T >, ReductionOf< P > >::derive(), bpp::CWiseMean< R, ReductionOf< T >, P >::derive(), bpp::CWiseMul< R, std::tuple< T0, T1 > >::derive(), bpp::CWiseMul< R, ReductionOf< T > >::derive(), bpp::CWiseDiv< R, std::tuple< T0, T1 > >::derive(), bpp::CWiseNegate< T >::derive(), bpp::CWiseInverse< T >::derive(), bpp::CWiseLog< T >::derive(), bpp::CWiseExp< T >::derive(), bpp::CWiseConstantPow< T >::derive(), bpp::ScalarProduct< R, T0, T1 >::derive(), bpp::SumOfLogarithms< F >::derive(), bpp::LogSumExp< R, T0, T1 >::derive(), bpp::MatrixProduct< R, T0, T1 >::derive(), bpp::ShiftDelta< T >::derive(), bpp::CombineDeltaShifted< T >::derive(), bpp::Convert< R, F >::derive(), bpp::Identity< R >::derive(), bpp::ProbabilitiesFromDiscreteDistribution::derive(), bpp::ProbabilityFromDiscreteDistribution::derive(), bpp::CategoryFromDiscreteDistribution::derive(), bpp::FrequenciesFromFrequencySet::derive(), bpp::EquilibriumFrequenciesFromModel::derive(), bpp::TransitionMatrixFromModel::derive(), bpp::TransitionFunctionFromModel::derive(), bpp::ProbabilitiesFromMixedModel::derive(), bpp::ProbabilityFromMixedModel::derive(), bpp::ShiftParameter::derive(), bpp::ValueFromConfiguredParameter::derive(), bpp::FrequenciesFromSimplex::derive(), bpp::EquilibriumFrequenciesFromTransitionMatrix::derive(), bpp::TransitionMatrixFromTransitionMatrix::derive(), bpp::BackwardHmmLikelihood_DF::derive(), derive(), bpp::ValueFromConfiguredParameter::description(), getValue(), recreate(), setValue(), and bpp::writeDotEdge().
|
inlinenoexceptinherited |
Definition at line 175 of file DataFlow.h.
References bpp::Node_DF::dependentNodes_.
Returns a node computing d(this_node_expression)/d(node_expression).
The expression represented by 'node' is considered as a variable. Event if 'node' is a constant value node, d(node)/d(node) == 1. The derivative of a matrix is the matrix of the derivatives. Derivation is undefined by default, and this function will throw an exception. Implementations will usually recursively derive sub-expressions and combine them.
Reimplemented from bpp::Node_DF.
Reimplemented in bpp::ShiftParameter.
Definition at line 68 of file Parameter.cpp.
References bpp::ConstantOne< T >::create(), and bpp::Node_DF::dependency().
|
inlineinherited |
Derive and cast result as Value<T> (most nodes derive to the same value type).
Definition at line 389 of file DataFlow.h.
|
overridevirtual |
Node pretty name (default = type name).
Reimplemented from bpp::Node_DF.
Reimplemented in bpp::ShiftParameter.
Definition at line 27 of file Parameter.cpp.
References bpp::Parameter::getName(), getValue(), and bpp::to_string().
Referenced by bpp::ShiftParameter::description().
|
inlineoverridevirtual |
Reimplemented from bpp::Parameter.
Reimplemented in bpp::ShiftParameter.
Definition at line 98 of file Parameter.h.
References bpp::Value< Parameter * >::accessValueConst(), bpp::Node_DF::dependency(), bpp::Parameter::getValue(), and bpp::Value< Parameter * >::targetValue().
Referenced by ConfiguredParameter(), and description().
|
overridevirtual |
Return the hash of node-specific configuration.
Compute a hash from additional arguments of the node. The hashed values must the same as the ones compared by compareAdditionalArguments. The default returns 0, which is ok if there are no additional arguments.
Reimplemented from bpp::Node_DF.
Reimplemented in bpp::ShiftParameter.
Definition at line 62 of file Parameter.cpp.
|
virtualinherited |
Test if the node has the given numerical property.
This is an optional indication only, used for optimisations. If unsure, leave it to always false (the default implementation). This should be non recursive, to ensure a constant time check.
Reimplemented in bpp::NumericConstant< T >, bpp::ConstantOne< T >, and bpp::ConstantZero< T >.
Definition at line 168 of file DataFlow.cpp.
Referenced by bpp::ScalarProduct< R, T0, T1 >::create(), bpp::CWisePattern< R >::create(), bpp::CWiseAdd< R, T >::create(), bpp::CWiseMean< R, ReductionOf< T >, ReductionOf< P > >::create(), bpp::CWiseDiv< R, std::tuple< T0, T1 > >::create(), bpp::CWiseNegate< T >::create(), bpp::CWiseInverse< T >::create(), bpp::CWiseLog< T >::create(), bpp::CWiseExp< T >::create(), bpp::CWiseConstantPow< T >::create(), and bpp::CombineDeltaShifted< T >::create().
|
protectednoexceptinherited |
Invalidate (transitively) dependent nodes from this one.
Not thread safe !
Definition at line 219 of file DataFlow.cpp.
References bpp::Node_DF::isValid().
Referenced by bpp::Value< T >::modify(), and bpp::Node_DF::resetDependencies_().
|
inlinenoexceptinherited |
Definition at line 166 of file DataFlow.h.
References bpp::Node_DF::isValid_.
Referenced by bpp::Node_DF::computeRecursively(), bpp::Node_DF::invalidateRecursively(), and bpp::writeDotNode().
|
inlineprotectednoexceptinherited |
Definition at line 270 of file DataFlow.h.
References bpp::Node_DF::isValid_.
Referenced by bpp::Node_DF::resetDependencies_().
|
inlineprotectednoexceptinherited |
Definition at line 271 of file DataFlow.h.
References bpp::Node_DF::isValid_.
Referenced by bpp::Value< T >::modify(), bpp::NumericConstant< T >::NumericConstant(), bpp::NumericMutable< T >::NumericMutable(), and bpp::Sequence_DF::Sequence_DF().
|
inlineinherited |
General case for modification of the T object.
Takes a callable object (lambda, function pointer) that performs the modification. It must take a single T& as argument, which will refer to the T object to modify. The callable is called exactly once.
modifier | callable to modify this object |
makeValid | boolean if this object is valid after modification (which means no call to this->compute() |
Definition at line 405 of file DataFlow.h.
|
inlinenoexceptinherited |
Number of dependencies (ie nodes we depend on)
Definition at line 181 of file DataFlow.h.
References bpp::Node_DF::dependencyNodes_.
Referenced by bpp::SumOfLogarithms< F >::compute(), bpp::CWiseMean< R, ReductionOf< T >, ReductionOf< P > >::compute(), bpp::CWiseMean< R, ReductionOf< T >, P >::compute(), bpp::EquilibriumFrequenciesFromModel::compute(), bpp::TransitionMatrixFromModel::compute(), bpp::CWiseMatching< R, ReductionOf< T > >::compute(), bpp::CWiseCompound< R, ReductionOf< T > >::compute(), bpp::CWiseMatching< R, ReductionOf< T > >::derive(), bpp::CWiseCompound< R, ReductionOf< T > >::derive(), bpp::CWiseAdd< R, ReductionOf< T > >::derive(), bpp::CWiseMean< R, ReductionOf< T >, ReductionOf< P > >::derive(), bpp::CWiseMean< R, ReductionOf< T >, P >::derive(), bpp::CWiseMul< R, ReductionOf< T > >::derive(), bpp::SumOfLogarithms< F >::derive(), bpp::CombineDeltaShifted< T >::derive(), bpp::EquilibriumFrequenciesFromModel::derive(), and bpp::TransitionMatrixFromModel::derive().
|
inlinenoexceptinherited |
Number of dependent nodes (ie nodes that depend on this)
Definition at line 172 of file DataFlow.h.
References bpp::Node_DF::dependentNodes_.
Definition at line 78 of file Parameter.cpp.
References bpp::NumericMutable< T >::create(), create(), and bpp::Node_DF::dependency().
|
overridevirtual |
Recreate the node with different dependencies.
Reimplemented from bpp::Node_DF.
Reimplemented in bpp::ShiftParameter.
Definition at line 83 of file Parameter.cpp.
References create().
|
privateinherited |
Definition at line 240 of file DataFlow.cpp.
References bpp::Node_DF::dependentNodes_.
|
inlinestatic |
Definition at line 51 of file Parameter.h.
References bpp::checkDependenciesNotNull(), and bpp::checkDependencyVectorSize().
Referenced by bpp::LikelihoodCalculationSingleProcess::setClockLike().
|
inlineprotectedinherited |
Definition at line 288 of file DataFlow.h.
References bpp::Node_DF::dependencyNodes_, bpp::Node_DF::invalidateRecursively(), and bpp::Node_DF::makeInvalid().
|
inlineoverridevirtual |
Reimplemented from bpp::Parameter.
Reimplemented in bpp::ShiftParameter.
Definition at line 87 of file Parameter.h.
References bpp::Node_DF::dependency(), bpp::Parameter::getValue(), and bpp::Parameter::setValue().
|
inlinevirtualinherited |
Reimplemented in bpp::MatrixProduct< R, T0, T1 >, bpp::CWiseDiv< R, std::tuple< T0, T1 > >, bpp::CWiseMul< R, std::tuple< T0, T1 > >, bpp::CWiseMean< R, ReductionOf< T >, P >, bpp::CWiseMean< R, ReductionOf< T >, ReductionOf< P > >, bpp::CWiseAdd< R, std::tuple< T0, T1 > >, bpp::CWiseApply< R, T, F >, bpp::TransitionMatrixFromTransitionMatrix, bpp::TransitionFunctionFromModel, and bpp::TransitionMatrixFromModel.
Definition at line 195 of file DataFlow.h.
Referenced by bpp::writeDotNode().
|
inlineinherited |
Access value, recompute if needed.
Recompute the value if it is not up to date. Then access it as const. Recomputation is single threaded and not thread safe.
Definition at line 374 of file DataFlow.h.
|
privateinherited |
Definition at line 245 of file DataFlow.cpp.
References bpp::Node_DF::dependentNodes_.
|
private |
Definition at line 29 of file Parameter.h.
|
privateinherited |
Definition at line 312 of file DataFlow.h.
Referenced by bpp::Node_DF::dependencies(), bpp::Node_DF::dependency(), bpp::Node_DF::nbDependencies(), bpp::Node_DF::Node_DF(), bpp::Node_DF::resetDependencies_(), and bpp::Node_DF::~Node_DF().
|
privateinherited |
Definition at line 313 of file DataFlow.h.
Referenced by bpp::Node_DF::dependentNodes(), bpp::Node_DF::nbDependentNodes(), bpp::Node_DF::registerNode(), and bpp::Node_DF::unregisterNode().
|
privateinherited |
Definition at line 314 of file DataFlow.h.
Referenced by bpp::Node_DF::isValid(), bpp::Node_DF::makeInvalid(), and bpp::Node_DF::makeValid().