Package statechum.analysis.learning

Examples of statechum.analysis.learning.MarkovUniversalLearner$MarkovOutcome


  /** This one is similar to the {@link #testUpdateMarkovSideways1b}, except that there are a few additional negative transitions and the computation is forward. */
  @Test
  public void testUpdateMarkovSideways1d()
  {
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B-a->C / B-b->C-a-#D / B-c-#D","testUpdateMarkovSideways1c",config, converter);
    MarkovUniversalLearner m = new MarkovUniversalLearner(2);
    m.updateMarkov(graph,true,false);
    Assert.assertTrue(m.getMarkov(false).isEmpty());Assert.assertEquals(7,m.getMarkov(true).size());
    Assert.assertEquals(MarkovOutcome.failure,m.getMarkov(true).get(new Trace(Arrays.asList(new Label[]{lblA,lblA}),true)));
    Assert.assertEquals(MarkovOutcome.positive,m.getMarkov(true).get(new Trace(Arrays.asList(new Label[]{lblA,lblB}),true)));
    Assert.assertEquals(MarkovOutcome.negative,m.getMarkov(true).get(new Trace(Arrays.asList(new Label[]{lblA,lblC}),true)));
    Assert.assertEquals(MarkovOutcome.negative,m.getMarkov(true).get(new Trace(Arrays.asList(new Label[]{lblB,lblA}),true)));

    Assert.assertEquals(MarkovOutcome.failure,m.getMarkov(true).get(new Trace(Arrays.asList(new Label[]{lblA}),true)));
    Assert.assertEquals(MarkovOutcome.positive,m.getMarkov(true).get(new Trace(Arrays.asList(new Label[]{lblB}),true)));
    Assert.assertEquals(MarkovOutcome.negative,m.getMarkov(true).get(new Trace(Arrays.asList(new Label[]{lblC}),true)));
   
    Set<List<Label>> plusStrings = buildSet(new String[][] {},config,converter), minusStrings = buildSet(new String[][] { new String[]{"a","a","a"},new String[]{"a","b","a"},new String[]{"a","c"} },config,converter);
    MarkovUniversalLearner another = new MarkovUniversalLearner(2);
    another.createMarkovLearner(plusStrings, minusStrings, false);

    Assert.assertTrue(another.getMarkov(false).isEmpty());Assert.assertEquals(7,another.getMarkov(true).size());
    Assert.assertEquals(MarkovOutcome.failure,another.getMarkov(true).get(new Trace(Arrays.asList(new Label[]{lblA,lblA}),true)));
    Assert.assertEquals(MarkovOutcome.positive,another.getMarkov(true).get(new Trace(Arrays.asList(new Label[]{lblA,lblB}),true)));
    Assert.assertEquals(MarkovOutcome.negative,another.getMarkov(true).get(new Trace(Arrays.asList(new Label[]{lblA,lblC}),true)));
    Assert.assertEquals(MarkovOutcome.negative,another.getMarkov(true).get(new Trace(Arrays.asList(new Label[]{lblB,lblA}),true)));

    Assert.assertEquals(MarkovOutcome.failure,another.getMarkov(true).get(new Trace(Arrays.asList(new Label[]{lblA}),true)));
    Assert.assertEquals(MarkovOutcome.positive,another.getMarkov(true).get(new Trace(Arrays.asList(new Label[]{lblB}),true)));
    Assert.assertEquals(MarkovOutcome.negative,another.getMarkov(true).get(new Trace(Arrays.asList(new Label[]{lblC}),true)));
  }
View Full Code Here


  @Test
  public void testUpdateMarkovSideways2()
  {
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B-c->C / B-b-#D","testUpdateMarkovSideways2",config, converter);
    MarkovUniversalLearner m = new MarkovUniversalLearner(2);
    m.updateMarkov(graph,false,true);
    Assert.assertTrue(m.getMarkov(true).isEmpty());
    Assert.assertEquals(3,m.getMarkov(false).size());
    Assert.assertEquals(MarkovOutcome.positive,m.getMarkov(false).get(new Trace(Arrays.asList(new Label[]{lblA,lblA}),true)));
    Assert.assertEquals(MarkovOutcome.negative,m.getMarkov(false).get(new Trace(Arrays.asList(new Label[]{lblC,lblB}),true)));
    Assert.assertEquals(MarkovOutcome.positive,m.getMarkov(false).get(new Trace(Arrays.asList(new Label[]{lblC,lblC}),true)));
  }
