Package statechum.analysis.learning.rpnicore

Examples of statechum.analysis.learning.rpnicore.LearnerGraphND


  /** Tests non-deterministic case of {@link MarkovClassifier#tracePath}, deterministic case is tested with {@link TestPathTracing}. */
  @Test
  public void testTracePath1()
  {
    final LearnerGraph fsm = FsmParser.buildLearnerGraph("A-a->B-b->C", "testTracePath1",config,converter);
    LearnerGraphND ndFSM = new LearnerGraphND(fsm,config);
    synchronized(AbstractLearnerGraph.syncObj)
    {
      ndFSM.addVertex(ndFSM.addVertex(fsm.findVertex("A"), true, lblA),true,lblA);
    }
    Assert.assertTrue(MarkovClassifier.tracePath(ndFSM,AbstractLearnerGraph.buildList(Arrays.asList(new String[]{}),config,converter),fsm.findVertex("A")));
    Assert.assertTrue(MarkovClassifier.tracePath(ndFSM,AbstractLearnerGraph.buildList(Arrays.asList(new String[]{"a","b"}),config,converter),fsm.findVertex("A")));
    Assert.assertTrue(MarkovClassifier.tracePath(ndFSM,AbstractLearnerGraph.buildList(Arrays.asList(new String[]{"a","a"}),config,converter),fsm.findVertex("A")));
  }
View Full Code Here


  /** Tests non-deterministic case of {@link MarkovClassifier#tracePath}, deterministic case is tested with {@link TestPathTracing}. */
  @Test
  public void testTracePath2()
  {
    final LearnerGraph fsm = FsmParser.buildLearnerGraph("A-a->B-b->C", "testTracePath1",config,converter);
    LearnerGraphND ndFSM = new LearnerGraphND(fsm,config);
    synchronized(AbstractLearnerGraph.syncObj)
    {
      CmpVertex AA=ndFSM.addVertex(ndFSM.addVertex(fsm.findVertex("A"), true, lblA),true,lblA);
      ndFSM.addVertex(AA, true, lblA);ndFSM.addVertex(AA, true, lblC);
    }
    Assert.assertEquals(7,ndFSM.getStateNumber());
    Assert.assertTrue(MarkovClassifier.tracePath(ndFSM,AbstractLearnerGraph.buildList(Arrays.asList(new String[]{"a","a","c"}),config,converter),fsm.findVertex("A")));
    Assert.assertTrue(MarkovClassifier.tracePath(ndFSM,AbstractLearnerGraph.buildList(Arrays.asList(new String[]{"a","a","a"}),config,converter),fsm.findVertex("A")));
    Assert.assertFalse(MarkovClassifier.tracePath(ndFSM,AbstractLearnerGraph.buildList(Arrays.asList(new String[]{"a","a","b"}),config,converter),fsm.findVertex("A")));
    Assert.assertFalse(MarkovClassifier.tracePath(ndFSM,AbstractLearnerGraph.buildList(Arrays.asList(new String[]{"a","a","a","a"}),config,converter),fsm.findVertex("A")));
  }
