pass FactorGraph as reference into split
parent
06b7f8ee04
commit
d4f92c7bb6
|
@ -331,9 +331,8 @@ map<string, string> FactorGraph<Factor>::findMinimumSpanningTree() const {
|
|||
}
|
||||
|
||||
template<class Factor>
|
||||
pair<FactorGraph<Factor>, FactorGraph<Factor> > FactorGraph<Factor>::split(map<string, string> tree) const {
|
||||
void FactorGraph<Factor>::split(map<string, string> tree, FactorGraph<Factor>& Ab1, FactorGraph<Factor>& Ab2) const {
|
||||
|
||||
FactorGraph<Factor> Ab1, Ab2;
|
||||
BOOST_FOREACH(sharedFactor factor, factors_){
|
||||
if (factor->keys().size() > 2)
|
||||
throw(invalid_argument("split: only support factors with at most two keys"));
|
||||
|
@ -350,8 +349,6 @@ pair<FactorGraph<Factor>, FactorGraph<Factor> > FactorGraph<Factor>::split(map<s
|
|||
else
|
||||
Ab2.push_back(factor);
|
||||
}
|
||||
|
||||
return make_pair(Ab1, Ab2);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -125,7 +125,8 @@ namespace gtsam {
|
|||
* Split the graph into two parts: one corresponds to the given spanning tre,
|
||||
* and the other corresponds to the rest of the factors
|
||||
*/
|
||||
std::pair<FactorGraph<Factor>, FactorGraph<Factor> > split(std::map<std::string, std::string> tree) const;
|
||||
void split(std::map<std::string, std::string> tree,
|
||||
FactorGraph<Factor>& Ab1, FactorGraph<Factor>& Ab2) const;
|
||||
|
||||
private:
|
||||
/** Associate factor index with the variables connected to the factor */
|
||||
|
|
|
@ -64,6 +64,8 @@ VectorConfig optimize(const GaussianBayesNet& bn)
|
|||
|
||||
/** solve each node in turn in topological sort order (parents first)*/
|
||||
BOOST_REVERSE_FOREACH(GaussianConditional::shared_ptr cg, bn) {
|
||||
cg->print();
|
||||
result.print();
|
||||
Vector x = cg->solve(result); // Solve for that variable
|
||||
result.insert(cg->key(),x); // store result in partial solution
|
||||
}
|
||||
|
|
|
@ -769,9 +769,7 @@ TEST( GaussianFactorGraph, split )
|
|||
tree["x4"] = "x1";
|
||||
|
||||
GaussianFactorGraph Ab1, Ab2;
|
||||
pair<FactorGraph<GaussianFactor>, FactorGraph<GaussianFactor> > gg = g.split(tree);
|
||||
Ab1 = *reinterpret_cast<GaussianFactorGraph*>(&(gg.first));
|
||||
Ab2 = *reinterpret_cast<GaussianFactorGraph*>(&(gg.second));
|
||||
g.split(tree, Ab1, Ab2);
|
||||
LONGS_EQUAL(3, Ab1.size());
|
||||
LONGS_EQUAL(2, Ab2.size());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue