23 #ifndef DOXYGEN_SHOULD_SKIP_THIS 32 template <
typename GUM_SCALAR >
35 const std::string& filePath) :
36 BNReader< GUM_SCALAR >(bn, filePath) {
45 template <
typename GUM_SCALAR >
56 template <
typename GUM_SCALAR >
60 std::string status =
"Loading File ...";
66 if (xmlDoc.NoChildren()) {
68 ": Loading fail, please check the file for any syntax error.");
72 status =
"File loaded. Now looking for BIF element ...";
78 status =
"BIF Element reached. Now searching network ...";
84 status =
"Network found. Now proceedind variables instanciation...";
90 status =
"All variables have been instancied. Now filling up diagram...";
95 status =
"Instanciation of network completed";
105 template <
typename GUM_SCALAR >
112 for (varIte = varIte.begin(parentNetwork); varIte != varIte.end(); ++varIte)
118 for (varIte = varIte.begin(parentNetwork); varIte != varIte.end(); ++varIte) {
130 auto newVar =
new LabelizedVariable(varName, varDescription, 0);
135 for (varOutComesIte = varOutComesIte.begin(currentVar);
136 varOutComesIte != varOutComesIte.end();
138 newVar->addLabel(varOutComesIte->GetTextOrDefault(
""));
146 "Network found. Now proceedind variables instanciation...";
147 int progress = (int)((
float)nbIte / (float)nbVar * 45) + 10;
153 template <
typename GUM_SCALAR >
159 for (definitionIte = definitionIte.begin(parentNetwork);
160 definitionIte != definitionIte.end();
167 for (definitionIte = definitionIte.begin(parentNetwork);
168 definitionIte != definitionIte.end();
173 std::string currentVarName =
175 NodeId currentVarId =
__bn->idFromName(currentVarName);
179 List< NodeId > parentList;
181 for (givenIte = givenIte.begin(currentVar); givenIte != givenIte.end();
183 std::string parentNode = givenIte->GetTextOrDefault(
"");
184 NodeId parentId =
__bn->idFromName(parentNode);
185 parentList.pushBack(parentId);
189 parentListIte != parentList.rendSafe();
191 __bn->addArc(*parentListIte, currentVarId);
196 std::list< GUM_SCALAR > tablelist;
199 while (!issTableString.eof()) {
200 issTableString >> value;
201 tablelist.push_back(value);
204 std::vector< GUM_SCALAR > tablevector(tablelist.begin(), tablelist.end());
207 __bn->cpt(currentVarId).fillWith(tablevector);
211 "All variables have been instancied. Now filling up diagram...";
212 int progress = (int)((
float)nbIte / (float)nbDef * 45) + 55;
220 #endif // DOXYGEN_SHOULD_SKIP_THIS void __parsingVariables(ticpp::Element *parentNetwork)
Parsing xml element containing data on variables.
Wrapper around TiXmlElement.
std::string GetTextOrDefault(const std::string &defaultValue) const
Gets the text of an Element, if it doesn't exist it will return the defaultValue. ...
BayesNet< GUM_SCALAR > * __bn
An handle to the bayes net in which will be load the content of the xml filePath. ...
std::string __filePath
the path to the xml filePath
ListIteratorSafe< Val > iterator_safe
Types for STL compliance.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void __fillingBN(ticpp::Element *parentNetwork)
fill the diagram
const char * what() const
Override std::exception::what() to return m_details.
This is a ticpp exception class.
#define GUM_EMIT2(signal, arg1, arg2)
gum::Signaler2< int, std::string > onProceed
Signaler used to indicates how many percent of the Xml files have been parsed yet.
Size proceed() final
Reads the bayes net from the file referenced by filePath given at the creation of class...
Wrapper around TiXmlDocument.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Element * FirstChildElement(bool throwIfNoChildren=true) const
The first child element of this node.
Iterator for conveniently stepping through Nodes and Attributes.
BIFXMLBNReader(BayesNet< GUM_SCALAR > *bn, const std::string &filePath)
Constructor A reader is created to reading a defined file.
Size NodeId
Type for node ids.
~BIFXMLBNReader() final
Default destructor.
#define GUM_ERROR(type, msg)