aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
gum::BIFWriter< GUM_SCALAR > Class Template Referencefinal

Writes a IBayesNet in the BIF format. More...

#include <agrum/BN/io/BIF/BIFWriter.h>

Inheritance diagram for gum::BIFWriter< GUM_SCALAR >:
Collaboration diagram for gum::BIFWriter< GUM_SCALAR >:

Public Member Functions

void write (std::ostream &output, const IBayesNet< GUM_SCALAR > &bn)
 Writes a Bayesian network in the output stream.
void write (const std::string &filePath, const IBayesNet< GUM_SCALAR > &bn)
 Writes a Bayesian network in the file referenced by filePath.
GUM_NODISCARD bool isModificationAllowed () const
void setAllowModification (bool am)
Constructor & destructor
 BIFWriter ()
 Default constructor.
 ~BIFWriter () override
 Destructor.
 BIFWriter (const BIFWriter &)=default
 Default constructor.
 BIFWriter (BIFWriter &&) noexcept=default
 Default constructor.
BIFWriteroperator= (const BIFWriter &)=default
 Default constructor.
BIFWriteroperator= (BIFWriter &&) noexcept=default
 Default constructor.

Protected Member Functions

void _doWrite (std::ostream &output, const IBayesNet< GUM_SCALAR > &bn) final
 Writes a Bayesian network in the output stream using the BIF format.
void _doWrite (const std::string &filePath, const IBayesNet< GUM_SCALAR > &bn) final
 Writes a Bayesian network in the referenced file using the BIF format.
void _syntacticalCheck (const IBayesNet< GUM_SCALAR > &bn) final
 Check whether the BN is syntactically correct for BIF format.

Private Member Functions

std::string _header_ (const IBayesNet< GUM_SCALAR > &bn)
std::string _variableBloc_ (const DiscreteVariable &var)
std::string _variableCPT_ (const Tensor< GUM_SCALAR > &cpt)
std::string _variablesLabels_ (const Sequence< const DiscreteVariable * > &varsSeq, const Instantiation &inst)
void _validCharInNamesCheck (const IBayesNet< GUM_SCALAR > &bn)
 }
std::string _onlyValidCharsInName (const std::string &name)
 }
std::string _buildNameWithOnlyValidChars (const std::string &name)
 }
bool _allowModification_ = false
 }

Detailed Description

template<typename GUM_SCALAR>
class gum::BIFWriter< GUM_SCALAR >

Writes a IBayesNet in the BIF format.

This class servers to write the content of a Bayesian network in the BIF format. See http://www.cs.cmu.edu/~fgcozman/Research/InterchangeFormat/Old/xmlbif02.html for information on this format.

Definition at line 79 of file BIFWriter.h.

Constructor & Destructor Documentation

◆ BIFWriter() [1/3]

template<typename GUM_SCALAR>
gum::BIFWriter< GUM_SCALAR >::BIFWriter ( )

Default constructor.

Referenced by BIFWriter(), BIFWriter(), _variablesLabels_(), operator=(), and operator=().

Here is the caller graph for this function:

◆ ~BIFWriter()

template<typename GUM_SCALAR>
gum::BIFWriter< GUM_SCALAR >::~BIFWriter ( )
override

Destructor.

◆ BIFWriter() [2/3]

template<typename GUM_SCALAR>
gum::BIFWriter< GUM_SCALAR >::BIFWriter ( const BIFWriter< GUM_SCALAR > & )
default

Default constructor.

References BIFWriter().

Here is the call graph for this function:

◆ BIFWriter() [3/3]

template<typename GUM_SCALAR>
gum::BIFWriter< GUM_SCALAR >::BIFWriter ( BIFWriter< GUM_SCALAR > && )
defaultnoexcept

Default constructor.

References BIFWriter().

Here is the call graph for this function:

Member Function Documentation

◆ _buildNameWithOnlyValidChars()

template<typename GUM_SCALAR>
std::string gum::BNWriter< GUM_SCALAR >::_buildNameWithOnlyValidChars ( const std::string & name)
protectedinherited

}

References _buildNameWithOnlyValidChars().

Referenced by _buildNameWithOnlyValidChars().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _doWrite() [1/2]

template<typename GUM_SCALAR>
void gum::BIFWriter< GUM_SCALAR >::_doWrite ( const std::string & filePath,
const IBayesNet< GUM_SCALAR > & bn )
finalprotectedvirtual

Writes a Bayesian network in the referenced file using the BIF format.

If the files doesn't exists, it is created.

Parameters
filePathThe path to the file used to write the Bayesian network.
bnThe Bayesian network writed in the file.
Exceptions
IOErrorRaised if and I/O error occurs.

Implements gum::BNWriter< GUM_SCALAR >.

References _doWrite().

Here is the call graph for this function:

◆ _doWrite() [2/2]

template<typename GUM_SCALAR>
void gum::BIFWriter< GUM_SCALAR >::_doWrite ( std::ostream & output,
const IBayesNet< GUM_SCALAR > & bn )
finalprotectedvirtual

Writes a Bayesian network in the output stream using the BIF format.

