// MS: we definitely need to cache all the results or use a proper graph structure TransitionGraph::TransitionPtrSet TransitionGraph::outEdges(const EState* estate) { ROSE_ASSERT(estate); if(getModeLTLDriven()) { ROSE_ASSERT(_analyzer); if(_outEdges[estate].size()==0) { ROSE_ASSERT(_analyzer); Analyzer::SubSolverResultType subSolverResult=_analyzer->subSolver(estate); EStateWorkList& deferedWorkList=subSolverResult.first; EStateSet& existingEStateSet=subSolverResult.second; EStatePtrSet succNodes; for(EStateWorkList::iterator i=deferedWorkList.begin(); i!=deferedWorkList.end(); ++i) { succNodes.insert(*i); } for(EStateSet::iterator i=existingEStateSet.begin(); i!=existingEStateSet.end(); ++i) { succNodes.insert(*i); } //cout<<"DEBUG: succ:"<<deferedWorkList.size()<<","<<existingEStateSet.size()<<":"<<succNodes.size()<<endl; for(EStatePtrSet::iterator j=succNodes.begin(); j!=succNodes.end(); ++j) { Edge newEdge(estate->label(),EDGE_PATH,(*j)->label()); Transition t(estate,newEdge,*j); add(t); } } //if(_outEdges[estate].size()>0) cout<<"DEBUG: #out-edges="<<_outEdges[estate].size()<<endl; } return _outEdges[estate]; }
EStatePtrSet TransitionGraph::succ(const EState* estate) { EStatePtrSet succNodes; TransitionPtrSet tset=outEdges(estate); for(TransitionPtrSet::iterator i=tset.begin(); i!=tset.end(); ++i) { succNodes.insert((*i)->target); } return succNodes; }
EStatePtrSet TransitionGraph::pred(const EState* estate) { EStatePtrSet predNodes; TransitionPtrSet tset=inEdges(estate); for(TransitionPtrSet::iterator i=tset.begin(); i!=tset.end(); ++i) { predNodes.insert((*i)->source); } return predNodes; }
pair<EStatePtrSet, EStatePtrSet> CounterexampleAnalyzer::getConcreteOutputAndAbstractInput(TransitionGraph* model) { EStatePtrSet allEStates=model->estateSet(); EStatePtrSet concreteOutputStates; EStatePtrSet abstractInputStates; concreteOutputStates.insert(model->getStartEState()); // the start state has following input states just like output states do. for(EStatePtrSet::iterator i=allEStates.begin(); i!=allEStates.end(); ++i) { if ((*i)->isRersTopified(_analyzer->getVariableIdMapping())) { if ((*i)->io.isStdInIO()) { abstractInputStates.insert(*i); } } else { if ((*i)->io.isStdOutIO()) { concreteOutputStates.insert(*i); } } } return pair<EStatePtrSet, EStatePtrSet> (concreteOutputStates, abstractInputStates); }
EStatePtrSet CounterexampleAnalyzer::addAllPrefixOutputStates(EStatePtrSet& startAndOuputStatesPrefix, TransitionGraph* model) { EStatePtrSet allEStates = model->estateSet(); for (EStatePtrSet::iterator i=allEStates.begin(); i!=allEStates.end(); ++i) { //start state has already been added if ((*i)->io.isStdOutIO()) { if (! (*i)->isRersTopified(_analyzer->getVariableIdMapping())) { startAndOuputStatesPrefix.insert(*i); } } } return startAndOuputStatesPrefix; }