23 #ifndef DOXYGEN_SHOULD_SKIP_THIS 36 template <
typename GUM_SCALAR >
38 InfluenceDiagram< GUM_SCALAR >* infdiag,
const std::string& filePath) :
39 IDReader< GUM_SCALAR >(infdiag, filePath) {
48 template <
typename GUM_SCALAR >
59 template <
typename GUM_SCALAR >
63 std::string status =
"Loading File ...";
69 if (xmlDoc.NoChildren()) {
71 ": Loading fail, please check the file for any syntax error.");
75 status =
"File loaded. Now looking for BIF element ...";
81 status =
"BIF Element reached. Now searching network ...";
87 status =
"Network found. Now proceeding variables instanciation...";
93 status =
"All variables have been instancied. Now filling up diagram...";
98 status =
"Instanciation of network completed";
106 template <
typename GUM_SCALAR >
113 for (varIte = varIte.begin(parentNetwork); varIte != varIte.end(); ++varIte)
119 for (varIte = varIte.begin(parentNetwork); varIte != varIte.end(); ++varIte) {
131 LabelizedVariable newVar(varName, varDescription, 0);
136 for (varOutComesIte = varOutComesIte.begin(currentVar);
137 varOutComesIte != varOutComesIte.end();
139 newVar.addLabel(varOutComesIte->GetTextOrDefault(
""));
142 std::string nodeType = currentVar->
GetAttribute< std::string >(
"TYPE");
145 if (nodeType.compare(
"decision") == 0)
147 else if (nodeType.compare(
"utility") == 0)
154 "Network found. Now proceedind variables instanciation...";
155 int progress = (int)((
float)nbIte / (float)nbVar * 45) + 10;
161 template <
typename GUM_SCALAR >
168 for (definitionIte = definitionIte.begin(parentNetwork);
169 definitionIte != definitionIte.end();
176 for (definitionIte = definitionIte.begin(parentNetwork);
177 definitionIte != definitionIte.end();
182 std::string currentVarName =
188 List< NodeId > parentList;
190 for (givenIte = givenIte.begin(currentVar); givenIte != givenIte.end();
192 std::string parentNode = givenIte->GetTextOrDefault(
"");
194 parentList.pushBack(parentId);
198 parentListIte != parentList.rendSafe();
200 __infdiag->addArc(*parentListIte, currentVarId);
203 if (!
__infdiag->isDecisionNode(currentVarId)) {
206 std::list< GUM_SCALAR > tablelist;
209 while (!issTableString.eof()) {
210 issTableString >> value;
211 tablelist.push_back(value);
214 std::vector< GUM_SCALAR > tablevector(tablelist.begin(), tablelist.end());
217 if (
__infdiag->isChanceNode(currentVarId)) {
218 const Potential< GUM_SCALAR >* table = &
__infdiag->cpt(currentVarId);
219 table->populate(tablevector);
220 }
else if (
__infdiag->isUtilityNode(currentVarId)) {
221 const Potential< GUM_SCALAR >* table = &
__infdiag->utility(currentVarId);
222 table->populate(tablevector);
228 "All variables have been instancied. Now filling up diagram...";
229 int progress = (int)((
float)nbIte / (float)nbDef * 45) + 55;
237 #endif // DOXYGEN_SHOULD_SKIP_THIS Wrapper around TiXmlElement.
std::string __filePath
the path to the xml filePath
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
gum::Signaler2< int, std::string > onProceed
Signaler used to indicates how many percent of the Xml files have been parsed yet.
std::string GetTextOrDefault(const std::string &defaultValue) const
Gets the text of an Element, if it doesn't exist it will return the defaultValue. ...
ListIteratorSafe< Val > iterator_safe
Types for STL compliance.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void __parsingVariables(ticpp::Element *parentNetwork)
Parsing xml element containing data on variables.
void __fillingDiagram(ticpp::Element *parentNetwork)
fill the diagram
BIFXMLIDReader(InfluenceDiagram< GUM_SCALAR > *infdiag, const std::string &filePath)
Constructor A reader is created to reading a defined file.
const char * what() const
Override std::exception::what() to return m_details.
This is a ticpp exception class.
#define GUM_EMIT2(signal, arg1, arg2)
InfluenceDiagram< GUM_SCALAR > * __infdiag
An handle to the influence diagram in which will be load the content of the xml filePath.
~BIFXMLIDReader()
Default destructor.
Wrapper around TiXmlDocument.
T GetAttribute(const std::string &name, bool throwIfNotFound=true) const
Returns an attribute of name from an element.
Element * FirstChildElement(bool throwIfNoChildren=true) const
The first child element of this node.
Iterator for conveniently stepping through Nodes and Attributes.
virtual void proceed()
Reads the influence diagram from the file referenced by filePath given at the creation of class...
Size NodeId
Type for node ids.
#define GUM_ERROR(type, msg)