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
 | ||||
|   // highest label, we need to do a complicated and expensive recursive call.
 | ||||
|   template<typename L, typename Y> template<typename Iterator> | ||||
|   typename DecisionTree<L, Y>::NodePtr DecisionTree<L, Y>::compose( | ||||
|       Iterator begin, Iterator end, const L& label) const { | ||||
|   typename DecisionTree<L, Y>::NodePtr DecisionTree<L, Y>::compose(Iterator begin, | ||||
|       Iterator end, const L& label) const { | ||||
| 
 | ||||
|     // find highest label among branches
 | ||||
|     boost::optional<L> highestLabel; | ||||
|     boost::optional<size_t> nrChoices; | ||||
|     for (Iterator it = begin; it != end; it++) { | ||||
|       if (it->root_->isLeaf()) continue; | ||||
|       boost::shared_ptr<const Choice> c = boost::dynamic_pointer_cast<const Choice> (it->root_); | ||||
|       if (it->root_->isLeaf()) | ||||
|         continue; | ||||
|       boost::shared_ptr<const Choice> c = | ||||
|           boost::dynamic_pointer_cast<const Choice>(it->root_); | ||||
|       if (!highestLabel || c->label() > *highestLabel) { | ||||
|         highestLabel.reset(c->label()); | ||||
|         nrChoices.reset(c->nrChoices()); | ||||
|  | @ -483,25 +485,26 @@ namespace gtsam { | |||
|       for (Iterator it = begin; it != end; it++) | ||||
|         choiceOnLabel->push_back(it->root_); | ||||
|       return Choice::Unique(choiceOnLabel); | ||||
|     } | ||||
| 
 | ||||
|     // Set up a new choice on the highest label
 | ||||
|     boost::shared_ptr<Choice> choiceOnHighestLabel(new Choice(*highestLabel, *nrChoices)); | ||||
|     // now, for all possible values of highestLabel
 | ||||
|     for (size_t index = 0; index < *nrChoices; index++) { | ||||
|       // make a new set of functions for composing by iterating over the given
 | ||||
|       // functions, and selecting the appropriate branch.
 | ||||
|       std::vector<DecisionTree> functions; | ||||
|       for (Iterator it = begin; it != end; it++) { | ||||
|         // by restricting the input functions to value i for labelBelow
 | ||||
|         DecisionTree chosen = it->choose(*highestLabel, index); | ||||
|         functions.push_back(chosen); | ||||
|     } else { | ||||
|       // Set up a new choice on the highest label
 | ||||
|       boost::shared_ptr<Choice> choiceOnHighestLabel( | ||||
|           new Choice(*highestLabel, *nrChoices)); | ||||
|       // now, for all possible values of highestLabel
 | ||||
|       for (size_t index = 0; index < *nrChoices; index++) { | ||||
|         // make a new set of functions for composing by iterating over the given
 | ||||
|         // functions, and selecting the appropriate branch.
 | ||||
|         std::vector<DecisionTree> functions; | ||||
|         for (Iterator it = begin; it != end; it++) { | ||||
|           // by restricting the input functions to value i for labelBelow
 | ||||
|           DecisionTree chosen = it->choose(*highestLabel, index); | ||||
|           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
 | ||||
|       NodePtr fi = compose(functions.begin(), functions.end(), label); | ||||
|       choiceOnHighestLabel->push_back(fi); | ||||
|       return Choice::Unique(choiceOnHighestLabel); | ||||
|     } | ||||
|     return Choice::Unique(choiceOnHighestLabel); | ||||
|   } | ||||
| 
 | ||||
|   /*********************************************************************************/ | ||||
|  | @ -667,9 +670,10 @@ namespace gtsam { | |||
|   void DecisionTree<L, Y>::dot(const std::string& name, bool showZero) const { | ||||
|     std::ofstream os((name + ".dot").c_str()); | ||||
|     dot(os, showZero); | ||||
|     system( | ||||
|     int result = system( | ||||
|         ("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