Skip to content

Commit

Permalink
Add 'zdd_bot(...)' and 'zdd_top(...)'
Browse files Browse the repository at this point in the history
This specifically is to address the suddenly missing feature with the prior
breaking change to 'zdd_powerset(...)' not being able to take the global domain
as an input. This is (arguably?) an even prettier solution.
  • Loading branch information
SSoelvsten committed Sep 24, 2023
1 parent 61bcee8 commit 6477cd1
Show file tree
Hide file tree
Showing 3 changed files with 444 additions and 0 deletions.
64 changes: 64 additions & 0 deletions src/adiar/zdd.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,70 @@ namespace adiar
return zdd_powerset(internal::iterator_gen<zdd::label_t>(begin, end));
}

//////////////////////////////////////////////////////////////////////////////
/// \brief Bottom of the powerset lattice.
///
/// \param vars Generator function of the variables in *descending* order.
///
/// \see zdd_empty
//////////////////////////////////////////////////////////////////////////////
inline zdd zdd_bot(const std::function<zdd::label_t()> &/*dom*/)
{ return zdd_empty(); }

//////////////////////////////////////////////////////////////////////////////
/// \brief Bottom of the powerset lattice.
///
/// \param begin Iterator that provides the variables in *descending* order.
///
/// \param end Iterator that marks the end for `begin`.
///
/// \see zdd_empty
//////////////////////////////////////////////////////////////////////////////
template<typename IT>
inline zdd zdd_bot(IT /*begin*/, IT /*end*/)
{ return zdd_empty(); }

//////////////////////////////////////////////////////////////////////////////
/// \brief Bottom of the powerset lattice.
///
/// \see zdd_empty
//////////////////////////////////////////////////////////////////////////////
inline zdd zdd_bot()
{ return zdd_empty(); }

//////////////////////////////////////////////////////////////////////////////
/// \brief Top of the powerset lattice.
///
/// \param vars Generator function of the variables in *descending* order.
///
/// \see zdd_powerset, zdd_null
//////////////////////////////////////////////////////////////////////////////
inline zdd zdd_top(const std::function<zdd::label_t()> &dom)
{ return zdd_powerset(dom); }

//////////////////////////////////////////////////////////////////////////////
/// \brief Top of the powerset lattice.
///
/// \param begin Iterator that provides the variables in *descending* order.
///
/// \param end Iterator that marks the end for `begin`.
///
/// \see zdd_empty
//////////////////////////////////////////////////////////////////////////////
template<typename IT>
inline zdd zdd_top(IT begin, IT end)
{ return zdd_powerset(begin, end); }

//////////////////////////////////////////////////////////////////////////////
/// \brief Top of the powerset lattice.
///
/// \details Since no set of variables is given, the global \ref
/// module__domain is used (if available).
///
/// \see zdd_powerset, zdd_null
//////////////////////////////////////////////////////////////////////////////
zdd zdd_top();

/// \}
//////////////////////////////////////////////////////////////////////////////

Expand Down
13 changes: 13 additions & 0 deletions src/adiar/zdd/build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,17 @@ namespace adiar
internal::chain_both<zdd_policy> p;
return internal::build_chain<>(p, vars);
}

//////////////////////////////////////////////////////////////////////////////
zdd zdd_top()
{
if (!adiar_has_domain()) {
return zdd_null();
}

const shared_file<domain_var_t> dom = adiar_get_domain();
internal::file_stream<domain_var_t, true> ds(dom);

return zdd_powerset(internal::stream_gen<zdd::label_t>(ds));
}
}
Loading

0 comments on commit 6477cd1

Please sign in to comment.