aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
clusteredLayerGenerator.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_CLUSTERED_LAYER_GENERATOR_H
50#define GUM_CLUSTERED_LAYER_GENERATOR_H
51
52#include <cstdlib>
53#include <ctime>
54#include <list>
55#include <sstream>
56#include <string>
57#include <vector>
58
60
61#include <string_view>
62
63namespace gum {
64 namespace prm {
65
73 template < GUM_Numeric GUM_SCALAR >
74 class ClusteredLayerGenerator: public PRMGenerator< GUM_SCALAR > {
75 public:
76 // ========================================================================
78 // ========================================================================
80
89
91 // ========================================================================
93 // ========================================================================
95
97 Size getDomainSize() const;
98
100 void setDomainSize(Size s);
101
104 Size getMaxParents() const;
105
108 void setMaxParents(Size s);
109
111 double getClusterRatio() const;
112
114 void setClusterRatio(double ratio);
115
123 void setLayers(const std::vector< typename LayerGenerator< GUM_SCALAR >::LayerData >& v);
124
125 std::vector< typename LayerGenerator< GUM_SCALAR >::LayerData >& getLayer();
126 const std::vector< typename LayerGenerator< GUM_SCALAR >::LayerData >& getLayer() const;
127
129 virtual PRM< GUM_SCALAR >* generate();
130
132
133 private:
134 std::vector< typename LayerGenerator< GUM_SCALAR >::LayerData > _layers_;
139
140 struct MyData {
141 // interface name
142 std::string i;
143 std::vector< std::string > a;
144 std::vector< std::string > g;
145 std::string r;
146 std::vector< std::string > c;
147 };
148
150
152 std::string_view type,
153 std::vector< MyData >& l);
154
156 std::string_view type,
157 std::vector< typename ClusteredLayerGenerator::MyData >& l);
158
160 std::string_view type,
161 std::vector< typename ClusteredLayerGenerator::MyData >& l,
162 Size lvl,
164
166 std::string_view type,
167 std::vector< typename ClusteredLayerGenerator::MyData >& l,
168 Size lvl,
170
171 void _generateClassDag_(Size lvl,
172 DAG& dag,
174 std::vector< typename ClusteredLayerGenerator::MyData >& l);
175
177 std::vector< typename ClusteredLayerGenerator::MyData >& l);
178 };
179
180 } /* namespace prm */
181} /* namespace gum */
182
184
185#endif /* GUM_CLUSTERED_LAYER_GENERATOR_H */
Base class for dag.
Definition DAG.h:121
The class for generic Hash Tables.
Definition hashTable.h:640
void _generateSystem_(PRMFactory< GUM_SCALAR > &factory, std::vector< typename ClusteredLayerGenerator::MyData > &l)
std::vector< typename LayerGenerator< GUM_SCALAR >::LayerData > & getLayer()
Getters and setters.
void _generateClassDag_(Size lvl, DAG &dag, Bijection< std::string, NodeId > &names, std::vector< typename ClusteredLayerGenerator::MyData > &l)
std::string _generateType_(PRMFactory< GUM_SCALAR > &f)
virtual PRM< GUM_SCALAR > * generate()
Proceeds with the generation of the PRM<GUM_SCALAR>.
Size getDomainSize() const
Getters and setters.
void _generateClasses_(PRMFactory< GUM_SCALAR > &f, std::string_view type, std::vector< typename ClusteredLayerGenerator::MyData > &l)
void _generateClass_(PRMFactory< GUM_SCALAR > &f, std::string_view type, std::vector< typename ClusteredLayerGenerator::MyData > &l, Size lvl, Set< std::string > &i)
void _generateCluster_(PRMFactory< GUM_SCALAR > &f, std::string_view type, std::vector< typename ClusteredLayerGenerator::MyData > &l, Size lvl, Set< std::string > &i)
void setLayers(const std::vector< typename LayerGenerator< GUM_SCALAR >::LayerData > &v)
Defines the structure of each layers.
std::vector< typename LayerGenerator< GUM_SCALAR >::LayerData > _layers_
void setClusterRatio(double ratio)
Define the odds of a given class to be replaced by a cluster.
HashTable< std::string, std::vector< std::string > * > _cluster_map_
void _generateInterfaces_(PRMFactory< GUM_SCALAR > &f, std::string_view type, std::vector< MyData > &l)
double getClusterRatio() const
Returns the odds of a given class to be replaced by a cluster.
Size getMaxParents() const
Returns the max number of parents allowed for any attribute or aggregator.
void setMaxParents(Size s)
Returns the max number of parents allowed for any attribute or aggregator.
ClusteredLayerGenerator & operator=(const ClusteredLayerGenerator &source)
Copy operator.
void setDomainSize(Size s)
Set the domain size of generated types.
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
Inline implementation of ClusteredLayerGenerator.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74
Headers 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