aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
gum::CNFWriter< GUM_SCALAR, IApproximationPolicy > Class Template Referenceabstract

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

#include <agrum/BN/io/cnf/CNFWriter.h>

Inheritance diagram for gum::CNFWriter< GUM_SCALAR, IApproximationPolicy >:
Collaboration diagram for gum::CNFWriter< GUM_SCALAR, IApproximationPolicy >:

Public Member Functions

void write (std::ostream &output, IBayesNet< GUM_SCALAR > &bn)
 Writes a Bayesian network in the output stream.
void write (std::string_view filePath, IBayesNet< GUM_SCALAR > &bn)
 Writes a Bayesian network in the file referenced by filePath.
GUM_NODISCARD bool isModificationAllowed () const
void setAllowModification (bool am)
std::string toString (const IBayesNet< GUM_SCALAR > &bn)
Constructor & destructor
 CNFWriter ()
 Default constructor.
 ~CNFWriter () override
 Destructor.
 CNFWriter (const CNFWriter &)=default
 Default constructor.
 CNFWriter (CNFWriter &&) noexcept=default
 Default constructor.
CNFWriteroperator= (const CNFWriter &)=default
 Default constructor.
CNFWriteroperator= (CNFWriter &&) noexcept=default
 Default constructor.
Accessors/Modifiers
INLINE GUM_SCALAR fromExact (const GUM_SCALAR &value) const override
 Convert value to approximation representation.
void combineAdd (const ApproximationPolicy< GUM_SCALAR > *ap) override
 Combine using addition with the given gum::ApproximationPolicy.
void combineSub (const ApproximationPolicy< GUM_SCALAR > *ap) override
 Combine using subtraction with the given gum::ApproximationPolicy.
void combineMult (const ApproximationPolicy< GUM_SCALAR > *ap) override
 Combine using multiplication with the given gum::ApproximationPolicy.
void combineDiv (const ApproximationPolicy< GUM_SCALAR > *ap) override
 Combine using division with the given gum::ApproximationPolicy.
void combineMax (const ApproximationPolicy< GUM_SCALAR > *ap) override
 Combine using max with the given gum::ApproximationPolicy.
void combineMin (const ApproximationPolicy< GUM_SCALAR > *ap) override
 Combine using min with the given gum::ApproximationPolicy.

Protected Member Functions

void _doWrite (std::ostream &output, const IBayesNet< GUM_SCALAR > &bn) override=0
 Writes a Bayesian network in the output stream using the BN format.
void _doWrite (std::string_view filePath, const IBayesNet< GUM_SCALAR > &bn) override=0
 Writes a Bayesian network in the referenced file using the BN format.
GUM_SCALAR fromExact (const GUM_SCALAR &value) const override
 Convert value to his approximation.
virtual void _syntacticalCheck (const IBayesNet< GUM_SCALAR > &bn)
 Check whether the BN is syntactically correct for BIF format.
void _validCharInNamesCheck (const IBayesNet< GUM_SCALAR > &bn)
 }
std::string _onlyValidCharsInName (std::string_view name)
 }
std::string _buildNameWithOnlyValidChars (std::string_view name)
 }
bool _allowModification_ = false
 }

Detailed Description

template<GUM_Numeric GUM_SCALAR, template< typename > class IApproximationPolicy = ExactPolicy>
class gum::CNFWriter< GUM_SCALAR, IApproximationPolicy >

Writes a IBayesNet in the BN format.

This class servers to write the content of a Bayesian network in the BN format. See TODO for information on this format.

Definition at line 86 of file CNFWriter.h.

Constructor & Destructor Documentation

◆ CNFWriter() [1/3]

template<GUM_Numeric GUM_SCALAR, template< typename > class IApproximationPolicy = ExactPolicy>
gum::CNFWriter< GUM_SCALAR, IApproximationPolicy >::CNFWriter ( )

Default constructor.

Referenced by CNFWriter(), CNFWriter(), fromExact(), operator=(), and operator=().

Here is the caller graph for this function:

◆ ~CNFWriter()

template<GUM_Numeric GUM_SCALAR, template< typename > class IApproximationPolicy = ExactPolicy>
gum::CNFWriter< GUM_SCALAR, IApproximationPolicy >::~CNFWriter ( )
override

