after dragging the data structure through cli variant::is<>() does not recognize the type correctly
A Nondeterministic z-automaton created by ExactPatternMatchingAutomaton cannot when run through cli.
I'm iterating through the transition function of the Nondeterminstic-Z-Automaton (NZA) within the c++ code.
LHS of the transition function is split into state/symbol of the root and state/symbol of the children.
When qureying the root in the transition function whether it is a SymbolType or a StateType via variant::is
I get positive results for both alternatives. (see the code and output below)
This does not work when the algorithm is invoked via CLI. It does work correctly when invoked from CPP code.
How to reproduce:
- Apply this patch to ToArcFactored.h a.patch
diff --git a/alib2algo/src/automaton/simplify/ToArcFactored.h b/alib2algo/src/automaton/simplify/ToArcFactored.h
index e47f8ee54..3eb0887ce 100644
--- a/alib2algo/src/automaton/simplify/ToArcFactored.h
+++ b/alib2algo/src/automaton/simplify/ToArcFactored.h
@@ -20,6 +20,7 @@
#include <alib/vector>
#include <alib/variant>
+#include <global/GlobalData.h>
#include "automaton/TA/NondeterministicZAutomaton.h"
#include "automaton/TA/ArcFactoredNondeterministicZAutomaton.h"
@@ -42,6 +43,17 @@ public:
template < class SymbolType, class StateType >
ArcFactoredNondeterministicZAutomaton < SymbolType, ext::vector < ext::variant < SymbolType, StateType > > > ToArcFactored::convert ( const NondeterministicZAutomaton < SymbolType, StateType > & automaton ) {
+
+ for (const auto& [from, to] : automaton.getTransitions()) {
+ common::Streams::log << "************" << std::endl;
+ if (from.first.template is<SymbolType>()) {
+ common::Streams::log << "PARENT=SYMBOL_TYPE: " << from << " -> " << to << std::endl;
+ }
+ if (from.first.template is<StateType>()) {
+ common::Streams::log << "PARENT=STATE_TYPE: " << from << " -> " << to << std::endl;
+ }
+ }
+
ext::map < StateType, ext::set < StateType > > epsilonClosure = automaton::properties::AllEpsilonClosure::allEpsilonClosure ( automaton );
ext::multimap < ext::pair < ext::variant < SymbolType, StateType >, ext::vector < ext::variant < SymbolType, StateType > > >, StateType > nonEpsilonTransitions;
- Run this aql script and see the failure. YOu will see something like this:
(NondeterministicZAutomaton states = {0, 1, 2, 3, 4} inputAlphabet = {97, 98, 99} finalStates = {2} transitions = {((0, [0]), 0), ((1, [4]), 2), ((3, [0]), 4), ((97, []), 0), ((97, []), 1), ((97, []), 3), ((98, []), 0), ((99, []), 0)})
************
PARENT=SYMBOL_TYPE: (0, [0]) -> 0
PARENT=STATE_TYPE: (0, [0]) -> 0
************
PARENT=SYMBOL_TYPE: (1, [4]) -> 2
PARENT=STATE_TYPE: (1, [4]) -> 2
************
PARENT=SYMBOL_TYPE: (3, [0]) -> 4
PARENT=STATE_TYPE: (3, [0]) -> 4
************
PARENT=SYMBOL_TYPE: (97, []) -> 0
PARENT=STATE_TYPE: (97, []) -> 0
************
PARENT=SYMBOL_TYPE: (97, []) -> 1
PARENT=STATE_TYPE: (97, []) -> 1
************
PARENT=SYMBOL_TYPE: (97, []) -> 3
PARENT=STATE_TYPE: (97, []) -> 3
************
PARENT=SYMBOL_TYPE: (98, []) -> 0
PARENT=STATE_TYPE: (98, []) -> 0
************
PARENT=SYMBOL_TYPE: (99, []) -> 0
PARENT=STATE_TYPE: (99, []) -> 0
- See that it does work when running from cpp test.cpp