Try to fix another warning
parent
5714c56bab
commit
9d7caa77fe
|
@ -462,15 +462,17 @@ namespace gtsam {
|
||||||
// cannot just create a root Choice node on the label: if the label is not the
|
// cannot just create a root Choice node on the label: if the label is not the
|
||||||
// highest label, we need to do a complicated and expensive recursive call.
|
// highest label, we need to do a complicated and expensive recursive call.
|
||||||
template<typename L, typename Y> template<typename Iterator>
|
template<typename L, typename Y> template<typename Iterator>
|
||||||
typename DecisionTree<L, Y>::NodePtr DecisionTree<L, Y>::compose(
|
typename DecisionTree<L, Y>::NodePtr DecisionTree<L, Y>::compose(Iterator begin,
|
||||||
Iterator begin, Iterator end, const L& label) const {
|
Iterator end, const L& label) const {
|
||||||
|
|
||||||
// find highest label among branches
|
// find highest label among branches
|
||||||
boost::optional<L> highestLabel;
|
boost::optional<L> highestLabel;
|
||||||
boost::optional<size_t> nrChoices;
|
boost::optional<size_t> nrChoices;
|
||||||
for (Iterator it = begin; it != end; it++) {
|
for (Iterator it = begin; it != end; it++) {
|
||||||
if (it->root_->isLeaf()) continue;
|
if (it->root_->isLeaf())
|
||||||
boost::shared_ptr<const Choice> c = boost::dynamic_pointer_cast<const Choice> (it->root_);
|
continue;
|
||||||
|
boost::shared_ptr<const Choice> c =
|
||||||
|
boost::dynamic_pointer_cast<const Choice>(it->root_);
|
||||||
if (!highestLabel || c->label() > *highestLabel) {
|
if (!highestLabel || c->label() > *highestLabel) {
|
||||||
highestLabel.reset(c->label());
|
highestLabel.reset(c->label());
|
||||||
nrChoices.reset(c->nrChoices());
|
nrChoices.reset(c->nrChoices());
|
||||||
|
@ -483,25 +485,26 @@ namespace gtsam {
|
||||||
for (Iterator it = begin; it != end; it++)
|
for (Iterator it = begin; it != end; it++)
|
||||||
choiceOnLabel->push_back(it->root_);
|
choiceOnLabel->push_back(it->root_);
|
||||||
return Choice::Unique(choiceOnLabel);
|
return Choice::Unique(choiceOnLabel);
|
||||||
}
|
} else {
|
||||||
|
// Set up a new choice on the highest label
|
||||||
// Set up a new choice on the highest label
|
boost::shared_ptr<Choice> choiceOnHighestLabel(
|
||||||
boost::shared_ptr<Choice> choiceOnHighestLabel(new Choice(*highestLabel, *nrChoices));
|
new Choice(*highestLabel, *nrChoices));
|
||||||
// now, for all possible values of highestLabel
|
// now, for all possible values of highestLabel
|
||||||
for (size_t index = 0; index < *nrChoices; index++) {
|
for (size_t index = 0; index < *nrChoices; index++) {
|
||||||
// make a new set of functions for composing by iterating over the given
|
// make a new set of functions for composing by iterating over the given
|
||||||
// functions, and selecting the appropriate branch.
|
// functions, and selecting the appropriate branch.
|
||||||
std::vector<DecisionTree> functions;
|
std::vector<DecisionTree> functions;
|
||||||
for (Iterator it = begin; it != end; it++) {
|
for (Iterator it = begin; it != end; it++) {
|
||||||
// by restricting the input functions to value i for labelBelow
|
// by restricting the input functions to value i for labelBelow
|
||||||
DecisionTree chosen = it->choose(*highestLabel, index);
|
DecisionTree chosen = it->choose(*highestLabel, index);
|
||||||
functions.push_back(chosen);
|
functions.push_back(chosen);
|
||||||
|
}
|
||||||
|
// We then recurse, for all values of the highest label
|
||||||
|
NodePtr fi = compose(functions.begin(), functions.end(), label);
|
||||||
|
choiceOnHighestLabel->push_back(fi);
|
||||||
}
|
}
|
||||||
// We then recurse, for all values of the highest label
|
return Choice::Unique(choiceOnHighestLabel);
|
||||||
NodePtr fi = compose(functions.begin(), functions.end(), label);
|
|
||||||
choiceOnHighestLabel->push_back(fi);
|
|
||||||
}
|
}
|
||||||
return Choice::Unique(choiceOnHighestLabel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
|
@ -667,9 +670,10 @@ namespace gtsam {
|
||||||
void DecisionTree<L, Y>::dot(const std::string& name, bool showZero) const {
|
void DecisionTree<L, Y>::dot(const std::string& name, bool showZero) const {
|
||||||
std::ofstream os((name + ".dot").c_str());
|
std::ofstream os((name + ".dot").c_str());
|
||||||
dot(os, showZero);
|
dot(os, showZero);
|
||||||
system(
|
int result = system(
|
||||||
("dot -Tpdf " + name + ".dot -o " + name + ".pdf >& /dev/null").c_str());
|
("dot -Tpdf " + name + ".dot -o " + name + ".pdf >& /dev/null").c_str());
|
||||||
}
|
if (result==-1) throw std::runtime_error("DecisionTree::dot system call failed");
|
||||||
|
}
|
||||||
|
|
||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue