49 template < GUM_Numeric GUM_SCALAR >
56 template < GUM_Numeric GUM_SCALAR >
63 template < GUM_Numeric GUM_SCALAR >
68 template < GUM_Numeric GUM_SCALAR >
71 auto nNodes = cpt->size();
74 for (
NodeId node = 0; node < nNodes; node++) {
75 auto pConfs = (*cpt)[node].size();
78 for (
Size pconf = 0; pconf < pConfs; pconf++) {
79 Size nVertices =
Size((*cpt)[node][pconf].size());
81 superiorPow(
static_cast< unsigned long >(nVertices), b, c);
90 template < GUM_Numeric GUM_SCALAR >
92 const std::vector< Size >& key) {
94 std::list< Size >& nets =
myVarHashs_.getWithDefault(key, std::list< Size >());
96 for (std::list< Size >::iterator it = nets.begin(); it != nets.end(); ++it) {
106 std::list< varKey >()) .push_back(key);
110 template < GUM_Numeric GUM_SCALAR >
114 std::list< Size >& old_nets
115 =
myVarHashs_.getWithDefault(key, std::list< Size >());
118 for (std::list< Size >::iterator it = old_nets.begin(); it != old_nets.end(); ++it) {
120 std::list< varKey >& netKeys
121 =
myHashVars_.getWithDefault(*it, std::list< varKey >());
124 if (netKeys.size() == 1) {
129 for (std::list< varKey >::iterator it2 = netKeys.begin(); it2 != netKeys.end(); ++it2) {
155 std::list< Size >& nets =
myVarHashs_.getWithDefault(key, std::list< Size >());
157 for (std::list< Size >::iterator it = nets.begin(); it != nets.end(); ++it) {
180 template < GUM_Numeric GUM_SCALAR >
182 const std::vector< std::vector< std::vector< bool > > >& sample) {
185 for (
Size i = 0; i < sample.size(); i++)
186 for (
Size j = 0; j < sample[j].size(); j++)
187 for (
Size k = 0; k < sample[i][j].size(); k++)
196 template < GUM_Numeric GUM_SCALAR >
201 template < GUM_Numeric GUM_SCALAR >
202 const std::vector< std::vector< std::vector< bool > > >&
207 template < GUM_Numeric GUM_SCALAR >
208 const std::vector< std::vector< bool >* >
211 if (!
myVarHashs_.exists(key))
return std::vector< std::vector< bool >* >();
215 std::vector< dBN* > nets;
216 nets.resize(netsHash.size());
218 std::list< Size >::iterator it = netsHash.begin();
220 for (
Size i = 0; i < netsHash.size(); i++, ++it) {
227 template < GUM_Numeric GUM_SCALAR >
228 std::vector< std::vector< std::vector< std::vector< bool > > > >
230 if (
cnet_ ==
nullptr)
232 "No CredalNet associated to me ! Can't get FullBNOptsFromKey : " << key);
238 std::vector< std::vector< std::vector< std::vector< bool > > > > nets;
241 std::list< Size >::iterator it = netsHash.begin();
243 for (
Size i = 0; i < netsHash.size(); i++, ++it) {
245 dBN::iterator it2 =
myHashNet_ [*it] .begin();
250 nets[i][j][k][l] = *it2;
260 template < GUM_Numeric GUM_SCALAR >
Exception : operation not allowed.
Class template representing a Credal Network.
const NodeProperty< std::vector< std::vector< std::vector< GUM_SCALAR > > > > & credalNet_currentCpt() const
Size getEntrySize() const
Get the number of IBayesNet stored.
varHashs myVarHashs_
Map varKey - list(id) : get all optimal nets id from the given key : variable, modality and min=0 ( o...
const dBN & getCurrentSample()
Get the current sample as a vector of bits without structure.
dBN currentSample_
The current sampled IBayesNet.
std::vector< std::vector< std::vector< std::vector< bool > > > > getFullBNOptsFromKey(const std::vector< Size > &key)
Get optimum IBayesNet (s) with structure of the given variable, modality for min or max.
std::hash< std::vector< bool > > vectHash_
The hash fuction.
hashNet myHashNet_
Map id - dBN : get a net from it's id.
const std::vector< dBN * > getBNOptsFromKey(const std::vector< Size > &key)
Get optimum IBayesNet (s) without structure of the given variable, modality for min or max.
~VarMod2BNsMap()
Destructor.
const std::vector< std::vector< std::vector< bool > > > & getSampleDef()
Get the sample structure.
Size currentHash_
The current sampled IBayesNet hash.
bool insert(const std::vector< bool > &bn, const std::vector< Size > &key)
Insert for thread fusion.
void setCurrentSample(const std::vector< std::vector< std::vector< bool > > > &sample)
Set the current thread sample and it's hash.
void setCNet(const CredalNet< GUM_SCALAR > &cn)
Initialize sampleDef from the CredalNet.
const CredalNet< GUM_SCALAR > * cnet_
A pointer to the CredalNet to be used.
hashVars myHashVars_
Map id - list(varKey) : get all variables, modalities associated to this optimal net id.
std::vector< std::vector< std::vector< bool > > > sampleDef_
Since all samples have the same structure, this will be used as default initialization (copy construc...
VarMod2BNsMap(const CredalNet< GUM_SCALAR > &cn)
Thread constructor.
VarMod2BNsMap()
Default constructor that should be used only by InferenceEngine since it has a member variable.
#define GUM_ERROR(type, msg)
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Size NodeId
Type for node ids.
void superiorPow(unsigned long card, unsigned long &num_bits, unsigned long &new_card)
Compute the superior and closest power of two of an integer.
namespace for all credal networks entities
gum is the global namespace for all aGrUM entities
Class used to store optimum IBayesNet during some inference algorithms.