Loading...
Searching...
No Matches
SymbolicConditional.h
Go to the documentation of this file.
/* ----------------------------------------------------------------------------
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
* Atlanta, Georgia 30332-0415
* All Rights Reserved
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
* See LICENSE for the license information
* -------------------------------------------------------------------------- */
#pragma once
#include <gtsam/base/Testable.h>
#include <gtsam/base/types.h>
#include <gtsam/inference/Conditional-inst.h>
#include <gtsam/symbolic/SymbolicFactor.h>
namespace gtsam {
class GTSAM_EXPORT SymbolicConditional :
public SymbolicFactor,
public Conditional<SymbolicFactor, SymbolicConditional> {
public:
typedef SymbolicConditional This;
typedef SymbolicFactor BaseFactor;
typedef Conditional<BaseFactor, This> BaseConditional;
typedef boost::shared_ptr<This> shared_ptr;
typedef BaseFactor::iterator iterator;
typedef BaseFactor::const_iterator const_iterator;
SymbolicConditional() {}
SymbolicConditional(Key j) : BaseFactor(j), BaseConditional(1) {}
SymbolicConditional(Key j, Key parent) : BaseFactor(j, parent), BaseConditional(1) {}
SymbolicConditional(Key j, Key parent1, Key parent2) : BaseFactor(j, parent1, parent2), BaseConditional(1) {}
SymbolicConditional(Key j, Key parent1, Key parent2, Key parent3) : BaseFactor(j, parent1, parent2, parent3), BaseConditional(1) {}
template<typename ITERATOR>
static SymbolicConditional FromIterators(ITERATOR firstKey, ITERATOR lastKey, size_t nrFrontals)
{
SymbolicConditional result;
(BaseFactor&)result = BaseFactor::FromIterators(firstKey, lastKey);
result.nrFrontals_ = nrFrontals;
return result;
}
template<typename ITERATOR>
static SymbolicConditional::shared_ptr FromIteratorsShared(ITERATOR firstKey, ITERATOR lastKey, size_t nrFrontals)
{
SymbolicConditional::shared_ptr result = boost::make_shared<SymbolicConditional>();
result->keys_.assign(firstKey, lastKey);
result->nrFrontals_ = nrFrontals;
return result;
}
template<class CONTAINER>
static SymbolicConditional FromKeys(const CONTAINER& keys, size_t nrFrontals) {
return FromIterators(keys.begin(), keys.end(), nrFrontals);
}
template<class CONTAINER>
static SymbolicConditional::shared_ptr FromKeysShared(const CONTAINER& keys, size_t nrFrontals) {
return FromIteratorsShared(keys.begin(), keys.end(), nrFrontals);
}
SymbolicFactor::shared_ptr clone() const { return boost::make_shared<This>(*this); }
void print(
const std::string& str = "",
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const override;
bool equals(const This& c, double tol = 1e-9) const;
double logProbability(const HybridValues& x) const override;
double evaluate(const HybridValues& x) const override;
using Conditional::operator(); // Expose evaluate(const HybridValues&) method..
using SymbolicFactor::error; // Expose error(const HybridValues&) method..
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int /*version*/) {
ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(BaseFactor);
ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(BaseConditional);
}
};
template<>
struct traits<SymbolicConditional> : public Testable<SymbolicConditional> {
};
} //\ namespace gtsam
types.h
Typedefs for easier changing of types.
Testable.h
Concept check for values that can be used in unit tests.
SymbolicFactor.h
gtsam
Global functions in a separate testing namespace.
Definition chartTesting.h:28
gtsam::print
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition Matrix.cpp:156
gtsam::KeyFormatter
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
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition types.h:100
gtsam::traits
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition concepts.h:30
gtsam::equals
Template to create a binary predicate.
Definition Testable.h:111
gtsam::Testable
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:151
gtsam::HybridValues
HybridValues represents a collection of DiscreteValues and VectorValues.
Definition HybridValues.h:38
gtsam::Conditional::nrFrontals_
size_t nrFrontals_
The first nrFrontal variables are frontal and the rest are parents.
Definition Conditional.h:67
gtsam::Conditional< SymbolicFactor, SymbolicConditional >::nrFrontals
size_t nrFrontals() const
Definition Conditional.h:110
gtsam::Conditional< SymbolicFactor, SymbolicConditional >::Conditional
Conditional()
Definition Conditional.h:85
gtsam::Factor::keys
const KeyVector & keys() const
Access the factor's involved variable keys.
Definition Factor.h:140
gtsam::Factor::const_iterator
KeyVector::const_iterator const_iterator
Const iterator over keys.
Definition Factor.h:80
gtsam::Factor::iterator
KeyVector::iterator iterator
Iterator over keys.
Definition Factor.h:77
gtsam::SymbolicConditional
SymbolicConditional is a conditional with keys but no probability data, produced by symbolic eliminat...
Definition SymbolicConditional.h:38
gtsam::SymbolicConditional::SymbolicConditional
SymbolicConditional(Key j, Key parent1, Key parent2, Key parent3)
Three parents.
Definition SymbolicConditional.h:64
gtsam::SymbolicConditional::SymbolicConditional
SymbolicConditional()
Empty Constructor to make serialization possible.
Definition SymbolicConditional.h:52
gtsam::SymbolicConditional::FromKeys
static SymbolicConditional FromKeys(const CONTAINER &keys, size_t nrFrontals)
Named constructor from an arbitrary number of keys and frontals.
Definition SymbolicConditional.h:88
gtsam::SymbolicConditional::const_iterator
BaseFactor::const_iterator const_iterator
iterator to keys
Definition SymbolicConditional.h:46
gtsam::SymbolicConditional::shared_ptr
boost::shared_ptr< This > shared_ptr
Typedef to the conditional base class.
Definition SymbolicConditional.h:44
gtsam::SymbolicConditional::BaseConditional
Conditional< BaseFactor, This > BaseConditional
Typedef to the factor base class.
Definition SymbolicConditional.h:43
gtsam::SymbolicConditional::FromIteratorsShared
static SymbolicConditional::shared_ptr FromIteratorsShared(ITERATOR firstKey, ITERATOR lastKey, size_t nrFrontals)
Named constructor from an arbitrary number of keys and frontals.
Definition SymbolicConditional.h:78
gtsam::SymbolicConditional::FromIterators
static SymbolicConditional FromIterators(ITERATOR firstKey, ITERATOR lastKey, size_t nrFrontals)
Named constructor from an arbitrary number of keys and frontals.
Definition SymbolicConditional.h:68
gtsam::SymbolicConditional::SymbolicConditional
SymbolicConditional(Key j, Key parent)
Single parent.
Definition SymbolicConditional.h:58
gtsam::SymbolicConditional::SymbolicConditional
SymbolicConditional(Key j)
No parents.
Definition SymbolicConditional.h:55
gtsam::SymbolicConditional::SymbolicConditional
SymbolicConditional(Key j, Key parent1, Key parent2)
Two parents.
Definition SymbolicConditional.h:61
gtsam::SymbolicConditional::clone
SymbolicFactor::shared_ptr clone() const
Copy this object as its actual derived type.
Definition SymbolicConditional.h:99
gtsam::SymbolicConditional::iterator
BaseFactor::iterator iterator
Boost shared_ptr to this class.
Definition SymbolicConditional.h:45
gtsam::SymbolicConditional::BaseFactor
SymbolicFactor BaseFactor
Typedef to this class.
Definition SymbolicConditional.h:42
gtsam::SymbolicConditional::FromKeysShared
static SymbolicConditional::shared_ptr FromKeysShared(const CONTAINER &keys, size_t nrFrontals)
Named constructor from an arbitrary number of keys and frontals.
Definition SymbolicConditional.h:94
gtsam::SymbolicFactor::shared_ptr
boost::shared_ptr< This > shared_ptr
Overriding the shared_ptr typedef.
Definition SymbolicFactor.h:48
gtsam::SymbolicFactor::error
double error(const HybridValues &c) const override
The error method throws an exception.
Definition SymbolicFactor.cpp:30
gtsam::SymbolicFactor::FromIterators
static SymbolicFactor FromIterators(KEYITERATOR beginKey, KEYITERATOR endKey)
Constructor from a collection of keys.
Definition SymbolicFactor.h:115
gtsam::SymbolicFactor::SymbolicFactor
SymbolicFactor()
Default constructor for I/O.
Definition SymbolicFactor.h:54