Package statechum.analysis.learning.linear.GD

Examples of statechum.analysis.learning.linear.GD.ChangesRecorder


 
  @Test
  public final void testWriteAndLoad3()
  {
    LearnerGraph graph = buildLearnerGraph("A-a->B-a-#C\nA-d-#D\nA-c->A","testAddTransitions4",Configuration.getDefaultConfiguration(),converter);
    ChangesRecorder patcher = new ChangesRecorder(null);
    patcher.addTransition(graph.findVertex("B"), AbstractLearnerGraph.generateNewLabel("c", cloneConfig,converter), graph.findVertex("B"));
    patcher.removeTransition(graph.findVertex("A"), label_a, graph.findVertex("B"));
    patcher.addTransition(graph.findVertex("A"), label_q, graph.findVertex("B"));
    patcher.setInitial(graph.findVertex("A"));
    ChangesRecorder.applyGD(graph, patcher.writeGD(createDoc()), converter);
    LearnerGraph expected = buildLearnerGraph("A-q->B-a-#C\nA-d-#D\nA-c->A\nB-c->B","testWriteAndLoad1",Configuration.getDefaultConfiguration(),converter);
    WMethod.checkM_and_colours(expected, graph, VERTEX_COMPARISON_KIND.DEEP);
  }
View Full Code Here


  /** Tests that initial state has to be assigned. */
  @Test
  public final void testWriteAndLoad4()
  {
    LearnerGraph graph = buildLearnerGraph("A-a->B-a-#C\nA-d-#D\nA-c->A","testAddTransitions4",Configuration.getDefaultConfiguration(),converter);
    final ChangesRecorder patcher = new ChangesRecorder(null);
    patcher.addTransition(graph.findVertex("B"), AbstractLearnerGraph.generateNewLabel("c", cloneConfig,converter), graph.findVertex("B"));
    patcher.removeTransition(graph.findVertex("A"), label_a, graph.findVertex("B"));
    patcher.addTransition(graph.findVertex("A"), label_q, graph.findVertex("B"));
    checkForCorrectException(new whatToRun() { public @Override void run() {
      patcher.writeGD(createDoc());}},
    IllegalArgumentException.class,"init state is was not defined");
  }
View Full Code Here

      {
        LearnerGraphND loadedA1 = new LearnerGraphND(config);AbstractPersistence.loadGraph(fileA1, loadedA1, converter);
        LearnerGraph loadedA2 = new LearnerGraph(config);AbstractPersistence.loadGraph(fileA2, loadedA2, converter);
        graph = LearnerGraphND.UniteTransitionMatrices(loadedA1,loadedA2);TestGD_ExistingGraphs.addColourAndTransitionsRandomly(graph, new Random(0));
      }
      ChangesRecorder patcher = new ChangesRecorder(null);
      //gd.computeGD(grA, grB, threadNumber, patcher,config);
      gd.init(grA, grB, threadNumber,config);
      gd.identifyKeyPairs();
      if (!gd.fallbackToInitialPair) TestGD_ExistingGraphs.addPairsRandomly(gd,pairsToAdd);
      else Assert.assertEquals(-1.,low_to_high_ratio,Configuration.fpAccuracy);
      gd.makeSteps();
      gd.computeDifference(patcher);

      LearnerGraphND outcome = new LearnerGraphND(config);
      ChangesRecorder.applyGD_WithRelabelling(graph, patcher.writeGD(TestGD.createDoc()), converter,outcome);
      Assert.assertNull(testDetails(),WMethod.checkM(grB,graph));
      Assert.assertEquals(testDetails(),grB.getStateNumber(),graph.getStateNumber());
      Assert.assertEquals(grB,outcome);
     
      // Cannot do checkM_and_colours here because merged vertices may change their colours and other attributes.
