Skip to content
Snippets Groups Projects
Commit aa48d6c1 authored by vincent  lorrain's avatar vincent lorrain
Browse files

ignored inconue node types by creating a spesific branch of the FSM that cancels the transition

parent 7eb944b3
No related branches found
No related tags found
No related merge requests found
...@@ -116,7 +116,7 @@ namespace Aidge{ ...@@ -116,7 +116,7 @@ namespace Aidge{
}; };
/** /**
* @brief class spesialisation for not commun node (node that must be match one Unique) transition * @brief class specialization for not commun node (node that must be match one Unique) transition
*/ */
class FsmEdgeUnique:public FsmEdge class FsmEdgeUnique:public FsmEdge
{ {
...@@ -127,7 +127,7 @@ namespace Aidge{ ...@@ -127,7 +127,7 @@ namespace Aidge{
}; };
/** /**
* @brief class spesialisation for commun node transition * @brief class specialization for commun node transition
* @see FsmEdge * @see FsmEdge
*/ */
class FsmEdgeCommon:public FsmEdge class FsmEdgeCommon:public FsmEdge
...@@ -181,7 +181,7 @@ namespace Aidge{ ...@@ -181,7 +181,7 @@ namespace Aidge{
}; };
/** /**
* @brief class spesialisation for ref empty transition * @brief class specialization for ref empty transition
* @see FsmEdge * @see FsmEdge
*/ */
class FsmEdgeEmpty:public FsmEdge class FsmEdgeEmpty:public FsmEdge
...@@ -195,6 +195,20 @@ namespace Aidge{ ...@@ -195,6 +195,20 @@ namespace Aidge{
}; };
/**
* @brief class specialization for ref empty transition
* @see FsmEdge
*/
class FsmEdgeNone:public FsmEdge
{
public:
FsmEdgeNone(std::shared_ptr<FsmNode> source,std::shared_ptr<FsmNode> dest);
const EdgeTestResult test(const std::shared_ptr<FsmRunTimeContext> /*stmContext*/) override;
};
//////////////////////// ////////////////////////
// FACTORY // FACTORY
......
...@@ -128,7 +128,7 @@ std::shared_ptr<FsmGraph> GraphFsmInterpreter::qomF(std::shared_ptr<FsmGraph> fs ...@@ -128,7 +128,7 @@ std::shared_ptr<FsmGraph> GraphFsmInterpreter::qomF(std::shared_ptr<FsmGraph> fs
for(auto valid : allValid){ for(auto valid : allValid){
if(haveCommon){ if(haveCommon){
/* /*
the // quantif case the // quantify case
get the go back and make a lexeme id(number) get the go back and make a lexeme id(number)
we need to go back to the ref delta min #TODO we need to go back to the ref delta min #TODO
*/ */
...@@ -145,7 +145,7 @@ std::shared_ptr<FsmGraph> GraphFsmInterpreter::qomF(std::shared_ptr<FsmGraph> fs ...@@ -145,7 +145,7 @@ std::shared_ptr<FsmGraph> GraphFsmInterpreter::qomF(std::shared_ptr<FsmGraph> fs
edge = FsmEdgeFactory::make(valid,start,FsmEdgeTypes::REF,mNodesCondition, lexem.str()); edge = FsmEdgeFactory::make(valid,start,FsmEdgeTypes::REF,mNodesCondition, lexem.str());
}else{ }else{
/* /*
the sequensial quantif case the sequencial quantify case
no reference to common no reference to common
*/ */
edge = FsmEdgeFactory::make(valid,start,FsmEdgeTypes::EMPTY,mNodesCondition,""); edge = FsmEdgeFactory::make(valid,start,FsmEdgeTypes::EMPTY,mNodesCondition,"");
......
...@@ -226,6 +226,14 @@ const EdgeTestResult FsmEdgeEmpty::test(const std::shared_ptr<FsmRunTimeContext> ...@@ -226,6 +226,14 @@ const EdgeTestResult FsmEdgeEmpty::test(const std::shared_ptr<FsmRunTimeContext>
} }
return {true,std::set<NodePtr>({opNode})};//none return {true,std::set<NodePtr>({opNode})};//none
} }
//////////////
FsmEdgeNone::FsmEdgeNone(std::shared_ptr<FsmNode> source,std::shared_ptr<FsmNode> dest)
:FsmEdge(source,dest,nullptr)
{}
const EdgeTestResult FsmEdgeNone::test(const std::shared_ptr<FsmRunTimeContext> /*stmContext*/){
return {false,std::set<NodePtr>()};
}
/// factory /// factory
std::shared_ptr<FsmEdge> FsmEdgeFactory::make( std::shared_ptr<FsmEdge> FsmEdgeFactory::make(
...@@ -260,7 +268,10 @@ const std::string lexeme) ...@@ -260,7 +268,10 @@ const std::string lexeme)
std::string commonKey = edgeType + std::to_string(commonIdx); std::string commonKey = edgeType + std::to_string(commonIdx);
if(allTest.find(edgeType) == allTest.end()){ if(allTest.find(edgeType) == allTest.end()){
throw std::invalid_argument("Bad Node Test " + edgeType ); //if the key is not linked to a condition
//by default, it is initialized by a edge that is always false
return std::make_shared<FsmEdgeNone>(source, dest);
//throw std::invalid_argument("Bad Node Test " + edgeType );
} }
return std::make_shared<FsmEdgeCommon> (source, dest, allTest.at(edgeType), commonKey); return std::make_shared<FsmEdgeCommon> (source, dest, allTest.at(edgeType), commonKey);
...@@ -274,7 +285,11 @@ const std::string lexeme) ...@@ -274,7 +285,11 @@ const std::string lexeme)
std::string edgeType = m[1]; std::string edgeType = m[1];
if(allTest.find(edgeType) == allTest.end()){ if(allTest.find(edgeType) == allTest.end()){
throw std::invalid_argument("Bad Node Test " + edgeType );
//if the key is not linked to a condition
//by default, it is initialized by a edge that is always false
return std::make_shared<FsmEdgeNone>(source, dest);
//throw std::invalid_argument("Bad Node Test " + edgeType );
} }
return std::make_shared<FsmEdgeUnique>(source, dest, allTest.at(edgeType)); return std::make_shared<FsmEdgeUnique>(source, dest, allTest.at(edgeType));
......
...@@ -55,7 +55,7 @@ TEST_CASE("GraphRegexUser") { ...@@ -55,7 +55,7 @@ TEST_CASE("GraphRegexUser") {
} }
SECTION("CC") { SECTION("2 query") {
std::shared_ptr<GraphRegex> sut = std::make_shared<GraphRegex>(); std::shared_ptr<GraphRegex> sut = std::make_shared<GraphRegex>();
std::shared_ptr<GraphView> g1 = std::make_shared<GraphView>("TestGraph"); std::shared_ptr<GraphView> g1 = std::make_shared<GraphView>("TestGraph");
...@@ -88,6 +88,41 @@ TEST_CASE("GraphRegexUser") { ...@@ -88,6 +88,41 @@ TEST_CASE("GraphRegexUser") {
} }
SECTION("Not define node Test") {
//test if the FC is not define only match query not query2
std::shared_ptr<GraphRegex> sut = std::make_shared<GraphRegex>();
std::shared_ptr<GraphView> g1 = std::make_shared<GraphView>("TestGraph");
std::shared_ptr<Node> conv = GenericOperator("Conv", 1, 1, 1, "c");
std::shared_ptr<Node> conv1 = GenericOperator("Conv", 1, 1, 1, "c1");
std::shared_ptr<Node> conv2 = GenericOperator("Conv", 1, 1, 1, "c2");
std::shared_ptr<Node> conv3 = GenericOperator("FC", 1, 1, 1, "c3");
g1->add(conv);
g1->addChild(conv1, "c");
g1->addChild(conv2, "c1");
g1->addChild(conv3, "c2");
//sut->setKeyFromGraph(g1);
const std::string query = "Conv->Conv";
const std::string query2 = "Conv->FC";
sut->setNodeKey("Conv","getType($) =='Conv'");
sut->addQuery(query);
sut->addQuery(query2);
for (const auto& solution : sut->match(g1)) {
REQUIRE(solution->getQuery() == query);
}
}
SECTION("Applied Recipes"){ SECTION("Applied Recipes"){
// generate the original GraphView // generate the original GraphView
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment