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

Merge branch 'addFeature/graphRegex/defaultNodeTester' into 'main'

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

See merge request !51
parents 7eb944b3 aa48d6c1
No related branches found
No related tags found
1 merge request!51Ignored inconue node types by creating a spesific branch of the FSM that cancels the transition
Pipeline #34610 passed
......@@ -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
{
......@@ -127,7 +127,7 @@ namespace Aidge{
};
/**
* @brief class spesialisation for commun node transition
* @brief class specialization for commun node transition
* @see FsmEdge
*/
class FsmEdgeCommon:public FsmEdge
......@@ -181,7 +181,7 @@ namespace Aidge{
};
/**
* @brief class spesialisation for ref empty transition
* @brief class specialization for ref empty transition
* @see FsmEdge
*/
class FsmEdgeEmpty:public FsmEdge
......@@ -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
......
......@@ -128,7 +128,7 @@ std::shared_ptr<FsmGraph> GraphFsmInterpreter::qomF(std::shared_ptr<FsmGraph> fs
for(auto valid : allValid){
if(haveCommon){
/*
the // quantif case
the // quantify case
get the go back and make a lexeme id(number)
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
edge = FsmEdgeFactory::make(valid,start,FsmEdgeTypes::REF,mNodesCondition, lexem.str());
}else{
/*
the sequensial quantif case
the sequencial quantify case
no reference to common
*/
edge = FsmEdgeFactory::make(valid,start,FsmEdgeTypes::EMPTY,mNodesCondition,"");
......
......@@ -226,6 +226,14 @@ const EdgeTestResult FsmEdgeEmpty::test(const std::shared_ptr<FsmRunTimeContext>
}
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
std::shared_ptr<FsmEdge> FsmEdgeFactory::make(
......@@ -260,7 +268,10 @@ const std::string lexeme)
std::string commonKey = edgeType + std::to_string(commonIdx);
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);
......@@ -274,7 +285,11 @@ const std::string lexeme)
std::string edgeType = m[1];
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));
......
......@@ -55,7 +55,7 @@ TEST_CASE("GraphRegexUser") {
}
SECTION("CC") {
SECTION("2 query") {
std::shared_ptr<GraphRegex> sut = std::make_shared<GraphRegex>();
std::shared_ptr<GraphView> g1 = std::make_shared<GraphView>("TestGraph");
......@@ -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"){
// 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