Skip to content

Commit

Permalink
Add 'zdd_offset(A, var)' and 'zdd_onset(A, var)'
Browse files Browse the repository at this point in the history
  • Loading branch information
SSoelvsten committed Nov 4, 2023
1 parent 8559cf5 commit 783d537
Show file tree
Hide file tree
Showing 3 changed files with 593 additions and 434 deletions.
28 changes: 28 additions & 0 deletions src/adiar/zdd.h
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,20 @@ namespace adiar
ForwardIt end)
{ return zdd_offset(ep, A, make_generator(begin, end)); }

//////////////////////////////////////////////////////////////////////////////
/// \brief Subset that do \em not include the given element.
///
/// \param A Family of set
///
/// \param var Variable to include.
//////////////////////////////////////////////////////////////////////////////
__zdd zdd_offset(const zdd &A, zdd::label_type var);

//////////////////////////////////////////////////////////////////////////////
/// \brief Subset that do \em not include the given element.
//////////////////////////////////////////////////////////////////////////////
__zdd zdd_offset(const exec_policy &ep, const zdd &A, zdd::label_type var);

//////////////////////////////////////////////////////////////////////////////
/// \brief Subset that \em do include the given set of variables.
///
Expand Down Expand Up @@ -707,6 +721,20 @@ namespace adiar
ForwardIt end)
{ return zdd_onset(ep, A, make_generator(begin, end)); }

//////////////////////////////////////////////////////////////////////////////
/// \brief Subset that \em do include the given element.
///
/// \param A Family of set
///
/// \param var Variable to include.
//////////////////////////////////////////////////////////////////////////////
__zdd zdd_onset(const zdd &A, zdd::label_type var);

//////////////////////////////////////////////////////////////////////////////
/// \brief Subset that \em do include the given element.
//////////////////////////////////////////////////////////////////////////////
__zdd zdd_onset(const exec_policy &ep, const zdd &A, zdd::label_type var);

//////////////////////////////////////////////////////////////////////////////
/// \brief Project family of sets onto a domain, i.e. remove from every
/// set all variables not within the domain.
Expand Down
36 changes: 36 additions & 0 deletions src/adiar/zdd/subset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@

namespace adiar
{
// TODO: Merge with the generator in `bdd_restrict(f, var, val)`.
inline auto make_generator(const zdd::label_type &var, bool &gen_called)
{
adiar_assert(!gen_called);

return [&gen_called, &var]() -> zdd::label_type {
if (gen_called) {
return generator_end<zdd::label_type>::value;
}
gen_called = true;
return var;
};
}

template<assignment FIX_VALUE>
class zdd_subset_labels
{
Expand Down Expand Up @@ -135,6 +149,17 @@ namespace adiar
return zdd_offset(exec_policy(), A, vars);
}

__zdd zdd_offset(const exec_policy &ep, const zdd &A, zdd::label_type var)
{
bool gen_called = false;
return zdd_offset(ep, A, make_generator(var, gen_called));
}

__zdd zdd_offset(const zdd &A, zdd::label_type var)
{
return zdd_offset(exec_policy(), A, var);
}

//////////////////////////////////////////////////////////////////////////////
template<typename assignment_mgr>
class zdd_onset_policy : public zdd_policy
Expand Down Expand Up @@ -212,4 +237,15 @@ namespace adiar
{
return zdd_onset(exec_policy(), A, xs);
}

__zdd zdd_onset(const exec_policy &ep, const zdd &A, zdd::label_type var)
{
bool gen_called = false;
return zdd_onset(ep, A, make_generator(var, gen_called));
}

__zdd zdd_onset(const zdd &A, zdd::label_type var)
{
return zdd_onset(exec_policy(), A, var);
}
}
Loading

0 comments on commit 783d537

Please sign in to comment.