Package statechum.DeterministicDirectedSparseGraph

Examples of statechum.DeterministicDirectedSparseGraph.VertexID


  @Test(expected = IllegalArgumentException.class)
  public final void testMerge_fail1a()
  {
    DirectedSparseGraph g=FsmParser.buildGraph(largeGraph1_invalid5,"testMerge_fail1");
    CmpVertex
      a = DeterministicDirectedSparseGraph.findVertexNamed(new VertexID("A"), g),
      b = DeterministicDirectedSparseGraph.findVertexNamed(new VertexID("B"), g);
    StatePair pair = new StatePair(b,a);// A is red
    MergeStates.mergeAndDeterminize(g, pair,testConfig);
  }
View Full Code Here


  @Test(expected = IllegalArgumentException.class)
  public final void testMerge_fail2()
  {
    LearnerGraph l=new LearnerGraph(FsmParser.buildGraph(largeGraph1_invalid5,"testMerge_fail1"),testConfig);
    CmpVertex
      a = l.findVertex(new VertexID("A")),
      b = l.findVertex(new VertexID("B"));
    StatePair pair = new StatePair(b,a);// A is red
    MergeStates.mergeAndDeterminize(l, pair);
  }
View Full Code Here

  @Test(expected = IllegalArgumentException.class)
  public final void testMerge_fail3()
  {
    LearnerGraph l=new LearnerGraph(FsmParser.buildGraph(largeGraph1_invalid5,"testMerge_fail1"),testConfig);
    CmpVertex
      a = l.findVertex(new VertexID("A")),
      b = l.findVertex(new VertexID("B"));
    StatePair pair = new StatePair(b,a);// A is red
    MergeStates.mergeAndDeterminize_general(l, pair);
  }
View Full Code Here

  private final void testChooseStatePairsInternal(DirectedSparseGraph g,LearnerGraph l, String [] initialReds, String [][] expectedReds,
      List<PairScore> expectedPairs,InterfaceChooserToTest chooser)
  {
    for(String red:initialReds)
    {
      CmpVertex v = l.findVertex(new VertexID(red));v.setColour(JUConstants.RED);
    }
    Stack<? extends StatePair> pairs = chooser.choosePairs();

    Map<Integer,Set<PairScore>> distribution = new HashMap<Integer,Set<PairScore>>();// maps scores to sets of states which should correspond to them. The aim is to verify the contents of the stack regardless of the order in which elements with the same score are arranged.
View Full Code Here

  {
    //buildRubyTests(fsm,expectedComputedScore,graphName);
   
    DirectedSparseGraph g = FsmParser.buildGraph(fsm, graphName);
    OrigStatePair pairOrig = new OrigStatePair(
        DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL, new VertexID("B"), g),
        DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL, new VertexID("A"), g));
   
    LearnerGraph s = new LearnerGraph(g, testConfig);
    StatePair pairNew = new StatePair(
        s.findVertex(new VertexID("B")),
        s.findVertex(new VertexID("A")));
    doneEdges = new HashSet<DirectedSparseEdge>();
    s.config.setLearnerScoreMode(Configuration.ScoreMode.CONVENTIONAL);s.setMaxScore(maxScoreConstant-1);
    int origScore = computeScore(g, pairOrig),
      newScoreA = s.pairscores.computeStateScore(pairNew),
      newScoreB = s.pairscores.computePairCompatibilityScore(pairNew);
View Full Code Here

        assert incompatibleRow.length == 2;
        fsm.addToCompatibility(fsm.findVertex(incompatibleRow[0]), fsm.findVertex(incompatibleRow[1]),JUConstants.PAIRCOMPATIBILITY.INCOMPATIBLE);
      }
    Collection<AMEquivalenceClass<CmpVertex,LearnerGraphCachedData>> result = new LinkedList<AMEquivalenceClass<CmpVertex,LearnerGraphCachedData>>();
    int score = -2;
    score = fsm.pairscores.computePairCompatibilityScore_general(new StatePair(fsm.findVertex(new VertexID("A")),fsm.findVertex(new VertexID("B"))),result);
    //Visualiser.updateFrame(g, result);Visualiser.waitForKey();
    Assert.assertEquals(expectedScore, score);
    if (score >=0)
      matchCollectionsOfVertices(result, expectedSrc);
   
    result.clear();score = -2;
    score = fsm.pairscores.computePairCompatibilityScore_general(new StatePair(fsm.findVertex(new VertexID("B")),fsm.findVertex(new VertexID("A"))),result);
    Assert.assertEquals(expectedScore, score);
    if (score >=0)
      matchCollectionsOfVertices(result, expectedSrc);
  }
