aGrUM  0.14.2
clusteredLayerGenerator.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
27 #ifndef GUM_CLUSTERED_LAYER_GENERATOR_H
28 #define GUM_CLUSTERED_LAYER_GENERATOR_H
29 
30 #include <cstdlib>
31 #include <ctime>
32 #include <list>
33 #include <sstream>
34 #include <string>
35 #include <vector>
36 
38 
39 #include <agrum/PRM/PRMFactory.h>
42 
43 namespace gum {
44  namespace prm {
45 
53  template < typename GUM_SCALAR >
54  class ClusteredLayerGenerator : public PRMGenerator< GUM_SCALAR > {
55  public:
56  // ========================================================================
58  // ========================================================================
60 
68  virtual ~ClusteredLayerGenerator();
69 
71  // ========================================================================
73  // ========================================================================
75 
77  Size getDomainSize() const;
78 
80  void setDomainSize(Size s);
81 
84  Size getMaxParents() const;
85 
88  void setMaxParents(Size s);
89 
91  double getClusterRatio() const;
92 
94  void setClusterRatio(double ratio);
95 
103  void setLayers(
104  const std::vector< typename LayerGenerator< GUM_SCALAR >::LayerData >& v);
105 
106  std::vector< typename LayerGenerator< GUM_SCALAR >::LayerData >& getLayer();
107  const std::vector< typename LayerGenerator< GUM_SCALAR >::LayerData >&
108  getLayer() const;
109 
111  virtual PRM< GUM_SCALAR >* generate();
112 
114  private:
115  std::vector< typename LayerGenerator< GUM_SCALAR >::LayerData > __layers;
120 
121  struct MyData {
122  // interface name
123  std::string i;
124  std::vector< std::string > a;
125  std::vector< std::string > g;
126  std::string r;
127  std::vector< std::string > c;
128  };
129 
131 
133  const std::string& type,
134  std::vector< MyData >& l);
135 
136  void __generateClasses(
138  const std::string& type,
139  std::vector< typename ClusteredLayerGenerator::MyData >& l);
140 
141  void __generateCluster(
143  const std::string& type,
144  std::vector< typename ClusteredLayerGenerator::MyData >& l,
145  Size lvl,
147 
148  void __generateClass(
150  const std::string& type,
151  std::vector< typename ClusteredLayerGenerator::MyData >& l,
152  Size lvl,
154 
155  void __generateClassDag(
156  Size lvl,
157  DAG& dag,
159  std::vector< typename ClusteredLayerGenerator::MyData >& l);
160 
161  void __generateSystem(
162  PRMFactory< GUM_SCALAR >& factory,
163  std::vector< typename ClusteredLayerGenerator::MyData >& l);
164  };
165 
166  } /* namespace prm */
167 } /* namespace gum */
168 
170 
171 #endif /* GUM_CLUSTERED_LAYER_GENERATOR_H */
This class is the base class to all PRM generators.
Definition: PRMGenerator.h:46
HashTable< std::string, std::vector< std::string > *> __cluster_map
Headers of PRMGenerator.
Size getMaxParents() const
Returns the max number of parents allowed for any attribute or aggregator.
<agrum/PRM/generator/clusteredLayerGenerator.h>
Class for generating bayesian networks.
std::string __generateType(PRMFactory< GUM_SCALAR > &f)
void __generateSystem(PRMFactory< GUM_SCALAR > &factory, std::vector< typename ClusteredLayerGenerator::MyData > &l)
void setLayers(const std::vector< typename LayerGenerator< GUM_SCALAR >::LayerData > &v)
Defines the structure of each layers.
Headers of LayerGenerator.
std::vector< typename LayerGenerator< GUM_SCALAR >::LayerData > & getLayer()
Getters and setters.
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
double getClusterRatio() const
Returns the odds of a given class to be replaced by a cluster.
The class for generic Hash Tables.
Definition: hashTable.h:676
ClusteredLayerGenerator & operator=(const ClusteredLayerGenerator &source)
Copy operator.
void __generateInterfaces(PRMFactory< GUM_SCALAR > &f, const std::string &type, std::vector< MyData > &l)
Inline implementation of ClusteredLayerGenerator.
std::vector< typename LayerGenerator< GUM_SCALAR >::LayerData > __layers
Factory which builds a PRM<GUM_SCALAR>.
Definition: PRMType.h:47
void __generateClassDag(Size lvl, DAG &dag, Bijection< std::string, NodeId > &names, std::vector< typename ClusteredLayerGenerator::MyData > &l)
void __generateClasses(PRMFactory< GUM_SCALAR > &f, const std::string &type, std::vector< typename ClusteredLayerGenerator::MyData > &l)
virtual PRM< GUM_SCALAR > * generate()
Proceeds with the generation of the PRM<GUM_SCALAR>.
This class represents a Probabilistic Relational PRMSystem<GUM_SCALAR>.
Definition: PRM.h:63
void __generateClass(PRMFactory< GUM_SCALAR > &f, const std::string &type, std::vector< typename ClusteredLayerGenerator::MyData > &l, Size lvl, Set< std::string > &i)
void setClusterRatio(double ratio)
Define the odds of a given class to be replaced by a cluster.
void setDomainSize(Size s)
Set the domain size of generated types.
void setMaxParents(Size s)
Returns the max number of parents allowed for any attribute or aggregator.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:45
void __generateCluster(PRMFactory< GUM_SCALAR > &f, const std::string &type, std::vector< typename ClusteredLayerGenerator::MyData > &l, Size lvl, Set< std::string > &i)
Base class for dag.
Definition: DAG.h:99
Size getDomainSize() const
Getters and setters.
Headers of PRMFactory.