aGrUM  0.16.0
O3prmrInterpreter.h
Go to the documentation of this file.
1 
30 #ifndef SKOORINTERPRETER_H
31 #define SKOORINTERPRETER_H
32 
33 #ifndef DOXYGEN_SHOULD_SKIP_THIS
37 
39 #endif // DOXYGEN_SHOULD_SKIP_THIS
40 
41 namespace gum {
42 
43  namespace prm {
44 
45  namespace o3prmr {
46 
50  class SingleResult {
51  public:
52  std::string label;
53  float p;
54  };
55 
59  class QueryResult {
60  public:
61  double time;
62  std::string command;
63  std::vector< SingleResult > values;
64  };
65 
71  public:
76 
85  bool interpretFile(const std::string& filename);
86  bool interpretLine(const std::string& line);
87 
89  const gum::prm::PRM< double >* prm() const;
91  const gum::prm::PRMInference< double >* inference() const;
95  const std::vector< QueryResult >& results() const;
97  ErrorsContainer errorsContainer() const;
98 
100  O3prmrContext< double >* getContext() const;
101  void setContext(O3prmrContext< double >* context);
102 
106  std::vector< std::string > getPaths() const;
107  void addPath(std::string path);
108  void clearPaths();
109 
112  bool isInSyntaxMode() const;
113  void setSyntaxMode(bool f);
114 
117  bool isVerboseMode() const;
118  void setVerboseMode(bool f);
119 
123  Size count() const;
126  Size errors() const;
128  Size warnings() const;
130  ParseError error(Idx i) const;
132  void showElegantErrors(std::ostream& o = std::cerr) const;
134  void showElegantErrorsAndWarnings(std::ostream& o = std::cerr) const;
136  void showErrorCounts(std::ostream& o = std::cerr) const;
137 
138  private:
139  bool checkSemantic(O3prmrContext< double >* context);
140  bool checkSetEngine(SetEngineCommand* command);
141  bool checkSetGndEngine(SetGndEngineCommand* command);
142  bool checkObserve(ObserveCommand< double >* command);
143  bool checkUnobserve(UnobserveCommand< double >* command);
144  bool checkQuery(QueryCommand< double >* command);
145 
146  bool interpret(O3prmrContext< double >* c);
147  bool import(O3prmrContext< double >* context, std::string import);
148  bool observe(const ObserveCommand< double >* command);
149  bool unobserve(const UnobserveCommand< double >* command);
150  void query(const QueryCommand< double >* command);
151  void setEngine(const SetEngineCommand* command);
152  void setGndEngine(const SetGndEngineCommand* command);
153 
154  std::string findSystemName(std::string& s);
155  std::string findInstanceName(std::string& s,
156  const gum::prm::PRMSystem< double >& sys);
157  std::string
158  findAttributeName(const std::string& s,
159  const gum::prm::PRMInstance< double >& instance);
160  const PRMSystem< double >& system(std::string& ident);
161  void generateInfEngine(const gum::prm::PRMSystem< double >& sys);
162 
163  void addError(std::string msg);
164  void addWarning(std::string msg);
165 
166  std::string __readFile(const std::string& file);
167 
170  std::vector< std::string > m_paths;
172  // Don't delete this, the m_inf_map will do it
175  std::string m_engine;
176  std::string m_bn_engine;
177  std::vector< QueryResult > m_results;
180  bool m_verbose;
181  std::ostream& m_log;
183 
185  // gum::BayesNetInference<gum::prm::prm_float>* bn;
186 
187  }; // class O3prmrInterpreter
188 
189  } // namespace o3prmr
190  } // namespace prm
191 } // namespace gum
192 
193 #endif // GUM_SKOORINTERPRETER_H
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.
An PRMInstance is a Bayesian Network fragment defined by a Class and used in a PRMSystem.
Definition: PRMInstance.h:63
This class is used to represent parsing errors for the different parser implemented in aGrUM...
This class is used contain and manipulate gum::ParseError.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
The class for generic Hash Tables.
Definition: hashTable.h:679
gum::prm::o3prm::O3prmReader< double > * m_reader
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
std::vector< SingleResult > values
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
gum::prm::PRMInference< double > * m_inf
std::vector< std::string > m_paths
Represents a O3PRMR context.
Size Idx
Type for indexes.
Definition: types.h:53
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
HashTable< const PRMSystem< double > *, PRMInference< double > *> m_inf_map
std::vector< QueryResult > m_results
O3prmrContext< double > * m_context