View Full Code Here

 
  @Test
  public void testUpdateMarkovSideways3()
  {
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B-b->C / B-u-#D / A-c->E-u->F / E-c->G","testUpdateMarkovSideways3",config, converter);
    MarkovUniversalLearner m = new MarkovUniversalLearner(2);
    m.updateMarkov(graph,false,true);
    Assert.assertTrue(m.getMarkov(true).isEmpty());
    Assert.assertEquals(9,m.getMarkov(false).size());
    Assert.assertEquals(MarkovOutcome.positive,m.getMarkov(false).get(new Trace(Arrays.asList(new Label[]{lblA,lblA}),true)));
    Assert.assertEquals(MarkovOutcome.positive,m.getMarkov(false).get(new Trace(Arrays.asList(new Label[]{lblA,lblC}),true)));
    Assert.assertEquals(MarkovOutcome.positive,m.getMarkov(false).get(new Trace(Arrays.asList(new Label[]{lblC,lblA}),true)));
   
    Assert.assertEquals(MarkovOutcome.negative,m.getMarkov(false).get(new Trace(Arrays.asList(new Label[]{lblB,lblU}),true)));
    Assert.assertEquals(MarkovOutcome.positive,m.getMarkov(false).get(new Trace(Arrays.asList(new Label[]{lblB,lblB}),true)));
   
    Assert.assertEquals(MarkovOutcome.positive,m.getMarkov(false).get(new Trace(Arrays.asList(new Label[]{lblC,lblC}),true)));
    Assert.assertEquals(MarkovOutcome.positive,m.getMarkov(false).get(new Trace(Arrays.asList(new Label[]{lblU,lblU}),true)));
    Assert.assertEquals(MarkovOutcome.positive,m.getMarkov(false).get(new Trace(Arrays.asList(new Label[]{lblC,lblU}),true)));
    Assert.assertEquals(MarkovOutcome.positive,m.getMarkov(false).get(new Trace(Arrays.asList(new Label[]{lblU,lblC}),true)));
  }
View Full Code Here

 
  @Test
  public void testUpdateMarkovSideways4()
  {
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B-b->C / B-u-#D / A-c->E-u->F / E-c->G","testUpdateMarkovSideways3",config, converter);
    MarkovUniversalLearner m = new MarkovUniversalLearner(3);
    m.updateMarkov(graph,false,true);
    Assert.assertTrue(m.getMarkov(true).isEmpty());
    Assert.assertEquals(6,m.getMarkov(false).size());
    Assert.assertEquals(MarkovOutcome.positive,m.getMarkov(false).get(new Trace(Arrays.asList(new Label[]{lblA,lblB,lblC}),true)));
    Assert.assertEquals(MarkovOutcome.positive,m.getMarkov(false).get(new Trace(Arrays.asList(new Label[]{lblA,lblB,lblA}),true)));
   
    Assert.assertEquals(MarkovOutcome.positive,m.getMarkov(false).get(new Trace(Arrays.asList(new Label[]{lblC,lblU,lblC}),true)));
    Assert.assertEquals(MarkovOutcome.positive,m.getMarkov(false).get(new Trace(Arrays.asList(new Label[]{lblC,lblU,lblA}),true)));
   
    Assert.assertEquals(MarkovOutcome.positive,m.getMarkov(false).get(new Trace(Arrays.asList(new Label[]{lblC,lblC,lblC}),true)));
    Assert.assertEquals(MarkovOutcome.positive,m.getMarkov(false).get(new Trace(Arrays.asList(new Label[]{lblC,lblC,lblA}),true)));
  }