View Full Code Here

  {
    assert (enteredName == null) == (ExpectedResult >= 0);
    final DirectedSparseGraph g = buildGraph(fsmString, "sample FSM");
    final LearnerGraph fsm = new LearnerGraph(g,config);
    assertEquals(ExpectedResult, fsm.paths.tracePath(Arrays.asList(path),fsm.findVertex(startingState)));
    Vertex starting = DeterministicDirectedSparseGraph.findVertexNamed(new VertexID(startingState),g);
    CmpVertex expected = (enteredName == null)? null:new LearnerGraph(g, conf).findVertex(new VertexID(enteredName));
    Vertex received = RPNIBlueFringeLearnerOrig.getVertex(g, starting, Arrays.asList(path));
    if (expected == null)
      Assert.assertNull(received);
    else
    {
View Full Code Here

  public final void testNewLearnerIncompatible(String fsm, String name)
  {
    DirectedSparseGraph g = TestFSMAlgo.buildGraph(fsm, name);
    //Visualiser.updateFrame(g, null);Visualiser.waitForKey();
    LearnerGraph s = new LearnerGraph(g, testConfig);
    OrigStatePair pairOrig = new OrigStatePair(DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL, new VertexID("B"), g),
        DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL, new VertexID("A"), g));
    StatePair pairNew = new StatePair(s.findVertex(new VertexID("B")),s.findVertex(new VertexID("A")));
    doneEdges = new HashSet<DirectedSparseEdge>();
    int origScore = computeScore(g, pairOrig),
      newScoreA = s.pairscores.computeStateScore(pairNew);
    Assert.assertEquals(-1, origScore);
    Assert.assertEquals(-1, newScoreA);
View Full Code Here

    DirectedSparseGraph g = TestFSMAlgo.buildGraph(fsm, learnerName);
    //Visualiser.updateFrame(g, null);Visualiser.waitForKey();
    LearnerGraph s = new LearnerGraph(g, testConfig);
    OrigStatePair pairOrig =
      new OrigStatePair(
          DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL, new VertexID("B"), g),
          DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL, new VertexID("A"), g));
    StatePair pairNew1 = new StatePair(s.findVertex(new VertexID("B")),s.findVertex(new VertexID("A")));
    DirectedSparseGraph
      temp = mergeAndDeterminize((Graph)g.copy(), pairOrig),
      tempB = MergeStates.mergeAndDeterminize(g, pairNew1,testConfig);
   
    // Now check that ComputeStateScores properly does  mergeAndDeterminize
    // (on the test data we are dealing with in these tests, there are separate tests for mergeAndDeterminize)
    LearnerGraph tempG = new LearnerGraph(temp,testConfig), tempBG = new LearnerGraph(tempB,testConfig);
    Assert.assertEquals(false, tempG.wmethod.checkUnreachableStates());Assert.assertEquals(false, tempBG.wmethod.checkUnreachableStates());
    WMethod.checkM(tempG, tempBG);
   
   
    doneEdges = new HashSet<DirectedSparseEdge>();
    int origScore = computeScore(g, pairOrig),
      newScoreA = s.pairscores.computeStateScore(pairNew1),
      newScoreB = s.pairscores.computePairCompatibilityScore(pairNew1),
      newScoreC = s.pairscores.computePairCompatibilityScore_general(pairNew1, new LinkedList<Collection<CmpVertex>>());

    LearnerGraph learner2 = new LearnerGraph(g, testConfig);
    StatePair pairNew2 = new StatePair(learner2.findVertex(new VertexID("B")),learner2.findVertex(new VertexID("A")));
    //Visualiser.updateFrame(g, MergeStates.mergeAndDeterminize_general(learner2, pairNew2).paths.getGraph(learnerName));Visualiser.waitForKey();
    Collection<List<String>>
      // Since computeQS assumes that red names remain unchanged in the merged version, I have to use a specific merging procedure
      questionsB = ComputeQuestions.computeQS_orig(pairNew2, learner2,MergeStates.mergeAndDeterminize(learner2, pairNew2)),
      questionsC = ComputeQuestions.computeQS_orig(pairNew2, learner2,MergeStates.mergeAndDeterminize_general(learner2, pairNew2)),
View Full Code Here

  @Test
  public final void testGetTempRed2()
  {
    DirectedSparseGraph a=TestFSMAlgo.buildGraph("A-a->B-a->B-c->C-c->D", "testGetTempRed1 model"),
      temp=TestFSMAlgo.buildGraph("C-a->Q-a->Q-c->Q", "testGetTempRed1 temp");
    Vertex foundA = getTempRed_DijkstraShortestPath(a, DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL, new VertexID("D"), a), temp);
    Vertex foundB = RPNIBlueFringeLearnerTestComponent.getTempRed(a, DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL, new VertexID("D"), a), temp);
    Assert.assertTrue(DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL, new VertexID("Q"), temp).equals(foundA));
    Assert.assertTrue(DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL, new VertexID("Q"), temp).equals(foundB));
  }
View Full Code Here

TOP

Related Classes of statechum.DeterministicDirectedSparseGraph.VertexID

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.