Parameters
outputThe output stream.
bnThe Bayesian network writen in output.
Exceptions
IOErrorRaised if and I/O error occurs.

Implements gum::BNWriter< GUM_SCALAR >.

References _doWrite().

Referenced by _doWrite(), and _doWrite().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _header_()

template<typename GUM_SCALAR>
std::string gum::BIFWriter< GUM_SCALAR >::_header_ ( const IBayesNet< GUM_SCALAR > & bn)
private

References _header_().

Referenced by _header_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _onlyValidCharsInName()

template<typename GUM_SCALAR>
std::string gum::BNWriter< GUM_SCALAR >::_onlyValidCharsInName ( const std::string & name)
protectedinherited

}

References _onlyValidCharsInName().

Referenced by _onlyValidCharsInName().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _syntacticalCheck()

template<typename GUM_SCALAR>
void gum::BIFWriter< GUM_SCALAR >::_syntacticalCheck ( const IBayesNet< GUM_SCALAR > & bn)
finalprotectedvirtual

Check whether the BN is syntactically correct for BIF format.

Exceptions
FatalErrorif found.

Reimplemented from gum::BNWriter< GUM_SCALAR >.

References _syntacticalCheck().

Referenced by _syntacticalCheck().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _validCharInNamesCheck()

template<typename GUM_SCALAR>
void gum::BNWriter< GUM_SCALAR >::_validCharInNamesCheck ( const IBayesNet< GUM_SCALAR > & bn)
protectedinherited

}

References _validCharInNamesCheck().

Referenced by _validCharInNamesCheck().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _variableBloc_()

template<typename GUM_SCALAR>
std::string gum::BIFWriter< GUM_SCALAR >::_variableBloc_ ( const DiscreteVariable & var)
private

References _variableBloc_().

Referenced by _variableBloc_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _variableCPT_()

template<typename GUM_SCALAR>
std::string gum::BIFWriter< GUM_SCALAR >::_variableCPT_ ( const Tensor< GUM_SCALAR > & cpt)
private

References _variableCPT_().

Referenced by _variableCPT_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _variablesLabels_()

template<typename GUM_SCALAR>
std::string gum::BIFWriter< GUM_SCALAR >::_variablesLabels_ ( const Sequence< const DiscreteVariable * > & varsSeq,
const Instantiation & inst )
private

References BIFWriter(), and _variablesLabels_().

Referenced by _variablesLabels_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isModificationAllowed()

template<typename GUM_SCALAR>
GUM_NODISCARD bool gum::BNWriter< GUM_SCALAR >::isModificationAllowed ( ) const
inherited

References GUM_NODISCARD, and isModificationAllowed().

Referenced by isModificationAllowed().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [1/2]

template<typename GUM_SCALAR>
BIFWriter & gum::BIFWriter< GUM_SCALAR >::operator= ( BIFWriter< GUM_SCALAR > && )
defaultnoexcept

Default constructor.

References BIFWriter().

Here is the call graph for this function:

◆ operator=() [2/2]

template<typename GUM_SCALAR>
BIFWriter & gum::BIFWriter< GUM_SCALAR >::operator= ( const BIFWriter< GUM_SCALAR > & )
default

Default constructor.

References BIFWriter().

Here is the call graph for this function:

◆ setAllowModification()

template<typename GUM_SCALAR>
void gum::BNWriter< GUM_SCALAR >::setAllowModification ( bool am)
inherited

References setAllowModification().

Referenced by setAllowModification().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write() [1/2]

template<typename GUM_SCALAR>
void gum::BNWriter< GUM_SCALAR >::write ( const std::string & filePath,
const IBayesNet< GUM_SCALAR > & bn )
inherited

Writes a Bayesian network in the file referenced by filePath.

  • If the file doesn't exists, it is created.
  • If the file exists, it's content will be erased.
  • If the bn can not be written for syntactical reasons, throw an error or try to correct it (conditioned by the value of allowModification
Parameters
filePathThe path to the file used to write the Bayesian network.
bnThe Bayesian network writen in the file.
Exceptions
IOErrorRaised if an I/O error occurs.

References write().

Here is the call graph for this function:

◆ write() [2/2]

template<typename GUM_SCALAR>
void gum::BNWriter< GUM_SCALAR >::write ( std::ostream & output,
const IBayesNet< GUM_SCALAR > & bn )
inherited

Writes a Bayesian network in the output stream.

  • If the bn can not be written for syntactical reasons, throw an error or try to correct it (conditioned by the value of allowModification
Parameters
outputThe output stream.
bnThe Bayesian network written in output.
Exceptions
IOErrorRaised if an I/O error occurs.
SyntaxErrorRaised if syntactical errors in the BN

References write().

Referenced by gum::credal::CredalNet< GUM_SCALAR >::saveBNsMinMax(), write(), and write().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _allowModification_

template<typename GUM_SCALAR>
bool gum::BNWriter< GUM_SCALAR >::_allowModification_ = false
privateinherited

}

Definition at line 163 of file BNWriter.h.


The documentation for this class was generated from the following file: