Package statechum.analysis.learning.linear.GDLearnerGraph

Examples of statechum.analysis.learning.linear.GDLearnerGraph.DetermineDiagonalAndRightHandSide


    config.setGdScoreComputationAlgorithm_RandomWalk_PathLength(4);
    LearnerGraph gr=buildLearnerGraph(NDGraph, "testCount_computeGraphs", config);
    GDLearnerGraph ndGraph = new GDLearnerGraph(gr,LearnerGraphND.ignoreRejectStates, true);
    ndGraph.computeWalkSequences(new StateBasedRandom(80), 1);
   
    DetermineDiagonalAndRightHandSide matcher = ndGraph.new DDRH_BCR();
    getMatcherValue(gr,ndGraph,ndGraph.matrixForward, matcher,"C","D");
    Assert.assertEquals(4.76190476190,matcher.getRightHandSide(),Configuration.fpAccuracy);
    Assert.assertEquals(2*2,matcher.getDiagonal(),Configuration.fpAccuracy);

    getMatcherValue(gr,ndGraph,ndGraph.matrixForward, matcher,"E","B");
    Assert.assertEquals(6.374807987711213,matcher.getRightHandSide(),Configuration.fpAccuracy);
    Assert.assertEquals(2*2,matcher.getDiagonal(),Configuration.fpAccuracy);
  }
 
View Full Code Here


  {
    int size=gr.getStateNumber()*(gr.getStateNumber()+1)/2;
    DoubleMatrix1D result = DoubleFactory1D.dense.make(size);
    StatesToConsider filter = LearnerGraphND.ignoreRejectStates;
    GDLearnerGraph ndGraph = new GDLearnerGraph(gr,filter, false);
    DetermineDiagonalAndRightHandSide ddrhInstance = ndGraph.new DDRH_default();
    for(Entry<CmpVertex,Map<Label,List<CmpVertex>>> entryA:ndGraph.matrixForward.transitionMatrix.entrySet())
    {
      // Now iterate through states
      Iterator<Entry<CmpVertex,Map<Label,List<CmpVertex>>>> stateB_It = ndGraph.matrixForward.transitionMatrix.entrySet().iterator();
      while(stateB_It.hasNext())
      {
        Entry<CmpVertex,Map<Label,List<CmpVertex>>> stateB = stateB_It.next();

        int currentStatePair = ndGraph.vertexToIntNR(stateB.getKey(),entryA.getKey());
        ddrhInstance.compute(entryA.getKey(),stateB.getKey(),entryA.getValue(),stateB.getValue());
        result.setQuick(currentStatePair, ddrhInstance.getRightHandSide());
       
        if (stateB.getKey().equals(entryA.getKey())) break; // we only process a triangular subset.
      }
    }
   
View Full Code Here

    config.setGdScoreComputationAlgorithm(GDScoreComputationAlgorithmEnum.SCORE_TESTSET);
    LearnerGraph gr=buildLearnerGraph(NDGraph, "testCount_computeGraphs", config);
    GDLearnerGraph ndGraph = new GDLearnerGraph(gr,LearnerGraphND.ignoreRejectStates, true);
    ndGraph.computeWalkSequences(new StateBasedRandom(80), 1);
   
    DetermineDiagonalAndRightHandSide matcher = ndGraph.new DDRH_BCR();
    getMatcherValue(gr,ndGraph,ndGraph.matrixForward, matcher,"C","D");
    Assert.assertEquals(100./3.,matcher.getRightHandSide(),Configuration.fpAccuracy);
    Assert.assertEquals(2*2,matcher.getDiagonal(),Configuration.fpAccuracy);

    getMatcherValue(gr,ndGraph,ndGraph.matrixForward, matcher,"E","B");
    Assert.assertEquals(100,matcher.getRightHandSide(),Configuration.fpAccuracy);
    Assert.assertEquals(2*2,matcher.getDiagonal(),Configuration.fpAccuracy);
  }
 
