Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bdd/relprod/quality of life #689

Merged
merged 4 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/system_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
cmake ../ -D CMAKE_BUILD_TYPE=Release && cmake --build . --target ${{ matrix.exec }}

- name: Run Benchmark
run: for n in ${{ matrix.N }}; do build/src/${{ matrix.exec }} -N $n -M 1024; done
run: for n in ${{ matrix.N }}; do build/src/${{ matrix.exec }} -n $n -M 1024; done

run-picotrav:
name: 'System Test: Picotrav (${{ matrix.name }})'
Expand Down
96 changes: 94 additions & 2 deletions src/adiar/bdd.h
Original file line number Diff line number Diff line change
Expand Up @@ -1456,6 +1456,52 @@ namespace adiar
const function<optional<bdd::label_type>(bdd::label_type)>& m,
replace_type m_type);

//////////////////////////////////////////////////////////////////////////////////////////////////
/// \brief Forwards step with the Relational Product for *disjoint* variable orderings,
/// including relabelling.
///
/// \param states
/// A symbolic representation of the *current* set of states. These are all encoded with the
/// variables `0`, `1`, ... `varcount - 1`.
///
/// \param relation
/// A relation between *current* and *next* state variables. The *next* state is encoded with
/// variables `varcount`, `varcount+1`, ... `2*varcount - 1`.
//////////////////////////////////////////////////////////////////////////////////////////////////
bdd
bdd_relnext(const bdd& states, const bdd& relation, const bdd::label_type varcount);

//////////////////////////////////////////////////////////////////////////////////////////////////
/// \brief Forwards step with the Relational Product for *disjoint* variable orderings,
/// including relabelling.
//////////////////////////////////////////////////////////////////////////////////////////////////
bdd
bdd_relnext(const exec_policy& ep,
const bdd& states,
const bdd& relation,
const bdd::label_type varcount);

//////////////////////////////////////////////////////////////////////////////////////////////////
/// \brief Forwards step with the Relational Product for *interleaved* variable orderings,
/// including relabelling.
///
/// \param states
/// A symbolic representation of the *current* set of states. These are all encoded with
/// *even* variables.
///
/// \param relation
/// A relation between *current* (even) and *next* (odd) state variables.
//////////////////////////////////////////////////////////////////////////////////////////////////
bdd
bdd_relnext(const bdd& states, const bdd& relation);

//////////////////////////////////////////////////////////////////////////////////////////////////
/// \brief Forwards step with the Relational Product for *interleaved* variable orderings,
/// including relabelling.
//////////////////////////////////////////////////////////////////////////////////////////////////
bdd
bdd_relnext(const exec_policy& ep, const bdd& states, const bdd& relation);

//////////////////////////////////////////////////////////////////////////////////////////////////
/// \brief Backwards step with the Relational Product, including relabelling.
///
Expand All @@ -1476,7 +1522,7 @@ namespace adiar
const function<optional<bdd::label_type>(bdd::label_type)>& m);

//////////////////////////////////////////////////////////////////////////////////////////////////
/// \brief Forwards step with the Relational Product, including relabelling.
/// \brief Backwards step with the Relational Product, including relabelling.
//////////////////////////////////////////////////////////////////////////////////////////////////
bdd
bdd_relprev(const exec_policy& ep,
Expand Down Expand Up @@ -1508,7 +1554,7 @@ namespace adiar
replace_type m_type);

//////////////////////////////////////////////////////////////////////////////////////////////////
/// \brief Forwards step with the Relational Product, including relabelling.
/// \brief Backwards step with the Relational Product, including relabelling.
//////////////////////////////////////////////////////////////////////////////////////////////////
bdd
bdd_relprev(const exec_policy& ep,
Expand All @@ -1517,6 +1563,52 @@ namespace adiar
const function<optional<bdd::label_type>(bdd::label_type)>& m,
replace_type m_type);