View Full Code Here

      LearnerGraph grA = new LearnerGraph(config);AbstractPersistence.loadGraph(fileA, grA, converter);addColourAndIncompatiblesRandomly(grA, new Random(0));
      LearnerGraph grB = new LearnerGraph(config);AbstractPersistence.loadGraph(fileB, grB, converter);addColourAndIncompatiblesRandomly(grB, new Random(1));
      GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData> gd = new GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>();
      LearnerGraph graph = new LearnerGraph(config);AbstractPersistence.loadGraph(fileA, graph, converter);addColourAndIncompatiblesRandomly(graph, new Random(0));
      LearnerGraph outcome = new LearnerGraph(config);
      ChangesRecorder patcher = new ChangesRecorder(null);
      //gd.computeGD(grA, grB, threadNumber, patcher,config);
     
      gd.init(grA, grB, threadNumber,config);
      if (checkScores) scoresLogger.checkOrRecord(parametersToString(threadNumber,pairsToAdd,low_to_high_ratio,fileA,fileB), gd.serialiseScores());
      gd.identifyKeyPairs();
      if (!gd.fallbackToInitialPair) addPairsRandomly(gd,pairsToAdd);
      else Assert.assertEquals(-1.,low_to_high_ratio,Configuration.fpAccuracy);
      gd.makeSteps();
      gd.computeDifference(patcher);

      ChangesRecorder.applyGD_WithRelabelling(graph, patcher.writeGD(TestGD.createDoc()), converter,outcome);
      Assert.assertNull(testDetails(),WMethod.checkM(grB,graph));
      Assert.assertEquals(testDetails(),grB.getStateNumber(),graph.getStateNumber());
      DifferentFSMException ex= WMethod.checkM_and_colours(grB,outcome,VERTEX_COMPARISON_KIND.DEEP);
      Assert.assertNull(testDetails()+ex,WMethod.checkM_and_colours(grB,outcome,VERTEX_COMPARISON_KIND.DEEP));Assert.assertEquals(grB.getStateNumber(),graph.getStateNumber());
      Assert.assertEquals(grB,outcome);