View Full Code Here

  {
    int size=gr.getStateNumber()*(gr.getStateNumber()+1)/2;
    DoubleMatrix1D result = DoubleFactory1D.dense.make(size);
    StatesToConsider filter = LearnerGraphND.ignoreRejectStates;
    GDLearnerGraph ndGraph = new GDLearnerGraph(gr,filter, false);
    DetermineDiagonalAndRightHandSide ddrhInstance = ndGraph.new DDRH_default();
    for(Entry<CmpVertex,Map<Label,List<CmpVertex>>> entryA:ndGraph.matrixForward.transitionMatrix.entrySet())
    {
      // Now iterate through states
      Iterator<Entry<CmpVertex,Map<Label,List<CmpVertex>>>> stateB_It = ndGraph.matrixForward.transitionMatrix.entrySet().iterator();
      while(stateB_It.hasNext())
      {
        Entry<CmpVertex,Map<Label,List<CmpVertex>>> stateB = stateB_It.next();

        int currentStatePair = ndGraph.vertexToIntNR(stateB.getKey(),entryA.getKey());
        ddrhInstance.compute(entryA.getKey(),stateB.getKey(),entryA.getValue(),stateB.getValue());
        result.setQuick(currentStatePair, ddrhInstance.getRightHandSide());
       
        if (stateB.getKey().equals(entryA.getKey())) break; // we only process a triangular subset.
      }
    }
   
View Full Code Here

  {
    int size=gr.getStateNumber()*(gr.getStateNumber()+1)/2;
    DoubleMatrix1D result = DoubleFactory1D.dense.make(size);
    StatesToConsider filter = LearnerGraphND.ignoreRejectStates;
    GDLearnerGraph ndGraph = new GDLearnerGraph(gr,filter, false);
    DetermineDiagonalAndRightHandSide ddrhInstance = ndGraph.new DDRH_default();
    for(Entry<CmpVertex,Map<Label,List<CmpVertex>>> entryA:ndGraph.matrixForward.transitionMatrix.entrySet())
    {
      // Now iterate through states
      Iterator<Entry<CmpVertex,Map<Label,List<CmpVertex>>>> stateB_It = ndGraph.matrixForward.transitionMatrix.entrySet().iterator();
      while(stateB_It.hasNext())
      {
        Entry<CmpVertex,Map<Label,List<CmpVertex>>> stateB = stateB_It.next();

        int currentStatePair = ndGraph.vertexToIntNR(stateB.getKey(),entryA.getKey());
        ddrhInstance.compute(entryA.getKey(),stateB.getKey(),entryA.getValue(),stateB.getValue());
        result.setQuick(currentStatePair, ddrhInstance.getRightHandSide());
       
        if (stateB.getKey().equals(entryA.getKey())) break; // we only process a triangular subset.
      }
    }
   
View Full Code Here

  public final void testCountMatchingOutgoing_nd2a()
  {
    LearnerGraph gr=buildLearnerGraph("A1-a->C\nA2-a->C\nA3-a->C<-b-G\nB1-a->D<-a-B2\nE-b->D<-b-F\n"
        +"N-c->C", "testCountMatchingOutgoing_nd2a", configMain,converter);
    GDLearnerGraph ndGraph = new GDLearnerGraph(gr,LearnerGraphND.ignoreRejectStates, false);
    DetermineDiagonalAndRightHandSide matcher = ndGraph.new DDRH_default();
    getMatcherValue(gr,ndGraph,ndGraph.matrixInverse, matcher,"C","D");
    Assert.assertEquals(8,matcher.getRightHandSide(),Configuration.fpAccuracy);
    Assert.assertEquals(9*2,matcher.getDiagonal(),Configuration.fpAccuracy);
  }
 
View Full Code Here

    LearnerGraph gr=buildLearnerGraph("A1-a->C\nA2-a->C\nA3-a->C<-b-G\nB1-a->D<-a-B2\nE-b->D<-b-F\n"
        +"N-c->C\n"
        +"M-d->D"
        , "testCountMatchingOutgoing_nd2b", configMain,converter);
    GDLearnerGraph ndGraph = new GDLearnerGraph(gr,LearnerGraphND.ignoreRejectStates, false);
    DetermineDiagonalAndRightHandSide matcher = ndGraph.new DDRH_default();
    getMatcherValue(gr,ndGraph,ndGraph.matrixInverse, matcher,"C","D");
    Assert.assertEquals(8,matcher.getRightHandSide(),Configuration.fpAccuracy);
    Assert.assertEquals(10*2,matcher.getDiagonal(),Configuration.fpAccuracy);
  }
 
View Full Code Here

  {
    LearnerGraph gr=buildLearnerGraph("A1-a->C\nA2-a->C\nA3-a->C<-b-G\nB1-a->D<-a-B2\nE-b->D<-b-F\n"
        +"N-c->C\n"
        +"N-a->C", "testCountMatchingOutgoing_nd3a", configMain,converter);
    GDLearnerGraph ndGraph = new GDLearnerGraph(gr,LearnerGraphND.ignoreRejectStates, false);
    DetermineDiagonalAndRightHandSide matcher = ndGraph.new DDRH_default();
    getMatcherValue(gr,ndGraph,ndGraph.matrixInverse, matcher,"C","D");
    Assert.assertEquals(10,matcher.getRightHandSide(),Configuration.fpAccuracy);
    Assert.assertEquals(11*2,matcher.getDiagonal(),Configuration.fpAccuracy);
  }
 
View Full Code Here

    LearnerGraph gr=buildLearnerGraph("A1-a->C\nA2-a->C\nA3-a->C<-b-G\nB1-a->D<-a-B2\nE-b->D<-b-F\n"
        +"N-c->C<-f-U\n"
        +"N-a->C\nS-r->D", "testCountMatchingOutgoing_nd3b", configMain,converter);
    //Visualiser.updateFrame(gr, null);
    GDLearnerGraph ndGraph = new GDLearnerGraph(gr,LearnerGraphND.ignoreRejectStates, false);
    DetermineDiagonalAndRightHandSide matcher = ndGraph.new DDRH_default();
    getMatcherValue(gr,ndGraph,ndGraph.matrixInverse, matcher,"C","D");
    Assert.assertEquals(10,matcher.getRightHandSide(),Configuration.fpAccuracy);
    Assert.assertEquals(13*2,matcher.getDiagonal(),Configuration.fpAccuracy);
  }
 
