Package statechum.analysis.learning

Examples of statechum.analysis.learning.MarkovUniversalLearner$MarkovOutcome


 
  /** Nothing to add because there not enough evidence. */
  @Test
  public void testConstructExtendedGraph1()
  {
    MarkovUniversalLearner m = new MarkovUniversalLearner(2);
    Set<List<Label>> plusStrings = buildSet(new String[][] { new String[]{"a","p"} },config,converter), minusStrings = buildSet(new String[][] { new String[]{"a","u"} },config,converter);
    m.createMarkovLearner(plusStrings, minusStrings,false);
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-u->B-p->B","testConstructExtendedGraph1",config, converter);
    Map<CmpVertex, Map<Label, MarkovOutcome>> newTransitions = m.constructMarkovTentative(graph,true);
    Assert.assertTrue(newTransitions.isEmpty());// not enough evidence to update, hence nothing should be recorded.
    final LearnerGraph expected = FsmParser.buildLearnerGraph("A-u->B-p->B","testConstructExtendedGraph1",config, converter);
    DifferentFSMException ex = WMethod.checkM(expected, m.get_extension_model());
    if (ex != null)
      throw ex;
    Assert.assertNotSame(graph, m.get_extension_model());
  }
View Full Code Here


 
  /** Nothing to add because the alphabet of the graph of interest consists of a single letter for which there is no statistical data. */
  @Test
  public void testConstructExtendedGraph2()
  {
    MarkovUniversalLearner m = new MarkovUniversalLearner(2);
    Set<List<Label>> plusStrings = buildSet(new String[][] { new String[]{"a","p"} },config,converter), minusStrings = buildSet(new String[][] { new String[]{"a","u"} },config,converter);
    m.createMarkovLearner(plusStrings, minusStrings,false);
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B","testConstructExtendedGraph2",config, converter);
    Map<CmpVertex, Map<Label, MarkovOutcome>> newTransitions = m.constructMarkovTentative(graph,true);
    Assert.assertTrue(newTransitions.isEmpty());// not enough evidence to update, hence nothing should be recorded.
    final LearnerGraph expected = FsmParser.buildLearnerGraph("A-a->B","testConstructExtendedGraph2",config, converter);
    DifferentFSMException ex = WMethod.checkM(expected, m.get_extension_model());
    if (ex != null)
      throw ex;
    Assert.assertNotSame(graph, m.get_extension_model());
  }
View Full Code Here

 
  /** A bit has been added. */
  @Test
  public void testConstructExtendedGraph3()
  {
    MarkovUniversalLearner m = new MarkovUniversalLearner(2);
    Set<List<Label>> plusStrings = buildSet(new String[][] { new String[]{"a","b"} },config,converter), minusStrings = buildSet(new String[][] { new String[]{"a","u"} },config,converter);
    m.createMarkovLearner(plusStrings, minusStrings,false);
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B / T-b->T-u->T","testConstructExtendedGraph3a",config, converter);
    Map<CmpVertex, Map<Label, MarkovOutcome>> newTransitions = m.constructMarkovTentative(graph,true);
    Assert.assertEquals(1,newTransitions.size());// not enough evidence to update, hence nothing should be recorded.

    Assert.assertSame(MarkovOutcome.negative, newTransitions.get(graph.findVertex("B")).get(lblU));
   
    Assert.assertSame(MarkovOutcome.positive, newTransitions.get(graph.findVertex("B")).get(lblB));

    final LearnerGraph expected = FsmParser.buildLearnerGraph("A-a->B-b->C / B-u-#D / T-b->T-u->T","testConstructExtendedGraph3b",config, converter);
    DifferentFSMException ex = WMethod.checkM(expected, m.get_extension_model());
    if (ex != null)
      throw ex;
    Assert.assertNotSame(graph, m.get_extension_model());
  }
View Full Code Here

 
  /** A bit has been added, but reject-transition was not because is present both in the positive and negative light in the initial traces. */
  @Test
  public void testConstructExtendedGraph4()
  {
    MarkovUniversalLearner m = new MarkovUniversalLearner(2);
    Set<List<Label>> plusStrings = buildSet(new String[][] { new String[]{"a","b"},new String[]{"a","u"} },config,converter), minusStrings = buildSet(new String[][] { new String[]{"a","u"} },config,converter);
    m.createMarkovLearner(plusStrings, minusStrings,false);
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B / T-b->T-u->T","testConstructExtendedGraph3a",config, converter);
    Map<CmpVertex, Map<Label, MarkovOutcome>> newTransitions = m.constructMarkovTentative(graph,true);
    Assert.assertEquals(1,newTransitions.size());// not enough evidence to update, hence nothing should be recorded.

    Assert.assertFalse(newTransitions.get(graph.findVertex("B")).containsKey(lblU));// failure ignored
   
    Assert.assertSame(MarkovOutcome.positive, newTransitions.get(graph.findVertex("B")).get(lblB));

    final LearnerGraph expected = FsmParser.buildLearnerGraph("A-a->B-b->C / T-b->T-u->T","testConstructExtendedGraph4b",config, converter);
    DifferentFSMException ex = WMethod.checkM(expected, m.get_extension_model());
    if (ex != null)
      throw ex;
    Assert.assertNotSame(graph, m.get_extension_model());
  }