View Full Code Here

    GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData> gd = new GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>();
    Configuration configMakeSteps = configGraph.copy();configMakeSteps.setGdPropagateDet(true);
    gd.init(graphA, graphB, threadNumber,configMakeSteps);
    Assert.assertTrue(gd.identifyKeyPairs());
    //TestGD.printListOfPairs(gd.frontWave, gd.newToOrig);
    ChangesRecorder recorder = new ChangesRecorder(null);
    gd.makeSteps();gd.computeDifference(recorder);
    //printListOfPairs(gd,allKeyPairs);
    for(Entry<CmpVertex,CmpVertex> pair:gd.aTOb.entrySet())
    {
      CmpVertex A=pair.getKey(), B=gd.newBToOrig.get(pair.getValue());
View Full Code Here

    GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData> gd = new GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>();
    Configuration configMakeSteps = config.copy();configMakeSteps.setGdPropagateDet(false);
    gd.init(graphA, graphB, threadNumber,configMakeSteps);
    Assert.assertTrue(gd.identifyKeyPairs());
    //TestGD.printListOfPairs(gd.frontWave, gd.newToOrig);
    ChangesRecorder recorder = new ChangesRecorder(null);
    gd.makeSteps();gd.computeDifference(recorder);
    //printListOfPairs(gd,allKeyPairs);
    for(Entry<CmpVertex,CmpVertex> pair:gd.aTOb.entrySet())
    {
      CmpVertex A=pair.getKey(), B=gd.newBToOrig.get(pair.getValue());
View Full Code Here

 
    gd.init(grA, grB, threadNumber,configOneWay);
    gd.identifyKeyPairs();
    //printListOfPairs(gd, gd.currentWave);
    //printListOfPairs(gd, gd.frontWave);
    ChangesRecorder recorder = new ChangesRecorder(null);
    gd.makeSteps();gd.computeDifference(recorder);
    //printListOfPairs(gd, allKeyPairs);
    Assert.assertEquals(expectedMatchedPairs,gd.aTOb.size());
    LearnerGraph graph = buildLearnerGraph(graphA,name+"A",configOneWay,converter);
    ChangesRecorder.applyGD(graph, recorder.writeGD(TestGD.createDoc()), converter);
    Assert.assertNull(WMethod.checkM(graph, grB));
    Assert.assertEquals(grB.getStateNumber(),graph.getStateNumber());
  }
View Full Code Here

    Configuration configNesting = argConfig;if (configNesting == null) configNesting = config;
    LearnerGraph grA = buildLearnerGraph(graphA,name+"A",configNesting,converter);
    LearnerGraph grB = buildLearnerGraph(graphB,name+"B",configNesting,converter);
    grA.setIDNumbers();grB.setIDNumbers();
    GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData> gd = new GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>();
    ChangesRecorder rec1 =   new ChangesRecorder(null);
    ChangesDisplay  rec2 = new ChangesDisplay(rec1);
    ChangesCounter<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData> rec3 = new ChangesCounter<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>(grA,grB,rec2);
    ChangesRecorder rec4 =   new ChangesRecorder(rec3);
    ChangesDisplay  rec5 = new ChangesDisplay(rec4);
    ChangesCounter<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>  rec6 = new ChangesCounter<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>(grA,grB,rec5);
    ChangesRecorder rec7 =   new ChangesRecorder(rec6);
    ChangesDisplay  rec8 = new ChangesDisplay(rec7);
    ChangesCounter<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>  rec9 = new ChangesCounter<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>(grA,grB,rec8);
    {// compute GD and check that changes recorded by rec9 are correct.
      LearnerGraph graph1 = buildLearnerGraph(graphA,name+"A",configNesting,converter);
      ChangesRecorder.applyGD(graph1, gd.computeGDToXML(grA, grB, threadNumber, TestGD.createDoc(), rec9,configNesting), converter);
      Assert.assertNull(WMethod.checkM(graph1, grB));Assert.assertEquals(grB.getStateNumber(),graph1.getStateNumber());
    }
    {// check that changes propagated to rec7 are correct.
      LearnerGraph graph2 = buildLearnerGraph(graphA,name+"A",configNesting,converter);
      ChangesRecorder.applyGD(graph2, rec7.writeGD(TestGD.createDoc()), converter);
      Assert.assertNull(WMethod.checkM(graph2, grB));Assert.assertEquals(grB.getStateNumber(),graph2.getStateNumber());
    }
    {// check that changes propagated to rec4 are correct.
      LearnerGraph graph3 = buildLearnerGraph(graphA,name+"A",configNesting,converter);
      ChangesRecorder.applyGD(graph3, rec4.writeGD(TestGD.createDoc()), converter);
View Full Code Here

  public final void testComputeGD5b_RA()
  {
    Configuration configGD5b = config.copy();configGD5b.setGdFailOnDuplicateNames(false);
    LearnerGraph grA = new LearnerGraph(configGD5b);grA.getInit().setAccept(false);
    LearnerGraph grB = convertToNumerical(new LearnerGraph(configGD5b));
    ChangesRecorder recorder = new ChangesRecorder(null);
    GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData> gd = new GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>();
    gd.computeGD(grA, grB, threadNumber, recorder,configGD5b);
    LearnerGraph graph = new LearnerGraph(configGD5b);graph.setInit(null);graph.transitionMatrix.clear();
    ChangesRecorder.applyGD(graph, recorder.writeGD(TestGD.createDoc()), converter);
    Assert.assertNull(WMethod.checkM(graph, grB));Assert.assertEquals(grB.getStateNumber(),graph.getStateNumber());
  }
View Full Code Here

  public final void testComputeGD5b_AR()
  {
    Configuration configGD5b = config.copy();configGD5b.setGdFailOnDuplicateNames(false);
    LearnerGraph grA = new LearnerGraph(configGD5b);
    LearnerGraph grB = convertToNumerical(new LearnerGraph(configGD5b));grB.getInit().setAccept(false);
    ChangesRecorder recorder = new ChangesRecorder(null);
    GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData> gd = new GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>();
    gd.computeGD(grA, grB, threadNumber, recorder,configGD5b);
    LearnerGraph graph = new LearnerGraph(configGD5b);graph.setInit(null);graph.transitionMatrix.clear();
    ChangesRecorder.applyGD(graph, recorder.writeGD(TestGD.createDoc()), converter);
    Assert.assertNull(WMethod.checkM(graph, grB));Assert.assertEquals(grB.getStateNumber(),graph.getStateNumber());
  }
View Full Code Here

TOP

Related Classes of statechum.analysis.learning.linear.GD.ChangesRecorder

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.