Examples of StatePair


Examples of statechum.analysis.learning.StatePair

  {
    List<StatePair> pairs = new LinkedList<StatePair>();
    LearnerGraph sourcePta = new LearnerGraph(pta,pta.config);
    List<CmpVertex> whatToMerge = constructPairsToMergeWithOutgoing(sourcePta,unique);
    for(CmpVertex vert:whatToMerge)
      pairs.add(new StatePair(sourcePta.getInit(),vert));
    List<AMEquivalenceClass<CmpVertex,LearnerGraphCachedData>> verticesToMerge = new ArrayList<AMEquivalenceClass<CmpVertex,LearnerGraphCachedData>>();
   
    if (sourcePta.pairscores.computePairCompatibilityScore_general(null, pairs, verticesToMerge) < 0)
      throw new IllegalArgumentException("failed to merge states corresponding to a unique outgoing transition "+unique);
    LearnerGraph outcome = MergeStates.mergeCollectionOfVertices(sourcePta, null, verticesToMerge);
View Full Code Here

Examples of statechum.analysis.learning.StatePair

    return new PairScore(aV,bV, score,score);
  }

  static protected void checkLess(String a, String b, int abS, String c, String d, int cdS, Configuration config)
  {
    StatePair p = constructPairScore(a,b,abS,config),
        q=constructPairScore(c,d,cdS,config);
    assertFalse(p.equals(q));
    assertTrue(p.compareTo(q)<0);
    assertTrue(q.compareTo(p)>0);
    assertFalse(p.hashCode() == q.hashCode());
    assertEquals(0,p.compareTo(p));
    assertEquals(0,q.compareTo(q));
  }
View Full Code Here

Examples of statechum.analysis.learning.StatePair

  }

  @Test
  public void testPairScoreEquality()
  {
    StatePair p = constructPairScore("a","b",4,testConfig), q=constructPairScore("a","b",4,testConfig);
    assertTrue(p.equals(p));
    assertTrue(p.equals(q));
    assertFalse(p.equals(null));
    assertFalse(p.equals("test"));
    assertFalse(p.equals(constructPairScore("a","c",4,testConfig)));
    assertFalse(p.equals(constructPairScore("a","b",6,testConfig)));
    assertFalse(p.equals(constructPairScore("b","b",4,testConfig)));
  }
View Full Code Here

Examples of statechum.analysis.learning.StatePair

        CmpVertex newInit = Transform.addToGraph(result, gr);
        int score = -1;
        do
        {
          CmpVertex vertResult = Transform.pickRandomState(result,rnd);
          StatePair whatToMerge = new StatePair(vertResult,newInit);
          LinkedList<Collection<CmpVertex>> collectionOfVerticesToMerge = new LinkedList<Collection<CmpVertex>>();
          score = result.pairscores.computePairCompatibilityScore_general(whatToMerge,collectionOfVerticesToMerge);
          if (score >= 0) result = MergeStates.mergeAndDeterminize_general(result, whatToMerge,collectionOfVerticesToMerge);
          else throw new IllegalArgumentException("failed to merge states");// no easy way to restart with a different pair since result has already been modified, should've cloned perhaps, but absence of negative states ensures that no failure is possible.
        }
View Full Code Here

