DDD  1.9.0.20240826145154
MLSHom.h
Go to the documentation of this file.
1 #ifndef __MLSHOM__H__
2 #define __MLSHOM__H__
3 
4 #include "ddd/AdditiveMap.hpp"
5 #include "ddd/SHom.h"
6 
7 class MLShom;
8 
11 
12 class _MLShom;
13 
14 class MLShom {
15 
18  friend MLShom operator+(const MLShom &,const MLShom &);
21  const _MLShom* concret;
22 
23  public :
24 
27  static const MLShom id;
28 
32 
33  MLShom(const GShom &h);
34  MLShom (const GShom & up, const MLShom & down);
35  MLShom (const _MLShom &);
37  MLShom (const _MLShom *);
38 
39 
46  MLShom(int var, const DataSet & val, const MLShom &h=MLShom::id);
47 
48  virtual ~MLShom();
49 
50 
51  bool operator<(const MLShom &h) const {return concret<h.concret;};
52  bool operator==(const MLShom &h) const {return concret==h.concret;};
57  size_t hash() const { return ddd::knuth32_hash(reinterpret_cast<const size_t>(concret)); };
58 
62  SHomNodeMap eval(const GSDD &) const ;
64  SHomNodeMap operator() (const GSDD &) const;
65 
66 
70  static void garbage();
71 
72 };
73 
79 MLShom operator+(const MLShom &,const MLShom &);
80 
81 class _MLShom {
84  mutable int refCounter;
89  mutable bool marking;
90 
92  friend class MLShom;
93 
95  virtual void mark() const{};
96 
97 
98 public:
99  _MLShom (int ref=0) : refCounter(ref),marking(false) {}
101  virtual bool shouldCache () const { return true ; }
102 
104  virtual ~_MLShom(){};
105  virtual SHomNodeMap eval(const GSDD &) const = 0;
106 
108  virtual size_t hash() const = 0;
109  virtual bool operator==(const _MLShom &h) const=0;
110  // for use by unique table : return new MyConcreteClassName(*this);
111  virtual _MLShom * clone () const =0 ;
112 
113 };
114 
115 class StrongMLShom : public _MLShom {
116  public :
117 
118  bool operator==(const _MLShom &h) const;
119 
120  virtual bool operator==(const StrongMLShom &) const=0;
121 
122  SHomNodeMap eval(const GSDD &) const ;
123 
125  virtual SHomHomMap phi (int var,const DataSet & val) const=0;
126  virtual SHomNodeMap phiOne () const=0;
127 
128 };
129 
130 #endif
AdditiveMap< GShom, GSDD > SHomNodeMap
Definition: MLSHom.h:7
MLShom operator+(const MLShom &, const MLShom &)
Composition by union of two homomorphisms.
Definition: MLSHom.cpp:239
AdditiveMap< GShom, MLShom > SHomHomMap
Definition: MLSHom.h:10
Definition: AdditiveMap.hpp:8
This class is an abstraction of a set of data.
Definition: DataSet.h:44
This class is the base class representing a hierarchical Set Decision Diagram.
Definition: SDD.h:49
This class is the base class for Homomorphisms over SDD.
Definition: SHom.h:57
Definition: MLSHom.h:14
static const MLShom id
Elementary homomorphism Identity, defined as a constant.
Definition: MLSHom.h:27
static void garbage()
Collects and destroys unused homomorphisms.
Definition: MLSHom.cpp:246
MLShom()
Default public constructor.
Definition: MLSHom.h:31
SHomNodeMap eval(const GSDD &) const
The computation function responsible for evaluation over a node.
const _MLShom * concret
The real implementation class.
Definition: MLSHom.h:21
SHomNodeMap operator()(const GSDD &) const
cache calls to eval
Definition: MLSHom.cpp:195
size_t hash() const
Hash key computation.
Definition: MLSHom.h:57
friend MLShom operator+(const MLShom &, const MLShom &)
By definition, as homomorphism are linear, (h+g) (d) = h(d) + g(d) ; Where g,h are homomorphisms and ...
Definition: MLSHom.cpp:239
bool operator==(const MLShom &h) const
Definition: MLSHom.h:52
MLShom(_MLShom *)
bool operator<(const MLShom &h) const
Definition: MLSHom.h:51
virtual ~MLShom()
Definition: MLSHom.cpp:185
Definition: MLSHom.h:115
virtual bool operator==(const StrongMLShom &) const =0
virtual SHomHomMap phi(int var, const DataSet &val) const =0
User defined behavior is input through this function.
bool operator==(const _MLShom &h) const
Definition: MLSHom.cpp:202
SHomNodeMap eval(const GSDD &) const
Definition: MLSHom.cpp:207
virtual SHomNodeMap phiOne() const =0
Definition: MLSHom.h:81
virtual bool shouldCache() const
test if caching should be done : default means should cache
Definition: MLSHom.h:101
virtual void mark() const
For garbage collection. Used in first phase of garbage collection.
Definition: MLSHom.h:95
_MLShom(int ref=0)
Definition: MLSHom.h:99
virtual size_t hash() const =0
unique table trivia
int refCounter
For garbage collection.
Definition: MLSHom.h:84
virtual bool operator==(const _MLShom &h) const =0
bool marking
For garbage collection.
Definition: MLSHom.h:89
virtual _MLShom * clone() const =0
virtual ~_MLShom()
Virtual Destructor.
Definition: MLSHom.h:104
virtual SHomNodeMap eval(const GSDD &) const =0
size_t knuth32_hash(size_t key)
Knuth's Multiplicative hash function.
Definition: hashfunc.hh:73

Please comment this page and report errors about it on the RefDocComments page.
Generated on Mon Aug 26 2024 14:54:00 for DDD by doxygen 1.9.1