aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
varMod2BNsMap.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2025 by *
5 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
6 * - Christophe GONZALES(_at_AMU) *
7 * *
8 * The aGrUM/pyAgrum library is free software; you can redistribute it *
9 * and/or modify it under the terms of either : *
10 * *
11 * - the GNU Lesser General Public License as published by *
12 * the Free Software Foundation, either version 3 of the License, *
13 * or (at your option) any later version, *
14 * - the MIT license (MIT), *
15 * - or both in dual license, as here. *
16 * *
17 * (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18 * *
19 * This aGrUM/pyAgrum library is distributed in the hope that it will be *
20 * useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26 * OTHER DEALINGS IN THE SOFTWARE. *
27 * *
28 * See LICENCES for more details. *
29 * *
30 * SPDX-FileCopyrightText: Copyright 2005-2025 *
31 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
32 * - Christophe GONZALES(_at_AMU) *
33 * SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34 * *
35 * Contact : info_at_agrum_dot_org *
36 * homepage : http://agrum.gitlab.io *
37 * gitlab : https://gitlab.com/agrumery/agrum *
38 * *
39 ****************************************************************************/
40
41
48
49#ifndef __VAR_MOD_2_BNS_MAP__H__
50#define __VAR_MOD_2_BNS_MAP__H__
51
52#include <list>
53
54// #include <tr1/functional>
55
56
57#include <agrum/CN/credalNet.h>
58
59namespace gum {
60 namespace credal {
61
71
72 template < typename GUM_SCALAR >
74 using dBN = std::vector< bool >;
75 using varKey = std::vector< Size >;
79
80 protected:
90
94 std::vector< std::vector< std::vector< bool > > > sampleDef_;
95
101 std::hash< std::vector< bool > > vectHash_;
102
105
106 public:
109
116 explicit VarMod2BNsMap(const CredalNet< GUM_SCALAR >& cn);
117
122
125
127
137 bool insert(const std::vector< bool >& bn, const std::vector< Size >& key);
138
146 bool insert(const std::vector< Size >& key, const bool isBetter);
147
150
158 void setCNet(const CredalNet< GUM_SCALAR >& cn);
159
164 void setCurrentSample(const std::vector< std::vector< std::vector< bool > > >& sample);
165
171 const dBN& getCurrentSample();
172
177 const std::vector< std::vector< std::vector< bool > > >& getSampleDef();
178
187 const std::vector< dBN* > getBNOptsFromKey(const std::vector< Size >& key);
188
196 std::vector< std::vector< std::vector< std::vector< bool > > > >
197 getFullBNOptsFromKey(const std::vector< Size >& key);
198
200 Size getEntrySize() const;
201
203
204 }; // end of OptBN
205
206
207#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
208 extern template class VarMod2BNsMap< double >;
209#endif
210
211 } // namespace credal
212} // namespace gum
213
215
216#endif
Class template representing a Credal Network.
Definition credalNet.h:97
Class used to store optimum IBayesNet during some inference algorithms.
Size getEntrySize() const
Get the number of IBayesNet stored.
std::vector< Size > varKey
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.
gum::HashTable< Size, dBN > hashNet
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.
const std::vector< std::vector< std::vector< bool > > > & getSampleDef()
Get the sample structure.
std::vector< bool > dBN
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.
gum::HashTable< varKey, std::list< Size > > varHashs
gum::HashTable< Size, std::list< varKey > > hashVars
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.
Class representing Credal Networks.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74
namespace for all credal networks entities
Definition agrum.h:61
gum is the global namespace for all aGrUM entities
Definition agrum.h:46