48 template <
typename GUM_SCALAR >
55 template <
typename GUM_SCALAR >
62 template <
typename GUM_SCALAR >
67 template <
typename GUM_SCALAR >
70 auto nNodes = cpt->size();
73 for (
NodeId node = 0; node < nNodes; node++) {
74 auto pConfs = (*cpt)[node].size();
77 for (
Size pconf = 0; pconf < pConfs; pconf++) {
78 Size nVertices =
Size((*cpt)[node][pconf].size());
80 superiorPow(
static_cast< unsigned long >(nVertices), b, c);
89 template <
typename GUM_SCALAR >
91 const std::vector< Size >& key) {
93 std::list< Size >& nets =
myVarHashs_.getWithDefault(key, std::list< Size >());
95 for (std::list< Size >::iterator it = nets.begin(); it != nets.end(); ++it) {
105 std::list< varKey >()) .push_back(key);
109 template <
typename GUM_SCALAR >
113 std::list< Size >& old_nets
114 =
myVarHashs_.getWithDefault(key, std::list< Size >());
117 for (std::list< Size >::iterator it = old_nets.begin(); it != old_nets.end(); ++it) {
119 std::list< varKey >& netKeys
120 =
myHashVars_.getWithDefault(*it, std::list< varKey >());
123 if (netKeys.size() == 1) {
128 for (std::list< varKey >::iterator it2 = netKeys.begin(); it2 != netKeys.end(); ++it2) {
154 std::list< Size >& nets =
myVarHashs_.getWithDefault(key, std::list< Size >());
156 for (std::list< Size >::iterator it = nets.begin(); it != nets.end(); ++it) {
179 template <
typename GUM_SCALAR >
181 const std::vector< std::vector< std::vector< bool > > >& sample) {
184 for (
Size i = 0; i < sample.size(); i++)
185 for (
Size j = 0; j < sample[j].size(); j++)
186 for (
Size k = 0; k < sample[i][j].size(); k++)
195 template <
typename GUM_SCALAR >
200 template <
typename GUM_SCALAR >
201 const std::vector< std::vector< std::vector< bool > > >&
206 template <
typename GUM_SCALAR >
207 const std::vector< std::vector< bool >* >
210 if (!
myVarHashs_.exists(key))
return std::vector< std::vector< bool >* >();
214 std::vector< dBN* > nets;
215 nets.resize(netsHash.size());
217 std::list< Size >::iterator it = netsHash.begin();
219 for (
Size i = 0; i < netsHash.size(); i++, ++it) {
226 template <
typename GUM_SCALAR >
227 std::vector< std::vector< std::vector< std::vector< bool > > > >
231 "No CredalNet associated to me ! Can't get FullBNOptsFromKey : " << key);
234 return std::vector< std::vector< std::vector< std::vector< bool > > > >();
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 <
typename 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.
const CredalNet< GUM_SCALAR > * cnet
A pointer to the CredalNet to be used.
~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.
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.