Package statechum.analysis.learning

Examples of statechum.analysis.learning.PairScore


       public static int countChoices(Stack<PairScore> stack)
       {
           if (stack.isEmpty())
                   return 0;
           int outcome = 1;
           PairScore top = stack.peek();
          
          int i=stack.size()-2;
           while(i>=0)
           {
                   PairScore curr = stack.get(i);--i;
//                   if (curr.getScore() != top.getScore() || curr.getR() != top.getR() )
                     if (curr.getScore() != top.getScore())

                           break;
                   ++outcome;
           }
           return outcome;
View Full Code Here


       public static int countChoicesOther(Stack<PairScore> stack)
       {
           if (stack.isEmpty())
                   return 0;
           int outcome = 1;
           PairScore top = stack.peek();
          
          int i=stack.size()-2;
           while(i>=0)
           {
                   PairScore curr = stack.get(i);--i;
//                   if (curr.getScore() != top.getScore() || curr.getR() != top.getR() )
                     if (curr.getAnotherScore() != top.getAnotherScore())

                           break;
                   ++outcome;
           }
           return outcome;
View Full Code Here

       public static Stack<PairScore> getChoices(Stack<PairScore> stack)
       {
           if (stack.isEmpty())
                   return null;
           Stack<PairScore> outcome = new Stack<PairScore>();
           PairScore top = stack.peek();
           outcome.add(top);
           int i=stack.size()-2;
           while(i>=0)
           {
                   PairScore curr = stack.get(i);--i;
                   if (curr.getScore() != top.getScore())
                           break;
                   outcome.add(curr);
           }
           return outcome;
       }
View Full Code Here

    List<StatePair> pairsToMerge = new LinkedList<StatePair>();
    for(Entry<CmpVertex,Map<Label,CmpVertex>> entry:graph.transitionMatrix.entrySet())
      for(Entry<Label,CmpVertex> transition:entry.getValue().entrySet())
        if (graph.transitionMatrix.get(transition.getValue()).containsKey(transition.getKey()))
        {// we have a potential loop
          PairScore p = new PairScore(entry.getKey(),transition.getValue(),0,0);
          ArrayList<PairScore> pairOfInterest = new ArrayList<PairScore>(1);pairOfInterest.add(p);
         
          verticesToMerge = new LinkedList<AMEquivalenceClass<CmpVertex,LearnerGraphCachedData>>();
          long genScore = graph.pairscores.computePairCompatibilityScore_general(p, null, verticesToMerge);
          LearnerGraph mergedForThisPair = MergeStates.mergeCollectionOfVertices(graph, null, verticesToMerge);
View Full Code Here

    List<StatePair> pairsToMerge = new LinkedList<StatePair>();
    for(Entry<CmpVertex,Map<Label,CmpVertex>> entry:merged.transitionMatrix.entrySet())
      for(Entry<Label,CmpVertex> transition:entry.getValue().entrySet())
        if (merged.transitionMatrix.get(transition.getValue()).containsKey(transition.getKey()))
        {// we have a potential loop
          PairScore p = new PairScore(entry.getKey(),transition.getValue(),0,0);
          ArrayList<PairScore> pairOfInterest = new ArrayList<PairScore>(1);pairOfInterest.add(p);
          List<PairScore> correctPairs = new ArrayList<PairScore>(1), wrongPairs = new ArrayList<PairScore>(1);
          SplitSetOfPairsIntoRightAndWrong(graph, referenceGraph, pairOfInterest, correctPairs, wrongPairs);
         
          verticesToMerge = new LinkedList<AMEquivalenceClass<CmpVertex,LearnerGraphCachedData>>();
          long genScore = graph.pairscores.computePairCompatibilityScore_general(p, null, verticesToMerge);
          LearnerGraph mergedForThisPair = MergeStates.mergeCollectionOfVertices(graph, null, verticesToMerge);
          long value = MarkovUniversalLearner.computeInconsistency(mergedForThisPair, directionForwardOrInverse, m, checker,false);
         
          boolean decidedToMerge= (value == 0 && genScore >= genScoreThreshold);
          if (decidedToMerge)
          {
            pairsToMerge.add(p);
            ++nrOfMergers;
          }
         
          if ( !wrongPairs.isEmpty() && decidedToMerge)
              //(wrongPairs.isEmpty() && value > 0 || genScore < genScoreThreshold) ||  (!wrongPairs.isEmpty() && value == 0 && genScore >= genScoreThreshold))
          {
            System.out.println( p.toString()+(wrongPairs.isEmpty()?"valid, ":"invalid:")+value+ "(score "+genScore+")");
            System.out.println( "R: " + graph.transitionMatrix.get(p.getR())+" B: "+graph.transitionMatrix.get(p.getQ()));
          }
        }
    //System.out.println("mergers identified: "+nrOfMergers);
    /*
    long genScore = graph.pairscores.computePairCompatibilityScore_general(null, pairsToMerge, verticesToMerge);
View Full Code Here

 
  @Test
  public void testSplitSetOfPairsIntoRightAndWrong2()
  {
    Collection<PairScore> correctPairs = new LinkedList<PairScore>(), wrongPairs = new LinkedList<PairScore>();
    PairScore pairA = new PairScore(tentativeGraph.findVertex("A1"), tentativeGraph.findVertex("A1"),0,0);
   
    int outcome = PairQualityLearner.SplitSetOfPairsIntoRightAndWrong(tentativeGraph, correctGraph, Arrays.asList(new PairScore[]{
        pairA
    }), correctPairs, wrongPairs);
    Assert.assertEquals(0, outcome);
View Full Code Here

 
  @Test
  public void testSplitSetOfPairsIntoRightAndWrong3()
  {
    Collection<PairScore> correctPairs = new LinkedList<PairScore>(), wrongPairs = new LinkedList<PairScore>();
    PairScore pairA = new PairScore(tentativeGraph.findVertex("A1"), tentativeGraph.findVertex("A2"),0,0),pairB=new PairScore(tentativeGraph.findVertex("B1"), tentativeGraph.findVertex("B2"),0,0),
        pairC=new PairScore(tentativeGraph.findVertex("A1"), tentativeGraph.findVertex("B2"),0,0);
   
    int outcome = PairQualityLearner.SplitSetOfPairsIntoRightAndWrong(tentativeGraph, correctGraph, Arrays.asList(new PairScore[]{
        pairA,pairC,pairB
    }), correctPairs, wrongPairs);
    Assert.assertEquals(0, outcome);
View Full Code Here

    constructPairsToMergeBasedOnSetsToMerge(graph.transitionMatrix.keySet(),verticesToMergeBasedOnInitialPTA);   
    for(CmpVertex v0:tr)
      for(CmpVertex v1:tr)
        if (v0 != v1)
        {
          PairScore p = new PairScore(v0,v1,0,0);
          ArrayList<PairScore> pairOfInterest = new ArrayList<PairScore>(1);pairOfInterest.add(p);
          List<PairScore> correctPairs = new ArrayList<PairScore>(1), wrongPairs = new ArrayList<PairScore>(1);
          SplitSetOfPairsIntoRightAndWrong(graph, referenceGraph, pairOfInterest, correctPairs, wrongPairs);
         
          verticesToMerge = new LinkedList<AMEquivalenceClass<CmpVertex,LearnerGraphCachedData>>();
          genScore = graph.pairscores.computePairCompatibilityScore_general(p, null, verticesToMerge);
          LearnerGraph merged = MergeStates.mergeCollectionOfVertices(graph, null, verticesToMerge);
          long value = MarkovUniversalLearner.computeInconsistency(merged, predictForwardOrInverse, m, checker,false);
          if ( (wrongPairs.isEmpty() && value > 0) ||  (!wrongPairs.isEmpty() && value == 0))
          {
            System.out.println( p.toString()+(wrongPairs.isEmpty()?"valid, ":"invalid:")+value+ "(score "+genScore+")");
            System.out.println( "R: " + graph.transitionMatrix.get(p.getR())+" B: "+graph.transitionMatrix.get(p.getQ()));
          }
        }
   
    System.out.println("finished dumping inconsistencies");
  }
View Full Code Here

 
  @Test
  public void testSplitSetOfPairsIntoRightAndWrong4()
  {
    Collection<PairScore> correctPairs = new LinkedList<PairScore>(), wrongPairs = new LinkedList<PairScore>();
    PairScore pairA = new PairScore(tentativeGraph.findVertex("A1"), tentativeGraph.findVertex("A2"),0,0),pairB=new PairScore(tentativeGraph.findVertex("B1"), tentativeGraph.findVertex("B2"),0,0),
        pairC=new PairScore(tentativeGraph.findVertex("A1"), tentativeGraph.findVertex("B2"),0,0);
   
    int outcome = PairQualityLearner.SplitSetOfPairsIntoRightAndWrong(tentativeGraph, correctGraph, Arrays.asList(new PairScore[]{
        pairC,pairB,pairB,pairA
    }), correctPairs, wrongPairs);
    Assert.assertEquals(1, outcome);
View Full Code Here

 
  @Test
  public void testSplitSetOfPairsIntoRightAndWrong5()
  {
    Collection<PairScore> correctPairs = new LinkedList<PairScore>(), wrongPairs = new LinkedList<PairScore>();
    PairScore pairA = new PairScore(tentativeGraph.findVertex("C1"), tentativeGraph.findVertex("A2"),0,0),pairB=new PairScore(tentativeGraph.findVertex("C1"), tentativeGraph.findVertex("C2"),0,0),
        pairC=new PairScore(tentativeGraph.findVertex("A1"), tentativeGraph.findVertex("B2"),0,0);
   
    int outcome = PairQualityLearner.SplitSetOfPairsIntoRightAndWrong(tentativeGraph, correctGraph, Arrays.asList(new PairScore[]{
        pairC,pairB,pairB,pairA
    }), correctPairs, wrongPairs);
    Assert.assertEquals(1, outcome);
View Full Code Here

TOP

Related Classes of statechum.analysis.learning.PairScore

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.