9 #include <boost/assign/std/list.hpp> 10 #include <boost/assign/std/set.hpp> 11 #include <boost/assign/std/vector.hpp> 13 #include <boost/make_shared.hpp> 20 using namespace gtsam;
33 std::vector<size_t>
keys; keys += 0, 1, 2, 3, 4;
36 boost::optional<MetisResult> actual = separatorPartitionByMetis<GenericGraph2D>(
graph,
keys,
39 CHECK(actual.is_initialized());
40 vector<size_t> A_expected; A_expected += 0, 3;
41 vector<size_t> B_expected; B_expected += 2, 4;
42 vector<size_t> C_expected; C_expected += 1;
43 CHECK(A_expected == actual->A);
44 CHECK(B_expected == actual->B);
45 CHECK(C_expected == actual->C);
51 TEST ( Partition, separatorPartitionByMetis2 )
58 std::vector<size_t>
keys; keys += 1, 2, 3, 5, 6;
61 boost::optional<MetisResult> actual = separatorPartitionByMetis<GenericGraph2D>(
graph,
keys,
64 CHECK(actual.is_initialized());
65 vector<size_t> A_expected; A_expected += 1, 5;
66 vector<size_t> B_expected; B_expected += 3, 6;
67 vector<size_t> C_expected; C_expected += 2;
68 CHECK(A_expected == actual->A);
69 CHECK(B_expected == actual->B);
70 CHECK(C_expected == actual->C);
81 std::vector<size_t>
keys; keys += 0, 1, 2, 3;
84 boost::optional<MetisResult> actual = edgePartitionByMetis<GenericGraph3D>(
graph,
keys,
87 CHECK(actual.is_initialized());
88 vector<size_t> A_expected; A_expected += 0, 1;
89 vector<size_t> B_expected; B_expected += 2, 3;
90 vector<size_t> C_expected;
98 CHECK(A_expected == actual->A || A_expected == actual->B);
99 CHECK(B_expected == actual->B || B_expected == actual->A);
100 CHECK(C_expected == actual->C);
105 TEST ( Partition, edgePartitionByMetis2 )
112 std::vector<size_t>
keys; keys += 0, 1, 2, 3, 4;
115 boost::optional<MetisResult> actual = edgePartitionByMetis<GenericGraph3D>(
graph,
keys,
117 CHECK(actual.is_initialized());
118 vector<size_t> A_expected; A_expected += 0, 1;
119 vector<size_t> B_expected; B_expected += 2, 3, 4;
120 vector<size_t> C_expected;
121 CHECK(A_expected == actual->A);
122 CHECK(B_expected == actual->B);
123 CHECK(C_expected == actual->C);
136 std::vector<size_t>
keys; keys += 0, 1, 2, 3, 4;
139 int minNodesPerMap = -1;
140 bool reduceGraph =
false;
141 int numSubmaps = findSeparator<GenericGraph2D>(
graph,
keys, minNodesPerMap, workspace,
142 false, boost::none, reduceGraph, 0, 0);
155 TEST ( Partition, findSeparator2 )
162 std::vector<size_t>
keys; keys += 1, 2, 3, 5, 6;
165 int minNodesPerMap = -1;
166 bool reduceGraph =
false;
167 int numSubmaps = findSeparator<GenericGraph2D>(
graph,
keys, minNodesPerMap, workspace,
168 false, boost::none, reduceGraph, 0, 0);
187 TEST ( Partition, findSeparator3_with_reduced_camera )
190 for (
int j=1;
j<=8;
j++)
191 graph.
push_back(boost::make_shared<GenericFactor3D>(25,
j));
192 for (
int j=1;
j<=16;
j++)
193 graph.push_back(boost::make_shared<GenericFactor3D>(26,
j));
194 for (
int j=9;
j<=24;
j++)
195 graph.push_back(boost::make_shared<GenericFactor3D>(27,
j));
196 for (
int j=17;
j<=24;
j++)
197 graph.push_back(boost::make_shared<GenericFactor3D>(28,
j));
199 std::vector<size_t>
keys;
200 for(
int i=1;
i<=28;
i++)
203 vector<Symbol> int2symbol;
204 int2symbol.push_back(
Symbol(
'x',0));
205 for(
int i=1;
i<=24;
i++)
206 int2symbol.push_back(
Symbol(
'l',
i));
207 int2symbol.push_back(
Symbol(
'x',25));
208 int2symbol.push_back(
Symbol(
'x',26));
209 int2symbol.push_back(
Symbol(
'x',27));
210 int2symbol.push_back(
Symbol(
'x',28));
213 bool reduceGraph =
true;
214 int numIsland =
findSeparator(graph, keys, 3, workspace,
false, int2symbol, reduceGraph, 0, 0);
218 for (
int j=1;
j<=8;
j++)
220 for (
int j=9; j<=16; j++)
222 for (
int j=17; j<=24; j++)
static int runAllTests(TestResult &result)
TEST(Partition, separatorPartitionByMetis)
IsDerived< DERIVEDFACTOR > push_back(boost::shared_ptr< DERIVEDFACTOR > factor)
Add a factor directly using a shared_ptr.
NonlinearFactorGraph graph
PartitionTable partitionTable
std::vector< sharedGenericFactor2D > GenericGraph2D
std::vector< sharedGenericFactor3D > GenericGraph3D
boost::optional< MetisResult > separatorPartitionByMetis(const GenericGraph &graph, const std::vector< size_t > &keys, WorkSpace &workspace, bool verbose)
#define LONGS_EQUAL(expected, actual)
std::vector< int > PartitionTable
int findSeparator(const GenericGraph &graph, const std::vector< size_t > &keys, const int minNodesPerMap, WorkSpace &workspace, bool verbose, const boost::optional< std::vector< Symbol > > &int2symbol, const bool reduceGraph, const int minNrConstraintsPerCamera, const int minNrConstraintsPerLandmark)
boost::optional< MetisResult > edgePartitionByMetis(const GenericGraph &graph, const std::vector< size_t > &keys, WorkSpace &workspace, bool verbose)