//////////////////////////////////////////////////////////////////////////////////////////////////
/// \brief Backwards step with the Relational Product for *disjoint* variable orderings,
/// including relabelling.
///
/// \param states
/// A symbolic representation of the *current* set of states. These are all encoded with the
/// variables `0`, `1`, ... `varcount - 1`.
///
/// \param relation
/// A relation between *current* and *next* state variables. The *next* state is encoded with
/// variables `varcount`, `varcount+1`, ... `2*varcount - 1`.
//////////////////////////////////////////////////////////////////////////////////////////////////
bdd
bdd_relprev(const bdd& states, const bdd& relation, const bdd::label_type varcount);

//////////////////////////////////////////////////////////////////////////////////////////////////
/// \brief Backwards step with the Relational Product for *disjoint* variable orderings,
/// including relabelling.
//////////////////////////////////////////////////////////////////////////////////////////////////
bdd
bdd_relprev(const exec_policy& ep,
const bdd& states,
const bdd& relation,
const bdd::label_type varcount);

//////////////////////////////////////////////////////////////////////////////////////////////////
/// \brief Backwards step with the Relational Product for *interleaved* variable orderings,
/// including relabelling.
///
/// \param states
/// A symbolic representation of the *current* set of states. These are all encoded with
/// *even* variables.
///
/// \param relation
/// A relation between *current* (even) and *next* (odd) state variables.
//////////////////////////////////////////////////////////////////////////////////////////////////
bdd
bdd_relprev(const bdd& states, const bdd& relation);

//////////////////////////////////////////////////////////////////////////////////////////////////
/// \brief Backwards step with the Relational Product for *interleaved* variable orderings,
/// including relabelling.
//////////////////////////////////////////////////////////////////////////////////////////////////
bdd
bdd_relprev(const exec_policy& ep, const bdd& states, const bdd& relation);

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

Expand Down
66 changes: 66 additions & 0 deletions src/adiar/bdd/relprod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,39 @@ namespace adiar
return bdd_relnext(exec_policy(), states, relation, m);
}

bdd
bdd_relnext(const exec_policy& ep,
const bdd& states,
const bdd& relation,
const bdd::label_type varcount)
{
const auto map = [=](const bdd::label_type x) -> adiar::optional<int> {
return x < varcount ? adiar::make_optional<int>() : adiar::make_optional<int>(x - varcount);
};
return bdd_relnext(ep, states, relation, map, replace_type::Shift);
}

bdd
bdd_relnext(const bdd& states, const bdd& relation, const bdd::label_type varcount)
{
return bdd_relnext(exec_policy(), states, relation, varcount);
}

bdd
bdd_relnext(const exec_policy& ep, const bdd& states, const bdd& relation)
{
const auto map = [](const bdd::label_type x) -> adiar::optional<int> {
return (x % 2) == 0 ? adiar::make_optional<int>() : adiar::make_optional<int>(x - 1);
};
return bdd_relnext(ep, states, relation, map, replace_type::Shift);
}

bdd
bdd_relnext(const bdd& states, const bdd& relation)
{
return bdd_relnext(exec_policy(), states, relation);
}

//////////////////////////////////////////////////////////////////////////////////////////////////
bdd
bdd_relprev(const exec_policy& ep,
Expand Down Expand Up @@ -399,4 +432,37 @@ namespace adiar
{
return bdd_relprev(exec_policy(), states, relation, m);
}

bdd
bdd_relprev(const exec_policy& ep,
const bdd& states,
const bdd& relation,
const bdd::label_type varcount)
{
const auto map = [=](const bdd::label_type x) -> adiar::optional<int> {
return varcount <= x ? adiar::make_optional<int>() : adiar::make_optional<int>(x + varcount);
};
return bdd_relprev(ep, states, relation, map, replace_type::Shift);
}

bdd
bdd_relprev(const bdd& states, const bdd& relation, const bdd::label_type varcount)
{
return bdd_relprev(exec_policy(), states, relation, varcount);
}

bdd
bdd_relprev(const exec_policy& ep, const bdd& states, const bdd& relation)
{
const auto map = [](const bdd::label_type x) -> adiar::optional<int> {
return (x % 2) == 1 ? adiar::make_optional<int>() : adiar::make_optional<int>(x + 1);
};
return bdd_relprev(ep, states, relation, map, replace_type::Shift);
}

bdd
bdd_relprev(const bdd& states, const bdd& relation)
{
return bdd_relprev(exec_policy(), states, relation);
}
}
Loading
Loading