aGrUM
3.2.0
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
layerGenerator.h
Go to the documentation of this file.
1
/****************************************************************************
2
* This file is part of the aGrUM/pyAgrum library. *
3
* *
4
* Copyright (c) 2005-2026 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-2026 *
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 GUM_LAYER_GENERATOR_H
50
#define GUM_LAYER_GENERATOR_H
51
#include <cstdlib>
52
#include <ctime>
53
#include <list>
54
#include <sstream>
55
#include <string>
56
#include <vector>
57
58
#include <
agrum/BN/generator/simpleBayesNetGenerator.h
>
59
#include <
agrum/PRM/generator/PRMGenerator.h
>
60
#include <
agrum/PRM/PRMFactory.h
>
61
62
#include <string_view>
63
64
namespace
gum
{
65
namespace
prm
{
66
74
template
< GUM_Numeric GUM_SCALAR >
75
class
LayerGenerator
:
public
PRMGenerator
< GUM_SCALAR > {
76
public
:
77
// ========================================================================
79
// ========================================================================
81
83
LayerGenerator
();
85
LayerGenerator
(
const
LayerGenerator
& source);
87
LayerGenerator
&
operator=
(
const
LayerGenerator
& source);
89
virtual
~LayerGenerator
();
90
92
// ========================================================================
94
// ========================================================================
96
99
struct
LayerData
{
100
// Number of attributes for the layer's interface.
101
Size
a
;
102
// Number of aggregates for the layer's interface.
103
Size
g
;
104
// Number of classes for this layer.
105
Size
c
;
106
// Number of instances for this layer.
107
Size
o
;
108
// Density of arcs between attributes of the same classe in this layer.
109
float
inner_density
;
110
// The odds of an instance of the precedent layer to be added to a
111
// reference slot of a class of this layer.
112
float
outter_density
;
113
};
114
116
Size
getDomainSize
()
const
;
117
119
void
setDomainSize
(
Size
s);
120
123
Size
getMaxParents
()
const
;
124
127
void
setMaxParents
(
Size
s);
128
136
void
setLayers
(
const
std::vector< LayerData >& v);
137
138
std::vector< LayerData >&
getLayer
();
139
const
std::vector< LayerData >&
getLayer
()
const
;
140
142
virtual
PRM< GUM_SCALAR >
*
generate
();
143
145
146
private
:
147
std::vector< LayerData >
_layers_
;
148
Size
_domain_size_
;
149
Size
_max_parents_
;
150
151
struct
MyData
{
152
// interface name
153
std::string
i
;
154
std::vector< std::string >
a
;
155
std::vector< std::string >
g
;
156
std::string
r
;
157
std::vector< std::string >
c
;
158
};
159
160
std::string
_generateType_
(
PRMFactory< GUM_SCALAR >
& f);
161
162
void
_generateInterfaces_
(
PRMFactory< GUM_SCALAR >
& f,
163
std::string_view type,
164
std::vector< MyData >& l);
165
166
void
_generateClasses_
(
PRMFactory< GUM_SCALAR >
& f,
167
std::string_view type,
168
std::vector< typename LayerGenerator::MyData >& l);
169
170
void
_generateClassDag_
(
Size
lvl,
171
DAG
& dag,
172
Bijection< std::string, NodeId >
& names,
173
std::vector< typename LayerGenerator::MyData >& l);
174
175
void
_generateSystem_
(
PRMFactory< GUM_SCALAR >
& factory,
176
std::vector< typename LayerGenerator::MyData >& l);
177
};
178
179
}
/* namespace prm */
180
}
/* namespace gum */
181
182
#include <
agrum/PRM/generator/layerGenerator_tpl.h
>
183
184
#endif
/* GUM_LAYER_GENERATOR_H */
PRMFactory.h
Headers of PRMFactory.
PRMGenerator.h
Headers of PRMGenerator.
gum::Bijection< std::string, NodeId >
gum::DAG
Base class for dag.
Definition
DAG.h:121
gum::prm::LayerGenerator::getDomainSize
Size getDomainSize() const
Returns the domain size of generated types.
Definition
layerGenerator_tpl.h:305
gum::prm::LayerGenerator::getMaxParents
Size getMaxParents() const
Returns the max number of parents allowed for any attribute or aggregator.
Definition
layerGenerator_tpl.h:315
gum::prm::LayerGenerator::_generateClassDag_
void _generateClassDag_(Size lvl, DAG &dag, Bijection< std::string, NodeId > &names, std::vector< typename LayerGenerator::MyData > &l)
Definition
layerGenerator_tpl.h:183
gum::prm::LayerGenerator::_generateType_
std::string _generateType_(PRMFactory< GUM_SCALAR > &f)
Definition
layerGenerator_tpl.h:71
gum::prm::LayerGenerator::setLayers
void setLayers(const std::vector< LayerData > &v)
Defines the structure of each layers.
Definition
layerGenerator_tpl.h:325
gum::prm::LayerGenerator::generate
virtual PRM< GUM_SCALAR > * generate()
Proceeds with the generation of the PRM<GUM_SCALAR>.
Definition
layerGenerator_tpl.h:56
gum::prm::LayerGenerator::setDomainSize
void setDomainSize(Size s)
Set the domain size of generated types.
Definition
layerGenerator_tpl.h:310
gum::prm::LayerGenerator::operator=
LayerGenerator & operator=(const LayerGenerator &source)
Copy operator.
Definition
layerGenerator_tpl.h:297
gum::prm::LayerGenerator::_generateClasses_
void _generateClasses_(PRMFactory< GUM_SCALAR > &f, std::string_view type, std::vector< typename LayerGenerator::MyData > &l)
Definition
layerGenerator_tpl.h:113
gum::prm::LayerGenerator::_layers_
std::vector< LayerData > _layers_
Definition
layerGenerator.h:147
gum::prm::LayerGenerator::_generateSystem_
void _generateSystem_(PRMFactory< GUM_SCALAR > &factory, std::vector< typename LayerGenerator::MyData > &l)
Definition
layerGenerator_tpl.h:233
gum::prm::LayerGenerator::_max_parents_
Size _max_parents_
Definition
layerGenerator.h:149
gum::prm::LayerGenerator::_generateInterfaces_
void _generateInterfaces_(PRMFactory< GUM_SCALAR > &f, std::string_view type, std::vector< MyData > &l)
Definition
layerGenerator_tpl.h:84
gum::prm::LayerGenerator::_domain_size_
Size _domain_size_
Definition
layerGenerator.h:148
gum::prm::LayerGenerator::getLayer
std::vector< LayerData > & getLayer()
Returns the domain size of generated types.
Definition
layerGenerator_tpl.h:332
gum::prm::LayerGenerator::setMaxParents
void setMaxParents(Size s)
Returns the max number of parents allowed for any attribute or aggregator.
Definition
layerGenerator_tpl.h:320
gum::prm::LayerGenerator::LayerGenerator
LayerGenerator()
Default constructor.
Definition
layerGenerator_tpl.h:278
gum::prm::PRMFactory
Factory which builds a PRM<GUM_SCALAR>.
Definition
PRMFactory.h:90
gum::prm::PRMGenerator::PRMGenerator
PRMGenerator()
Default constructor.
Definition
PRMGenerator_tpl.h:56
gum::prm::PRM
This class represents a Probabilistic Relational PRMSystem<GUM_SCALAR>.
Definition
PRM.h:74
gum::Size
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition
types.h:74
layerGenerator_tpl.h
Inline implementation of LayerGenerator.
gum::prm
namespace for all probabilistic relational models entities
Definition
agrum.h:68
gum
gum is the global namespace for all aGrUM entities
Definition
agrum.h:46
simpleBayesNetGenerator.h
Class for generating Bayesian networks.
gum::prm::LayerGenerator::LayerData
Getters and setters.
Definition
layerGenerator.h:99
gum::prm::LayerGenerator::LayerData::g
Size g
Definition
layerGenerator.h:103
gum::prm::LayerGenerator::LayerData::a
Size a
Definition
layerGenerator.h:101
gum::prm::LayerGenerator::LayerData::c
Size c
Definition
layerGenerator.h:105
gum::prm::LayerGenerator::LayerData::o
Size o
Definition
layerGenerator.h:107
gum::prm::LayerGenerator::LayerData::inner_density
float inner_density
Definition
layerGenerator.h:109
gum::prm::LayerGenerator::LayerData::outter_density
float outter_density
Definition
layerGenerator.h:112
gum::prm::LayerGenerator::MyData
Definition
layerGenerator.h:151
gum::prm::LayerGenerator::MyData::r
std::string r
Definition
layerGenerator.h:156
gum::prm::LayerGenerator::MyData::c
std::vector< std::string > c
Definition
layerGenerator.h:157
gum::prm::LayerGenerator::MyData::i
std::string i
Definition
layerGenerator.h:153
gum::prm::LayerGenerator::MyData::a
std::vector< std::string > a
Definition
layerGenerator.h:154
gum::prm::LayerGenerator::MyData::g
std::vector< std::string > g
Definition
layerGenerator.h:155
aGrUM
3.2.0
© PHW&CG&others - 2022
DoXyGeN 1.18.0