Examples of statechum.analysis.learning.StatePair

          while(stateB_It.hasNext())
          {
            Entry<CmpVertex,Map<String,List<CmpVertex>>> stateB = stateB_It.next();
            if (stateB.getKey().isAccept())
            {// reject-states are ignored.
              StatePair currentPair = new StatePair(entryA.getKey(),stateB.getKey());
              if (gr.pairscores.computePairCompatibilityScore_general(currentPair, new LinkedList<Collection<CmpVertex>>()) < 0)
                synchronized(result)
                {
                  result.add(currentPair);
                }
View Full Code Here

Examples of statechum.analysis.learning.StatePair

  protected final void findIncompatibleTestHelper(LearnerGraph gr,List<StringPair> incompatibles_list)
  {
    HashSet<StatePair> incompatibles = new HashSet<StatePair>();
    for(StringPair p:incompatibles_list)
    {
      incompatibles.add(new StatePair(gr.findVertex(p.firstElem),gr.findVertex(p.secondElem)));
      incompatibles.add(new StatePair(gr.findVertex(p.secondElem),gr.findVertex(p.firstElem)));
    }
    Set<StatePair> incompatiblePairs = new HashSet<StatePair>();
    for(StatePair s:buildSetOfIncompatiblePairsSlowly(gr,ThreadNumber))
    {
      incompatiblePairs.add(s);incompatiblePairs.add(new StatePair(s.secondElem,s.firstElem));
    }
    // incompatiblePairs these are the pairs which cannot be merged which may be a larger set than
    // the set of clearly incompatible pairs. The difference is that when pairs are merged, more traces
    // are created, hence it is possible that some of those new traces will be in conflict.
    // Example: states A3 and A2 in findIncompatibleStates6()
    HashSet<StatePair> pairs_extra = new HashSet<StatePair>();pairs_extra.addAll(incompatibles);pairs_extra.removeAll(incompatiblePairs);
    Assert.assertTrue("compatible pairs included :"+pairs_extra,pairs_extra.isEmpty());

    final int size=gr.learnerCache.getAcceptStateNumber()*(gr.learnerCache.getAcceptStateNumber()+1)/2;
    final int highNumber = 10000;
    int pairs[]=new int[size];for(int i=0;i<pairs.length;++i) pairs[i]=highNumber;
    reverseMap = new HashMap<Integer,StatePair>();
    for(CmpVertex A:gr.transitionMatrix.keySet())
      if (A.isAccept())
      for(CmpVertex B:gr.transitionMatrix.keySet())
        if (B.isAccept())
          reverseMap.put(gr.wmethod.vertexToIntNR(A, B), new StatePair(A,B));
    Assert.assertEquals(size,reverseMap.size());
   
    gr.linear.buildMatrix(ThreadNumber);
    gr.linear.findIncompatiblePairs(pairs,ThreadNumber);
   
    int cnt=0;
    for(int i=0;i<pairs.length;++i)
    {
      StatePair pair = reverseMap.get(i);
      if (incompatibles.contains(pair))
        Assert.assertEquals("pair ("+pair.firstElem+","+pair.secondElem+") should be marked as incompatible",PAIR_INCOMPATIBLE,pairs[i]);// this pair is not compatible
      else
        Assert.assertEquals("invalid counter for pair ("+pair.firstElem+","+pair.secondElem+")",
            cnt++,pairs[i]);// pairs should have monotonically increasing numbers
View Full Code Here

Examples of statechum.analysis.learning.StatePair

    {
      mainConfiguration.setLearnerCloneGraph(false);
      origGraph = FsmParser.buildLearnerGraph(graphWithAppendixAfterMerging, "graphWithAppendixAfterMerging",mainConfiguration,converter);
      graph = new LearnerGraph(origGraph,mainConfiguration);
     
      pair = new StatePair(graph.findVertex("A1"),graph.findVertex("A2"));
      merged = MergeStates.mergeAndDeterminize_general(graph, pair);
     
      //Visualiser.updateFrame(graph, merged);Visualiser.waitForKey();
      compareGraphs(buildLearnerGraph("A-s->A1-a->B1-b->A1-c->C-d-#R4/C-c->CC/CC-f-#R3/CC-e->D", "testQuestionAnswering2b",mainConfiguration,converter),merged);
      questions = ComputeQuestions.computeQS_general(pair, graph, merged, new ComputeQuestions.QSMQuestionGenerator());
View Full Code Here

Examples of statechum.analysis.learning.StatePair

      LearnerGraph[] ifthenCollection = new LearnerGraph[]{
          buildLearnerGraph(ifthen_ab_to_c, "ifthen_ab_to_c", mainConfiguration,converter),
          buildLearnerGraph(ifthen_c_to_cc, "ifthen_c_to_cc", mainConfiguration,converter),     
          buildLearnerGraph(ifthen_ccc_to_ab, "ifthen_ccc_to_ab", mainConfiguration,converter)
      };
      pair = new StatePair(graph.findVertex("I"),graph.findVertex("A"));
      merged = MergeStates.mergeAndDeterminize_general(graph, pair);
      LearnerGraph expectedMergedGraph = buildLearnerGraph("A-s->A-c->A-a->B-b->C-a->D-b->E-a->F-b->G / "+
          "C-c->C11-c->C12-c->C13-c->C14-c->C15-c->C16-c->C17 / C13-a->C13A-b->C13B / C15-a->C15A-b->C15B /"+
          "E-c->C21-c->C22-c->C23-c->C24-c->C25-c->C26-c->C27 / C23-a->C23A-b->C23B / C25-a->C25A-b->C25B /"+
          "G-c->C31-c->C32-c->C33-c->C34-c->C35-c->C36-c->C37 / C33-a->C33A-b->C33B / C35-a->C35A-b->C35B", "testQuestionAnswering9b",mainConfiguration,converter);
View Full Code Here

Examples of statechum.analysis.learning.StatePair

   * @return trimmed copy of the reference graph.
   */
  public static Map<CmpVertex,Set<Label>> identifyUncoveredTransitions(LearnerGraph pta,LearnerGraph reference)
  {
    Map<CmpVertex,Set<Label>> outcome = new TreeMap<CmpVertex,Set<Label>>();
    StatePair reference_pta = new StatePair(reference.getInit(),pta.getInit());
    LinkedList<StatePair> pairsToExplore = new LinkedList<StatePair>();pairsToExplore.add(reference_pta);
    for(Entry<CmpVertex,Map<Label,CmpVertex>> entry:reference.transitionMatrix.entrySet())
      outcome.put(entry.getKey(), new TreeSet<Label>(entry.getValue().keySet()));
    Set<CmpVertex> visitedInTree = new HashSet<CmpVertex>();
    while(!pairsToExplore.isEmpty())
    {
      reference_pta = pairsToExplore.pop();
      Map<Label,CmpVertex> transitions=pta.transitionMatrix.get(reference_pta.secondElem);
      outcome.get(reference_pta.firstElem).removeAll(transitions.keySet());
      for(Entry<Label,CmpVertex> target:transitions.entrySet())
        if (target.getValue().isAccept())
        {
          if (visitedInTree.contains(target.getValue()))
            throw new IllegalArgumentException("PTA is not a tree");
          visitedInTree.add(target.getValue());
          CmpVertex nextGraphState = reference.transitionMatrix.get(reference_pta.firstElem).get(target.getKey());
          if (nextGraphState == null)
            throw new IllegalArgumentException("coverage has more transitions than the original graph");
          pairsToExplore.add(new StatePair(nextGraphState, target.getValue()));
        }
    }
   
    return outcome;
  }
View Full Code Here

Examples of statechum.analysis.learning.StatePair

    List<StatePair> listOfPairs = new LinkedList<StatePair>();
    for(List<List<Label>> lotOfPaths:pathsToMerge)
    {
      CmpVertex firstVertex = graph.getVertex(lotOfPaths.get(0));
      for(List<Label> seq:lotOfPaths)
        listOfPairs.add(new StatePair(firstVertex,graph.getVertex(seq)));
    }
    return listOfPairs;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.