Package statechum.analysis.learning.linear.GDLearnerGraph

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


  {
    Configuration config = configMain.copy();
    LearnerGraph gr=buildLearnerGraph("A-a->B\nA-b->B1\nA-c->C\nQ-a->R\nQ-b->S", "testCountMatchingOutgoing3d", config,converter);
    gr.linear.moveRejectToHighlight();
    GDLearnerGraph ndGraph = new GDLearnerGraph(gr,LearnerGraphND.ignoreRejectStates, false);
    DetermineDiagonalAndRightHandSide matcher = ndGraph.new DDRH_highlight();
    getMatcherValue(gr,ndGraph,ndGraph.matrixForward, matcher,"A","Q");
    // A and Q have 3 outgoing and 3 matched.
    // the score for the first pair is -1, for the other ones it is 1, hence the outcome is 1
    Assert.assertEquals(2,matcher.getRightHandSide(),Configuration.fpAccuracy);
  }
View Full Code Here


  @Test
  public final void testCountMatchingOutgoing4a()
  {
    LearnerGraph gr=buildLearnerGraph("A-a-#B\nA-b-#B1\nA-c->C\nQ-a->R\nQ-b->S", "testCountMatchingOutgoing1", configMain,converter);
    GDLearnerGraph ndGraph = new GDLearnerGraph(gr,LearnerGraphND.ignoreRejectStates, false);
    DetermineDiagonalAndRightHandSide matcher = ndGraph.new DDRH_default();
    // 3 outgoing and 2 matching reject, but we count them as positives
    getMatcherValue(gr,ndGraph,ndGraph.matrixForward, matcher,"A","Q");
    Assert.assertEquals(2,matcher.getRightHandSide(),Configuration.fpAccuracy);
  }
View Full Code Here

  {
    Configuration config = configMain.copy();
    LearnerGraph gr=buildLearnerGraph("A-a-#B\nA-b-#B1\nA-c->C\nQ-a->R\nQ-b->S", "testCountMatchingOutgoing1", config,converter);
    gr.linear.moveRejectToHighlight();
    GDLearnerGraph ndGraph = new GDLearnerGraph(gr,LearnerGraphND.ignoreRejectStates, false);
    DetermineDiagonalAndRightHandSide matcher = ndGraph.new DDRH_highlight();
    getMatcherValue(gr,ndGraph,ndGraph.matrixForward, matcher,"A","Q");
    Assert.assertEquals(0,matcher.getRightHandSide(),Configuration.fpAccuracy);
  }
View Full Code Here

  @Test
  public final void testCountMatchingOutgoing5a()
  {
    LearnerGraph gr=buildLearnerGraph("A-a-#B\nA-b-#B1\nA-c->C\nQ-a->R\nQ-b->S", "testCountMatchingOutgoing1", configMain,converter);
    GDLearnerGraph ndGraph = new GDLearnerGraph(gr,LearnerGraphND.ignoreRejectStates, false);
    DetermineDiagonalAndRightHandSide matcher = ndGraph.new DDRH_default();
    getMatcherValue(gr,ndGraph,ndGraph.matrixForward, matcher,"A","C");
    Assert.assertEquals(0,matcher.getRightHandSide(),Configuration.fpAccuracy);
    getMatcherValue(gr,ndGraph,ndGraph.matrixForward, matcher,"S","C");
    Assert.assertEquals(0,matcher.getRightHandSide(),Configuration.fpAccuracy);
  }
View Full Code Here

  {
    Configuration config = configMain.copy();
    LearnerGraph gr=buildLearnerGraph("A-a-#B\nA-b-#B1\nA-c->C\nQ-a->R\nQ-b->S", "testCountMatchingOutgoing1", config,converter);
    gr.linear.moveRejectToHighlight();
    GDLearnerGraph ndGraph = new GDLearnerGraph(gr,LearnerGraphND.ignoreRejectStates, false);
    DetermineDiagonalAndRightHandSide matcher = ndGraph.new DDRH_highlight();
    getMatcherValue(gr,ndGraph,ndGraph.matrixForward, matcher,"A","C");
    Assert.assertEquals(0,matcher.getRightHandSide(),Configuration.fpAccuracy);
    getMatcherValue(gr,ndGraph,ndGraph.matrixForward, matcher,"S","C");
    Assert.assertEquals(0,matcher.getRightHandSide(),Configuration.fpAccuracy);
  }
View Full Code Here

  @Test
  public final void testCountMatchingOutgoing6a()
  {
    LearnerGraph gr=buildLearnerGraph("A-a-#B\nA-b-#B1\nQ-a->R", "testCountMatchingOutgoing1", configMain,converter);
    GDLearnerGraph ndGraph = new GDLearnerGraph(gr,LearnerGraphND.ignoreRejectStates, false);
    DetermineDiagonalAndRightHandSide matcher = ndGraph.new DDRH_default();
    getMatcherValue(gr,ndGraph,ndGraph.matrixForward, matcher,"A","R");
    Assert.assertEquals(0,matcher.getRightHandSide(),Configuration.fpAccuracy);
  }
View Full Code Here

  public final void testCountMatchingOutgoing6b()
  {
    LearnerGraph gr=buildLearnerGraph("A-a-#B\nA-b-#B1\nQ-a->R", "testCountMatchingOutgoing1", configMain,converter);
    gr.linear.moveRejectToHighlight();
    GDLearnerGraph ndGraph = new GDLearnerGraph(gr,LearnerGraphND.ignoreRejectStates, false);
    DetermineDiagonalAndRightHandSide matcher = ndGraph.new DDRH_highlight();
    getMatcherValue(gr,ndGraph,ndGraph.matrixForward, matcher,"A","R");
    Assert.assertEquals(0,matcher.getRightHandSide(),Configuration.fpAccuracy);
  }
View Full Code Here

  @Test
  public final void testCountMatchingOutgoing_nd1()
  {
    LearnerGraph gr=buildLearnerGraph("A1-a->C\nA2-a->C\nA3-a->C<-b-G\nB1-a->D<-a-B2\nE-b->D<-b-F", "testCountMatchingOutgoing_nd1", 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(8*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

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.