Package statechum.model.testset

Examples of statechum.model.testset.PTASequenceEngine


   * @param vertTarget the target state
   * @return sequences of inputs to follow all paths found.
   */ 
  Collection<List<Label>> computePathsBetween(CmpVertex vertSource, CmpVertex vertTarget)
  {
    PTASequenceEngine engine = new PTASequenceEngine();engine.init(new PTASequenceSetAutomaton());
    PTASequenceEngine.SequenceSet initSet = engine.new SequenceSet();initSet.setIdentity();
    PTASequenceEngine.SequenceSet paths = engine.new SequenceSet();paths.setIdentity();
    computePathsSBetween(vertSource, vertTarget,initSet,paths);
    return engine.getData();
  }
View Full Code Here


    final RandomPathGenerator generator = new RandomPathGenerator(cvsGraph,new Random(0),5,null);
    final int posOrNegPerChunk = 50;
    generator.generateRandomPosNeg(posOrNegPerChunk*2,1);
    Collection<List<Label>> sequences = cvsGraph.wmethod.getFullTestSet(1);//generator.getAllSequences(0).getData(PTASequenceEngine.truePred);

    PTASequenceEngine walkEngine = new PTA_FSMStructure(cvsGraph,null);
    SequenceSet ptaWalk = walkEngine.new SequenceSet();ptaWalk.setIdentity();
    ptaWalk = ptaWalk.cross(sequences);
   
   
   