View Full Code Here

 
  /** A bit has been added, but reject-transition was not because is present both in the positive and negative light in the initial traces. */
  @Test
  public void testConstructExtendedGraph5()
  {
    MarkovUniversalLearner m = new MarkovUniversalLearner(2);// w below is to ensure that all elements of the alphabet are included in traces.
    Set<List<Label>> plusStrings = buildSet(new String[][] { new String[]{"a","b"},new String[]{"c","u"},new String[]{"w"} },config,converter), minusStrings = buildSet(new String[][] { new String[]{"a","u"} },config,converter);
    m.createMarkovLearner(plusStrings, minusStrings,false);
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B / A-w->M-c->B / T-b->T-u->T","testConstructExtendedGraph5a",config, converter);// the purpose of the w-transition is to ensure transition c is taken into account in graph comparison
    Map<CmpVertex, Map<Label, MarkovOutcome>> newTransitions = m.constructMarkovTentative(graph,true);
    Assert.assertEquals(1,newTransitions.size());

    Assert.assertEquals(1,newTransitions.get(graph.findVertex("B")).size());
   
    Assert.assertSame(MarkovOutcome.positive,newTransitions.get(graph.findVertex("B")).get(lblB));

    final LearnerGraph expected = FsmParser.buildLearnerGraph("A-a->B-b->C / A-w->M-c->B / T-b->T-u->T","testConstructExtendedGraph5b",config, converter);
    DifferentFSMException ex = WMethod.checkM(expected, m.get_extension_model());
    if (ex != null)
      throw ex;
    Assert.assertNotSame(graph, m.get_extension_model());
  }
View Full Code Here

 
  /** Nothing has been added. u has been seen both in the positive and negative light and lead to inconsistency. */
  @Test
  public void testConstructExtendedGraph6()
  {
    MarkovUniversalLearner m = new MarkovUniversalLearner(2);
    Set<List<Label>> plusStrings = buildSet(new String[][] { new String[]{"a","b"},new String[]{"c","u"} },config,converter), minusStrings = buildSet(new String[][] { new String[]{"a","u"} },config,converter);
    m.createMarkovLearner(plusStrings, minusStrings,false);
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B / A-c->B / T-b->T-u->T","testConstructExtendedGraph6a",config, converter);
    Map<CmpVertex, Map<Label, MarkovOutcome>> newTransitions = m.constructMarkovTentative(graph,true);
   
    Assert.assertEquals(1,newTransitions.size());

    Assert.assertEquals(1,newTransitions.get(graph.findVertex("B")).size());
   
    Assert.assertSame(MarkovOutcome.positive, newTransitions.get(graph.findVertex("B")).get(lblB));

    final LearnerGraph expected = FsmParser.buildLearnerGraph("A-a->B / A-c->B / B-b->C / T-b->T-u->T","testConstructExtendedGraph6b",config, converter);
    DifferentFSMException ex = WMethod.checkM(expected, m.get_extension_model());
    if (ex != null)
      throw ex;
    Assert.assertNotSame(graph, m.get_extension_model());
  }
