42#ifndef __CREDAL_NET__H__
43#define __CREDAL_NET__H__
78typedef __int64 int64_t;
79typedef unsigned __int64 uint64_t;
96 template <
typename GUM_SCALAR >
125 CredalNet(
const std::string& src_min_num,
const std::string& src_max_den =
"");
139 CredalNet(
const BayesNet< GUM_SCALAR >& src_min_num,
140 const BayesNet< GUM_SCALAR >& src_max_den = BayesNet< GUM_SCALAR >());
184 const std::vector< std::vector< std::vector< GUM_SCALAR > > >& cpt);
208 const std::vector< std::vector< GUM_SCALAR > >& cpt);
232 const std::vector< std::vector< GUM_SCALAR > >& cpt);
249 const std::vector< GUM_SCALAR >& lower,
250 const std::vector< GUM_SCALAR >& upper);
270 const std::vector< GUM_SCALAR >& lower,
271 const std::vector< GUM_SCALAR >& upper);
291 const std::vector< GUM_SCALAR >& lower,
292 const std::vector< GUM_SCALAR >& upper);
339 void bnToCredal(GUM_SCALAR beta,
bool oneNet,
bool keepZeroes);
340 void bnToCredal(GUM_SCALAR beta,
bool oneNet);
421 void saveBNsMinMax(
const std::string& min_path,
const std::string& max_path)
const;
452 const BayesNet< GUM_SCALAR >&
src_bn()
const;
459 const BayesNet< GUM_SCALAR >&
current_bn()
const;
645 const std::vector< std::vector< std::vector< GUM_SCALAR > > >& var_cpt)
const;
666 void _initCNNets_(
const std::string& src_min_num,
const std::string& src_max_den);
671 void _initCNNets_(
const BayesNet< GUM_SCALAR >& src_min_num,
672 const BayesNet< GUM_SCALAR >& src_max_den);
690 void _bnCopy_(BayesNet< GUM_SCALAR >& bn_dest);
705 void _H2Vlrs_(
const std::vector< std::vector< GUM_SCALAR > >& h_rep,
706 std::vector< std::vector< GUM_SCALAR > >& v_rep)
const;
711#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
Definition of templatized reader of BIF files for Bayesian networks.
Definition of class for BIF file output manipulation.
Class for assigning/browsing values to tuples of discrete variables.
Class template representing a Credal Network.
void _H2Vlrs_(const std::vector< std::vector< GUM_SCALAR > > &h_rep, std::vector< std::vector< GUM_SCALAR > > &v_rep) const
void _initParams_()
Initialize private constant variables after the Constructor has been called.
GUM_SCALAR _epsilonMoy_
The average perturbation of the BayesNet provided as input for this CredalNet.
void setCPTs(const NodeId &id, const std::vector< std::vector< std::vector< GUM_SCALAR > > > &cpt)
Set the vertices of the credal sets ( all of the conditionals ) of a given node
GUM_SCALAR _deltaC_
5 by default, used by fracC as number of decimals.
BayesNet< GUM_SCALAR > _src_bn_max_
BayesNet used to store upper probabilities.
void intervalToCredalWithFiles()
NodeId addVariable(const std::string &name, const Size &card)
Adds a discrete node into the network.
BayesNet< GUM_SCALAR > * _current_bn_
Up-to-date BayesNet (used as a DAG).
void _intervalToCredal_()
Computes the vertices of each credal set according to their interval definition (does not use lrs).
void saveBNsMinMax(const std::string &min_path, const std::string &max_path) const
If this CredalNet was built over a perturbed BayesNet, one can save the intervals as two BayesNet.
std::string toString() const
bool _hasComputedBinaryCPTMinMax_
Used by L2U, to know if lower and upper probabilities over the second modality has been stored in ord...
Size domainSize(const NodeId &id)
Get the cardinality of a node
NodeProperty< std::vector< std::vector< std::vector< GUM_SCALAR > > > > _credalNet_src_cpt_
This CredalNet original CPTs.
const GUM_SCALAR & epsilonMax() const
void _bnCopy_(BayesNet< GUM_SCALAR > &bn_dest)
bool hasComputedBinaryCPTMinMax() const
GUM_SCALAR _precision_
Precision used by frac.
const NodeProperty< std::vector< std::vector< std::vector< GUM_SCALAR > > > > & credalNet_currentCpt() const
Instantiation instantiation(const NodeId &id)
Get an Instantiation from a node id, usefull to fill the constraints of the network
void bnToCredal(GUM_SCALAR beta, bool oneNet, bool keepZeroes)
Perturbates the BayesNet provided as input for this CredalNet by generating intervals instead of poin...
void intervalToCredal()
Computes the vertices of each credal set according to their interval definition (uses lrs).
const GUM_SCALAR & epsilonMean() const
std::vector< std::vector< GUM_SCALAR > > _binCptMin_
Used with binary networks to speed-up L2U inference.
void approximatedBinarization()
Approximate binarization.
const BayesNet< GUM_SCALAR > & src_bn() const
int _find_dNode_card_(const std::vector< std::vector< std::vector< GUM_SCALAR > > > &var_cpt) const
BayesNet< GUM_SCALAR > _src_bn_
Original BayesNet (used as a DAG).
void computeBinaryCPTMinMax()
Used with binary networks to speed-up L2U inference.
const NodeProperty< std::vector< std::vector< std::vector< GUM_SCALAR > > > > & credalNet_srcCpt() const
NodeType currentNodeType(const NodeId &id) const
NodeProperty< NodeType > _original_nodeType_
The NodeType of each node from the ORIGINAL network.
void lagrangeNormalization()
Normalize counts of a BayesNet storing counts of each events such that no probability is 0.
NodeProperty< std::vector< std::vector< std::vector< GUM_SCALAR > > > > * _credalNet_current_cpt_
This CredalNet up-to-date CPTs.
bool isSeparatelySpecified() const
void _sort_varType_()
Set the NodeType of each node
void _initCNNets_(const std::string &src_min_num, const std::string &src_max_den)
Initialize private BayesNet variables after the Constructor has been called.
void idmLearning(const Idx s=0, const bool keepZeroes=false)
Learns parameters from a BayesNet storing counts of events.
GUM_SCALAR _epsilonMax_
The highest perturbation of the BayesNet provided as input for this CredalNet.
std::vector< std::vector< GUM_SCALAR > > _binCptMax_
Used with binary networks to speed-up L2U inference.
NodeType nodeType(const NodeId &id) const
void setCPT(const NodeId &id, Size &entry, const std::vector< std::vector< GUM_SCALAR > > &cpt)
Set the vertices of one credal set of a given node ( any instantiation index )
bool _separatelySpecified_
TRUE if this CredalNet is separately and interval specified, FALSE otherwise.
NodeProperty< std::vector< NodeId > > _var_bits_
Corresponding bits of each variable.
const std::vector< std::vector< GUM_SCALAR > > & get_binaryCPT_max() const
Used with binary networks to speed-up L2U inference.
BayesNet< GUM_SCALAR > _src_bn_min_
BayesNet used to store lower probabilities.
const BayesNet< GUM_SCALAR > & current_bn() const
void addArc(const NodeId &tail, const NodeId &head)
Adds an arc between two nodes.
const std::vector< std::vector< GUM_SCALAR > > & get_binaryCPT_min() const
Used with binary networks to speed-up L2U inference.
void fillConstraints(const NodeId &id, const std::vector< GUM_SCALAR > &lower, const std::vector< GUM_SCALAR > &upper)
Set the interval constraints of the credal sets of a given node (all instantiations )
GUM_SCALAR _epsilonMin_
The lowest perturbation of the BayesNet provided as input for this CredalNet.
const GUM_SCALAR & epsilonMin() const
NodeProperty< NodeType > * _current_nodeType_
The NodeType of each node from the up-to-date network.
GUM_SCALAR _denMax_
Highest possible denominator allowed when using farey.
void fillConstraint(const NodeId &id, const Idx &entry, const std::vector< GUM_SCALAR > &lower, const std::vector< GUM_SCALAR > &upper)
Set the interval constraints of a credal set of a given node ( from an instantiation index )
GUM_SCALAR _epsRedund_
Value under which a decimal number is considered to be zero when computing redundant vertices.
GUM_SCALAR _precisionC_
1e6 by default, used by fracC as precision.
NodeType
NodeType to speed-up computations in some algorithms.
CredalNet()
Constructor used to create a CredalNet step by step, i.e.
GUM_SCALAR _epsF_
Value under which a decimal number is considered to be zero when using farey.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Size Idx
Type for indexes.
Size NodeId
Type for node ids.
HashTable< NodeId, VAL > NodeProperty
Property on graph elements.
namespace for all credal networks entities
gum is the global namespace for all aGrUM entities
Implementation of pow functions with integers, faster than stl implementation.
The class to use to execute a function by several threads.
Utility functions used for exploiting OpenMP/STL parallelism.