1717
1818 ******************************************************************************/
1919
20+ #include " eval/visitors/func_evaluator.hpp"
2021#include " algorithms/cc/cc.hpp"
21- // #include "algorithms/cutvertex/cv_fact.hpp"
22+ #include " algorithms/mfvs/min_feedback_vertex_set.hpp"
23+ #include " algorithms/mfvs/mfvs_fact.hpp"
2224#include " algorithms/matching/matching_fact.hpp"
2325#include " algorithms/misc/causalization_builders.hpp"
2426#include " algorithms/scc/scc_fact.hpp"
2527// #include "algorithms/toposort/ts_fact.hpp"
2628#include " eval/base_type.hpp"
27- #include " eval/visitors/func_evaluator.hpp"
2829#include " sbg/bipartite_sbg.hpp"
2930#include " sbg/expression.hpp"
3031#include " sbg/interval.hpp"
@@ -43,85 +44,6 @@ namespace Eval {
4344
4445namespace detail {
4546
46- // //////////////////////////////////////////////////////////////////////////////
47- // Auxiliary functions ---------------------------------------------------------
48- // //////////////////////////////////////////////////////////////////////////////
49-
50- // TODO
51- /* *
52- * @brief Returns a new bipartite SBG constructed by copying \p times the
53- * the current bipartite SBG, disconnected one from each other.
54- */
55- /*
56- LIB::BipartiteSBG copy(unsigned int times, BipartiteSBG bsbg)
57- {
58- Set ith_V = _V;
59- Set new_V = ith_V;
60- PWMap ith_Vmap = _Vmap;
61- PWMap new_Vmap = ith_Vmap;
62- PWMap ith_map1 = _map1;
63- PWMap new_map1 = ith_map1;
64- PWMap ith_map2 = _map2;
65- PWMap new_map2 = ith_map2;
66- PWMap ith_Emap = _Emap;
67- PWMap new_Emap = ith_Emap;
68- PWMap ith_subE = _subEmap;
69- PWMap new_subE = ith_subE;
70- Set ith_X = _X;
71- Set new_X = ith_X;
72- Set ith_Y = _Y;
73- Set new_Y = ith_Y;
74-
75- if (!ith_V.isEmpty()) {
76- MD_NAT maxv = ith_V.maxElem();
77- auto dims = maxv.arity();
78- MD_NAT maxV
79- = ith_Vmap.isEmpty() ? MD_NAT(dims, 0) : ith_Vmap.image().maxElem();
80- MD_NAT maxe = _E.isEmpty() ? MD_NAT(dims, 0) : _E.maxElem();
81- MD_NAT maxE
82- = ith_Emap.isEmpty() ? MD_NAT(dims, 0) : ith_Emap.image().maxElem();
83-
84- Exp off;
85- for (unsigned int j = 0; j < dims; ++j) {
86- RATIONAL o = RATIONAL(maxv[j]) - RATIONAL(maxe[j]);
87- off.emplaceBack(LExp(0, o));
88- }
89-
90- for (unsigned int j = 0; j < times; ++j) {
91- if (j > 0) {
92- new_V = new_V.disjointCup(ith_V);
93- new_Vmap = new_Vmap.concatenation(ith_Vmap);
94- new_map1 = new_map1.concatenation(ith_map1);
95- new_map2 = new_map2.concatenation(ith_map2);
96- new_Emap = new_Emap.concatenation(ith_Emap);
97- new_subE = new_subE.concatenation(ith_subE);
98- new_X = new_X.disjointCup(ith_X);
99- new_Y = new_Y.disjointCup(ith_Y);
100- }
101-
102- ith_V = ith_V.offset(maxv);
103- ith_Vmap = ith_Vmap.offsetDom(maxv);
104- ith_Vmap = ith_Vmap.offsetImage(maxV);
105-
106- ith_map1 = ith_map1.offsetDom(maxe);
107- ith_map1 = ith_map1.offsetImage(off);
108- ith_map2 = ith_map2.offsetDom(maxe);
109- ith_map2 = ith_map2.offsetImage(off);
110- ith_Emap = ith_Emap.offsetDom(maxe);
111- ith_Emap = ith_Emap.offsetImage(maxE);
112- ith_subE = ith_subE.offsetDom(maxe);
113- ith_subE = ith_subE.offsetImage(maxE);
114-
115- ith_X = ith_X.offset(maxv);
116- ith_Y = ith_Y.offset(maxv);
117- }
118- }
119-
120- return BipartiteSBG{new_V, new_Vmap, new_map1, new_map2, new_Emap, new_subE
121- , new_X, new_Y};
122- }
123- */
124-
12547// //////////////////////////////////////////////////////////////////////////////
12648// Built-in operators evaluators -----------------------------------------------
12749// //////////////////////////////////////////////////////////////////////////////
@@ -631,22 +553,6 @@ ExprBaseType BuiltInFunctions::minMapEvaluator(const EBTList& args)
631553 return std::visit (min_map_evaluator, args[0 ], args[1 ]);
632554}
633555
634- // TODO
635- // ExprBaseType BuiltInFunctions::reduceEvaluator(const EBTList& args)
636- // {
637- // Util::ERROR_UNLESS(args.size() == 1
638- // , "reduceEvaluator: wrong number of arguments\n");
639- //
640- // const auto reduce_evaluator = Util::Overload {
641- // [](LIB::PWMap a) { return ExprBaseType{a.reduce()}; },
642- // [](auto a) {
643- // Util::ERROR("reduceEvaluator: wrong argument ", a, " for reduce\n");
644- // return ExprBaseType{};
645- // }
646- // };
647- // return std::visit(reduce_evaluator, args[0]);
648- // }
649-
650556ExprBaseType BuiltInFunctions::minAdjEvaluator (const EBTList& args)
651557{
652558 Util::ERROR_UNLESS (args.size () == 2
@@ -751,44 +657,6 @@ ExprBaseType BuiltInFunctions::sccEvaluator(const EBTList& args)
751657 return std::visit (scc_evaluator, args[0 ]);
752658}
753659
754- /*
755- ExprBaseType BuiltInFunctions::topoSortEvaluator(const EBTList& args)
756- {
757- Util::ERROR_UNLESS(args.size() == 1
758- , "topoSortEvaluator: wrong number of arguments\n");
759-
760- LIB::TopoSort ts_impl = LIB::TS_FACT.createTSAlgorithm();
761- const auto ts_evaluator = Util::Overload {
762- [&ts_impl](LIB::DirectedSBG a) {
763- return ExprBaseType{ts_impl.calculate(a)};
764- },
765- [](auto a) {
766- Util::ERROR("topoSortEvaluator: wrong argument ", a, " for sort\n");
767- return ExprBaseType{};
768- }
769- };
770- return std::visit(ts_evaluator, args[0]);
771- }
772-
773- ExprBaseType BuiltInFunctions::cutVertexEvaluator(const EBTList& args)
774- {
775- Util::ERROR_UNLESS(args.size() == 1
776- , "cutVertexEvaluator: wrong number of arguments\n");
777-
778- LIB::CutVertex cv_impl = LIB::CV_FACT.createCVAlgorithm();
779- const auto cv_evaluator = Util::Overload {
780- [&cv_impl](LIB::DirectedSBG a) {
781- return ExprBaseType{cv_impl.calculate(a)};
782- },
783- [](auto a) {
784- Util::ERROR("topoSortEvaluator: wrong argument ", a, " for sort\n");
785- return ExprBaseType{};
786- }
787- };
788- return std::visit(cv_evaluator, args[0]);
789- }
790- */
791-
792660ExprBaseType BuiltInFunctions::matchSCCEvaluator (const EBTList& args)
793661{
794662 Util::ERROR_UNLESS (args.size () == 2
@@ -817,7 +685,44 @@ ExprBaseType BuiltInFunctions::matchSCCEvaluator(const EBTList& args)
817685 return std::visit (match_scc_evaluator, args[0 ], args[1 ]);
818686}
819687
688+ ExprBaseType BuiltInFunctions::mfvsEvaluator (const EBTList& args)
689+ {
690+ Util::ERROR_UNLESS (args.size () == 1
691+ , " mfvsEvaluator: wrong number of arguments\n " );
692+
693+ LIB ::MinFeedbackVertexSet mfvs_impl = LIB ::MFVS_FACT .createMFVSAlgorithm ();
694+ const auto mfvs_evaluator = Util::Overload {
695+ [&mfvs_impl](LIB ::DirectedSBG a) {
696+ return ExprBaseType{mfvs_impl.calculate (a)};
697+ },
698+ [](auto a) {
699+ Util::ERROR (" mfvsEvaluator: wrong type of argument " , a
700+ , " for MFVS algorithm\n " );
701+ return ExprBaseType{};
702+ }
703+ };
704+ return std::visit (mfvs_evaluator, args[0 ]);
705+ }
706+
820707/*
708+ ExprBaseType BuiltInFunctions::topoSortEvaluator(const EBTList& args)
709+ {
710+ Util::ERROR_UNLESS(args.size() == 1
711+ , "topoSortEvaluator: wrong number of arguments\n");
712+
713+ LIB::TopoSort ts_impl = LIB::TS_FACT.createTSAlgorithm();
714+ const auto ts_evaluator = Util::Overload {
715+ [&ts_impl](LIB::DirectedSBG a) {
716+ return ExprBaseType{ts_impl.calculate(a)};
717+ },
718+ [](auto a) {
719+ Util::ERROR("topoSortEvaluator: wrong argument ", a, " for sort\n");
720+ return ExprBaseType{};
721+ }
722+ };
723+ return std::visit(ts_evaluator, args[0]);
724+ }
725+
821726ExprBaseType BuiltInFunctions::matchSCCTSEvaluator(const EBTList& args)
822727{
823728 const auto match_scc_ts_evaluator = Util::Overload {
0 commit comments