View Full Code Here

 
  /** A bit has been added. u has been seen both in the positive and negative light. */
  @Test
  public void testConstructExtendedGraph7()
  {
    MarkovUniversalLearner m = new MarkovUniversalLearner(2);
    Set<List<Label>> plusStrings = buildSet(new String[][] { new String[]{"a","b"},new String[]{"c","u"} },config,converter), minusStrings = buildSet(new String[][] { new String[]{"a","u"} },config,converter);
    m.createMarkovLearner(plusStrings, minusStrings,false);
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B / A-c->B-c->Z / T-b->T-u->T","testConstructExtendedGraph7a",config, converter);
    Map<CmpVertex, Map<Label, MarkovOutcome>> newTransitions = m.constructMarkovTentative(graph,true);
   
    Assert.assertEquals(2,newTransitions.size());

    Assert.assertEquals(1,newTransitions.get(graph.findVertex("B")).size());
    Assert.assertEquals(1,newTransitions.get(graph.findVertex("Z")).size());
   
    Assert.assertSame(MarkovOutcome.positive, newTransitions.get(graph.findVertex("B")).get(lblB));
    Assert.assertSame(MarkovOutcome.positive, newTransitions.get(graph.findVertex("Z")).get(lblU));

    final LearnerGraph expected = FsmParser.buildLearnerGraph("A-a->B / A-c->B-c->Z-u->Y / B-b->C / T-b->T-u->T","testConstructExtendedGraph7b",config, converter);
    DifferentFSMException ex = WMethod.checkM(expected, m.get_extension_model());
    if (ex != null)
      throw ex;
    Assert.assertNotSame(graph, m.get_extension_model());
  }
View Full Code Here

 
  /** No outgoing from B, hence no inconsistencies. */
  @Test
  public void testCheckFanoutInconsistency1a()
  {
    MarkovUniversalLearner m = new MarkovUniversalLearner(2);
    Set<List<Label>> plusStrings = buildSet(new String[][] { new String[]{"a","b"},new String[]{"c","u"} },config,converter), minusStrings = buildSet(new String[][] { new String[]{"a","u"} },config,converter);
    m.createMarkovLearner(plusStrings, minusStrings,false);
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B / A-c->B / T-b->T-u->T","testCheckFanoutInconsistency1a",config, converter);
   
    Configuration shallowCopy = graph.config.copy();shallowCopy.setLearnerCloneGraph(false);
    LearnerGraphND Inverse_Graph = new LearnerGraphND(shallowCopy);
    AbstractPathRoutines.buildInverse(graph,LearnerGraphND.ignoreNone,Inverse_Graph)// do the inverse to the tentative graph
    Assert.assertEquals(0,m.checkFanoutInconsistency(Inverse_Graph,true,graph,graph.findVertex("B"),m.getChunkLen(), new MarkovUniversalLearner.DifferentPredictionsInconsistency(graph)));
  }
View Full Code Here

 
  /** One from B with inconsistent predictions. */
  @Test
  public void testCheckFanoutInconsistency1b1()
  {
    MarkovUniversalLearner m = new MarkovUniversalLearner(2);
    Set<List<Label>> plusStrings = buildSet(new String[][] { new String[]{"a","b"},new String[]{"c","u"} },config,converter), minusStrings = buildSet(new String[][] { new String[]{"a","u"} },config,converter);
    m.createMarkovLearner(plusStrings, minusStrings,false);
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B / A-c->B / B-u->F / T-b->T-u->T","testCheckFanoutInconsistency1b1",config, converter);
   
    Configuration shallowCopy = graph.config.copy();shallowCopy.setLearnerCloneGraph(false);
    LearnerGraphND Inverse_Graph = new LearnerGraphND(shallowCopy);
    AbstractPathRoutines.buildInverse(graph,LearnerGraphND.ignoreNone,Inverse_Graph)// do the inverse to the tentative graph
    Assert.assertEquals(1,m.checkFanoutInconsistency(Inverse_Graph,true,graph,graph.findVertex("B"),m.getChunkLen(), new MarkovUniversalLearner.DifferentPredictionsInconsistency(graph)));
  }
View Full Code Here

 
  /** One from B where Markov cannot make up its mind. */
  @Test
  public void testCheckFanoutInconsistency1b2()
  {
    MarkovUniversalLearner m = new MarkovUniversalLearner(2);
    Set<List<Label>> plusStrings = buildSet(new String[][] { new String[]{"a","b"},new String[]{"a","u"} },config,converter), minusStrings = buildSet(new String[][] { new String[]{"a","u"} },config,converter);
    m.createMarkovLearner(plusStrings, minusStrings,false);
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B / A-c->B / B-u->F / T-b->T-u->T","testCheckFanoutInconsistency1b2",config, converter);
   
    Configuration shallowCopy = graph.config.copy();shallowCopy.setLearnerCloneGraph(false);
    LearnerGraphND Inverse_Graph = new LearnerGraphND(shallowCopy);
    AbstractPathRoutines.buildInverse(graph,LearnerGraphND.ignoreNone,Inverse_Graph)// do the inverse to the tentative graph
    Assert.assertEquals(1,m.checkFanoutInconsistency(Inverse_Graph,true,graph,graph.findVertex("B"),m.getChunkLen(), new MarkovUniversalLearner.DifferentPredictionsInconsistency(graph)));
  }
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.