DDD  1.9.0.20240826145154
Public Types | Private Member Functions | Private Attributes | Friends | List of all members
GDDD Class Reference

This class is the base class representing a Data Decision Diagram. More...

#include <DDD.h>

Inheritance diagram for GDDD:
Inheritance graph
Collaboration diagram for GDDD:
Collaboration graph

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, GDDDedge_t
 An edge is a pair <value,child node> More...
 
typedef std::vector< edge_tValuation
 To hide how arcs are actually stored. Use GDDD::Valuation to refer to arcs type. More...
 
typedef const edge_tconst_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...
 

Detailed Description

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.

Member Typedef Documentation

◆ const_iterator

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

◆ edge_t

typedef std::pair<val_t,GDDD> GDDD::edge_t

An edge is a pair <value,child node>

◆ id_t

typedef unsigned int GDDD::id_t

◆ val_t

typedef short GDDD::val_t

The type used as values of variables in a DDD.

◆ valsz_t

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.

◆ Valuation

typedef std::vector<edge_t > GDDD::Valuation

To hide how arcs are actually stored. Use GDDD::Valuation to refer to arcs type.

Constructor & Destructor Documentation

◆ GDDD() [1/6]

GDDD::GDDD ( const id_t _g)
private

A private constructor used in internals.

Parameters
_gThe pointer provided should point into the unicity table

◆ GDDD() [2/6]

GDDD::GDDD ( _GDDD _g)
private

UNIMPLEMENTED DELIBERATELY: see SHom.h for details.

user should use version above const & or below const * into unique storage.

◆ GDDD() [3/6]

GDDD::GDDD ( int  variable,
const Valuation value 
)

Construct a GDDD with arguments given.

Todo:
why is this public ??? WARNING Valuation should be sorted according to arc values
Parameters
variablethe variable labeling the node
valuethe set of arcs of the node

References concret, _GDDD::create_unique_GDDD(), GDDD(), and variable().

◆ GDDD() [4/6]

GDDD::GDDD ( )
inline

Default constructor creates the empty set DDD.

Referenced by GDDD().

◆ GDDD() [5/6]

GDDD::GDDD ( int  var,
val_t  val,
const GDDD d = one 
)

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 +, -, *, ^ ...

Parameters
varthe variable labeling the node
valthe value labeling the arc
dthe successor node or defaults to terminal GDDD::one if none provided

References concret, and _GDDD::create_unique_GDDD().

◆ GDDD() [6/6]

GDDD::GDDD ( int  var,
val_t  val1,
val_t  val2,
const GDDD d = one 
)

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.

Parameters
varthe variable labeling the node
val1lowest value labeling an arc
val2highest value labeling an arc
dthe successor node or defaults to terminal GDDD::one if none provided

References concret, and _GDDD::create_unique_GDDD().

Member Function Documentation

◆ begin()

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().

◆ end()

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().

◆ garbage()

void GDDD::garbage ( )
static

For garbage collection, do not call this directly, use MemoryManager::garbage() instead.

Todo:
describe garbage collection algorithm(s) + mark usage homogeneously in one place.

References MyNbStates::clear(), UniqueTableId< T, ID >::garbage(), UniqueTableId< T, ID >::instance(), mark(), one, and top.

Referenced by MemoryManager::garbage().

◆ getvarName()

const std::string GDDD::getvarName ( int  var)
static

Gets a variable's name.

Todo:
This function should be implemented in a name manager somewhere so that it is common to DDD and SDD variables.
Parameters
varthe index of the variable to be named
Returns
the name attached to this variable index

References mapVarName.

Referenced by dotExporter::collect(), _VarCompState::print(), _setVarConst::print(), _incVar::print(), _VarCompVar::print(), and print().

◆ hash()

size_t GDDD::hash ( ) const
inline

◆ mark()

void GDDD::mark ( ) const

◆ nbsons()

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().

◆ nbStates()

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().

◆ nodeIndex()

unsigned long int GDDD::nodeIndex ( const std::vector< id_t > &  ) const
private

Another function used in serialization.

References concret.

Referenced by saveNode().

◆ noSharedSize()

long double GDDD::noSharedSize ( ) const

Returns the number of nodes that would be used to represent a DDD if no unicity table was used.

◆ operator!=()

bool GDDD::operator!= ( const GDDD g) const
inline

Comparison between DDD.

Note that comparison is based on "concret" address in unicity table.

Parameters
gthe node to compare to
Returns
true if the nodes are not equal.

References concret.

◆ operator<()

bool GDDD::operator< ( const GDDD g) const

Total ordering function between DDD.

Note that comparison is based on "concret" address in unicity table. This ordering is necessary for hash and map storage of GDDD.

Parameters
gthe node to compare to
Returns
true if argument g is greater than "this" node.

References concret.

◆ operator==()

bool GDDD::operator== ( const GDDD g) const
inline

Comparison between DDD.

Note that comparison is based on "concret" address in unicity table.

Parameters
gthe node to compare to
Returns
true if the nodes are equal.

Referenced by DDD::empty().

◆ peak()

size_t GDDD::peak ( )
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().

◆ print()

void GDDD::print ( std::ostream &  os,
std::string  s 
) const
private

Internal function used in recursion for textual printing of GDDD.

References begin(), end(), getvarName(), one, top, and variable().

◆ pstats()

void GDDD::pstats ( bool  reinit = true)
static

Prints some statistics to std::cout.

Mostly used in debug and development phase. See also MemoryManager::pstats().

Todo:
allow output in other place than cout. Clean up output.

References UniqueTableId< T, ID >::instance(), and peak().

Referenced by MemoryManager::pstats().

◆ refCounter()

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.

◆ saveNode()

void GDDD::saveNode ( std::ostream &  ,
std::vector< id_t > &   
) const
private

A function for DDD serialization (beta).

References begin(), concret, end(), nodeIndex(), one, and top.

◆ size()

unsigned long int GDDD::size ( ) const

Returns the size in number of nodes of a DDD structure.

Referenced by Statistic::load().

◆ statistics()

unsigned int GDDD::statistics ( )
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().

◆ variable()

int GDDD::variable ( ) const

◆ varName()

void GDDD::varName ( int  var,
const std::string &  name 
)
static

Sets a variable's name.

Todo:
This function should be implemented in a name manager somewhere so that it is common to DDD and SDD variables.
Parameters
varthe index of the variable to be named
namethe name to attach to this variable index

References mapVarName.

Friends And Related Function Documentation

◆ DDD

friend class DDD
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().

◆ loadDDD

void loadDDD ( std::istream &  is,
std::vector< DDD > &  list 
)
friend

Function for deserialization. Load a set of DDD from a stream.

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const GDDD g 
)
friend

A textual output.

Don't use it with large number of paths as each element is printed on a different line

◆ saveDDD

void saveDDD ( std::ostream &  os,
std::vector< DDD list 
)
friend

Function for serialization. Save a set of DDD to a stream.

Member Data Documentation

◆ concret

id_t GDDD::concret
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().

◆ null

const GDDD GDDD::null
static

◆ one

const GDDD GDDD::one
static

◆ top

const GDDD GDDD::top
static

The documentation for this class was generated from the following files:

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