Skip to content

Commit

Permalink
Debugger minAdj + sbg_algorithms cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalashnikovni committed Jun 28, 2024
1 parent c34fec3 commit 8d0b725
Show file tree
Hide file tree
Showing 33 changed files with 141 additions and 524 deletions.
2 changes: 1 addition & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ boost_libdir ?= $(prefix)

# Flags, Libraries and Includes
INCLUDES := -I. -I$(boost_libdir)/include
CXXFLAGS := -std=c++17 -Wall -Werror -Wno-reorder -O3 -D BOOST_PHOENIX_STL_TUPLE_H_ -D BOOST_MPL_LIMIT_LIST_SIZE=30 -D BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
CXXFLAGS := -std=c++17 -Wall -Werror -Wno-reorder -O2 -D BOOST_PHOENIX_STL_TUPLE_H_ -D BOOST_MPL_LIMIT_LIST_SIZE=30 -D BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
ifeq ($(MODE),Debug)
CXXFLAGS += -ggdb
endif
Expand Down
69 changes: 33 additions & 36 deletions eval/visitors/eval_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,15 +246,15 @@ auto connected_visitor_ = Util::Overload {
};

auto matching_visitor_ = Util::Overload {
[](LIB::BaseSBG a, Util::MD_NAT b, Util::MD_NAT c, bool d) {
LIB::BaseMatch match(a.copy(b[0]), d);
return InfoBaseType(match.calculate(c[0]));
[](LIB::BaseSBG a, Util::MD_NAT b, bool c) {
LIB::BaseMatch match(a.copy(b[0]), c);
return InfoBaseType(match.calculate());
},
[](LIB::CanonSBG a, Util::MD_NAT b, Util::MD_NAT c, bool d) {
LIB::CanonMatch match(a.copy(b[0]), d);
return InfoBaseType(match.calculate(c[0]));
[](LIB::CanonSBG a, Util::MD_NAT b, bool c) {
LIB::CanonMatch match(a.copy(b[0]), c);
return InfoBaseType(match.calculate());
},
[](auto a, auto b, auto c, auto d) {
[](auto a, auto b, auto c) {
Util::ERROR("Wrong arguments for matching");
return InfoBaseType();
}
Expand Down Expand Up @@ -304,46 +304,46 @@ auto first_inv_visitor_ = Util::Overload {
};

auto match_scc_visitor_ = Util::Overload {
[](LIB::BaseSBG a, Util::MD_NAT b, Util::MD_NAT c, bool d) {
LIB::BaseMatch match(a.copy(b[0]), d);
match.calculate(c[0]);
LIB::BaseSCC scc(buildSCCFromMatching(match), d);
[](LIB::BaseSBG a, Util::MD_NAT b, bool c) {
LIB::BaseMatch match(a.copy(b[0]), c);
match.calculate();
LIB::BaseSCC scc(buildSCCFromMatching(match), c);
return MapBaseType(scc.calculate());
},
[](LIB::CanonSBG a, Util::MD_NAT b, Util::MD_NAT c, bool d) {
LIB::CanonMatch match(a.copy(b[0]), d);
match.calculate(c[0]);
LIB::CanonSCC scc(buildSCCFromMatching(match), d);
[](LIB::CanonSBG a, Util::MD_NAT b, bool c) {
LIB::CanonMatch match(a.copy(b[0]), c);
match.calculate();
LIB::CanonSCC scc(buildSCCFromMatching(match), c);
return MapBaseType(scc.calculate());
},
[](auto a, auto b, auto c, auto d) {
[](auto a, auto b, auto c) {
Util::ERROR("Wrong arguments for matching+scc");
return MapBaseType();
}
};

auto match_scc_ts_visitor_ = Util::Overload {
[](LIB::BaseSBG a, Util::MD_NAT b, Util::MD_NAT c, bool d) {
LIB::BaseMatch match(a.copy(b[0]), d);
LIB::UnordSet match_res = match.calculate(c[0]).matched_edges();
LIB::BaseSCC scc(buildSCCFromMatching(match), d);
[](LIB::BaseSBG a, Util::MD_NAT b, bool c) {
LIB::BaseMatch match(a.copy(b[0]), c);
LIB::UnordSet match_res = match.calculate().matched_edges();
LIB::BaseSCC scc(buildSCCFromMatching(match), c);
LIB::BasePWMap scc_res = scc.calculate();
LIB::BaseTopSort ts(buildSortFromSCC(scc, scc_res), d);
LIB::BaseTopSort ts(buildSortFromSCC(scc, scc_res), c);
LIB::BasePWMap ts_res = ts.calculate();
buildJson(match_res, scc_res, ts_res);
return MapBaseType(ts_res);
},
[](LIB::CanonSBG a, Util::MD_NAT b, Util::MD_NAT c, bool d) {
LIB::CanonMatch match(a.copy(b[0]), d);
LIB::OrdSet match_res = match.calculate(c[0]).matched_edges();
LIB::CanonSCC scc(buildSCCFromMatching(match), d);
[](LIB::CanonSBG a, Util::MD_NAT b, bool c) {
LIB::CanonMatch match(a.copy(b[0]), c);
LIB::OrdSet match_res = match.calculate().matched_edges();
LIB::CanonSCC scc(buildSCCFromMatching(match), c);
LIB::CanonPWMap scc_res = scc.calculate();
LIB::CanonTopSort ts(buildSortFromSCC(scc, scc_res), d);
LIB::CanonTopSort ts(buildSortFromSCC(scc, scc_res), c);
LIB::CanonPWMap ts_res = ts.calculate();
buildJson(match_res, scc_res, ts_res);
return MapBaseType(ts_res);
},
[](auto a, auto b, auto c, auto d) {
[](auto a, auto b, auto c) {
Util::ERROR("Wrong arguments for matching+scc+ts");
return MapBaseType();
}
Expand Down Expand Up @@ -675,14 +675,13 @@ ExprBaseType EvalExpression::operator()(AST::Call v) const
break;

case Eval::Func::matching:
if (eval_args.size() == 3) {
if (eval_args.size() == 2) {
arity_ok = true;

SBGBaseType g = std::visit(EvalGraph{}, eval_args[0]);
NatBaseType copies = std::visit(EvalNatBT{}, eval_args[1]);
NatBaseType k = std::visit(EvalNatBT{}, eval_args[2]);
InfoBaseType result = std::visit(
matching_visitor_, g, copies, k, std::variant<bool>(debug_)
matching_visitor_, g, copies, std::variant<bool>(debug_)
);
return result;
}
Expand Down Expand Up @@ -723,28 +722,26 @@ ExprBaseType EvalExpression::operator()(AST::Call v) const
}

case Eval::Func::match_scc:
if (eval_args.size() == 3) {
if (eval_args.size() == 2) {
arity_ok = true;

SBGBaseType g = std::visit(EvalGraph{}, eval_args[0]);
NatBaseType copies = std::visit(EvalNatBT{}, eval_args[1]);
NatBaseType k = std::visit(EvalNatBT{}, eval_args[2]);
MapBaseType result = std::visit(
match_scc_visitor_, g, copies, k, std::variant<bool>(debug_)
match_scc_visitor_, g, copies, std::variant<bool>(debug_)
);
return result;
}
break;

case Eval::Func::match_scc_ts:
if (eval_args.size() == 3) {
if (eval_args.size() == 2) {
arity_ok = true;

SBGBaseType g = std::visit(EvalGraph{}, eval_args[0]);
NatBaseType copies = std::visit(EvalNatBT{}, eval_args[1]);
NatBaseType k = std::visit(EvalNatBT{}, eval_args[2]);
MapBaseType result = std::visit(
match_scc_ts_visitor_, g, copies, k, std::variant<bool>(debug_)
match_scc_ts_visitor_, g, copies, std::variant<bool>(debug_)
);
return result;
}
Expand Down
5 changes: 3 additions & 2 deletions sbg/pw_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -717,9 +717,10 @@ PWMap<Set> PWMap<Set>::minAdjMap(const PWMap &other2, const PWMap &other3) const
PWMap ith_pw(ith);
Set again = dom_res.intersection(visited);
if (!again.isEmpty()) {
PWMap<Set> min_map = other3.minMap(res, ith_pw, other3);
PWMap aux_res = res.restrict(dom_res);
PWMap min_map = other3.minMap(aux_res, ith_pw, other3);
res = min_map.combine(ith_pw).combine(res);
visited = visited.cup(min_map.dom());
visited = visited.cup(ith_pw.dom());
}
else {
res.emplaceBack(ith);
Expand Down
Loading

0 comments on commit 8d0b725

Please sign in to comment.