aGrUM 2.3.2
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-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 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
62namespace gum {
63 namespace prm {
64
72 template < typename GUM_SCALAR >
73 class LayerGenerator: public PRMGenerator< GUM_SCALAR > {
74 public:
75 // ========================================================================
77 // ========================================================================
79
83 LayerGenerator(const LayerGenerator& source);
87 virtual ~LayerGenerator();
88
90 // ========================================================================
92 // ========================================================================
94
97 struct LayerData {
98 // Number of attributes for the layer's interface.
100 // Number of aggregates for the layer's interface.
102 // Number of classes for this layer.
104 // Number of instances for this layer.
106 // Density of arcs between attributes of the same classe in this layer.
108 // The odds of an instance of the precedent layer to be added to a
109 // reference slot of a class of this layer.
111 };
112
114 Size getDomainSize() const;
115
117 void setDomainSize(Size s);
118
121 Size getMaxParents() const;
122
125 void setMaxParents(Size s);
126
134 void setLayers(const std::vector< LayerData >& v);
135
136 std::vector< LayerData >& getLayer();
137 const std::vector< LayerData >& getLayer() const;
138
140 virtual PRM< GUM_SCALAR >* generate();
141
143
144 private:
145 std::vector< LayerData > _layers_;
148
149 struct MyData {
150 // interface name
151 std::string i;
152 std::vector< std::string > a;
153 std::vector< std::string > g;
154 std::string r;
155 std::vector< std::string > c;
156 };
157
159
161 const std::string& type,
162 std::vector< MyData >& l);
163
165 const std::string& type,
166 std::vector< typename LayerGenerator::MyData >& l);
167
168 void _generateClassDag_(Size lvl,
169 DAG& dag,
171 std::vector< typename LayerGenerator::MyData >& l);
172
174 std::vector< typename LayerGenerator::MyData >& l);
175 };
176
177 } /* namespace prm */
178} /* namespace gum */
179
181
182#endif /* GUM_LAYER_GENERATOR_H */
Headers of PRMFactory.
Headers of PRMGenerator.
Base class for dag.
Definition DAG.h:121
void _generateInterfaces_(PRMFactory< GUM_SCALAR > &f, const std::string &type, std::vector< MyData > &l)
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 _generateClasses_(PRMFactory< GUM_SCALAR > &f, const std::string &type, std::vector< typename LayerGenerator::MyData > &l)
Size getDomainSize() const
Returns the domain size of generated types.
virtual PRM< GUM_SCALAR > * generate()
Proceeds with the generation of the PRM<GUM_SCALAR>.
std::vector< LayerData > _layers_
void _generateSystem_(PRMFactory< GUM_SCALAR > &factory, std::vector< typename LayerGenerator::MyData > &l)
LayerGenerator & operator=(const LayerGenerator &source)
Copy operator.
void setDomainSize(Size s)
Set the domain size of generated types.
virtual ~LayerGenerator()
Destructor.
void setMaxParents(Size s)
Returns the max number of parents allowed for any attribute or aggregator.
std::vector< LayerData > & getLayer()
Returns the domain size of generated types.
Size getMaxParents() const
Returns the max number of parents allowed for any attribute or aggregator.
LayerGenerator()
Default constructor.
void setLayers(const std::vector< LayerData > &v)
Defines the structure of each layers.
Factory which builds a PRM<GUM_SCALAR>.
Definition PRMFactory.h:88
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