Package statechum.analysis.learning.linear.GD

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


    LearnerGraph grB = buildLearnerGraph("B-a->B","testKeyPairLeadingToNoOutgoingTransitions_with_attribute_change_b",config,converter);
    CmpVertex F=AbstractLearnerGraph.generateNewCmpVertex(VertexID.parseID("F"), config);
    grB.transitionMatrix.put(F,grB.createNewRow());
    GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData> gd = new GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>();
    LearnerGraph outcome = new LearnerGraph(config);
    ChangesRecorder patcher = new ChangesRecorder(null);
   
    gd.init(grA, grB, 1,config);
    gd.identifyKeyPairs();
    Assert.assertFalse(gd.fallbackToInitialPair);
    CmpVertex newF = gd.origToNewB.get(F);
    CmpVertex C = gd.grCombined.findVertex(VertexID.parseID("C"));

    // add C-newF as a new initial key pair.
    gd.frontWave.add(new PairScore(C,newF,1,0));
    gd.statesInKeyPairs.add(C);gd.statesInKeyPairs.add(newF);

    gd.makeSteps();
    ChangesDisplay recorder = new ChangesDisplay(patcher);
    gd.computeDifference(recorder);
    Assert.assertEquals(
        "mapping: A - B\n"+
        "mapping: C - F\n"+
        "initial : A\n"+
        "removed: C - a -> E\n"+
        "removed: C - b -> D\n"+
        "added vertex:C\n",
        recorder.toString());
    ChangesRecorder.applyGD_WithRelabelling(graph, patcher.writeGD(TestGD.createDoc()), converter,outcome);
    Assert.assertNull(WMethod.checkM(grB,graph));
    Assert.assertEquals(grB.getStateNumber(),graph.getStateNumber());
    if (vertexToChange != null) Assert.assertEquals(JUConstants.AMBER,grA.findVertex(VertexID.parseID(vertexToChange)).getColour());
  }
View Full Code Here


      LearnerGraph grB = buildLearnerGraph(graphB,name+"B",config,converter);
 
      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,converter);
      ChangesRecorder.applyGD(graph, recorder.writeGD(TestGD.createDoc()), converter);
      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 configGD5b = config.copy();configGD5b.setGdFailOnDuplicateNames(false);
    configGD5b.setGdMaxNumberOfStatesInCrossProduct(0);
    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

    Configuration cloneConfig = configCheckDiffBetweenND.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,configCheckDiffBetweenND);gd.identifyKeyPairs();
    //TestGD.printListOfPairs(gd.currentWave, gd.newBToOrig);
    ChangesRecorder recorder = new ChangesRecorder(null);
    gd.makeSteps();gd.computeDifference(recorder);
    //Visualiser.updateFrame(gd.showGD(grA, grB, 1), null);
    //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()), converter);
    Assert.assertNull(WMethod.checkM(grB, graph));
   
    // Now do the same as above, but renumber states to match grB
    AbstractLearnerGraph.copyGraphs(grA, graph);
    Configuration configMut = conf.copy();configCheckDiffBetweenND.setLearnerCloneGraph(false);
    LearnerGraphMutator<List<CmpVertex>,LearnerGraphNDCachedData> graphPatcher = new LearnerGraphMutator<List<CmpVertex>,LearnerGraphNDCachedData>(graph,configMut,null);
    ChangesRecorder.loadDiff(graphPatcher, recorder.writeGD(TestGD.createDoc()), converter);
    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,argConfig);gd.identifyKeyPairs();
    ChangesRecorder recorder = new ChangesRecorder(null);
    gd.makeSteps();gd.computeDifference(recorder);
    return gd;
  }
View Full Code Here

    GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData> gd = new GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>();
    Configuration config = configGraph.copy();config.setGdPropagateDet(true);
    gd.init(graphA, graphB, threadNumber,config);
    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 config = Configuration.getDefaultConfiguration().copy();config.setGdPropagateDet(false);
    gd.init(graphA, graphB, threadNumber,config);
    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>();
    gd.init(grA, grB, threadNumber,config);
    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",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 = buildLearnerGraph(graphA,name+"A",config);
    LearnerGraph grB = buildLearnerGraph(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<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",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 = buildLearnerGraph(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 = buildLearnerGraph(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.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

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.