aGrUM  0.16.0
BIFWriter.h
Go to the documentation of this file.
1 
33 #ifndef GUM_BIF_WRITER_H
34 #define GUM_BIF_WRITER_H
35 
36 #include <fstream>
37 #include <iostream>
38 #include <sstream>
39 #include <string>
40 
41 #include <agrum/BN/io/BNWriter.h>
42 
43 #include <agrum/agrum.h>
44 
45 namespace gum {
46 
59  template < typename GUM_SCALAR >
60  class BIFWriter : public BNWriter< GUM_SCALAR > {
61  public:
62  // ==========================================================================
64  // ==========================================================================
66 
70  BIFWriter();
71 
75  ~BIFWriter() final;
76 
78 
86  void write(std::ostream& output, const IBayesNet< GUM_SCALAR >& bn) final;
87 
96  void write(const std::string& filePath,
97  const IBayesNet< GUM_SCALAR >& bn) final;
98 
99  private:
100  // Returns the header of the BIF file.
101  std::string __header(const IBayesNet< GUM_SCALAR >& bn);
102 
103  // Returns a bloc defining a variable in the BIF format.
104  std::string __variableBloc(const DiscreteVariable& var);
105 
106  // Returns a bloc defining a variable's CPT in the BIF format.
107  std::string __variableCPT(const Potential< GUM_SCALAR >& cpt);
108 
109  // Returns the modalities labels of the variables in varsSeq
110  std::string
112  const Instantiation& inst);
113  };
114 
115 
116 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
117  extern template class BIFWriter< double >;
118 #endif
119 
120 } /* namespace gum */
121 
123 #endif // GUM_BIF_WRITER_H
~BIFWriter() final
Destructor.
aGrUM&#39;s Potential is a multi-dimensional array with tensor operators.
Definition: potential.h:60
std::string __variableBloc(const DiscreteVariable &var)
void write(std::ostream &output, const IBayesNet< GUM_SCALAR > &bn) final
Writes a Bayesian Network in the output stream using the BIF format.
The generic class for storing (ordered) sequences of objects.
Definition: sequence.h:1022
Base class for discrete random variable.
Class representing the minimal interface for Bayesian Network.
Definition: IBayesNet.h:62
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
Writes a IBayesNet in the BIF format.
Definition: BIFWriter.h:60
std::string __variableCPT(const Potential< GUM_SCALAR > &cpt)
Class for assigning/browsing values to tuples of discrete variables.
Definition: instantiation.h:83
std::string __variablesLabels(const Sequence< const DiscreteVariable * > &varsSeq, const Instantiation &inst)
std::string __header(const IBayesNet< GUM_SCALAR > &bn)
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Pure virtual class for writting a BN to a file.
Definition: BNWriter.h:57
BIFWriter()
Default constructor.