aGrUM  0.14.2
O3prmrInterpreter.h
Go to the documentation of this file.
1 
2 /***************************************************************************
3  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
4  * {prenom.nom}_at_lip6.fr *
5  * *
6  * This program is free software; you can redistribute it and/or modify *
7  * it under the terms of the GNU General Public License as published by *
8  * the Free Software Foundation; either version 2 of the License, or *
9  * (at your option) any later version. *
10  * *
11  * This program is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License *
17  * along with this program; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
20  ***************************************************************************/
28 #ifndef SKOORINTERPRETER_H
29 #define SKOORINTERPRETER_H
30 
31 #ifndef DOXYGEN_SHOULD_SKIP_THIS
35 
37 #endif // DOXYGEN_SHOULD_SKIP_THIS
38 
39 namespace gum {
40 
41  namespace prm {
42 
43  namespace o3prmr {
44 
48  class SingleResult {
49  public:
50  std::string label;
51  float p;
52  };
53 
57  class QueryResult {
58  public:
59  double time;
60  std::string command;
61  std::vector< SingleResult > values;
62  };
63 
69  public:
74 
83  bool interpretFile(const std::string& filename);
84  bool interpretLine(const std::string& line);
85 
87  const gum::prm::PRM< double >* prm() const;
89  const gum::prm::PRMInference< double >* inference() const;
93  const std::vector< QueryResult >& results() const;
95  ErrorsContainer errorsContainer() const;
96 
98  O3prmrContext< double >* getContext() const;
99  void setContext(O3prmrContext< double >* context);
100 
104  std::vector< std::string > getPaths() const;
105  void addPath(std::string path);
106  void clearPaths();
107 
110  bool isInSyntaxMode() const;
111  void setSyntaxMode(bool f);
112 
115  bool isVerboseMode() const;
116  void setVerboseMode(bool f);
117 
121  Size count() const;
124  Size errors() const;
126  Size warnings() const;
128  ParseError error(Idx i) const;
130  void showElegantErrors(std::ostream& o = std::cerr) const;
132  void showElegantErrorsAndWarnings(std::ostream& o = std::cerr) const;
134  void showErrorCounts(std::ostream& o = std::cerr) const;
135 
136  private:
137  bool checkSemantic(O3prmrContext< double >* context);
138  bool checkSetEngine(SetEngineCommand* command);
139  bool checkSetGndEngine(SetGndEngineCommand* command);
140  bool checkObserve(ObserveCommand< double >* command);
141  bool checkUnobserve(UnobserveCommand< double >* command);
142  bool checkQuery(QueryCommand< double >* command);
143 
144  bool interpret(O3prmrContext< double >* c);
145  bool import(O3prmrContext< double >* context, std::string import);
146  bool observe(const ObserveCommand< double >* command);
147  bool unobserve(const UnobserveCommand< double >* command);
148  void query(const QueryCommand< double >* command);
149  void setEngine(const SetEngineCommand* command);
150  void setGndEngine(const SetGndEngineCommand* command);
151 
152  std::string findSystemName(std::string& s);
153  std::string findInstanceName(std::string& s,
154  const gum::prm::PRMSystem< double >& sys);
155  std::string
156  findAttributeName(const std::string& s,
157  const gum::prm::PRMInstance< double >& instance);
158  const PRMSystem< double >& system(std::string& ident);
159  void generateInfEngine(const gum::prm::PRMSystem< double >& sys);
160 
161  void addError(std::string msg);
162  void addWarning(std::string msg);
163 
164  std::string __readFile(const std::string& file);
165 
168  std::vector< std::string > m_paths;
170  // Don't delete this, the m_inf_map will do it
173  std::string m_engine;
174  std::string m_bn_engine;
175  std::vector< QueryResult > m_results;
178  bool m_verbose;
179  std::ostream& m_log;
181 
183  // gum::BayesNetInference<gum::prm::prm_float>* bn;
184 
185  }; // class O3prmrInterpreter
186 
187  } // namespace o3prmr
188  } // namespace prm
189 } // namespace gum
190 
191 #endif // GUM_SKOORINTERPRETER_H
Headers of O3prmInterpreter.
Errors container (at least) for parser.
An PRMInstance is a Bayesian Network fragment defined by a Class and used in a PRMSystem.
Definition: PRMInstance.h:60
This class is used to represent parsing errors for the different parser implemented in aGrUM...
This class is used contain and manipulate gum::ParseError.
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
The class for generic Hash Tables.
Definition: hashTable.h:676
gum::prm::o3prm::O3prmReader< double > * m_reader
Headers for the O3prmReader class.
std::vector< SingleResult > values
Headers of PRMInference.
gum::prm::PRMInference< double > * m_inf
std::vector< std::string > m_paths
Represents a O3PRMR context.
Size Idx
Type for indexes.
Definition: types.h:50
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:45
HashTable< const PRMSystem< double > *, PRMInference< double > *> m_inf_map
std::vector< QueryResult > m_results
O3prmrContext< double > * m_context