DDD 1.9.0.20250409152518
MLHom.h
Go to the documentation of this file.
1/****************************************************************************/
2/* */
3/* This file is part of libDDD, a library for manipulation of DDD and SDD. */
4/* */
5/* Copyright (C) 2001-2008 Yann Thierry-Mieg, Jean-Michel Couvreur */
6/* and Denis Poitrenaud */
7/* */
8/* This program is free software; you can redistribute it and/or modify */
9/* it under the terms of the GNU Lesser General Public License as */
10/* published by the Free Software Foundation; either version 3 of the */
11/* License, or (at your option) any later version. */
12/* This program is distributed in the hope that it will be useful, */
13/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
14/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
15/* GNU LEsserGeneral Public License for more details. */
16/* */
17/* You should have received a copy of the GNU Lesser General Public License */
18/* along with this program; if not, write to the Free Software */
19/*Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
20/* */
21/****************************************************************************/
22
23#ifndef __MLHOM__H__
24#define __MLHOM__H__
25
26#include "ddd/Hom.h"
27#include "ddd/AdditiveMap.hpp"
28
29class MLHom;
30
32
34
35
36class _MLHom;
37class StrongMLHom;
38
39class MLHom {
40
43 friend MLHom operator+(const MLHom &,const MLHom &);
47
48#ifdef HASH_STAT
49 // open access to instrumented hashtable
50 template <class Value, class Key, class HashFcn,
51 class ExtractKey, class SetKey, class EqualKey, class Alloc>
52 friend class google::sparse_hashtable;
53#endif
54
55public :
56
59 static const MLHom id;
60
64
65 MLHom(const GHom &h);
66 MLHom (const GHom & up, const MLHom & down);
67 MLHom (const _MLHom &);
69 MLHom (const _MLHom *);
70
71
78 MLHom(int var, int val, const MLHom &h=MLHom::id);
79
80 virtual ~MLHom();
81
82
83 bool operator<(const MLHom &h) const {return concret<h.concret;};
84 bool operator==(const MLHom &h) const {return concret==h.concret;};
89 size_t hash() const { return ddd::knuth32_hash(reinterpret_cast<size_t>(concret)); };
90
94 HomNodeMap eval(const GDDD &d) const ;
96 HomNodeMap operator() (const GDDD &) const;
97
98
102 static void garbage();
103
104};
105
111MLHom operator+(const MLHom &,const MLHom &);
112
113class _MLHom {
116 mutable int refCounter;
121 mutable bool marking;
122
124 friend class MLHom;
125
127 virtual void mark() const{};
128
129
130public:
131 _MLHom (int ref=0) : refCounter(ref),marking(false) {}
133 virtual bool shouldCache () const { return true ; }
134
136 virtual ~_MLHom(){};
137 virtual HomNodeMap eval(const GDDD &) const = 0;
138
140 virtual size_t hash() const = 0;
141 virtual bool operator==(const _MLHom &h) const=0;
142 // for use by unique table : return new MyConcreteClassName(*this);
143 virtual _MLHom * clone () const =0 ;
144
145};
146
147class StrongMLHom : public _MLHom {
148public :
149
150 bool operator==(const _MLHom &h) const;
151
152 virtual bool operator==(const StrongMLHom &) const=0;
153
154 HomNodeMap eval(const GDDD &) const ;
155
157 virtual HomHomMap phi (int var,int val) const=0;
158 virtual HomNodeMap phiOne () const=0;
159
160};
161
162#endif
AdditiveMap< GHom, MLHom > HomHomMap
Definition MLHom.h:33
AdditiveMap< GHom, GDDD > HomNodeMap
Definition MLHom.h:31
MLHom operator+(const MLHom &, const MLHom &)
Composition by union of two homomorphisms.
Definition MLHom.cpp:279
Definition AdditiveMap.hpp:8
This class is the base class representing a Data Decision Diagram.
Definition DDD.h:49
This class is the base class representing a homomorphism over DDD.
Definition Hom.h:55
Definition MLHom.h:39
HomNodeMap eval(const GDDD &d) const
The computation function responsible for evaluation over a node.
Definition MLHom.cpp:229
bool operator==(const MLHom &h) const
Definition MLHom.h:84
const _MLHom * concret
The real implementation class.
Definition MLHom.h:46
MLHom()
Default public constructor.
Definition MLHom.h:63
bool operator<(const MLHom &h) const
Definition MLHom.h:83
MLHom(_MLHom *)
static const MLHom id
Elementary homomorphism Identity, defined as a constant.
Definition MLHom.h:59
size_t hash() const
Hash key computation.
Definition MLHom.h:89
virtual ~MLHom()
Definition MLHom.cpp:219
HomNodeMap operator()(const GDDD &) const
cache calls to eval
Definition MLHom.cpp:233
static void garbage()
Collects and destroys unused homomorphisms.
Definition MLHom.cpp:286
friend MLHom operator+(const MLHom &, const MLHom &)
By definition, as homomorphism are linear, (h+g) (d) = h(d) + g(d) ;.
Definition MLHom.cpp:279
Definition MLHom.h:147
HomNodeMap eval(const GDDD &) const
Definition MLHom.cpp:247
virtual HomNodeMap phiOne() const =0
bool operator==(const _MLHom &h) const
Definition MLHom.cpp:242
virtual bool operator==(const StrongMLHom &) const =0
virtual HomHomMap phi(int var, int val) const =0
User defined behavior is input through this function.
Definition MLHom.h:113
virtual void mark() const
For garbage collection. Used in first phase of garbage collection.
Definition MLHom.h:127
bool marking
For garbage collection.
Definition MLHom.h:121
virtual size_t hash() const =0
unique table trivia
virtual bool shouldCache() const
test if caching should be done : default means should cache
Definition MLHom.h:133
virtual ~_MLHom()
Virtual Destructor.
Definition MLHom.h:136
int refCounter
For garbage collection.
Definition MLHom.h:116
virtual bool operator==(const _MLHom &h) const =0
virtual HomNodeMap eval(const GDDD &) const =0
_MLHom(int ref=0)
Definition MLHom.h:131
virtual _MLHom * clone() 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 Wed Apr 9 2025 15:27:42 for DDD by doxygen 1.9.8