Package statechum.analysis.learning.linear.GD

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


  public final void testComputeGD5b_AR()
  {
    Configuration config = Configuration.getDefaultConfiguration().copy();config.setGdFailOnDuplicateNames(false);
    LearnerGraph grA = new LearnerGraph(config);
    LearnerGraph grB = convertToNumerical(new LearnerGraph(config));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,config);
    LearnerGraph graph = new LearnerGraph(config);graph.setInit(null);graph.transitionMatrix.clear();
    ChangesRecorder.applyGD(graph, recorder.writeGD(TestGD.createDoc()));
    Assert.assertNull(WMethod.checkM(graph, grB));Assert.assertEquals(grB.getStateNumber(),graph.getStateNumber());
  }
View Full Code Here


  public final void testComputeGD5_RR()
  {
    Configuration config = Configuration.getDefaultConfiguration().copy();config.setGdFailOnDuplicateNames(false);
    LearnerGraph grA = new LearnerGraph(config);grA.getInit().setAccept(false);
    LearnerGraph grB = convertToNumerical(new LearnerGraph(config));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,config);
    LearnerGraph graph = new LearnerGraph(config);graph.setInit(null);graph.transitionMatrix.clear();
    ChangesRecorder.applyGD(graph, recorder.writeGD(TestGD.createDoc()));
    Assert.assertNull(WMethod.checkM(graph, grB));Assert.assertEquals(grB.getStateNumber(),graph.getStateNumber());
  }
View Full Code Here

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

  public final void testComputeGD5e_RR()
  {
    Configuration config = Configuration.getDefaultConfiguration().copy();
    LearnerGraph grA = buildLearnerGraph(A6,"testComputeGD5b",config);
    LearnerGraph grB = convertToNumerical(new LearnerGraph(config));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,config);
    LearnerGraph graph = buildLearnerGraph(A6,"testComputeGD5b",config);
    ChangesRecorder.applyGD(graph, recorder.writeGD(TestGD.createDoc()));
    Assert.assertNull(WMethod.checkM(graph, grB));Assert.assertEquals(grB.getStateNumber(),graph.getStateNumber());
  }
View Full Code Here

      LearnerGraph grB = buildLearnerGraph(graphB,name+"B",config);
 
      GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData> gd = new GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>();
      gd.init(grA, grB, threadNumber,config);
      gd.identifyKeyPairs();
      ChangesRecorder recorder = new ChangesRecorder(null);
      gd.makeSteps();gd.computeDifference(recorder);
      Assert.assertEquals(expectedMatchedPairs,gd.aTOb.size());
      LearnerGraph graph = buildLearnerGraph(graphA,name+"A",config);
      ChangesRecorder.applyGD(graph, recorder.writeGD(TestGD.createDoc()));
      Assert.assertNull(WMethod.checkM(graph, grB));
      Assert.assertNull(WMethod.checkM(graph, graph.findVertex(otherA), grB, grB.findVertex(otherB),WMethod.VERTEX_COMPARISON_KIND.NONE));
    }
  }
View Full Code Here

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

    Configuration cloneConfig = config.copy();cloneConfig.setLearnerCloneGraph(true);
    AbstractLearnerGraph<List<CmpVertex>,LearnerGraphNDCachedData> copyOfA = grA.copy(cloneConfig), copyOfB = grB.copy(cloneConfig);
    GD<List<CmpVertex>,List<CmpVertex>,LearnerGraphNDCachedData,LearnerGraphNDCachedData> gd = new GD<List<CmpVertex>,List<CmpVertex>,LearnerGraphNDCachedData,LearnerGraphNDCachedData>();
    gd.init(grA, grB, threadNumber,config);gd.identifyKeyPairs();
    //TestGD.printListOfPairs(gd.frontWave, gd.newBToOrig);
    ChangesRecorder recorder = new ChangesRecorder(null);
    gd.makeSteps();gd.computeDifference(recorder);
    //Visualiser.updateFrame(grA, grB);
    Assert.assertEquals(expectedSizeOfATOb,gd.aTOb.size());
    Assert.assertEquals(expectedSizeOfDuplicates,gd.duplicates.size());
    LearnerGraphND graph = new LearnerGraphND(cloneConfig);AbstractLearnerGraph.copyGraphs(grA, graph);
    ChangesRecorder.applyGD(graph, recorder.writeGD(TestGD.createDoc()));
    Assert.assertNull(WMethod.checkM(grB, graph));
   
    // Now do the same as above, but renumber states to match grB
    AbstractLearnerGraph.copyGraphs(grA, graph);
    Configuration configMut = Configuration.getDefaultConfiguration().copy();config.setLearnerCloneGraph(false);
    LearnerGraphMutator<List<CmpVertex>,LearnerGraphNDCachedData> graphPatcher = new LearnerGraphMutator<List<CmpVertex>,LearnerGraphNDCachedData>(graph,configMut,null);
    ChangesRecorder.loadDiff(graphPatcher, recorder.writeGD(TestGD.createDoc()));
    graphPatcher.removeDanglingStates();
    LearnerGraphND result = new LearnerGraphND(configMut);
    graphPatcher.relabel(result);
    Assert.assertNull(WMethod.checkM_and_colours(grB, result,VERTEX_COMPARISON_KIND.DEEP));
   
