aGrUM 2.3.2
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-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_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
61namespace gum {
62 namespace prm {
63
71 template < typename GUM_SCALAR >
72 class ClusteredLayerGenerator: public PRMGenerator< GUM_SCALAR > {
73 public:
74 // ========================================================================
76 // ========================================================================
78
87
89 // ========================================================================
91 // ========================================================================
93
95 Size getDomainSize() const;
96
98 void setDomainSize(Size s);
99
102 Size getMaxParents() const;
103
106 void setMaxParents(Size s);
107
109 double getClusterRatio() const;
110
112 void setClusterRatio(double ratio);
113
121 void setLayers(const std::vector< typename LayerGenerator< GUM_SCALAR >::LayerData >& v);
122
123 std::vector< typename LayerGenerator< GUM_SCALAR >::LayerData >& getLayer();
124 const std::vector< typename LayerGenerator< GUM_SCALAR >::LayerData >& getLayer() const;
125
127 virtual PRM< GUM_SCALAR >* generate();
128
130
131 private:
132 std::vector< typename LayerGenerator< GUM_SCALAR >::LayerData > _layers_;
137
138 struct MyData {
139 // interface name
140 std::string i;
141 std::vector< std::string > a;
142 std::vector< std::string > g;
143 std::string r;
144 std::vector< std::string > c;
145 };
146
148
150 const std::string& type,
151 std::vector< MyData >& l);
152
154 const std::string& type,
155 std::vector< typename ClusteredLayerGenerator::MyData >& l);
156
158 const std::string& type,
159 std::vector< typename ClusteredLayerGenerator::MyData >& l,
160 Size lvl,
162
164 const std::string& type,
165 std::vector< typename ClusteredLayerGenerator::MyData >& l,
166 Size lvl,
168
169 void _generateClassDag_(Size lvl,
170 DAG& dag,
172 std::vector< typename ClusteredLayerGenerator::MyData >& l);
173
175 std::vector< typename ClusteredLayerGenerator::MyData >& l);
176 };
177
178 } /* namespace prm */
179} /* namespace gum */
180
182
183#endif /* GUM_CLUSTERED_LAYER_GENERATOR_H */
Base class for dag.
Definition DAG.h:121
The class for generic Hash Tables.
Definition hashTable.h:637
Size getDomainSize() const
Getters and setters.
void _generateClasses_(PRMFactory< GUM_SCALAR > &f, const std::string &type, std::vector< typename ClusteredLayerGenerator::MyData > &l)
void _generateSystem_(PRMFactory< GUM_SCALAR > &factory, std::vector< typename ClusteredLayerGenerator::MyData > &l)
ClusteredLayerGenerator & operator=(const ClusteredLayerGenerator &source)
Copy operator.
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>.
void _generateInterfaces_(PRMFactory< GUM_SCALAR > &f, const std::string &type, std::vector< MyData > &l)
double getClusterRatio() const
Returns the odds of a given class to be replaced by a cluster.
void setLayers(const std::vector< typename LayerGenerator< GUM_SCALAR >::LayerData > &v)
Defines the structure of each layers.
void setClusterRatio(double ratio)
Define the odds of a given class to be replaced by a cluster.
void _generateClass_(PRMFactory< GUM_SCALAR > &f, const std::string &type, std::vector< typename ClusteredLayerGenerator::MyData > &l, Size lvl, Set< std::string > &i)
std::vector< typename LayerGenerator< GUM_SCALAR >::LayerData > _layers_
HashTable< std::string, std::vector< std::string > * > _cluster_map_
Size getMaxParents() const
Returns the max number of parents allowed for any attribute or aggregator.
void _generateCluster_(PRMFactory< GUM_SCALAR > &f, const std::string &type, std::vector< typename ClusteredLayerGenerator::MyData > &l, Size lvl, Set< std::string > &i)
void setMaxParents(Size s)
Returns the max number of parents allowed for any attribute or aggregator.
void setDomainSize(Size s)
Set the domain size of generated types.
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
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