gtsam 4.2
gtsam
Loading...
Searching...
No Matches
Constraint.h
Go to the documentation of this file.
1/* ----------------------------------------------------------------------------
2
3 * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4 * Atlanta, Georgia 30332-0415
5 * All Rights Reserved
6 * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7
8 * See LICENSE for the license information
9
10 * -------------------------------------------------------------------------- */
11
17
18#pragma once
19
22#include <gtsam_unstable/dllexport.h>
23
24#include <boost/format.hpp>
25#include <map>
26
27namespace gtsam {
28
29class Domain;
30using Domains = std::map<Key, Domain>;
31
36class GTSAM_UNSTABLE_EXPORT Constraint : public DiscreteFactor {
37 public:
38 typedef boost::shared_ptr<Constraint> shared_ptr;
39
40 protected:
43
46
49
51 template <class KeyIterator>
52 Constraint(KeyIterator beginKey, KeyIterator endKey)
53 : DiscreteFactor(beginKey, endKey) {}
54
55 public:
58
61
63 ~Constraint() override {}
64
68
69 /*
70 * Ensure Arc-consistency by checking every possible value of domain j.
71 * @param j domain to be checked
72 * @param (in/out) domains all domains, but only domains->at(j) will be checked.
73 * @return true if domains->at(j) was changed, false otherwise.
74 */
75 virtual bool ensureArcConsistency(Key j, Domains* domains) const = 0;
76
78 virtual shared_ptr partiallyApply(const DiscreteValues&) const = 0;
79
81 virtual shared_ptr partiallyApply(const Domains&) const = 0;
85
87 std::string markdown(const KeyFormatter& keyFormatter = DefaultKeyFormatter,
88 const Names& names = {}) const override {
89 return (boost::format("`Constraint` on %1% variables\n") % (size())).str();
90 }
91
93 std::string html(const KeyFormatter& keyFormatter = DefaultKeyFormatter,
94 const Names& names = {}) const override {
95 return (boost::format("<p>Constraint on %1% variables</p>") % (size())).str();
96 }
97
99};
100// DiscreteFactor
101
102} // namespace gtsam
Global functions in a separate testing namespace.
Definition chartTesting.h:28
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition Key.h:86
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
std::uint64_t Key
Integer nonlinear key type.
Definition types.h:100
DiscreteValues::Names Names
Translation table from values to strings.
Definition DiscreteFactor.h:106
DiscreteFactor()
Default constructor creates empty factor.
Definition DiscreteFactor.h:55
A map from keys to values.
Definition DiscreteValues.h:34
~Constraint() override
Virtual destructor.
Definition Constraint.h:63
virtual shared_ptr partiallyApply(const Domains &) const =0
Partially apply known values, domain version.
Constraint(const KeyVector &js)
Construct n-way constraint factor.
Definition Constraint.h:48
Constraint()
Default constructor for I/O.
Constraint(Key j1, Key j2)
Construct binary constraint factor.
Definition Constraint.h:45
virtual shared_ptr partiallyApply(const DiscreteValues &) const =0
Partially apply known values.
Constraint(KeyIterator beginKey, KeyIterator endKey)
construct from container
Definition Constraint.h:52
std::string markdown(const KeyFormatter &keyFormatter=DefaultKeyFormatter, const Names &names={}) const override
Render as markdown table.
Definition Constraint.h:87
Constraint(Key j)
Construct unary constraint factor.
Definition Constraint.h:42
std::string html(const KeyFormatter &keyFormatter=DefaultKeyFormatter, const Names &names={}) const override
Render as html table.
Definition Constraint.h:93
The Domain class represents a constraint that restricts the possible values a particular variable,...
Definition Domain.h:19