Package statechum.analysis.learning.linear.GD

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


    // 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


  public final void testDisplay()
  {
    LearnerGraph grA = buildLearnerGraph("A-a->B\nA-b->B","testCounterA",config,converter);
    LearnerGraph grB = buildLearnerGraph("@A-a->@B\n@A-c->@B","testCounterB",config,converter);
    ChangesCounter<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData> counter = new ChangesCounter<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>(grA,grB,null);
    ChangesDisplay recorder = new ChangesDisplay(counter);
    GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData> gd = new GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>();
    gd.computeGD(grA, grB, threadNumber, recorder,config);
    Assert.assertEquals("mapping: A - @A\n"+
      "mapping: B - @B\n"+
      "initial : A\n"+
      "removed: A - b -> B\n"+
      "added  : A - c -> B\n",recorder.toString());
    Assert.assertEquals(1,counter.getAdded());Assert.assertEquals(1,counter.getRemoved());
  }
View Full Code Here

    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()));
      Assert.assertNull(WMethod.checkM(graph3, grB));Assert.assertEquals(grB.getStateNumber(),graph3.getStateNumber());
    }
    {// check that changes propagated to rec1 are correct.
      LearnerGraph graph4 = buildLearnerGraph(graphA,name+"A",config);
      ChangesRecorder.applyGD(graph4, rec1.writeGD(TestGD.createDoc()));
      Assert.assertNull(WMethod.checkM(graph4, grB));Assert.assertEquals(grB.getStateNumber(),graph4.getStateNumber());
    }
    String displayResult = rec8.toString();
    Assert.assertEquals(displayResult,rec5.toString());Assert.assertEquals(displayResult, rec2.toString());
   
    int added = rec9.getAdded(),removed = rec9.getRemoved();String result = rec9.toString();
    Assert.assertEquals(added,rec6.getAdded());Assert.assertEquals(removed,rec6.getRemoved());Assert.assertEquals(result,rec6.toString());
    Assert.assertEquals(added,rec3.getAdded());Assert.assertEquals(removed,rec3.getRemoved());Assert.assertEquals(result,rec3.toString());
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()));
View Full Code Here

  {
    Configuration config = Configuration.getDefaultConfiguration();
    LearnerGraph grA = buildLearnerGraph("A-a->B\nA-b->B","testCounterA",config);
    LearnerGraph grB = buildLearnerGraph("@A-a->@B\n@A-c->@B","testCounterB",config);
    ChangesCounter<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData> counter = new ChangesCounter<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>(grA,grB,null);
    ChangesDisplay recorder = new ChangesDisplay(counter);
    GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData> gd = new GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>();
    gd.computeGD(grA, grB, threadNumber, recorder,config);
    Assert.assertEquals("removed: A - b -> B\n"+
        "added  : A - c -> B\nmapping: A - @A\nmapping: B - @B\ninitial : A\n",recorder.toString());
    Assert.assertEquals(1,counter.getAdded());Assert.assertEquals(1,counter.getRemoved());
  }
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,configND3);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().equals(VertexID.parseID("testA")))
      {
        foundA = true;
        Assert.assertTrue(gd.newBToOrig.get(entry.getValue()).equals(VertexID.parseID(TestGD_Multithreaded.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(configND3);AbstractLearnerGraph.copyGraphs(grA, graph);
    Configuration configMut = config.copy();configND3.setLearnerCloneGraph(false);
    LearnerGraphMutator<List<CmpVertex>,LearnerGraphNDCachedData> graphPatcher = new LearnerGraphMutator<List<CmpVertex>,LearnerGraphNDCachedData>(graph,configMut,null);
    ChangesRecorder.loadDiff(graphPatcher, recorder.writeGD(TestGD.createDoc()), converter);
View Full Code Here

    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);
      Assert.assertNull(WMethod.checkM(graph3, grB));Assert.assertEquals(grB.getStateNumber(),graph3.getStateNumber());
    }
    {// check that changes propagated to rec1 are correct.
      LearnerGraph graph4 = buildLearnerGraph(graphA,name+"A",configNesting,converter);
      ChangesRecorder.applyGD(graph4, rec1.writeGD(TestGD.createDoc()), converter);
      Assert.assertNull(WMethod.checkM(graph4, grB));Assert.assertEquals(grB.getStateNumber(),graph4.getStateNumber());
    }
    String displayResult = rec8.toString();
    Assert.assertEquals(displayResult,rec5.toString());Assert.assertEquals(displayResult, rec2.toString());
   
    int added = rec9.getAdded(),removed = rec9.getRemoved();String result = rec9.toString();
    Assert.assertEquals(added,rec6.getAdded());Assert.assertEquals(removed,rec6.getRemoved());Assert.assertEquals(result,rec6.toString());
    Assert.assertEquals(added,rec3.getAdded());Assert.assertEquals(removed,rec3.getRemoved());Assert.assertEquals(result,rec3.toString());
View Full Code Here

  final private void checkPatch(String graphA, String graphB, String name, int keyPairs, String expectedPatch, Configuration configToUse)
  {
    LearnerGraph grA = buildLearnerGraph(graphA,name+"_A",configToUse,converter);
    LearnerGraph grB = buildLearnerGraph(graphB,name+"_B",configToUse,converter);
    ChangesCounter<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData> counter = new ChangesCounter<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>(grA,grB,null);
    ChangesDisplay recorder = new ChangesDisplay(counter);
    GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData> gd = new GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>();
    gd.computeGD(grA, grB, threadNumber, recorder,configToUse);Assert.assertEquals(keyPairs,gd.aTOb.size());
    Assert.assertEquals(expectedPatch,recorder.toString());
  }
View Full Code Here

        "added  : P1005 - b -> P1006\n";
    LearnerGraph grA = buildLearnerGraph(graphA,name+"_A",configNonFail,converter);
    grA.findVertex(VertexID.parseID("M")).setColour(JUConstants.RED);// ignored because it features in incompatibles.
    LearnerGraph grB = buildLearnerGraph(graphB,name+"_B",configNonFail,converter);
    ChangesCounter<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData> counter = new ChangesCounter<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>(grA,grB,null);
    ChangesDisplay recorder = new ChangesDisplay(counter);
    GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData> gd = new GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>();
    gd.init(grA, grB, threadNumber,configNonFail);
    gd.identifyKeyPairs();
    gd.makeSteps();
   
    // add M-N as a key pair.
    CmpVertex stateM = grA.findVertex(VertexID.parseID("M")), stateN = grB.findVertex(VertexID.parseID("N"));
    addToKeyPairs(gd,stateM,stateN);
   
    Assert.assertEquals(4,gd.aTOb.size());
    gd.computeDifference(recorder);
    Assert.assertEquals(expectedPatch,recorder.toString());
  }
View Full Code Here

        "added incompatibles: AC,N with value INCOMPATIBLE\n";
    LearnerGraph grA = buildLearnerGraph(graphA,name+"_A",configNonFail,converter);
    grA.findVertex(VertexID.parseID("M")).setColour(JUConstants.RED);// ignored because it features in incompatibles.
    LearnerGraph grB = buildLearnerGraph(graphB,name+"_B",configNonFail,converter);
    ChangesCounter<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData> counter = new ChangesCounter<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>(grA,grB,null);
    ChangesDisplay recorder = new ChangesDisplay(counter);
    GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData> gd = new GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>();
    gd.init(grA, grB, threadNumber,configNonFail);
    gd.identifyKeyPairs();
    gd.makeSteps();
   
    Assert.assertEquals(3,gd.aTOb.size());
    gd.computeDifference(recorder);
    Assert.assertEquals(expectedPatch,recorder.toString());
  }
View Full Code Here

TOP

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

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.