aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
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
61
62#include <string_view>
63
64namespace gum {
65 namespace prm {
66
74 template < GUM_Numeric GUM_SCALAR >
75 class LayerGenerator: public PRMGenerator< GUM_SCALAR > {
76 public:
77 // ========================================================================
79 // ========================================================================
81
85 LayerGenerator(const LayerGenerator& source);
89 virtual ~LayerGenerator();
90
92 // ========================================================================
94 // ========================================================================
96
99 struct LayerData {
100 // Number of attributes for the layer's interface.
102 // Number of aggregates for the layer's interface.
104 // Number of classes for this layer.
106 // Number of instances for this layer.
108 // Density of arcs between attributes of the same classe in this layer.
110 // The odds of an instance of the precedent layer to be added to a
111 // reference slot of a class of this layer.
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_;
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
161
163 std::string_view type,
164 std::vector< MyData >& l);
165
167 std::string_view type,
168 std::vector< typename LayerGenerator::MyData >& l);
169
170 void _generateClassDag_(Size lvl,
171 DAG& dag,
173 std::vector< typename LayerGenerator::MyData >& l);
174
176 std::vector< typename LayerGenerator::MyData >& l);
177 };
178
179 } /* namespace prm */
180} /* namespace gum */
181
183
184#endif /* GUM_LAYER_GENERATOR_H */
Headers of PRMFactory.
Headers of PRMGenerator.
Base class for dag.
Definition DAG.h:121
Size getDomainSize() const
Returns the domain size of generated types.
Size getMaxParents() const
Returns the max number of parents allowed for any attribute or aggregator.
void _generateClassDag_(Size lvl, DAG &dag, Bijection< std::string, NodeId > &names, std::vector< typename LayerGenerator::MyData > &l)
std::string _generateType_(PRMFactory< GUM_SCALAR > &f)
void setLayers(const std::vector< LayerData > &v)
Defines the structure of each layers.
virtual PRM< GUM_SCALAR > * generate()
Proceeds with the generation of the PRM<GUM_SCALAR>.
void setDomainSize(Size s)
Set the domain size of generated types.
LayerGenerator & operator=(const LayerGenerator &source)
Copy operator.
void _generateClasses_(PRMFactory< GUM_SCALAR > &f, std::string_view type, std::vector< typename LayerGenerator::MyData > &l)
std::vector< LayerData > _layers_
void _generateSystem_(PRMFactory< GUM_SCALAR > &factory, std::vector< typename LayerGenerator::MyData > &l)
void _generateInterfaces_(PRMFactory< GUM_SCALAR > &f, std::string_view type, std::vector< MyData > &l)
virtual ~LayerGenerator()
Destructor.
std::vector< LayerData > & getLayer()
Returns the domain size of generated types.
void setMaxParents(Size s)
Returns the max number of parents allowed for any attribute or aggregator.
LayerGenerator()
Default constructor.
Factory which builds a PRM<GUM_SCALAR>.
Definition PRMFactory.h:90
PRMGenerator()
Default constructor.
This class represents a Probabilistic Relational PRMSystem<GUM_SCALAR>.
Definition PRM.h:74
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74
Inline implementation of LayerGenerator.
namespace for all probabilistic relational models entities
Definition agrum.h:68
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
Class for generating Bayesian networks.
std::vector< std::string > c
std::vector< std::string > a
std::vector< std::string > g