Package statechum.analysis.learning.rpnicore.GD

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


 
  @Test
  public final void testWriteAndLoad3()
  {
    LearnerGraph graph = new LearnerGraph(buildGraph("A-a->B-a-#C\nA-d-#D\nA-c->A","testAddTransitions4"),Configuration.getDefaultConfiguration());
    ChangesRecorder patcher = new ChangesRecorder(null);
    patcher.addTransition(graph.findVertex("B"), "c", graph.findVertex("B"));
    patcher.removeTransition(graph.findVertex("A"), "a", graph.findVertex("B"));
    patcher.addTransition(graph.findVertex("A"), "q", graph.findVertex("B"));
    patcher.setInitial(graph.findVertex("A"));
    ChangesRecorder.applyGD(graph, patcher.writeGD(createDoc()));
    LearnerGraph expected = new LearnerGraph(buildGraph("A-q->B-a-#C\nA-d-#D\nA-c->A\nB-c->B","testWriteAndLoad1"),Configuration.getDefaultConfiguration());
    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 = new LearnerGraph(buildGraph("A-a->B-a-#C\nA-d-#D\nA-c->A","testAddTransitions4"),Configuration.getDefaultConfiguration());
    final ChangesRecorder patcher = new ChangesRecorder(null);
    patcher.addTransition(graph.findVertex("B"), "c", graph.findVertex("B"));
    patcher.removeTransition(graph.findVertex("A"), "a", graph.findVertex("B"));
    patcher.addTransition(graph.findVertex("A"), "q", graph.findVertex("B"));
    checkForCorrectException(new whatToRun() { public void run() {
      patcher.writeGD(createDoc());}},
    IllegalArgumentException.class,"init state is was not defined");
  }
View Full Code Here

  {
    LearnerGraphND graph = new LearnerGraphND(buildGraph("A-a->B-a-#C\nA-d-#D\nA-c->A\nA-a->S-a->S","testWriteAndLoad5"),Configuration.getDefaultConfiguration());
    graph.findVertex("B").setDepth(5);graph.findVertex("D").setColour(JUConstants.AMBER);
   
    graph.addToIncompatibles(graph.findVertex("A"), graph.findVertex("B"));
    ChangesRecorder patcher = new ChangesRecorder(null);
    patcher.addTransition(graph.findVertex("B"), "c", graph.findVertex("B"));
    patcher.removeTransition(graph.findVertex("A"), "a", graph.findVertex("B"));
    patcher.removeIncompatible(graph.findVertex("B"), graph.findVertex("A"));
    patcher.addIncompatible(graph.findVertex("B"), graph.findVertex("S"));
    patcher.addTransition(graph.findVertex("A"), "q", graph.findVertex("B"));
    patcher.setInitial(graph.findVertex("A"));
    patcher.addRelabelling(VertexID.parseID("A"), VertexID.parseID("U"));
    patcher.addRelabelling(VertexID.parseID("C"), VertexID.parseID("R"));
   
    CmpVertex danglingVertex = AbstractLearnerGraph.generateNewCmpVertex(VertexID.parseID("TEST"), cloneConfig);
    danglingVertex.setColour(JUConstants.BLUE);
    patcher.addVertex(danglingVertex);
    Configuration config = Configuration.getDefaultConfiguration().copy();config.setLearnerCloneGraph(false);
    LearnerGraphMutator<List<CmpVertex>,LearnerGraphNDCachedData> graphPatcher = new LearnerGraphMutator<List<CmpVertex>,LearnerGraphNDCachedData>(graph,config,null);
    ChangesRecorder.loadDiff(graphPatcher, patcher.writeGD(createDoc()));
    graphPatcher.removeDanglingStates();
    LearnerGraphND result = new LearnerGraphND(Configuration.getDefaultConfiguration());
    graphPatcher.relabel(result);
   
    LearnerGraphND expected = new LearnerGraphND(buildGraph("U-q->B-a-#R\nU-d-#D\nU-c->U\nB-c->B\nU-a->S-a->S","testWriteAndLoad1"),Configuration.getDefaultConfiguration());
View Full Code Here

        "@B-c->@B-d->@B","testMakeSteps1B"),Configuration.getDefaultConfiguration());

    GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData> gd = new GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>();
    gd.init(graphA, graphB, threadNumber,Configuration.getDefaultConfiguration());
    Assert.assertTrue(gd.identifyKeyPairs());
    ChangesRecorder recorder = new ChangesRecorder(null);
    gd.makeSteps(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>();
    gd.init(grA, grB, threadNumber,config);
    gd.identifyKeyPairs();
    //printListOfPairs(gd, gd.currentWave);
    //printListOfPairs(gd, gd.frontWave);
    ChangesRecorder recorder = new ChangesRecorder(null);
    gd.makeSteps(recorder);
    //printListOfPairs(gd, allKeyPairs);
    Assert.assertEquals(expectedMatchedPairs,gd.aTOb.size());
    LearnerGraph graph = new LearnerGraph(buildGraph(graphA,name+"A"),config);
    ChangesRecorder.applyGD(graph, recorder.writeGD(TestGD.createDoc()));
    Assert.assertNull(WMethod.checkM(graph, grB));Assert.assertEquals(grB.getStateNumber(),graph.getStateNumber());
  }
View Full Code Here

    Configuration config = argConfig;if (config == null) config = Configuration.getDefaultConfiguration();
    LearnerGraph grA = new LearnerGraph(buildGraph(graphA,name+"A"),config);
    LearnerGraph grB = new LearnerGraph(buildGraph(graphB,name+"B"),config);

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

  public final void testComputeGD5b_RA()
  {
    Configuration config = Configuration.getDefaultConfiguration().copy();config.setGdFailOnDuplicateNames(false);
    LearnerGraph grA = new LearnerGraph(config);grA.init.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.init = 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 testComputeGD5b_AR()
  {
    Configuration config = Configuration.getDefaultConfiguration().copy();config.setGdFailOnDuplicateNames(false);
    LearnerGraph grA = new LearnerGraph(config);
    LearnerGraph grB = convertToNumerical(new LearnerGraph(config));grB.init.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.init = 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.init.setAccept(false);
    LearnerGraph grB = convertToNumerical(new LearnerGraph(config));grB.init.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.init = 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.init.setAccept(false);
    LearnerGraph grB = convertToNumerical(new LearnerGraph(buildGraph(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.init = 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

TOP

Related Classes of statechum.analysis.learning.rpnicore.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.