Fix some CI issues
parent
8d6b6055fe
commit
af07409c10
|
@ -51,7 +51,7 @@ struct PrintForestVisitorPre {
|
||||||
void DiscreteJunctionTree::print(const std::string& s,
|
void DiscreteJunctionTree::print(const std::string& s,
|
||||||
const KeyFormatter& keyFormatter) const {
|
const KeyFormatter& keyFormatter) const {
|
||||||
PrintForestVisitorPre visitor(keyFormatter);
|
PrintForestVisitorPre visitor(keyFormatter);
|
||||||
treeTraversal::DepthFirstForest(*this, s, visitor);
|
treeTraversal::DepthFirstForest(*this, std::string(s), visitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace gtsam
|
} // namespace gtsam
|
||||||
|
|
|
@ -159,7 +159,8 @@ DiscreteSearch::DiscreteSearch(const DiscreteEliminationTree& etree) {
|
||||||
: DiscreteFactorGraph(factors).product();
|
: DiscreteFactorGraph(factors).product();
|
||||||
const size_t cardinality = factor->cardinality(node->key);
|
const size_t cardinality = factor->cardinality(node->key);
|
||||||
std::vector<std::pair<Key, size_t>> pairs{{node->key, cardinality}};
|
std::vector<std::pair<Key, size_t>> pairs{{node->key, cardinality}};
|
||||||
slots_.emplace_back(factor, DiscreteValues::CartesianProduct(pairs), 0.0);
|
const Slot slot(factor, DiscreteValues::CartesianProduct(pairs), 0.0);
|
||||||
|
slots_.emplace_back(std::move(slot));
|
||||||
return data + 1;
|
return data + 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -180,7 +181,8 @@ DiscreteSearch::DiscreteSearch(const DiscreteJunctionTree& junctionTree) {
|
||||||
for (Key key : cluster->orderedFrontalKeys) {
|
for (Key key : cluster->orderedFrontalKeys) {
|
||||||
pairs.emplace_back(key, factor->cardinality(key));
|
pairs.emplace_back(key, factor->cardinality(key));
|
||||||
}
|
}
|
||||||
slots_.emplace_back(factor, DiscreteValues::CartesianProduct(pairs), 0.0);
|
const Slot slot(factor, DiscreteValues::CartesianProduct(pairs), 0.0);
|
||||||
|
slots_.emplace_back(std::move(slot));
|
||||||
return data + 1;
|
return data + 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -205,7 +207,8 @@ DiscreteSearch DiscreteSearch::FromFactorGraph(
|
||||||
DiscreteSearch::DiscreteSearch(const DiscreteBayesNet& bayesNet) {
|
DiscreteSearch::DiscreteSearch(const DiscreteBayesNet& bayesNet) {
|
||||||
slots_.reserve(bayesNet.size());
|
slots_.reserve(bayesNet.size());
|
||||||
for (auto& conditional : bayesNet) {
|
for (auto& conditional : bayesNet) {
|
||||||
slots_.emplace_back(conditional, conditional->frontalAssignments(), 0.0);
|
const Slot slot(conditional, conditional->frontalAssignments(), 0.0);
|
||||||
|
slots_.emplace_back(std::move(slot));
|
||||||
}
|
}
|
||||||
lowerBound_ = computeHeuristic();
|
lowerBound_ = computeHeuristic();
|
||||||
}
|
}
|
||||||
|
@ -216,8 +219,8 @@ DiscreteSearch::DiscreteSearch(const DiscreteBayesTree& bayesTree) {
|
||||||
if (!clique) return;
|
if (!clique) return;
|
||||||
for (const auto& child : clique->children) collectConditionals(child);
|
for (const auto& child : clique->children) collectConditionals(child);
|
||||||
auto conditional = clique->conditional();
|
auto conditional = clique->conditional();
|
||||||
slots_.emplace_back(conditional, conditional->frontalAssignments(),
|
const Slot slot(conditional, conditional->frontalAssignments(), 0.0);
|
||||||
0.0);
|
slots_.emplace_back(std::move(slot));
|
||||||
};
|
};
|
||||||
|
|
||||||
slots_.reserve(bayesTree.size());
|
slots_.reserve(bayesTree.size());
|
||||||
|
@ -300,11 +303,10 @@ std::vector<Solution> DiscreteSearch::run(size_t K) const {
|
||||||
// lower bound of the cost for *all* slots.
|
// lower bound of the cost for *all* slots.
|
||||||
double DiscreteSearch::computeHeuristic() {
|
double DiscreteSearch::computeHeuristic() {
|
||||||
double error = 0.0;
|
double error = 0.0;
|
||||||
for (size_t i = 0; i < slots_.size(); ++i) {
|
for (auto& slot : slots_) {
|
||||||
slots_[i].heuristic = error;
|
slot.heuristic = error;
|
||||||
const auto& factor = slots_[i].factor;
|
Ordering ordering(slot.factor->begin(), slot.factor->end());
|
||||||
Ordering ordering(factor->begin(), factor->end());
|
auto maxx = slot.factor->max(ordering);
|
||||||
auto maxx = factor->max(ordering);
|
|
||||||
error -= std::log(maxx->evaluate({}));
|
error -= std::log(maxx->evaluate({}));
|
||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
|
|
Loading…
Reference in New Issue