From 4e953d8a783a01049384aed2afa74366eab9a9c2 Mon Sep 17 00:00:00 2001 From: cmoineau <cyril.moineau@cea.fr> Date: Tue, 17 Oct 2023 11:52:31 +0000 Subject: [PATCH] [FsmGraph] Fix issue with badly updated set. --- src/graphRegex/matchFsm/FsmGraph.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/graphRegex/matchFsm/FsmGraph.cpp b/src/graphRegex/matchFsm/FsmGraph.cpp index 09bc25d63..5a9f00d72 100644 --- a/src/graphRegex/matchFsm/FsmGraph.cpp +++ b/src/graphRegex/matchFsm/FsmGraph.cpp @@ -1,6 +1,6 @@ #include "aidge/graphRegex/matchFsm/FsmGraph.hpp" -using namespace Aidge; +using namespace Aidge; @@ -14,7 +14,7 @@ FsmGraph::FsmGraph(/* args */){ if(startNodes.size() != startNodesFsm.size()){ throw std::runtime_error("bad number of Start nodes"); } - + std::vector<std::shared_ptr<FsmRunTimeContext>> walks; for(std::size_t i = 0; i < startNodes.size(); i++){ walks.push_back(std::make_shared<FsmRunTimeContext>(startNodesFsm[i],startNodes[i])); @@ -32,16 +32,16 @@ FsmGraph::FsmGraph(/* args */){ for(auto fsmContext : walks){ allContextSee.push_back(fsmContext); //if we are in a valid st we save it - //it's one solution of the posible solution of the matching + //it's one solution of the posible solution of the matching if(fsmContext->isOnValidState()){ - //not save 2 time the same end point + //not save 2 time the same end point if(!std::any_of(allValidContext.begin(), allValidContext.end(), [&](std::shared_ptr<Aidge::FsmRunTimeContext> oldValid) { return fsmContext->areEqual(oldValid); })){ allValidContext.push_back(fsmContext); } - + } //dont test 2 time a fsmContext @@ -60,15 +60,15 @@ FsmGraph::FsmGraph(/* args */){ walks.swap(nextWalks); nextWalks.clear(); } - - + + return std::make_shared<MatchResult>(allValidContext,getNbSubFsm()); } /////////////// -// FSM construction +// FSM construction /////////////// const std::set<std::shared_ptr<FsmEdge>>& FsmGraph::getEdge(void){ return mEdges; @@ -140,7 +140,7 @@ void FsmGraph::mergeOneStartOneValid(const std::shared_ptr<FsmGraph> fsmGraph){ } unionG(fsmGraph); - //for loop useless but for future merge it's coudl be used + //for loop useless but for future merge it's coudl be used for(auto valid : validNodes){ valid->unValid(); for(auto start : startNodes){ @@ -159,9 +159,11 @@ void FsmGraph::incOrigineAllNodeBy(std::size_t incr){ for(auto node :nodes){ node->incOrigine(incr); } + std::set<std::size_t> updatedOrigin; for(auto origin : mAllOrigine){ - origin += incr; + updatedOrigin.insert(origin + incr); } + mAllOrigine.swap(updatedOrigin); } void FsmGraph::_mergeNode(std::shared_ptr<FsmNode> source,std::shared_ptr<FsmNode> dest){ @@ -189,7 +191,7 @@ void FsmGraph::_mergeNode(std::shared_ptr<FsmNode> source,std::shared_ptr<FsmNod } } - //check is source is not in graph + //check is source is not in graph nodes = getNodes(); if(nodes.find(source) != nodes.end() ){ throw std::runtime_error("FsmGraph merge node not effective"); -- GitLab