View Full Code Here

    config.setGdScoreComputationAlgorithm_RandomWalk_PathLength(4);
    LearnerGraph gr=buildLearnerGraph(NDGraph, "testCount_computeGraphs", config,converter);
    GDLearnerGraph ndGraph = new GDLearnerGraph(gr,LearnerGraphND.ignoreRejectStates, true);
    ndGraph.computeWalkSequences(new StateBasedRandom(80), 1);
   
    DetermineDiagonalAndRightHandSide matcher = ndGraph.new DDRH_BCR();
    getMatcherValue(gr,ndGraph,ndGraph.matrixForward, matcher,"C","D");
    Assert.assertEquals(4.76190476190,matcher.getRightHandSide(),Configuration.fpAccuracy);
    Assert.assertEquals(2*2,matcher.getDiagonal(),Configuration.fpAccuracy);

    getMatcherValue(gr,ndGraph,ndGraph.matrixForward, matcher,"E","B");
    Assert.assertEquals(6.374807987711213,matcher.getRightHandSide(),Configuration.fpAccuracy);
    Assert.assertEquals(2*2,matcher.getDiagonal(),Configuration.fpAccuracy);
  }
 
View Full Code Here

TOP

Related Classes of statechum.analysis.learning.linear.GDLearnerGraph.DetermineDiagonalAndRightHandSide

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.