View Full Code Here

  /** Tests non-deterministic case of {@link MarkovClassifier#tracePath}, deterministic case is tested with {@link TestPathTracing}. */
  @Test
  public void testTracePath3()
  {
    final LearnerGraph fsm = FsmParser.buildLearnerGraph("A-a->B-b->C", "testTracePath1",config,converter);
    LearnerGraphND ndFSM = new LearnerGraphND(fsm,config);
    synchronized(AbstractLearnerGraph.syncObj)
    {
      ndFSM.addVertex(ndFSM.addVertex(ndFSM.addVertex(ndFSM.addVertex(fsm.findVertex("A"), true, lblA),true,lblA),true,lblA),true,lblA);
      ndFSM.addVertex(ndFSM.addVertex(ndFSM.addVertex(fsm.findVertex("A"), true, lblA),true,lblA),true,lblA);
    }
    Assert.assertEquals(10,ndFSM.getStateNumber());
    Assert.assertTrue(MarkovClassifier.tracePath(ndFSM,AbstractLearnerGraph.buildList(Arrays.asList(new String[]{}),config,converter),fsm.findVertex("A")));
    Assert.assertTrue(MarkovClassifier.tracePath(ndFSM,AbstractLearnerGraph.buildList(Arrays.asList(new String[]{"a","b"}),config,converter),fsm.findVertex("A")));
    Assert.assertTrue(MarkovClassifier.tracePath(ndFSM,AbstractLearnerGraph.buildList(Arrays.asList(new String[]{"a","a","a"}),config,converter),fsm.findVertex("A")));
    Assert.assertTrue(MarkovClassifier.tracePath(ndFSM,AbstractLearnerGraph.buildList(Arrays.asList(new String[]{"a","a","a","a"}),config,converter),fsm.findVertex("A")));
    Assert.assertFalse(MarkovClassifier.tracePath(ndFSM,AbstractLearnerGraph.buildList(Arrays.asList(new String[]{"a","a","a","a","a"}),config,converter),fsm.findVertex("A")));
View Full Code Here

  /** Tests non-deterministic case of {@link MarkovClassifier#tracePath}, deterministic case is tested with {@link TestPathTracing}. */
  @Test
  public void testTracePath4()
  {
    final LearnerGraph fsm = FsmParser.buildLearnerGraph("A-t->B-b->C", "testTracePath1",config,converter);
    LearnerGraphND ndFSM = new LearnerGraphND(fsm,config);
    synchronized(AbstractLearnerGraph.syncObj)
    {
      ndFSM.addVertex(ndFSM.addVertex(ndFSM.addVertex(ndFSM.addVertex(fsm.findVertex("B"), true, lblA),true,lblA),true,lblA),true,lblA);
      ndFSM.addVertex(ndFSM.addVertex(ndFSM.addVertex(fsm.findVertex("B"), true, lblA),true,lblA),true,lblC);
    }
    Assert.assertEquals(10,ndFSM.getStateNumber());
    Assert.assertTrue(MarkovClassifier.tracePath(ndFSM,AbstractLearnerGraph.buildList(Arrays.asList(new String[]{}),config,converter),fsm.findVertex("A")));
    Assert.assertTrue(MarkovClassifier.tracePath(ndFSM,AbstractLearnerGraph.buildList(Arrays.asList(new String[]{"t","b"}),config,converter),fsm.findVertex("A")));
    Assert.assertTrue(MarkovClassifier.tracePath(ndFSM,AbstractLearnerGraph.buildList(Arrays.asList(new String[]{"t","a","a","a"}),config,converter),fsm.findVertex("A")));
    Assert.assertTrue(MarkovClassifier.tracePath(ndFSM,AbstractLearnerGraph.buildList(Arrays.asList(new String[]{"t","a","a","a","a"}),config,converter),fsm.findVertex("A")));
    Assert.assertTrue(MarkovClassifier.tracePath(ndFSM,AbstractLearnerGraph.buildList(Arrays.asList(new String[]{"t","a","a","c"}),config,converter),fsm.findVertex("A")));
View Full Code Here

  /** Tests non-deterministic case of {@link MarkovClassifier#tracePath}, deterministic case is tested with {@link TestPathTracing}. */
  @Test
  public void testTracePath5()
  {
    final LearnerGraph fsm = FsmParser.buildLearnerGraph("A-t->B-b->C", "testTracePath1",config,converter);
    LearnerGraphND ndFSM = new LearnerGraphND(fsm,config);
    CmpVertex Brej=null;
    synchronized(AbstractLearnerGraph.syncObj)
    {
      ndFSM.addVertex(ndFSM.addVertex(ndFSM.addVertex(ndFSM.addVertex(fsm.findVertex("B"), true, lblA),true,lblA),true,lblA),true,lblA);
      ndFSM.addVertex(ndFSM.addVertex(ndFSM.addVertex(fsm.findVertex("B"), true, lblA),true,lblA),false,lblC);
      Brej=ndFSM.addVertex(ndFSM.addVertex(fsm.findVertex("B"), true, lblA),false,lblB);
      ndFSM.addVertex(Brej,false,lblC);
    }
    Assert.assertEquals(13,ndFSM.getStateNumber());
    Assert.assertTrue(MarkovClassifier.tracePath(ndFSM,AbstractLearnerGraph.buildList(Arrays.asList(new String[]{}),config,converter),fsm.findVertex("A")));
    Assert.assertTrue(MarkovClassifier.tracePath(ndFSM,AbstractLearnerGraph.buildList(Arrays.asList(new String[]{"t","b"}),config,converter),fsm.findVertex("A")));
    Assert.assertTrue(MarkovClassifier.tracePath(ndFSM,AbstractLearnerGraph.buildList(Arrays.asList(new String[]{"t","a","a","a"}),config,converter),fsm.findVertex("A")));
    Assert.assertTrue(MarkovClassifier.tracePath(ndFSM,AbstractLearnerGraph.buildList(Arrays.asList(new String[]{"t","a","a","a","a"}),config,converter),fsm.findVertex("A")));
    Assert.assertFalse(MarkovClassifier.tracePath(ndFSM,AbstractLearnerGraph.buildList(Arrays.asList(new String[]{"t","a","a","c"}),config,converter),fsm.findVertex("A")));
View Full Code Here

  {
    Configuration config = Configuration.getDefaultConfiguration().copy();config.setTransitionMatrixImplType(STATETREE.STATETREE_SLOWTREE);
    config.setGdKeyPairThreshold(1);config.setGdLowToHighRatio(1);
    String name = "testVisual5";
    String common = "A-a->B-p->B\nA-a->C-q->C\nA-a->D-r->D\nS-a-#T";
    LearnerGraphND grA = FsmParser.buildLearnerGraphND("A-a->E-s->E\nA-a->F-v->F\nU-a-#V\n"+common,name+"A",config,null);
    LearnerGraphND grB = FsmParser.buildLearnerGraphND("A-a->G-u->G\nA-a->H-t->H\n"+common,name+"B",config,null);
    LearnerGraphND grA_reduced = new LearnerGraphND(config), grB_reduced = new LearnerGraphND(config);
    AbstractPathRoutines.removeRejectStates(grA, grA_reduced);
    AbstractPathRoutines.removeRejectStates(grB, grB_reduced);
    GD<List<CmpVertex>,List<CmpVertex>,LearnerGraphNDCachedData,LearnerGraphNDCachedData> gd =
      new GD<List<CmpVertex>,List<CmpVertex>,LearnerGraphNDCachedData,LearnerGraphNDCachedData>();
    DirectedSparseGraph graph = gd.showGD(grA_reduced,grB_reduced,  ExperimentRunner.getCpuNumber());
View Full Code Here

  {
    Configuration config = Configuration.getDefaultConfiguration().copy();config.setTransitionMatrixImplType(STATETREE.STATETREE_SLOWTREE);
    config.setGdKeyPairThreshold(1);config.setGdLowToHighRatio(1);config.setGdMaxNumberOfStatesInCrossProduct(0);
    String name = "testVisual5";
    String common = "A-a->B-p->B\nA-a->C-q->C\nA-a->D-r->D\nS-a-#T";
    LearnerGraphND grA = FsmParser.buildLearnerGraphND("A-a->E-s->E\nA-a->F-v->F\nU-a-#V\n"+common,name+"A",config,null);
    LearnerGraphND grB = FsmParser.buildLearnerGraphND("A-a->G-u->G\nA-a->H-t->H\n"+common,name+"B",config,null);
    LearnerGraphND grA_reduced = new LearnerGraphND(config), grB_reduced = new LearnerGraphND(config);
    AbstractPathRoutines.removeRejectStates(grA, grA_reduced);
    AbstractPathRoutines.removeRejectStates(grB, grB_reduced);
    GD<List<CmpVertex>,List<CmpVertex>,LearnerGraphNDCachedData,LearnerGraphNDCachedData> gd =
      new GD<List<CmpVertex>,List<CmpVertex>,LearnerGraphNDCachedData,LearnerGraphNDCachedData>();
    DirectedSparseGraph graph = gd.showGD(grA_reduced,grB_reduced,  ExperimentRunner.getCpuNumber());
View Full Code Here

   * @return inverted graph
   */
  public static LearnerGraphND computeInverseGraph(LearnerGraph graph)
  {
    Configuration shallowCopy = graph.config.copy();shallowCopy.setLearnerCloneGraph(false);
    LearnerGraphND inverseGraph = new LearnerGraphND(shallowCopy);inverseGraph.initEmpty();
    AbstractPathRoutines.buildInverse(graph,LearnerGraphND.ignoreNone,inverseGraph)// do the inverse to the tentative graph
    return inverseGraph;
  }
View Full Code Here

      }
  }
 
  public static void printTraceLeadingTo(LearnerGraph graph, String vert)
  {
    LearnerGraphND ptaInverse = new LearnerGraphND(graph.config);
    AbstractPathRoutines.buildInverse(graph, new StatesToConsider() {
      @Override public boolean stateToConsider(@SuppressWarnings("unused") CmpVertex v) { return true; }}
      , ptaInverse);
    CmpVertex v=ptaInverse.findVertex(vert);
    for(int i=0;i<10;++i)
    {
      Map<Label,List<CmpVertex>> transitions = ptaInverse.transitionMatrix.get(v);
      if (transitions.size() > 1)
      {
View Full Code Here

    GDLearnerGraph(AbstractLearnerGraph<TARGET_A_TYPE,CACHE_A_TYPE> coregraph,
    StatesToConsider stateFilter,
    boolean direction)
  {
    alphabet = coregraph.learnerCache.getAlphabet();config=coregraph.config;filter=stateFilter;
    matrixInverse = new LearnerGraphND(config);matrixInverse.initEmpty();
    matrixForward = new LearnerGraphND(config);matrixForward.initEmpty();
    pairCompatibility = coregraph.pairCompatibility;
   
    stateToNumberMap = new TreeMap<CmpVertex,Integer>();
    numberToStateArray = coregraph.buildStateToIntegerMap(filter,stateToNumberMap);
    assert numberToStateArray.length == stateToNumberMap.size();
View Full Code Here

TOP

Related Classes of statechum.analysis.learning.rpnicore.LearnerGraphND

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.