CDegreeCache.h
Go to the documentation of this file.
// -*- c++ -*-
//*****************************************************************************
//*****************************************************************************
#ifndef polybori_cache_CDegreeCache_h_
#define polybori_cache_CDegreeCache_h_
// include basic definitions
#include <polybori/pbori_defs.h>
#include <polybori/BooleEnv.h>
#include "CCacheManagement.h"
BEGIN_NAMESPACE_PBORI
//class BoolePolyRing;
template <class NaviType>
class CIndexHandle {
public:
enum { invalid = CTypes::max_idx };
typedef NaviType navigator;
typedef navigator base;
typedef typename navigator::bool_type bool_type;
typedef typename CTypes::idx_type idx_type;
typedef typename CTypes::size_type size_type;
typedef BoolePolyRing manager_type;
CIndexHandle(idx_type idx): m_idx(idx) {}
explicit CIndexHandle(navigator navi, const manager_type& mgr):
m_idx(fromNode(navi, mgr)) {}
idx_type operator*() const {
return m_idx;
}
bool isValid() const {
return (m_idx != invalid);
}
protected:
idx_type fromNode(navigator navi, const manager_type& mgr) const {
if (!navi.isValid())
return invalid;
if PBORI_UNLIKELY(navi.isConstant())
return mgr.nVariables();
else
return *navi;
}
idx_type m_idx;
};
template <class NaviType>
class CIndexCacheHandle {
public:
typedef NaviType navigator;
// typedef navigator base;
typedef typename navigator::bool_type bool_type;
typedef typename navigator::value_type idx_type;
typedef typename navigator::size_type size_type;
typedef BoolePolyRing manager_type;
CIndexCacheHandle(idx_type idx, const manager_type& mgr):
m_navi( toNode(idx, mgr) ) {}
explicit CIndexCacheHandle(navigator navi):
m_navi(navi) {}
operator navigator() const { return m_navi; }
protected:
navigator toNode(idx_type idx, const manager_type& mgr) const {
if PBORI_LIKELY((size_type)idx < mgr.nVariables())
return mgr.variable(idx).set().navigation();
return mgr.zero().navigation();
}
navigator m_navi;
};
template <class DDType>
class CDegreeCache:
public CCacheManagement<BoolePolyRing, typename CCacheTypes::degree, 1> {
typedef CDegreeCache self;
public:
typedef DDType dd_type;
typedef typename CCacheTypes::degree tag_type;
typedef CCacheManagement<BoolePolyRing, tag_type, 1> base;
typedef typename base::node_type input_node_type;
typedef typename base::manager_type manager_type;
typedef typename dd_type::navigator navi_type;
typedef CIndexHandle<navi_type> node_type;
typedef CIndexCacheHandle<navi_type> node_cache_type;
CDegreeCache(const manager_type& mgr): base(mgr) {}
CDegreeCache(const self& rhs): base(rhs) {}
~CDegreeCache() {}
node_type find(input_node_type navi) const{
return node_type(base::find(navi), base::manager()); }
node_type find(navi_type navi) const{
return node_type(base::find(navi), base::manager()); }
void insert(input_node_type navi, deg_type deg) const {
base::insert(navi, node_cache_type(deg, base::manager()));
}
void insert(navi_type navi, deg_type deg) const {
base::insert(navi, node_cache_type(deg, base::manager()));
}
node_type find(input_node_type navi, deg_type) const { return self::find(navi); }
node_type find(navi_type navi, deg_type) const{ return self::find(navi); }
void insert(input_node_type navi, deg_type, deg_type deg) const {
self::insert(navi, deg);
}
void insert(navi_type navi, deg_type, deg_type deg) const {
self::insert(navi, deg);
}
};
template <class DDType>
class CBoundedDegreeCache:
public CCacheManagement<BoolePolyRing, typename CCacheTypes::degree, 2> {
typedef CBoundedDegreeCache self;
public:
typedef DDType dd_type;
typedef typename CCacheTypes::degree tag_type;
typedef CCacheManagement<BoolePolyRing, tag_type, 2> base;
typedef typename base::node_type input_node_type;
typedef typename base::manager_type manager_type;
typedef typename dd_type::navigator navi_type;
typedef CIndexHandle<navi_type> node_type;
typedef CIndexCacheHandle<navi_type> node_cache_type;
CBoundedDegreeCache(const manager_type& mgr): base(mgr) {}
CBoundedDegreeCache(const self& rhs): base(rhs) {}
~CBoundedDegreeCache() {}
node_type find(input_node_type navi, deg_type upper_bound) const{
return node_type(base::find(navi,
node_cache_type(upper_bound, base::manager())),
base::manager());
}
node_type find(navi_type navi, deg_type upper_bound) const{
return node_type(base::find(navi,
node_cache_type(upper_bound, base::manager())),
base::manager());
}
void insert(input_node_type navi, deg_type upper_bound, deg_type deg) const {
base::insert(navi, node_cache_type(upper_bound, base::manager()),
node_cache_type(deg, base::manager()));
}
void insert(navi_type navi, deg_type upper_bound, deg_type deg) const {
base::insert(navi, node_cache_type(upper_bound, base::manager()),
node_cache_type(deg, base::manager()));
}
};
template <class DDType>
class CBlockDegreeCache:
public CCacheManagement<BoolePolyRing,
typename CCacheTypes::block_degree, 2> {
public:
typedef DDType dd_type;
typedef typename CCacheTypes::block_degree tag_type;
typedef CCacheManagement<BoolePolyRing, tag_type, 2> base;
typedef CBlockDegreeCache<dd_type> self;
typedef typename base::node_type input_node_type;
typedef typename base::manager_type manager_type;
typedef typename dd_type::navigator navi_type;
typedef CIndexHandle<navi_type> node_type;
typedef CIndexCacheHandle<navi_type> node_cache_type;
CBlockDegreeCache(const manager_type& mgr): base(mgr) {}
CBlockDegreeCache(const self& rhs): base(rhs) {}
~CBlockDegreeCache() {}
node_type find(input_node_type navi, idx_type idx) const{
return node_type(base::find(navi, node_cache_type(idx, base::manager())),
base::manager()); }
node_type find(navi_type navi, idx_type idx) const{
return node_type(base::find(navi, node_cache_type(idx, base::manager())),
base::manager()); }
void insert(input_node_type navi, idx_type idx, size_type deg) const {
base::insert(navi, node_cache_type(idx, base::manager()),
node_cache_type(deg, base::manager()));
}
void insert(navi_type navi, idx_type idx, size_type deg) const {
base::insert(navi, node_cache_type(idx, base::manager()),
node_cache_type(deg, base::manager()));
}
};
template <class TagType,
class DDType>
class CDegreeArgumentCache:
public CCacheManagement<BoolePolyRing, TagType, 2>,
public CAuxTypes {
public:
typedef DDType dd_type;
typedef TagType tag_type;
typedef CCacheManagement<BoolePolyRing, tag_type, 2> base;
typedef CDegreeArgumentCache<tag_type, dd_type> self;
typedef typename base::node_type node_type;
typedef typename base::manager_type manager_type;
typedef typename dd_type::navigator navi_type;
typedef CIndexCacheHandle<navi_type> degree_node_type;
CDegreeArgumentCache(const manager_type& mgr): base(mgr) {}
CDegreeArgumentCache(const self& rhs): base(rhs) {}
~CDegreeArgumentCache() {}
navi_type find(navi_type navi, size_type deg) const{
return base::find(navi, degree_node_type(deg, base::manager()));
}
void insert(navi_type navi, size_type deg, navi_type result) const {
base::insert(navi, degree_node_type(deg, base::manager()), result);
}
};
END_NAMESPACE_PBORI
#endif
polybori::CBoundedDegreeCache::navi_type
dd_type::navigator navi_type
Definition: CDegreeCache.h:215
polybori::CCacheManagement::node_type
base::node_type node_type
Extracting inherited node type.
Definition: CCacheManagement.h:474
polybori::CIndexHandle::manager_type
BoolePolyRing manager_type
Type of decision diagram manager.
Definition: CDegreeCache.h:54
polybori::CDegreeArgumentCache::dd_type
DDType dd_type
Definition: CDegreeCache.h:320
polybori::CDegreeCache::find
node_type find(navi_type navi) const
Definition: CDegreeCache.h:170
polybori::CBoundedDegreeCache::dd_type
DDType dd_type
Definition: CDegreeCache.h:206
END_NAMESPACE_PBORI
#define END_NAMESPACE_PBORI
Finish project's namespace.
Definition: pbori_defs.h:77
polybori::CBlockDegreeCache::base
CCacheManagement< BoolePolyRing, tag_type, 2 > base
Definition: CDegreeCache.h:267
polybori::CDegreeArgumentCache::base
CCacheManagement< BoolePolyRing, tag_type, 2 > base
Definition: CDegreeCache.h:322
polybori::CBlockDegreeCache::dd_type
DDType dd_type
Definition: CDegreeCache.h:265
polybori::CDegreeCache::navi_type
dd_type::navigator navi_type
Definition: CDegreeCache.h:152
polybori::CIndexCacheHandle::manager_type
BoolePolyRing manager_type
Type of decision diagram manager.
Definition: CDegreeCache.h:110
polybori::CDegreeArgumentCache::CDegreeArgumentCache
CDegreeArgumentCache(const manager_type &mgr)
Constructor.
Definition: CDegreeCache.h:335
polybori::CIndexHandle::fromNode
idx_type fromNode(navigator navi, const manager_type &mgr) const
Dereference to get stored index.
Definition: CDegreeCache.h:73
polybori::CCacheManagement< BoolePolyRing, CCacheTypes::degree, 1 >::deg_type
manager_type::deg_type deg_type
Definition: CCacheManagement.h:463
BEGIN_NAMESPACE_PBORI
#define BEGIN_NAMESPACE_PBORI
Start project's namespace.
Definition: pbori_defs.h:74
polybori::CDegreeCache::~CDegreeCache
~CDegreeCache()
Destructor.
Definition: CDegreeCache.h:164
polybori::CBlockDegreeCache::node_type
CIndexHandle< navi_type > node_type
Definition: CDegreeCache.h:276
polybori::CBlockDegreeCache::find
node_type find(navi_type navi, idx_type idx) const
Definition: CDegreeCache.h:294
polybori::CDegreeCache::find
node_type find(navi_type navi, deg_type) const
Definition: CDegreeCache.h:185
polybori::CCacheManagement
This template class forms the base for CCommutativeCacheManagement and CacheManager. It is an interface defining find and insert on decision diagram cache.
Definition: CCacheManagement.h:455
polybori::CIndexHandle::m_idx
idx_type m_idx
Definition: CDegreeCache.h:86
polybori::CDegreeArgumentCache::degree_node_type
CIndexCacheHandle< navi_type > degree_node_type
Definition: CDegreeCache.h:331
polybori::BoolePolyRing::variable
var_type variable(checked_idx_type nvar) const
Access nvar-th ring variable as diagram.
Definition: BoolePolyRing.cc:99
polybori::CCacheManagement::manager_type
ManagerType manager_type
Definition: CCacheManagement.h:462
polybori::CBoundedDegreeCache::node_cache_type
CIndexCacheHandle< navi_type > node_cache_type
Definition: CDegreeCache.h:217
polybori::CBoundedDegreeCache::insert
void insert(navi_type navi, deg_type upper_bound, deg_type deg) const
Store cached degree wrt. given navigator.
Definition: CDegreeCache.h:249
polybori::CDegreeArgumentCache
Definition: CDegreeCache.h:313
polybori::CBoundedDegreeCache::CBoundedDegreeCache
CBoundedDegreeCache(const manager_type &mgr)
Constructor.
Definition: CDegreeCache.h:221
polybori::BoolePolyRing::zero
dd_type zero() const
Get empty decision diagram.
Definition: BoolePolyRing.cc:42
polybori::CDegreeCache::base
CCacheManagement< BoolePolyRing, tag_type, 1 > base
Definition: CDegreeCache.h:145
polybori::CBoundedDegreeCache::input_node_type
base::node_type input_node_type
Definition: CDegreeCache.h:213
polybori::CBoundedDegreeCache::node_type
CIndexHandle< navi_type > node_type
Definition: CDegreeCache.h:216
polybori::CDegreeArgumentCache::~CDegreeArgumentCache
~CDegreeArgumentCache()
Destructor.
Definition: CDegreeCache.h:341
polybori::CDegreeCache::insert
void insert(input_node_type navi, deg_type deg) const
Store cached degree wrt. given navigator.
Definition: CDegreeCache.h:174
polybori::BoolePolyRing
This class reinterprets decicion diagram managers as Boolean polynomial rings, adds an ordering and v...
Definition: BoolePolyRing.h:40
polybori::CDegreeArgumentCache::find
navi_type find(navi_type navi, size_type deg) const
Find cached degree wrt. given navigator.
Definition: CDegreeCache.h:344
polybori::CBlockDegreeCache::navi_type
dd_type::navigator navi_type
Definition: CDegreeCache.h:275
polybori::CAuxTypes
This struct contains auxiliary type definitions.
Definition: pbori_defs.h:210
polybori::CBlockDegreeCache::CBlockDegreeCache
CBlockDegreeCache(const manager_type &mgr)
Constructor.
Definition: CDegreeCache.h:281
polybori::CBoundedDegreeCache::tag_type
CCacheTypes::degree tag_type
Definition: CDegreeCache.h:207
polybori::CDegreeCache::node_cache_type
CIndexCacheHandle< navi_type > node_cache_type
Definition: CDegreeCache.h:154
polybori::CIndexCacheHandle::navigator
NaviType navigator
Set actual storage type.
Definition: CDegreeCache.h:95
polybori::CDegreeCache::find
node_type find(input_node_type navi, deg_type) const
Find cached degree wrt. given navigator (ignoring bound as second argument)
Definition: CDegreeCache.h:183
polybori::CDegreeArgumentCache::insert
void insert(navi_type navi, size_type deg, navi_type result) const
Store cached degree wrt. given navigator.
Definition: CDegreeCache.h:349
polybori::CDegreeCache::CDegreeCache
CDegreeCache(const manager_type &mgr)
Constructor.
Definition: CDegreeCache.h:158
polybori::CIndexCacheHandle
Definition: CDegreeCache.h:91
PBORI_LIKELY
#define PBORI_LIKELY(expression)
For optimizing if-branches.
Definition: pbori_defs.h:56
polybori::CBoundedDegreeCache::~CBoundedDegreeCache
~CBoundedDegreeCache()
Destructor.
Definition: CDegreeCache.h:227
polybori::CIndexCacheHandle::m_navi
navigator m_navi
Actual navigator, which is stored.
Definition: CDegreeCache.h:133
polybori::CBoundedDegreeCache::find
node_type find(navi_type navi, deg_type upper_bound) const
Definition: CDegreeCache.h:236
polybori::CIndexHandle::base
navigator base
Define type base.
Definition: CDegreeCache.h:42
polybori::CDegreeCache::find
node_type find(input_node_type navi) const
Find cached degree wrt. given navigator.
Definition: CDegreeCache.h:167
polybori::CBlockDegreeCache::~CBlockDegreeCache
~CBlockDegreeCache()
Destructor.
Definition: CDegreeCache.h:287
polybori::CDegreeCache::insert
void insert(navi_type navi, deg_type deg) const
Store cached degree wrt. given navigator.
Definition: CDegreeCache.h:179
pbori_defs.h
polybori::CDegreeCache::tag_type
CCacheTypes::degree tag_type
Definition: CDegreeCache.h:144
polybori::CIndexHandle::CIndexHandle
CIndexHandle(navigator navi, const manager_type &mgr)
Construct from given navigator.
Definition: CDegreeCache.h:60
polybori::CIndexHandle::idx_type
CTypes::idx_type idx_type
Type for representing indices.
Definition: CDegreeCache.h:48
polybori::CBoundedDegreeCache::manager_type
base::manager_type manager_type
Definition: CDegreeCache.h:214
polybori::CCacheTypes::block_degree
Definition: CCacheManagement.h:93
polybori::CDegreeCache::insert
void insert(navi_type navi, deg_type, deg_type deg) const
Store cached degree wrt. given navigator.
Definition: CDegreeCache.h:193
polybori::CIndexCacheHandle::bool_type
navigator::bool_type bool_type
Define type base.
Definition: CDegreeCache.h:101
polybori::CBlockDegreeCache::manager_type
base::manager_type manager_type
Definition: CDegreeCache.h:274
polybori::CDegreeCache::dd_type
DDType dd_type
Definition: CDegreeCache.h:143
polybori::CIndexHandle::bool_type
navigator::bool_type bool_type
Plain Boolean type.
Definition: CDegreeCache.h:45
polybori::CIndexHandle::navigator
NaviType navigator
Set actual storage type.
Definition: CDegreeCache.h:39
polybori::CIndexCacheHandle::CIndexCacheHandle
CIndexCacheHandle(navigator navi)
Construct from given navigator.
Definition: CDegreeCache.h:117
polybori::CDegreeCache::input_node_type
base::node_type input_node_type
Definition: CDegreeCache.h:150
polybori::CBoundedDegreeCache
Definition: CDegreeCache.h:200
polybori::CCacheManagement< BoolePolyRing, CCacheTypes::block_degree, 2 >::idx_type
manager_type::idx_type idx_type
Definition: CCacheManagement.h:465
polybori::BoolePolyRing::nVariables
size_type nVariables() const
Get number of ring variables.
Definition: BoolePolyRing.h:126
polybori::CDegreeCache::CDegreeCache
CDegreeCache(const self &rhs)
Copy Constructor.
Definition: CDegreeCache.h:161
polybori::CBlockDegreeCache::insert
void insert(navi_type navi, idx_type idx, size_type deg) const
Store cached degree wrt. given navigator.
Definition: CDegreeCache.h:305
polybori::CBlockDegreeCache::node_cache_type
CIndexCacheHandle< navi_type > node_cache_type
Definition: CDegreeCache.h:277
polybori::CBlockDegreeCache
Definition: CDegreeCache.h:258
polybori::CCacheManagement< BoolePolyRing, CCacheTypes::block_degree, 2 >::size_type
manager_type::size_type size_type
Definition: CCacheManagement.h:464
polybori::CIndexCacheHandle::CIndexCacheHandle
CIndexCacheHandle(idx_type idx, const manager_type &mgr)
Construct from index.
Definition: CDegreeCache.h:113
polybori::CIndexHandle::CIndexHandle
CIndexHandle(idx_type idx)
Construct from index.
Definition: CDegreeCache.h:57
polybori::CDegreeArgumentCache::tag_type
TagType tag_type
Definition: CDegreeCache.h:321
polybori::CDegreeArgumentCache::node_type
base::node_type node_type
Definition: CDegreeCache.h:328
polybori::CBoundedDegreeCache::CBoundedDegreeCache
CBoundedDegreeCache(const self &rhs)
Copy Constructor.
Definition: CDegreeCache.h:224
polybori::CDegreeCache::manager_type
base::manager_type manager_type
Definition: CDegreeCache.h:151
polybori::CDegreeArgumentCache::navi_type
dd_type::navigator navi_type
Definition: CDegreeCache.h:330
CCacheManagement.h
polybori::groebner::idx_type
polybori::CTypes::idx_type idx_type
Definition: groebner_defs.h:44
polybori::CBlockDegreeCache::tag_type
CCacheTypes::block_degree tag_type
Definition: CDegreeCache.h:266
polybori::CIndexHandle::isValid
bool isValid() const
Definition: CDegreeCache.h:68
polybori::CDegreeCache::insert
void insert(input_node_type navi, deg_type, deg_type deg) const
Store cached degree wrt. given navigator (ignoring bound as second argument)
Definition: CDegreeCache.h:188
polybori::CBlockDegreeCache::insert
void insert(input_node_type navi, idx_type idx, size_type deg) const
Store cached degree wrt. given navigator.
Definition: CDegreeCache.h:299
polybori::CAuxTypes::size_type
std::size_t size_type
Type for lengths, dimensions, etc.
Definition: pbori_defs.h:219
polybori::CDegreeCache
Definition: CDegreeCache.h:137
polybori::CIndexCacheHandle::size_type
navigator::size_type size_type
Type for representing size.
Definition: CDegreeCache.h:107
polybori::CIndexHandle
This class defines an uses an navigator-like type for storing integer values from 0 upto nmax (number...
Definition: CDegreeCache.h:33
polybori::CCuddNavigator
This class defines an iterator for navigating through then and else branches of ZDDs.
Definition: CCuddNavigator.h:36
polybori::CBlockDegreeCache::input_node_type
base::node_type input_node_type
Definition: CDegreeCache.h:273
polybori::CBlockDegreeCache::CBlockDegreeCache
CBlockDegreeCache(const self &rhs)
Copy Constructor.
Definition: CDegreeCache.h:284
polybori::CIndexCacheHandle::idx_type
navigator::value_type idx_type
Type for representing indices.
Definition: CDegreeCache.h:104
polybori::CBoundedDegreeCache::find
node_type find(input_node_type navi, deg_type upper_bound) const
Find cached degree wrt. given navigator.
Definition: CDegreeCache.h:230
polybori::CIndexHandle::size_type
CTypes::size_type size_type
Type for representing size.
Definition: CDegreeCache.h:51
polybori::CDegreeCache::node_type
CIndexHandle< navi_type > node_type
Definition: CDegreeCache.h:153
polybori::CDegreeArgumentCache::manager_type
base::manager_type manager_type
Definition: CDegreeCache.h:329
polybori::CIndexCacheHandle::toNode
navigator toNode(idx_type idx, const manager_type &mgr) const
Convert plain number to navigation type.
Definition: CDegreeCache.h:124
polybori::CBlockDegreeCache::find
node_type find(input_node_type navi, idx_type idx) const
Find cached degree wrt. given navigator.
Definition: CDegreeCache.h:290
PBORI_UNLIKELY
#define PBORI_UNLIKELY(expression)
Definition: pbori_defs.h:59
polybori::CDegreeArgumentCache::CDegreeArgumentCache
CDegreeArgumentCache(const self &rhs)
Copy Constructor.
Definition: CDegreeCache.h:338
polybori::CBoundedDegreeCache::base
CCacheManagement< BoolePolyRing, tag_type, 2 > base
Definition: CDegreeCache.h:208
polybori::CIndexHandle::operator*
idx_type operator*() const
Dereference to get stored index.
Definition: CDegreeCache.h:64
BooleEnv.h
polybori::CBoundedDegreeCache::insert
void insert(input_node_type navi, deg_type upper_bound, deg_type deg) const
Store cached degree wrt. given navigator.
Definition: CDegreeCache.h:243
polybori::CCacheTypes::degree
Definition: CCacheManagement.h:59