DDD
1.9.0.20240826145154
|
This class is the base class representing a Data Decision Diagram. More...
#include <DDD.h>
Public Types | |
typedef unsigned int | id_t |
Public Member Functions | |
Public Constructors | |
GDDD (int variable, const Valuation &value) | |
Construct a GDDD with arguments given. More... | |
GDDD () | |
Default constructor creates the empty set DDD. More... | |
GDDD (int var, val_t val, const GDDD &d=one) | |
The most common way for the user of creating DDD. More... | |
GDDD (int var, val_t val1, val_t val2, const GDDD &d=one) | |
To create a DDD with arcs covering a range of values. More... | |
Comparisons for hash and map storage | |
bool | operator== (const GDDD &g) const |
Comparison between DDD. More... | |
bool | operator!= (const GDDD &g) const |
Comparison between DDD. More... | |
bool | operator< (const GDDD &g) const |
Total ordering function between DDD. More... | |
unsigned int | refCounter () const |
Returns current reference count of a node. More... | |
unsigned long int | size () const |
Returns the size in number of nodes of a DDD structure. More... | |
size_t | nbsons () const |
Returns the number of successors of a given node. This is the size of the arc array of the node. More... | |
long double | nbStates () const |
Returns the number of states or paths represented by a given node. More... | |
long double | noSharedSize () const |
Returns the number of nodes that would be used to represent a DDD if no unicity table was used. More... | |
Static Public Member Functions | |
Variable naming. | |
static void | varName (int var, const std::string &name) |
Sets a variable's name. More... | |
static const std::string | getvarName (int var) |
Gets a variable's name. More... | |
Static Public Attributes | |
Terminal nodes defined as constants | |
static const GDDD | one |
The accepting terminal. This is the basic leaf for accepted sequences. More... | |
static const GDDD | null |
The non-accepting terminal. More... | |
static const GDDD | top |
The approximation terminal. More... | |
Private Member Functions | |
GDDD (const id_t &_g) | |
A private constructor used in internals. More... | |
GDDD (_GDDD *_g) | |
UNIMPLEMENTED DELIBERATELY: see SHom.h for details. More... | |
void | print (std::ostream &os, std::string s) const |
Internal function used in recursion for textual printing of GDDD. More... | |
void | saveNode (std::ostream &, std::vector< id_t > &) const |
A function for DDD serialization (beta). More... | |
unsigned long int | nodeIndex (const std::vector< id_t > &) const |
Another function used in serialization. More... | |
Private Attributes | |
id_t | concret |
The real implementation class. More... | |
Friends | |
class | DDD |
Open access to concret for reference counting in DDD. More... | |
std::ostream & | operator<< (std::ostream &os, const GDDD &g) |
A textual output. More... | |
Serialization functions. | |
void | saveDDD (std::ostream &, std::vector< DDD >) |
Function for serialization. Save a set of DDD to a stream. More... | |
void | loadDDD (std::istream &, std::vector< DDD > &) |
Function for deserialization. Load a set of DDD from a stream. More... | |
Public Accessors | |
typedef short | val_t |
The type used as values of variables in a DDD. More... | |
typedef unsigned short | valsz_t |
A type wide enough to count how many outgoing edges a DDD node has, should be congruent to val_t. More... | |
typedef std::pair< val_t, GDDD > | edge_t |
An edge is a pair <value,child node> More... | |
typedef std::vector< edge_t > | Valuation |
To hide how arcs are actually stored. Use GDDD::Valuation to refer to arcs type. More... | |
typedef const edge_t * | const_iterator |
To hide how arcs are stored. More... | |
int | variable () const |
Returns a node's variable. More... | |
const_iterator | begin () const |
API for iterating over the arcs of a DDD manually. More... | |
const_iterator | end () const |
API for iterating over the arcs of a DDD manually. More... | |
Memory Management | |
void | mark () const |
For garbage collection internals. More... | |
size_t | hash () const |
For storage in a hash table. More... | |
static unsigned int | statistics () |
Returns unicity table current size. Gives the number of different nodes created and not yet destroyed. More... | |
static void | garbage () |
For garbage collection, do not call this directly, use MemoryManager::garbage() instead. More... | |
static void | pstats (bool reinit=true) |
Prints some statistics to std::cout. More... | |
static size_t | peak () |
Returns the peak size of the DDD unicity table. This value is maintained up to date upon GarbageCollection. More... | |
This class is the base class representing a Data Decision Diagram.
It is composed of a set of arcs labeled by integers that point to successor GDDD nodes. This class does not implement reference counting : GDDD are destroyed on MemoryManager::Garbage unless they are also referenced as DDD. Note that this class is in fact a kind of smart pointer : operations are delegated on "concret" the true implementation class (of private hidden type _GDDD) that contains the data and has a single memory occurrence thanks to the unicity table.
typedef const edge_t* GDDD::const_iterator |
To hide how arcs are stored.
Also for more compact expressions : use GDDD::const_iterator to iterate over the arcs of a DDD
typedef std::pair<val_t,GDDD> GDDD::edge_t |
An edge is a pair <value,child node>
typedef unsigned int GDDD::id_t |
typedef short GDDD::val_t |
The type used as values of variables in a DDD.
typedef unsigned short GDDD::valsz_t |
A type wide enough to count how many outgoing edges a DDD node has, should be congruent to val_t.
typedef std::vector<edge_t > GDDD::Valuation |
To hide how arcs are actually stored. Use GDDD::Valuation to refer to arcs type.
|
private |
A private constructor used in internals.
_g | The pointer provided should point into the unicity table |
|
private |
UNIMPLEMENTED DELIBERATELY: see SHom.h for details.
user should use version above const & or below const * into unique storage.
GDDD::GDDD | ( | int | variable, |
const Valuation & | value | ||
) |
Construct a GDDD with arguments given.
variable | the variable labeling the node |
value | the set of arcs of the node |
References concret, _GDDD::create_unique_GDDD(), GDDD(), and variable().
The most common way for the user of creating DDD.
This constructor builds a node with a single arc of the form var-val->d. Usually a user will create these single path DDD, possibly by imbrication as in GDDD(var1, val1, GDDD( var2, val2 )). Then compose them using +, -, *, ^ ...
var | the variable labeling the node |
val | the value labeling the arc |
d | the successor node or defaults to terminal GDDD::one if none provided |
References concret, and _GDDD::create_unique_GDDD().
To create a DDD with arcs covering a range of values.
This interface creates nodes with a set of arcs bearing the values in the interval [val1,var2] that point to the same successor node d.
var | the variable labeling the node |
val1 | lowest value labeling an arc |
val2 | highest value labeling an arc |
d | the successor node or defaults to terminal GDDD::one if none provided |
References concret, and _GDDD::create_unique_GDDD().
GDDD::const_iterator GDDD::begin | ( | ) | const |
API for iterating over the arcs of a DDD manually.
i.e. not using a predefined evaluation mechanism such as StrongHom
for (GDDD::const_iterator it = a_gddd.begin() ; it != a_gddd.end() ; it++ ) { // do something }
returns the first arc
References _GDDD::begin(), concret, and _GDDD::resolve().
Referenced by DED::add(), dotExporter::collect(), _DED_Mult::eval(), _DED_Minus::eval(), _DED_Concat::eval(), StrongHom::eval(), StrongMLHom::eval(), Apply2k::eval(), DomExtract::eval(), _GHom::eval_skip(), StrongHom::has_image(), _GHom::has_image_skip(), _setVarConst::invert(), _incVar::invert(), MySize::mysize(), MyNbStates::nbStates(), print(), saveNode(), and SddSize::sddsize().
GDDD::const_iterator GDDD::end | ( | ) | const |
API for iterating over the arcs of a DDD manually.
i.e. not using a predefined evaluation mechanism such as StrongHom
for (GDDD::const_iterator it = a_gddd.begin() ; it != a_gddd.end() ; it++ ) { // do something }
returns a past the end iterator
References concret, _GDDD::end(), and _GDDD::resolve().
Referenced by dotExporter::collect(), _DED_Mult::eval(), _DED_Minus::eval(), _DED_Concat::eval(), StrongHom::eval(), StrongMLHom::eval(), Apply2k::eval(), DomExtract::eval(), _GHom::eval_skip(), StrongHom::has_image(), _GHom::has_image_skip(), _setVarConst::invert(), MySize::mysize(), MyNbStates::nbStates(), print(), saveNode(), and SddSize::sddsize().
|
static |
For garbage collection, do not call this directly, use MemoryManager::garbage() instead.
References MyNbStates::clear(), UniqueTableId< T, ID >::garbage(), UniqueTableId< T, ID >::instance(), mark(), one, and top.
Referenced by MemoryManager::garbage().
|
static |
Gets a variable's name.
var | the index of the variable to be named |
References mapVarName.
Referenced by dotExporter::collect(), _VarCompState::print(), _setVarConst::print(), _incVar::print(), _VarCompVar::print(), and print().
|
inline |
For storage in a hash table.
References concret, and ddd::int32_hash().
Referenced by _DED_Mult::create(), _DED_Mult::hash(), _DED_Minus::hash(), _DED_Concat::hash(), _DED_Hom::hash(), Constant::hash(), Apply2k::hash(), Mult::hash(), LeftConcat::hash(), RightConcat::hash(), Minus::hash(), nsMLHom::LeftConcat::hash(), and DDD::set_hash().
void GDDD::mark | ( | ) | const |
For garbage collection internals.
Marks a GDDD as in use in garbage collection phase.
References concret, UniqueTableId< T, ID >::instance(), and UniqueTableId< T, ID >::mark().
Referenced by Fixpoint::eval(), garbage(), DDD::mark(), Constant::mark(), Apply2k::mark(), Mult::mark(), LeftConcat::mark(), RightConcat::mark(), Minus::mark(), and MemoryManager::mark().
size_t GDDD::nbsons | ( | ) | const |
Returns the number of successors of a given node. This is the size of the arc array of the node.
References concret, _GDDD::resolve(), and _GDDD::valuation_size.
Referenced by _DED_Mult::eval(), _DED_Minus::eval(), and _incVar::invert().
long double GDDD::nbStates | ( | ) | const |
Returns the number of states or paths represented by a given node.
Referenced by Statistic::load(), and DDD::set_size().
|
private |
long double GDDD::noSharedSize | ( | ) | const |
Returns the number of nodes that would be used to represent a DDD if no unicity table was used.
|
inline |
bool GDDD::operator< | ( | const GDDD & | g | ) | const |
|
inline |
Comparison between DDD.
Note that comparison is based on "concret" address in unicity table.
g | the node to compare to |
Referenced by DDD::empty().
|
static |
Returns the peak size of the DDD unicity table. This value is maintained up to date upon GarbageCollection.
References UniqueTableId< T, ID >::instance(), and UniqueTableId< T, ID >::peak_size().
Referenced by Statistic::load(), and pstats().
|
private |
Internal function used in recursion for textual printing of GDDD.
References begin(), end(), getvarName(), one, top, and variable().
|
static |
Prints some statistics to std::cout.
Mostly used in debug and development phase. See also MemoryManager::pstats().
References UniqueTableId< T, ID >::instance(), and peak().
Referenced by MemoryManager::pstats().
unsigned int GDDD::refCounter | ( | ) | const |
Returns current reference count of a node.
Reference count corresponds to the number of DDD that use a given concrete node. No recursive reference counting is used : son nodes may have refCount=0 even if this node has a positive refCounter.
|
private |
unsigned long int GDDD::size | ( | ) | const |
Returns the size in number of nodes of a DDD structure.
Referenced by Statistic::load().
|
static |
Returns unicity table current size. Gives the number of different nodes created and not yet destroyed.
References UniqueTableId< T, ID >::instance(), and UniqueTableId< T, ID >::size().
Referenced by MemoryManager::nbDDD().
int GDDD::variable | ( | ) | const |
Returns a node's variable.
References concret, _GDDD::resolve(), and _GDDD::variable.
Referenced by dotExporter::collect(), _DED_Mult::create(), _DED_Minus::create(), _DED_Mult::eval(), _DED_Minus::eval(), _DED_Concat::eval(), StrongHom::eval(), StrongMLHom::eval(), Apply2k::eval(), DomExtract::eval(), Add::eval(), Monotonic::eval(), And::eval(), Fixpoint::eval(), _GHom::eval_skip(), GDDD(), StrongHom::has_image(), Add::has_image(), Fixpoint::has_image(), _GHom::has_image_skip(), and print().
|
static |
Sets a variable's name.
var | the index of the variable to be named |
name | the name to attach to this variable index |
References mapVarName.
|
friend |
Open access to concret for reference counting in DDD.
Referenced by DDD::empty_set(), DDD::newcopy(), DDD::set_intersect(), DDD::set_minus(), and DDD::set_union().
|
friend |
Function for deserialization. Load a set of DDD from a stream.
|
friend |
A textual output.
Don't use it with large number of paths as each element is printed on a different line
|
friend |
Function for serialization. Save a set of DDD to a stream.
|
private |
The real implementation class.
All true operations are delagated on this pointer. Construction/destruction take care of ensuring concret is only instantiated once in memory.
Referenced by begin(), DDD::DDD(), end(), GDDD(), hash(), mark(), nbsons(), nodeIndex(), operator!=(), operator<(), DDD::operator=(), saveNode(), variable(), and DDD::~DDD().
|
static |
The non-accepting terminal.
As DDD are a zero-suppressed variant of decision diagrams, paths leading to null are suppressed. Only the empty set is represented by null.
Referenced by GHom::add(), DED::add(), apply2k(), dotExporter::collect(), _VarCompState::compose(), _VarCompVar::compose(), _GHom::compose(), _DED_Mult::create(), _DED_Minus::create(), _DED_Concat::create(), _DED_Hom::create(), _DED_Add::create(), DDD::empty(), _DED_Mult::eval(), _DED_Minus::eval(), StrongHom::eval(), StrongMLHom::eval(), Constant::eval(), Apply2k::eval(), DomExtract::eval(), NotCond::eval(), Add::eval(), Monotonic::eval(), And::eval(), Fixpoint::eval(), sns::SApply2k::eval(), sns::LocalApply::eval(), sns::RecFireSat::eval(), _GHom::eval_skip(), StrongHom::has_image(), Inter::has_image(), NotCond::has_image(), Add::has_image(), And::has_image(), Fixpoint::has_image(), GHom::has_image(), sns::LocalApply::has_image(), _GHom::has_image_skip(), _GHom::invert(), Compose::invert(), Constant::is_selector(), iterateDDD(), MyNbStates::nbStates(), Identity::negate(), Constant::negate(), GHom::operator()(), operator*(), _VarCompState::phi(), varGtVar(), varLtVar(), and varNeqVar().
|
static |
The accepting terminal. This is the basic leaf for accepted sequences.
Referenced by apply2k(), dotExporter::collect(), _DED_Mult::create(), _DED_Minus::create(), _DED_Concat::create(), _DED_Add::create(), StrongHom::eval(), StrongMLHom::eval(), DomExtract::eval(), NotCond::eval(), Add::eval(), Monotonic::eval(), And::eval(), Fixpoint::eval(), _GHom::eval_skip(), garbage(), StrongHom::has_image(), Add::has_image(), Fixpoint::has_image(), _GHom::has_image_skip(), iterateDDD(), MyNbStates::nbStates(), _VarCompState::phiOne(), _setVarConst::phiOne(), _incVar::phiOne(), _VarCompVar::phiOne(), print(), and saveNode().
|
static |
The approximation terminal.
This represents any finite set of assignment sequences. In a "normal" usage pattern, top terminals should not be produced.
Referenced by apply2k(), dotExporter::collect(), _DED_Mult::create(), _DED_Minus::create(), _DED_Concat::create(), _DED_Add::create(), StrongHom::eval(), StrongMLHom::eval(), DomExtract::eval(), NotCond::eval(), Add::eval(), Monotonic::eval(), And::eval(), Fixpoint::eval(), _GHom::eval_skip(), garbage(), StrongHom::has_image(), Add::has_image(), Fixpoint::has_image(), _GHom::has_image_skip(), iterateDDD(), MyNbStates::nbStates(), StrongHom::phiOne(), print(), and saveNode().