|
gtsam
|
Base class for discrete probabilistic factors The most general one is the derived DecisionTreeFactor.
DecisionTreeFactor, which represent a discrete distribution over a set of variables.
Wrapper support | |
| using | Names = DiscreteValues::Names |
| Translation table from values to strings. | |
| virtual std::string | markdown (const KeyFormatter &keyFormatter=DefaultKeyFormatter, const Names &names={}) const =0 |
| Render as markdown table. | |
| virtual std::string | html (const KeyFormatter &keyFormatter=DefaultKeyFormatter, const Names &names={}) const =0 |
| Render as html table. | |
Public Member Functions | |
Standard Constructors | |
| DiscreteFactor () | |
| Default constructor creates empty factor. | |
| template<typename CONTAINER> | |
| DiscreteFactor (const CONTAINER &keys, const std::map< Key, size_t > cardinalities={}) | |
| Construct from container of keys and map of cardinalities. | |
Testable | |
| virtual bool | equals (const DiscreteFactor &lf, double tol=1e-9) const |
| equals | |
| void | print (const std::string &s="DiscreteFactor\n", const KeyFormatter &formatter=DefaultKeyFormatter) const override |
| print | |
Standard Interface | |
| DiscreteKeys | discreteKeys () const |
| Return all the discrete keys associated with this factor. | |
| std::map< Key, size_t > | cardinalities () const |
| size_t | cardinality (Key j) const |
| virtual double | evaluate (const Assignment< Key > &values) const =0 |
| Calculate probability for given values. | |
| double | operator() (const DiscreteValues &values) const |
| Find value for given assignment of values to variables. | |
| virtual double | error (const DiscreteValues &values) const |
| Error is just -log(value). | |
| double | error (const HybridValues &c) const override |
| All factor types need to implement an error function. | |
| virtual AlgebraicDecisionTree< Key > | errorTree () const |
| Compute error for each assignment and return as a tree. | |
| virtual DiscreteFactor::shared_ptr | operator* (double s) const =0 |
| Multiply with a scalar. | |
| virtual DecisionTreeFactor | operator* (const DecisionTreeFactor &) const =0 |
| Multiply in a DecisionTreeFactor and return the result as DecisionTreeFactor. | |
| virtual DiscreteFactor::shared_ptr | multiply (const DiscreteFactor::shared_ptr &df) const |
| Multiply in a DiscreteFactor and return the result as DiscreteFactor, both via shared pointers. | |
| virtual DiscreteFactor::shared_ptr | operator/ (const DiscreteFactor::shared_ptr &df) const =0 |
| divide by DiscreteFactor::shared_ptr f (safely) | |
| virtual DecisionTreeFactor | toDecisionTreeFactor () const =0 |
| virtual TableFactor | toTableFactor () const |
| Convert to a sparse table, falling back through a decision tree. | |
| virtual DiscreteFactor::shared_ptr | sum (size_t nrFrontals) const =0 |
| Create new factor by summing all values with the same separator values. | |
| virtual DiscreteFactor::shared_ptr | sum (const Ordering &keys) const =0 |
| Create new factor by summing all values with the same separator values. | |
| virtual double | max () const =0 |
| Find the maximum value in the factor. | |
| virtual DiscreteFactor::shared_ptr | max (size_t nrFrontals) const =0 |
| Create new factor by maximizing over all values with the same separator. | |
| virtual DiscreteFactor::shared_ptr | max (const Ordering &keys) const =0 |
| Create new factor by maximizing over all values with the same separator. | |
| DiscreteFactor::shared_ptr | scale () const |
| Scale the factor values by the maximum to prevent underflow/overflow. | |
| virtual uint64_t | nrValues () const =0 |
| Get the number of non-zero values contained in this factor. | |
| virtual DiscreteFactor::shared_ptr | restrict (const DiscreteValues &assignment) const =0 |
| Restrict the factor to the given assignment. | |
| Public Member Functions inherited from gtsam::Factor | |
| virtual | ~Factor ()=default |
| Default destructor. | |
| bool | empty () const |
| Whether the factor is empty (involves zero variables). | |
| Key | front () const |
| First key. | |
| Key | back () const |
| Last key. | |
| const_iterator | find (Key key) const |
| find | |
| const KeyVector & | keys () const |
| Access the factor's involved variable keys. | |
| const_iterator | begin () const |
| Iterator at beginning of involved variable keys. | |
| const_iterator | end () const |
| Iterator at end of involved variable keys. | |
| size_t | size () const |
| virtual void | printKeys (const std::string &s="Factor", const KeyFormatter &formatter=DefaultKeyFormatter) const |
| print only keys | |
| bool | equals (const This &other, double tol=1e-9) const |
| check equality | |
| KeyVector & | keys () |
| iterator | begin () |
| Iterator at beginning of involved variable keys. | |
| iterator | end () |
| Iterator at end of involved variable keys. | |
Public Types | |
| typedef DiscreteFactor | This |
| This class. | |
| typedef std::shared_ptr< DiscreteFactor > | shared_ptr |
| shared_ptr to this class | |
| typedef Factor | Base |
| Our base class. | |
| using | Values = DiscreteValues |
| backwards compatibility | |
| using | Unary = std::function<double(const double&)> |
| using | UnaryAssignment |
| using | Binary = std::function<double(const double, const double)> |
| Public Types inherited from gtsam::Factor | |
| typedef KeyVector::iterator | iterator |
| Iterator over keys. | |
| typedef KeyVector::const_iterator | const_iterator |
| Const iterator over keys. | |
Protected Attributes | |
| std::map< Key, size_t > | cardinalities_ |
| Map of Keys and their cardinalities. | |
| Protected Attributes inherited from gtsam::Factor | |
| KeyVector | keys_ |
| The keys involved in this factor. | |
Additional Inherited Members | |
| Factor () | |
| Default constructor for I/O. | |
| template<typename CONTAINER> | |
| Factor (const CONTAINER &keys) | |
| Construct factor from container of keys. | |
| template<typename ITERATOR> | |
| Factor (ITERATOR first, ITERATOR last) | |
| Construct factor from iterator keys. | |
| template<typename CONTAINER> | |
| static Factor | FromKeys (const CONTAINER &keys) |
| Construct factor from container of keys. | |
| template<typename ITERATOR> | |
| static Factor | FromIterators (ITERATOR first, ITERATOR last) |
| Construct factor from iterator keys. | |
| using gtsam::DiscreteFactor::UnaryAssignment |
|
inline |
Construct from container of keys and map of cardinalities.
This constructor is used internally from derived factor constructors, either from a container of keys or from a boost::assign::list_of.
|
virtual |
equals
Reimplemented in gtsam::AllDiff, gtsam::BinaryAllDiff, gtsam::DecisionTreeFactor, gtsam::DiscreteConditional, gtsam::Domain, gtsam::SingleValue, gtsam::TableDistribution, and gtsam::TableFactor.
|
virtual |
Error is just -log(value).
Reimplemented in gtsam::DecisionTreeFactor, gtsam::DiscreteConditional, and gtsam::TableFactor.
|
overridevirtual |
All factor types need to implement an error function.
In factor graphs, this is the negative log-likelihood.
Reimplemented from gtsam::Factor.
Reimplemented in gtsam::TableFactor.
|
virtual |
Compute error for each assignment and return as a tree.
Reimplemented in gtsam::Constraint.
|
pure virtual |
Calculate probability for given values.
Calls specialized evaluation under the hood.
Note: Uses Assignment<Key> as it is the base class of DiscreteValues.
| values | Discrete assignment. |
Implemented in gtsam::AllDiff, gtsam::BinaryAllDiff, gtsam::DecisionTreeFactor, gtsam::DiscreteConditional, gtsam::Domain, gtsam::SingleValue, gtsam::TableDistribution, and gtsam::TableFactor.
|
pure virtual |
Render as html table.
| keyFormatter | GTSAM-style Key formatter. |
| names | optional, category names corresponding to choices. |
Implemented in gtsam::Constraint, gtsam::DecisionTreeFactor, gtsam::DiscreteConditional, and gtsam::TableFactor.
|
pure virtual |
Render as markdown table.
| keyFormatter | GTSAM-style Key formatter. |
| names | optional, category names corresponding to choices. |
Implemented in gtsam::Constraint, gtsam::DecisionTreeFactor, gtsam::DiscreteConditional, and gtsam::TableFactor.
|
pure virtual |
Find the maximum value in the factor.
Implemented in gtsam::Constraint, gtsam::DecisionTreeFactor, gtsam::TableDistribution, and gtsam::TableFactor.
|
pure virtual |
Create new factor by maximizing over all values with the same separator.
Implemented in gtsam::Constraint, gtsam::DecisionTreeFactor, gtsam::DiscreteConditional, gtsam::TableDistribution, and gtsam::TableFactor.
|
pure virtual |
Create new factor by maximizing over all values with the same separator.
Implemented in gtsam::Constraint, gtsam::DecisionTreeFactor, gtsam::TableDistribution, and gtsam::TableFactor.
|
virtual |
Multiply in a DiscreteFactor and return the result as DiscreteFactor, both via shared pointers.
| df | DiscreteFactor shared_ptr |
Reimplemented in gtsam::DecisionTreeFactor, and gtsam::TableFactor.
|
pure virtual |
Get the number of non-zero values contained in this factor.
It could be much smaller than prod_{key}(cardinality(key)).
Implemented in gtsam::Constraint, gtsam::DecisionTreeFactor, gtsam::Domain, gtsam::TableDistribution, and gtsam::TableFactor.
|
pure virtual |
Multiply in a DecisionTreeFactor and return the result as DecisionTreeFactor.
Implemented in gtsam::AllDiff, gtsam::BinaryAllDiff, gtsam::Constraint, gtsam::DecisionTreeFactor, gtsam::DiscreteBoundaryFactor, gtsam::DiscreteConditional, gtsam::Domain, gtsam::SingleValue, and gtsam::TableFactor.
|
pure virtual |
Multiply with a scalar.
Implemented in gtsam::Constraint, gtsam::DecisionTreeFactor, gtsam::DiscreteBoundaryFactor, gtsam::DiscreteConditional, gtsam::TableDistribution, and gtsam::TableFactor.
|
pure virtual |
divide by DiscreteFactor::shared_ptr f (safely)
Implemented in gtsam::Constraint, gtsam::DecisionTreeFactor, gtsam::DiscreteBoundaryFactor, gtsam::TableDistribution, and gtsam::TableFactor.
|
inlineoverridevirtual |
Reimplemented from gtsam::Factor.
Reimplemented in gtsam::DiscreteLookupTable, gtsam::Domain, gtsam::SingleValue, gtsam::TableDistribution, and gtsam::TableFactor.
|
pure virtual |
Restrict the factor to the given assignment.
Implemented in gtsam::Constraint, gtsam::DecisionTreeFactor, and gtsam::TableFactor.
| DiscreteFactor::shared_ptr DiscreteFactor::scale | ( | ) | const |
Scale the factor values by the maximum to prevent underflow/overflow.
|
pure virtual |
Create new factor by summing all values with the same separator values.
Implemented in gtsam::Constraint, gtsam::DecisionTreeFactor, gtsam::TableDistribution, and gtsam::TableFactor.
|
pure virtual |
Create new factor by summing all values with the same separator values.
Implemented in gtsam::Constraint, gtsam::DecisionTreeFactor, gtsam::TableDistribution, and gtsam::TableFactor.
|
pure virtual |
|
virtual |
Convert to a sparse table, falling back through a decision tree.
Reimplemented in gtsam::AllDiff, gtsam::DecisionTreeFactor, gtsam::TableDistribution, and gtsam::TableFactor.