View Full Code Here

    // The last check: ensure that disconnected states are or are not key pairs.
    // This chunk of code simply returns GD, the checking is performed by the caller of this method.
    GD<List<CmpVertex>,List<CmpVertex>,LearnerGraphNDCachedData,LearnerGraphNDCachedData> gd = new GD<List<CmpVertex>,List<CmpVertex>,LearnerGraphNDCachedData,LearnerGraphNDCachedData>();
    gd.init(grA, grB, threadNumber,config);gd.identifyKeyPairs();
    ChangesRecorder recorder = new ChangesRecorder(null);
    gd.makeSteps();gd.computeDifference(recorder);
    return gd;
  }
View Full Code Here

    // The last check: ensure that disconnected states are or are not key pairs.
    // This chunk of code simply returns GD, the checking is performed by the caller of this method.
    GD<List<CmpVertex>,List<CmpVertex>,LearnerGraphNDCachedData,LearnerGraphNDCachedData> gd = new GD<List<CmpVertex>,List<CmpVertex>,LearnerGraphNDCachedData,LearnerGraphNDCachedData>();
    gd.init(grA, grB, threadNumber,config);gd.identifyKeyPairs();
    ChangesDisplay display = new ChangesDisplay(null);
    ChangesRecorder recorder = new ChangesRecorder(display);
    gd.makeSteps();gd.computeDifference(recorder);
   
    boolean foundA = false;
    for(Entry<CmpVertex,CmpVertex> entry:gd.aTOb.entrySet())
    {
      if (entry.getKey().getID().equals(VertexID.parseID("testA")))
      {
        foundA = true;
        Assert.assertTrue(gd.newBToOrig.get(entry.getValue()).getID().equals(VertexID.parseID(nameC)));
      }
    }
    Assert.assertTrue(foundA);
    Assert.assertTrue(display.toString().contains("added vertex:testA"));// this has to be done because testA is disconnected and will be killed by removeDisconnected
   
    LearnerGraphND graph = new LearnerGraphND(config);AbstractLearnerGraph.copyGraphs(grA, graph);
    Configuration configMut = Configuration.getDefaultConfiguration().copy();config.setLearnerCloneGraph(false);
    LearnerGraphMutator<List<CmpVertex>,LearnerGraphNDCachedData> graphPatcher = new LearnerGraphMutator<List<CmpVertex>,LearnerGraphNDCachedData>(graph,configMut,null);
    ChangesRecorder.loadDiff(graphPatcher, recorder.writeGD(TestGD.createDoc()));
    graphPatcher.removeDanglingStates();
    LearnerGraphND outcome = new LearnerGraphND(configMut);
    graphPatcher.relabel(outcome);
   
    Assert.assertTrue(DeterministicDirectedSparseGraph.nonIDAttributesEquals(outcome.findVertex(nameC),grA.findVertex("testA")));
View Full Code Here

  public final void testWriteAndLoad1()
  {
    LearnerGraphND graph = buildLearnerGraphND("A-a->B-a-#C\nA-d-#D\nA-c->A","testAddTransitions4",Configuration.getDefaultConfiguration(), converter);
    LearnerGraphND removed = buildLearnerGraphND("A-d-#D\nB-a-#C","testRemoveTransitions1",Configuration.getDefaultConfiguration(), converter);
    LearnerGraphND added = buildLearnerGraphND("A-d-#E\nB-a-#C","testRemoveTransitions1",Configuration.getDefaultConfiguration(), converter);
    ChangesRecorder patcher = new ChangesRecorder(removed,added,null);

    ChangesRecorder.applyGD(graph, patcher.writeGD(createDoc()), converter);
    LearnerGraph expected = buildLearnerGraph("A-a->B-a-#C\nA-d-#E\nA-c->A","testWriteAndLoad1",Configuration.getDefaultConfiguration(),converter);
    Assert.assertNull(WMethod.checkM_and_colours(expected, graph, VERTEX_COMPARISON_KIND.DEEP));
  }
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.