Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
y
Enumerations
a
c
d
e
f
g
i
k
l
m
n
p
q
r
s
t
u
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
z
Classes
Class List
Class Hierarchy
Class Members
All
!
:
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
!
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Enumerations
a
b
c
d
f
k
l
m
n
o
p
r
s
t
v
z
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Related Functions
:
a
b
c
d
e
g
h
i
l
m
n
o
p
r
s
t
u
v
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
x
z
Enumerations
Enumerator
b
c
e
f
g
i
l
m
n
o
p
r
s
t
u
v
x
y
z
Macros
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Examples
gtsam_unstable
discrete
CSP.h
Go to the documentation of this file.
1
/*
2
* CSP.h
3
* @brief Constraint Satisfaction Problem class
4
* @date Feb 6, 2012
5
* @author Frank Dellaert
6
*/
7
8
#pragma once
9
10
#include <
gtsam/discrete/DiscreteFactorGraph.h
>
11
#include <
gtsam_unstable/discrete/AllDiff.h
>
12
#include <
gtsam_unstable/discrete/SingleValue.h
>
13
14
namespace
gtsam
{
15
21
class
GTSAM_UNSTABLE_EXPORT
CSP
:
public
DiscreteFactorGraph
{
22
public
:
23
using
Values
=
DiscreteValues
;
24
26
void
addSingleValue
(
const
DiscreteKey
& dkey,
size_t
value
) {
27
emplace_shared<SingleValue>(dkey,
value
);
28
}
29
31
void
addAllDiff
(
const
DiscreteKey
&
key1
,
const
DiscreteKey
&
key2
) {
32
emplace_shared<BinaryAllDiff>(
key1
,
key2
);
33
}
34
36
void
addAllDiff
(
const
DiscreteKeys
& dkeys) { emplace_shared<AllDiff>(dkeys); }
37
38
// /** return product of all factors as a single factor */
39
// DecisionTreeFactor product() const {
40
// DecisionTreeFactor result;
41
// for(const sharedFactor& factor: *this)
42
// if (factor) result = (*factor) * result;
43
// return result;
44
// }
45
46
// /*
47
// * Perform loopy belief propagation
48
// * True belief propagation would check for each value in domain
49
// * whether any satisfying separator assignment can be found.
50
// * This corresponds to hyper-arc consistency in CSP speak.
51
// * This can be done by creating a mini-factor graph and search.
52
// * For a nine-by-nine Sudoku, the search tree will be 8+6+6=20 levels
53
// deep.
54
// * It will be very expensive to exclude values that way.
55
// */
56
// void applyBeliefPropagation(size_t maxIterations = 10) const;
57
58
/*
59
* Apply arc-consistency ~ Approximate loopy belief propagation
60
* We need to give the domains to a constraint, and it returns
61
* a domain whose values don't conflict in the arc-consistency way.
62
* TODO: should get cardinality from DiscreteKeys
63
*/
64
Domains
runArcConsistency(
size_t
cardinality,
65
size_t
maxIterations = 10)
const
;
66
68
bool
runArcConsistency(
const
VariableIndex
& index,
Domains
* domains)
const
;
69
70
/*
71
* Create a new CSP, applying the given Domain constraints.
72
*/
73
CSP
partiallyApply(
const
Domains
& domains)
const
;
74
};
// CSP
75
76
}
// namespace gtsam
key1
const Symbol key1('v', 1)
gtsam::DiscreteFactorGraph
Definition:
DiscreteFactorGraph.h:99
DiscreteFactorGraph.h
gtsam::CSP::addAllDiff
void addAllDiff(const DiscreteKeys &dkeys)
Add a general AllDiff constraint.
Definition:
CSP.h:36
gtsam::DiscreteKeys
DiscreteKeys is a set of keys that can be assembled using the & operator.
Definition:
DiscreteKey.h:41
AllDiff.h
key2
const Symbol key2('v', 2)
SingleValue.h
gtsam::CSP::addAllDiff
void addAllDiff(const DiscreteKey &key1, const DiscreteKey &key2)
Add a binary AllDiff constraint.
Definition:
CSP.h:31
gtsam::CSP::addSingleValue
void addSingleValue(const DiscreteKey &dkey, size_t value)
Add a unary constraint, allowing only a single value.
Definition:
CSP.h:26
gtsam::Domains
std::map< Key, Domain > Domains
Definition:
Constraint.h:29
gtsam::VariableIndex
Definition:
VariableIndex.h:41
gtsam
traits
Definition:
SFMdata.h:40
gtsam::DiscreteValues
Definition:
DiscreteValues.h:34
gtsam::CSP
Definition:
CSP.h:21
gtsam::DiscreteKey
std::pair< Key, size_t > DiscreteKey
Definition:
DiscreteKey.h:38
test_callbacks.value
value
Definition:
test_callbacks.py:162
gtsam
Author(s):
autogenerated on Wed Mar 19 2025 03:01:30