21#include <boost/range.hpp>
62 template<
class FACTOR,
class DERIVEDCONDITIONAL>
75 typedef boost::iterator_range<typename FACTOR::const_iterator>
Frontals;
78 typedef boost::iterator_range<typename FACTOR::const_iterator>
Parents;
97 void print(
const std::string& s =
"Conditional",
const KeyFormatter& formatter = DefaultKeyFormatter)
const;
100 bool equals(
const This& c,
double tol = 1e-9)
const;
118 return asFactor().front();
120 throw std::invalid_argument(
"Requested Conditional::firstFrontalKey from a conditional with zero frontal keys");
160 typename FACTOR::const_iterator
beginFrontals()
const {
return asFactor().begin(); }
169 typename FACTOR::const_iterator
endParents()
const {
return asFactor().end(); }
184 typename FACTOR::iterator
endParents() {
return asFactor().end(); }
199 template <
class VALUES>
211 FACTOR& asFactor() {
return static_cast<FACTOR&
>(
static_cast<DERIVEDCONDITIONAL&
>(*this)); }
214 const FACTOR& asFactor()
const {
return static_cast<const FACTOR&
>(
static_cast<const DERIVEDCONDITIONAL&
>(*this)); }
218 template<
class ARCHIVE>
219 void serialize(ARCHIVE & ar,
const unsigned int ) {
Global functions in a separate testing namespace.
Definition chartTesting.h:28
std::uint64_t Key
Integer nonlinear key type.
Definition types.h:100
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition Key.h:35
Template to create a binary predicate.
Definition Testable.h:111
HybridValues represents a collection of DiscreteValues and VectorValues.
Definition HybridValues.h:38
Definition Conditional.h:64
static bool CheckInvariants(const DERIVEDCONDITIONAL &conditional, const VALUES &x)
Check invariants of this conditional, given the values x.
Definition Conditional-inst.h:77
size_t nrFrontals_
The first nrFrontal variables are frontal and the rest are parents.
Definition Conditional.h:67
virtual double logNormalizationConstant() const
All conditional types need to implement a log normalization constant to make it such that error>=0.
Definition Conditional-inst.h:62
Key firstFrontalKey() const
Convenience function to get the first frontal key.
Definition Conditional.h:116
FACTOR::const_iterator endFrontals() const
Iterator pointing past the last frontal key.
Definition Conditional.h:163
FACTOR::iterator endParents()
Mutable iterator pointing past the last parent key.
Definition Conditional.h:184
FACTOR::iterator endFrontals()
Mutable iterator pointing past the last frontal key.
Definition Conditional.h:178
virtual double evaluate(const HybridValues &c) const
All conditional types need to implement an evaluate function, that yields a true probability.
Definition Conditional-inst.h:55
Parents parents() const
return a view of the parent keys
Definition Conditional.h:127
double operator()(const HybridValues &x) const
Evaluate probability density, sugar.
Definition Conditional.h:142
boost::iterator_range< typename FACTOR::const_iterator > Parents
View of the separator keys (call parents())
Definition Conditional.h:78
virtual double logProbability(const HybridValues &c) const
All conditional types need to implement a logProbability function, for which exp(logProbability(x)) =...
Definition Conditional-inst.h:48
size_t nrFrontals() const
return the number of frontals
Definition Conditional.h:110
Conditional()
Empty Constructor to make serialization possible.
Definition Conditional.h:85
Conditional(size_t nrFrontals)
Constructor.
Definition Conditional.h:88
FACTOR::iterator beginParents()
Mutable iterator pointing to the first parent key.
Definition Conditional.h:181
size_t & nrFrontals()
Mutable version of nrFrontals.
Definition Conditional.h:172
FACTOR::iterator beginFrontals()
Mutable iterator pointing to first frontal key.
Definition Conditional.h:175
boost::iterator_range< typename FACTOR::const_iterator > Frontals
View of the frontal keys (call frontals())
Definition Conditional.h:75
Frontals frontals() const
return a view of the frontal keys
Definition Conditional.h:124
friend class boost::serialization::access
Serialization function.
Definition Conditional.h:217
FACTOR::const_iterator beginFrontals() const
Iterator pointing to first frontal key.
Definition Conditional.h:160
double normalizationConstant() const
Non-virtual, exponentiate logNormalizationConstant.
Definition Conditional-inst.h:70
size_t nrParents() const
return the number of parents
Definition Conditional.h:113
void print(const std::string &s="Conditional", const KeyFormatter &formatter=DefaultKeyFormatter) const
print with optional formatter
Definition Conditional-inst.h:30
FACTOR::const_iterator endParents() const
Iterator pointing past the last parent key.
Definition Conditional.h:169
FACTOR::const_iterator beginParents() const
Iterator pointing to the first parent key.
Definition Conditional.h:166