10 #include <boost/assign/std/map.hpp> 17 using namespace gtsam;
27 typedef std::pair<size_t, size_t>
IJ;
34 return dkeys_.at(IJ(i, j));
39 return dkey(i, j).first;
49 for (
size_t i = 0;
i <
n; ++
i) {
50 for (
size_t j = 0;
j <
n; ++
j, ++k) {
55 int value = va_arg(ap,
int);
57 if (value != 0) addSingleValue(dkeys_[ij], value - 1);
64 for (
size_t i = 0;
i <
n;
i++) {
66 for (
size_t j = 0;
j <
n;
j++)
72 for (
size_t j = 0;
j <
n;
j++) {
74 for (
size_t i = 0;
i <
n;
i++)
81 for (
size_t I = 0;
I <
N;
I++) {
83 for (
size_t J = 0;
J <
N;
J++) {
86 for (
size_t i = i0;
i < i0 +
N;
i++)
87 for (
size_t j = j0;
j < j0 +
N;
j++)
98 for (
size_t i = 0;
i < n_;
i++) {
99 for (
size_t j = 0;
j < n_;
j++) {
101 cout << 1 + assignment->at(k) <<
" ";
110 printAssignment(MPE);
132 (csp.
key(0,0), 0)(csp.
key(0,1), 1)(csp.
key(0,2), 2)(csp.
key(0,3), 3)
133 (csp.
key(1,0), 2)(csp.
key(1,1), 3)(csp.
key(1,2), 0)(csp.
key(1,3), 1)
134 (csp.
key(2,0), 3)(csp.
key(2,1), 2)(csp.
key(2,2), 1)(csp.
key(2,3), 0)
135 (csp.
key(3,0), 1)(csp.
key(3,1), 0)(csp.
key(3,2), 3)(csp.
key(3,3), 2);
154 5,0,0, 0,3,0, 7,0,0);
176 0,0,0, 2,7,5, 9,0,0);
182 VariableIndexOrdered index(sudoku);
183 index.print(
"index");
184 ofstream
os(
"/Users/dellaert/src/hmetis-1.5-osx-i686/extreme-dual.txt");
185 index.outputMetisFormat(os);
205 0,0,0, 1,0,0, 0,3,7);
static int runAllTests(TestResult &result)
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
Sudoku(size_t n,...)
Constructor.
void printAssignment(DiscreteFactor::sharedValues assignment) const
Print readable form of assignment.
void printSolution()
solve and print solution
std::pair< Key, size_t > DiscreteKey
std::pair< size_t, size_t > IJ
discrete keys
#define EXPECT(condition)
void runArcConsistency(size_t cardinality, size_t nrIterations=10, bool print=false) const
Key key(size_t i, size_t j) const
return Key for cell(i,j)
JacobiRotation< float > J
std::map< IJ, DiscreteKey > dkeys_
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
ofstream os("timeSchurFactors.csv")
boost::shared_ptr< Values > sharedValues
TEST_UNSAFE(Sudoku, small)
const DiscreteKey & dkey(size_t i, size_t j) const
return DiscreteKey for cell(i,j)
boost::shared_ptr< Values > sharedValues
std::uint64_t Key
Integer nonlinear key type.
sharedValues optimalAssignment() const
Find the best total assignment - can be expensive.
DiscreteKeys is a set of keys that can be assembled using the & operator.