View Full Code Here

  @Test
  public void testCheckFanoutInconsistencySideways1()
  {
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B-b->C / B-u-#D / A-c->E-u->F / E-c->G","testUpdateMarkovSideways3",config, converter);
    MarkovUniversalLearner m = new MarkovUniversalLearner(2);
    m.updateMarkov(graph,false,true);
    Assert.assertTrue(m.getMarkov(true).isEmpty());
    Assert.assertEquals(9,m.getMarkov(false).size());
   
    final LearnerGraph graph2 = FsmParser.buildLearnerGraph("A-s->B","testCheckFanoutInconsistencySideways1",config, converter);
    final AtomicInteger counterA=new AtomicInteger(0),counterB=new AtomicInteger(0);
    Assert.assertEquals(0,m.checkFanoutInconsistency(graph2,false,graph2,graph2.getInit(),m.getChunkLen(), new MarkovUniversalLearner.ConsistencyChecker(){

      @Override
      public boolean consistent(MarkovOutcome actual,MarkovOutcome predicted) {
        Assert.assertEquals(MarkovOutcome.positive,actual);Assert.assertNull(predicted);
        counterA.addAndGet(1);
View Full Code Here

 
  @Test
  public void testCheckFanoutInconsistencySideways2()
  {
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B-b->C / B-u-#D / A-c->E-u->F / E-c->G","testUpdateMarkovSideways3",config, converter);
    MarkovUniversalLearner m = new MarkovUniversalLearner(2);
    m.updateMarkov(graph,false,true);
    Assert.assertTrue(m.getMarkov(true).isEmpty());
    Assert.assertEquals(9,m.getMarkov(false).size());
   
    final LearnerGraph graph2 = FsmParser.buildLearnerGraph("A-a->B-a->B-b->B","testCheckFanoutInconsistencySideways2",config, converter);
    graph2.transitionMatrix.get(graph2.getInit()).clear();// make it look like a graph has no transitions
    Assert.assertEquals(0,m.checkFanoutInconsistency(graph2,false,graph2,graph2.getInit(),m.getChunkLen(), new MarkovUniversalLearner.ConsistencyChecker(){

      @SuppressWarnings("unused")
      @Override
      public boolean consistent(MarkovOutcome actual,MarkovOutcome predicted) {
        Assert.fail("should not be called");
View Full Code Here

 
  @Test
  public void testCheckFanoutInconsistencySideways3()
  {
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B-b->C / B-u-#D / A-c->E-u->F / E-c->G","testUpdateMarkovSideways3",config, converter);
    MarkovUniversalLearner m = new MarkovUniversalLearner(2);
    m.updateMarkov(graph,false,true);
    Assert.assertTrue(m.getMarkov(true).isEmpty());
    Assert.assertEquals(9,m.getMarkov(false).size());
   
    final LearnerGraph graph2 = FsmParser.buildLearnerGraph("A-a->B","testCheckFanoutInconsistencySideways3",config, converter);
    final AtomicInteger counterA=new AtomicInteger(0),counterB=new AtomicInteger(0);
    Assert.assertEquals(0,m.checkFanoutInconsistency(graph2,false,graph2,graph2.getInit(),m.getChunkLen(), new MarkovUniversalLearner.ConsistencyChecker(){

      @SuppressWarnings("unused")
      @Override
      public boolean consistent(MarkovOutcome actual,MarkovOutcome predicted) {
        counterA.addAndGet(1);
View Full Code Here

  /** Similar to 3 but with multiple outgoing paths. */
  @Test
  public void testCheckFanoutInconsistencySideways4()
  {
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B-b->C / B-u-#D / A-c->E-u->F / E-c->G","testUpdateMarkovSideways3",config, converter);
    MarkovUniversalLearner m = new MarkovUniversalLearner(2);
    m.updateMarkov(graph,false,true);
    Assert.assertTrue(m.getMarkov(true).isEmpty());
    Assert.assertEquals(9,m.getMarkov(false).size());
   
    final LearnerGraph graph2 = FsmParser.buildLearnerGraph("A-a->B / A-c->A","testCheckFanoutInconsistencySideways4",config, converter);
    final AtomicInteger counterA=new AtomicInteger(0),counterB=new AtomicInteger(0);
    Assert.assertEquals(0,m.checkFanoutInconsistency(graph2,false,graph2,graph2.getInit(),m.getChunkLen(), new MarkovUniversalLearner.ConsistencyChecker(){

      @SuppressWarnings("unused")
      @Override
      public boolean consistent(MarkovOutcome actual,MarkovOutcome predicted) {
        counterA.addAndGet(1);
View Full Code Here

  /** Tests that with only one path, we do a single check anyway, hence returning false from obtainAlphabet does not change anything. */
  @Test
  public void testCheckFanoutInconsistencySideways5()
  {
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B-b->C / B-u-#D / A-c->E-u->F / E-c->G","testUpdateMarkovSideways3",config, converter);
    MarkovUniversalLearner m = new MarkovUniversalLearner(2);
    m.updateMarkov(graph,false,true);
    Assert.assertTrue(m.getMarkov(true).isEmpty());
    Assert.assertEquals(9,m.getMarkov(false).size());
   
    final LearnerGraph graph2 = FsmParser.buildLearnerGraph("A-a->B","testCheckFanoutInconsistencySideways3",config, converter);
    final AtomicInteger counterA=new AtomicInteger(0),counterB=new AtomicInteger(0);
    Assert.assertEquals(0,m.checkFanoutInconsistency(graph2,false,graph2,graph2.getInit(),m.getChunkLen(), new MarkovUniversalLearner.ConsistencyChecker(){

      @SuppressWarnings("unused")
      @Override
      public boolean consistent(MarkovOutcome actual,MarkovOutcome predicted) {
        counterA.addAndGet(1);
View Full Code Here

  /** Tests that upon a label labelled as invalid, subsequent inconsistency checks are stopped. It is hence equivalent to a single incoming path. */
  @Test
  public void testCheckFanoutInconsistencySideways6()
  {
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B-b->C / B-u-#D / A-c->E-u->F / E-c->G","testUpdateMarkovSideways3",config, converter);
    MarkovUniversalLearner m = new MarkovUniversalLearner(2);
    m.updateMarkov(graph,false,true);
    Assert.assertTrue(m.getMarkov(true).isEmpty());
    Assert.assertEquals(9,m.getMarkov(false).size());
   
    final LearnerGraph graph2 = FsmParser.buildLearnerGraph("A-a->B / A-c->A","testCheckFanoutInconsistencySideways4",config, converter);
    final AtomicInteger counterA=new AtomicInteger(0),counterB=new AtomicInteger(0);
    Assert.assertEquals(0,m.checkFanoutInconsistency(graph2,false,graph2,graph2.getInit(),m.getChunkLen(), new MarkovUniversalLearner.ConsistencyChecker(){

      @SuppressWarnings("unused")
      @Override
      public boolean consistent(MarkovOutcome actual,MarkovOutcome predicted) {
        counterA.addAndGet(1);
View Full Code Here

TOP

Related Classes of statechum.analysis.learning.MarkovUniversalLearner$MarkovOutcome

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.