View Full Code Here

    return outcome;
  }
 
  public LearnerGraph learn(PTASequenceEngine engineArg, boolean useNegatives)
  {
    PTASequenceEngine engine = null;
    if (!useNegatives)
    {
      PTASequenceEngine positives = new PTASequenceEngine();positives.init(new Automaton());
      SequenceSet initSeq = positives.new SequenceSet();initSeq.setIdentity();
      initSeq.cross(engineArg.getData());
      engine = positives;
    }
    else
View Full Code Here

  }
 
  public static PTASequenceEngine computeQS_general(final StatePair pairToMerge,
      final LearnerGraph original, final LearnerGraph learnt,final QuestionConstructor qConstructor)
  {
    final PTASequenceEngine engine = qConstructor.constructEngine(original, learnt);
   
    final SequenceSet identity = engine.new SequenceSet();identity.setIdentity();
    for(AMEquivalenceClass<CmpVertex,LearnerGraphCachedData> eq:learnt.learnerCache.getMergedStates())
      qConstructor.addQuestionsForState(eq, original, learnt, pairToMerge,
          learnt.learnerCache.stateLearnt,new MergeData(){
View Full Code Here

  {
    CmpVertex mergedRed = merged.findVertex(pair.getR());
    if (mergedRed == null)
      throw new IllegalArgumentException("failed to find the red state in the merge result");
   
    PTASequenceEngine engine = new PTASequenceEngine();
    engine.init(original.new NonExistingPaths());
    PTASequenceEngine.SequenceSet paths = engine.new SequenceSet();
    PTASequenceEngine.SequenceSet initp = engine.new SequenceSet();initp.setIdentity();

    merged.pathroutines.computePathsSBetween(merged.getInit(),mergedRed, initp, paths);
   
    Collection<Label> inputsToMultWith = new LinkedList<Label>();
    for(Entry<Label,CmpVertex> loopEntry:merged.transitionMatrix.get(mergedRed).entrySet())
      if (loopEntry.getValue() == mergedRed)
      {// Note an input corresponding to any loop in temp can be followed in the original machine, since
        // a loop in temp is either due to the merge or because it was there in the first place.
        inputsToMultWith.add(loopEntry.getKey());
      }
    paths.unite(paths.crossWithSet(inputsToMultWith));// the resulting path does a "transition cover" on all transitions leaving the red state.
    merged.questions.buildQuestionsFromPair_Compatible(mergedRed, paths);
    return engine.getData();
  }
View Full Code Here

  {
    CmpVertex mergedRed = merged.findVertex(pair.getR());
    if (mergedRed == null)
      throw new IllegalArgumentException("failed to find the red state in the merge result");
   
    PTASequenceEngine engine = new PTASequenceEngine();
    engine.init(original.new NonExistingPaths());
    PTASequenceEngine.SequenceSet paths = engine.new SequenceSet();
    PTASequenceEngine.SequenceSet initp = engine.new SequenceSet();initp.setIdentity();

    List<Collection<Label>> sequenceOfSets = merged.paths.COMPAT_computePathsSBetween(merged.getInit(),mergedRed);
    if (sequenceOfSets == null)
      throw new IllegalArgumentException("failed to find the red state in the merge result");
    for(Collection<Label> inputsToMultWith:sequenceOfSets)
      initp = initp.crossWithSet(inputsToMultWith);
    paths.unite(initp);
    //merged.paths.computePathsSBetweenBooleanReduced(merged.init,mergedRed, initp, paths);
   
    Collection<Label> inputsToMultWith = new LinkedList<Label>();
    for(Entry<Label,CmpVertex> loopEntry:merged.transitionMatrix.get(mergedRed).entrySet())
      if (loopEntry.getValue() == mergedRed)
      {// Note an input corresponding to any loop in temp can be followed in the original machine, since
        // a loop in temp is either due to the merge or because it was there in the first place.
        inputsToMultWith.add(loopEntry.getKey());
      }
    paths.unite(paths.crossWithSet(inputsToMultWith));// the resulting path does a "transition cover" on all transitions leaving the red state.
    merged.questions.buildQuestionsFromPair_Compatible(mergedRed, paths);
    return engine.getData();
  }
View Full Code Here

  {
    CmpVertex mergedRed = merged.findVertex(pair.getR());
    if (mergedRed == null)
      throw new IllegalArgumentException("failed to find the red state in the merge result");
   
    PTASequenceEngine engine = new PTASequenceEngine();
    engine.init(original.new NonExistingPaths());
    PTASequenceEngine.SequenceSet initp = engine.new SequenceSet();initp.setIdentity();
    merged.questions.buildQuestionsFromPair_Compatible(mergedRed, initp);
    return engine.getData(PTASequenceEngine.truePred);
  }
View Full Code Here

      case CONVENTIONAL: qConstructor=new QSMQuestionGenerator();break;
      case CONVENTIONAL_IMPROVED:qConstructor=new QSMQuestionGeneratorImproved();break;
      case SYMMETRIC:qConstructor=new SymmetricQuestionGenerator();break;
      case ORIGINAL:assert false;break;// should not be reached because it is handled at the top of this routine.
    }
    PTASequenceEngine engine = original.learnerCache.getQuestionsPTA();
    if (engine == null)
    {
      engine = computeQS_general(pair, original, merged, qConstructor);
      original.learnerCache.questionsPTA = engine;
    }
   
    if (properties != null)
      try {
        // this marks visited questions so that getData() we'll subsequently do will return only those questions which were not answered by property automata
        Transform.augmentFromIfThenAutomaton(original, (NonExistingPaths)engine.getFSM(), properties, -1);
      } catch (IncompatibleStatesException e) {
        Helper.throwUnchecked("failure doing merge on the original graph", e);
        // An exception "cannot merge a tentative state" at this point means that
        // a merged graph had a valid path (absent from the original graph) which
        // contradicts the property automata, hence we should not even have gotten
View Full Code Here

      // proceed to merge them.
  }
 
  public static LearnerGraph constructGraphWithQuestions(final StatePair pair, LearnerGraph original, LearnerGraph merged)
  {
    PTASequenceEngine questionsPTA = getQuestionPta(pair,original,merged,null);
    Configuration config = original.config.copy();config.setLearnerCloneGraph(false);
    LearnerGraph updatedGraph = new LearnerGraph(original,config);
    updatedGraph.setName("graph_with_questions");
    // for the putAll below to work, I have to ensure that if a state of the original graph is cloned
    // in NonExistingPaths and points to some of the existing states, the references added by
    // putAll should refer the vertices from updatedGraphActual rather than those from graph.
    // This is best accomplished by not cloning vertices when making copies of graphs.
    updatedGraph.transitionMatrix.putAll(((NonExistingPaths)questionsPTA.getFSM()).getNonExistingTransitionMatrix());
    updatedGraph.learnerCache.invalidate();return updatedGraph;
  }
View Full Code Here

    private Map<CmpVertex,PTASequenceEngine.SequenceSet> fanout = null;
   
    @Override
    public PTASequenceEngine constructEngine(LearnerGraph original, @SuppressWarnings("unused") LearnerGraph learnt)
    {
      engine = new PTASequenceEngine();
      engine.init(original.new NonExistingPaths());
      return engine;
    }
View Full Code Here

TOP

Related Classes of statechum.model.testset.PTASequenceEngine

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.