Destructor.

◆ CNFWriter() [2/3]

template<GUM_Numeric GUM_SCALAR, template< typename > class IApproximationPolicy = ExactPolicy>
gum::CNFWriter< GUM_SCALAR, IApproximationPolicy >::CNFWriter ( const CNFWriter< GUM_SCALAR, IApproximationPolicy > & )
default

Default constructor.

References CNFWriter().

Here is the call graph for this function:

◆ CNFWriter() [3/3]

template<GUM_Numeric GUM_SCALAR, template< typename > class IApproximationPolicy = ExactPolicy>
gum::CNFWriter< GUM_SCALAR, IApproximationPolicy >::CNFWriter ( CNFWriter< GUM_SCALAR, IApproximationPolicy > && )
defaultnoexcept

Default constructor.

References CNFWriter().

Here is the call graph for this function:

Member Function Documentation

◆ _buildNameWithOnlyValidChars()

template<GUM_Numeric GUM_SCALAR>
std::string gum::BNWriter< GUM_SCALAR >::_buildNameWithOnlyValidChars ( std::string_view 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<GUM_Numeric GUM_SCALAR, template< typename > class IApproximationPolicy = ExactPolicy>
void gum::CNFWriter< GUM_SCALAR, IApproximationPolicy >::_doWrite ( std::ostream & output,
const IBayesNet< GUM_SCALAR > & bn )
overrideprotectedpure virtual

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

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

Implements gum::BNWriter< GUM_SCALAR >.

Implemented in gum::ContextualDependenciesCNFWriter< GUM_SCALAR, IApproximationPolicy >, gum::FactorisedValuesCNFWriter< GUM_SCALAR, IApproximationPolicy >, and gum::GeneralizedCNFWriter< GUM_SCALAR, IApproximationPolicy >.

References _doWrite().

Referenced by _doWrite(), and _doWrite().

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

◆ _doWrite() [2/2]

template<GUM_Numeric GUM_SCALAR, template< typename > class IApproximationPolicy = ExactPolicy>
void gum::CNFWriter< GUM_SCALAR, IApproximationPolicy >::_doWrite ( std::string_view filePath,
const IBayesNet< GUM_SCALAR > & bn )
overrideprotectedpure virtual

Writes a Bayesian network in the referenced file using the BN 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:

◆ _onlyValidCharsInName()

template<GUM_Numeric GUM_SCALAR>
std::string gum::BNWriter< GUM_SCALAR >::_onlyValidCharsInName ( std::string_view 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<GUM_Numeric GUM_SCALAR>
virtual void gum::BNWriter< GUM_SCALAR >::_syntacticalCheck ( const IBayesNet< GUM_SCALAR > & bn)
protectedvirtualinherited

Check whether the BN is syntactically correct for BIF format.

Exceptions
FatalErrorif found.

Reimplemented in gum::BIFWriter< GUM_SCALAR >, and gum::DSLWriter< 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<GUM_Numeric 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:

◆ combineAdd()

void gum::ExactPolicy< GUM_SCALAR >::combineAdd ( const ApproximationPolicy< GUM_SCALAR > * ap)
overridevirtualinherited

Combine using addition with the given gum::ApproximationPolicy.

Parameters
apThe policy to combine with.

Implements gum::ApproximationPolicy< GUM_SCALAR >.

Definition at line 97 of file exactPolicy_tpl.h.

69{}

◆ combineDiv()

void gum::ExactPolicy< GUM_SCALAR >::combineDiv ( const ApproximationPolicy< GUM_SCALAR > * ap)
overridevirtualinherited

Combine using division with the given gum::ApproximationPolicy.

Parameters
apThe policy to combine with.

Implements gum::ApproximationPolicy< GUM_SCALAR >.

Definition at line 117 of file exactPolicy_tpl.h.

83{}

◆ combineMax()

void gum::ExactPolicy< GUM_SCALAR >::combineMax ( const ApproximationPolicy< GUM_SCALAR > * ap)
overridevirtualinherited

Combine using max with the given gum::ApproximationPolicy.

Parameters
apThe policy to combine with.

Implements gum::ApproximationPolicy< GUM_SCALAR >.

Definition at line 123 of file exactPolicy_tpl.h.

87{}

◆ combineMin()

void gum::ExactPolicy< GUM_SCALAR >::combineMin ( const ApproximationPolicy< GUM_SCALAR > * ap)
overridevirtualinherited

Combine using min with the given gum::ApproximationPolicy.

Parameters
apThe policy to combine with.

Implements gum::ApproximationPolicy< GUM_SCALAR >.

Definition at line 129 of file exactPolicy_tpl.h.

91{}

◆ combineMult()

void gum::ExactPolicy< GUM_SCALAR >::combineMult ( const ApproximationPolicy< GUM_SCALAR > * ap)
overridevirtualinherited

Combine using multiplication with the given gum::ApproximationPolicy.

Parameters
apThe policy to combine with.

Implements gum::ApproximationPolicy< GUM_SCALAR >.

Definition at line 111 of file exactPolicy_tpl.h.

79{}

◆ combineSub()

void gum::ExactPolicy< GUM_SCALAR >::combineSub ( const ApproximationPolicy< GUM_SCALAR > * ap)
overridevirtualinherited

Combine using subtraction with the given gum::ApproximationPolicy.

Parameters
apThe policy to combine with.

Implements gum::ApproximationPolicy< GUM_SCALAR >.

Definition at line 104 of file exactPolicy_tpl.h.

74{}

◆ fromExact() [1/2]

template<GUM_Numeric GUM_SCALAR, template< typename > class IApproximationPolicy = ExactPolicy>
GUM_SCALAR gum::CNFWriter< GUM_SCALAR, IApproximationPolicy >::fromExact ( const GUM_SCALAR & value) const
overrideprotectedvirtual

Convert value to his approximation.

This method, at least in release mode, should not verify the limits

Parameters
valueThe converted value.
Returns
The value approximation representation.

Implements gum::ApproximationPolicy< GUM_SCALAR >.

References CNFWriter(), and fromExact().

Referenced by fromExact().

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

◆ fromExact() [2/2]

GUM_SCALAR gum::ExactPolicy< GUM_SCALAR >::fromExact ( const GUM_SCALAR & value) const
overrideinherited

Convert value to approximation representation.

Parameters
valueThe converted value.
Returns
The value approximation representation.

Definition at line 91 of file exactPolicy_tpl.h.

63 {
64 return value;
65 }
Class implementing exact approximation policy (meaning a value is approximate to itself).
Definition exactPolicy.h:67

◆ isModificationAllowed()

template<GUM_Numeric 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<GUM_Numeric GUM_SCALAR, template< typename > class IApproximationPolicy = ExactPolicy>
CNFWriter & gum::CNFWriter< GUM_SCALAR, IApproximationPolicy >::operator= ( CNFWriter< GUM_SCALAR, IApproximationPolicy > && )
defaultnoexcept

Default constructor.

References CNFWriter().

Here is the call graph for this function:

◆ operator=() [2/2]

template<GUM_Numeric GUM_SCALAR, template< typename > class IApproximationPolicy = ExactPolicy>
CNFWriter & gum::CNFWriter< GUM_SCALAR, IApproximationPolicy >::operator= ( const CNFWriter< GUM_SCALAR, IApproximationPolicy > & )
default

Default constructor.

References CNFWriter().

Here is the call graph for this function:

◆ setAllowModification()

template<GUM_Numeric 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:

◆ toString()

template<GUM_Numeric GUM_SCALAR>
std::string gum::BNWriter< GUM_SCALAR >::toString ( const IBayesNet< GUM_SCALAR > & bn)
inherited

References toString().

Referenced by toString().

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

◆ write() [1/2]

template<GUM_Numeric GUM_SCALAR>
void gum::BNWriter< GUM_SCALAR >::write ( std::ostream & output,
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 (not const since updateMetaData).
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:

◆ write() [2/2]

template<GUM_Numeric GUM_SCALAR>
void gum::BNWriter< GUM_SCALAR >::write ( std::string_view filePath,
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 written to the file (not const since updateMetaData).
Exceptions
IOErrorRaised if an I/O error occurs.

References write().

Here is the call graph for this function:

Member Data Documentation

◆ _allowModification_

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

}

Definition at line 167 of file BNWriter.h.


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