Package statechum

Examples of statechum.Configuration


    /** Maps states to a function associating labels to a sum of probabilities from a Markov matrix. Such a sum is supposed to predict the likelyhood of a transition with this label from every state. */
    Map<CmpVertex,Map<Label,UpdatablePairInteger>> state_outgoing_occurence=new HashMap<CmpVertex,Map<Label,UpdatablePairInteger>>();
    /** Maps states to a function associating labels to a probability of a transition with the label of interest from a state of interest. Computed from {@link MarkovUniversalLearner#state_outgoing_occurence}. */
    Map<CmpVertex,Map<Label,UpdatablePairDouble>> state_outgoing=new HashMap<CmpVertex,Map<Label,UpdatablePairDouble>>();

    final Configuration shallowCopy = graph.config.copy();shallowCopy.setLearnerCloneGraph(false);
    LearnerGraph outcome = new LearnerGraph(shallowCopy);
    LearnerGraph.copyGraphs(graph, outcome);
    final Set<Label> allElementsOfAlphabet = graph.learnerCache.getAlphabet();
    // mapping map to store all paths leave each state in different length
      for(CmpVertex vert:graph.transitionMatrix.keySet())
View Full Code Here


      throw new IllegalArgumentException("predictions are only supported in the forward direction, not inverse");

    /** Maps states to a function associating labels to a probability of a transition with the label of interest from a state of interest. Computed from {@link MarkovUniversalLearner#state_outgoing_occurence}. */
    Map<CmpVertex,Map<Label,MarkovOutcome>> state_outgoing=predictTransitions();

    final Configuration shallowCopy = graph.config.copy();shallowCopy.setLearnerCloneGraph(false);
    LearnerGraph graphWithPredictedTransitions = new LearnerGraph(shallowCopy);
    LearnerGraph.copyGraphs(graph, graphWithPredictedTransitions);

    // in this part the tree is extended depend on their outgoing transition probabilities
     for(Entry<CmpVertex, Map<Label, MarkovOutcome>> outgoing:state_outgoing.entrySet())
View Full Code Here

  }

  @Test
  public void testConfigurationEquals()
  {
    Configuration confA = new Configuration(), confB = new Configuration(),
      confC = new Configuration(), confD = new Configuration();
    confA.setBumpPositives(true);confA.setLearnerIdMode(Configuration.IDMode.NONE);confA.setDefaultInitialPTAName("test");
    confB.setBumpPositives(true);confB.setLearnerIdMode(Configuration.IDMode.NONE);confB.setDefaultInitialPTAName("test");
    confC.setBumpPositives(true);confC.setLearnerIdMode(Configuration.IDMode.NONE);confC.setDefaultInitialPTAName("a");
    confD.setLearnerIdMode(Configuration.IDMode.POSITIVE_NEGATIVE);
    equalityTestingHelper(confA, confB, confC, confD);
    confC.setDefaultInitialPTAName("test");confA.setDefaultInitialPTAName("b");
    equalityTestingHelper(confC, confB, confA, confD);
  }
View Full Code Here

  }
 
  @Test
  public void testConfigurationClone()
  {
    Configuration confA = new Configuration(),
    confC = new Configuration(), confD = new Configuration();
    confA.setBumpPositives(true);confA.setLearnerIdMode(Configuration.IDMode.NONE);confA.setDefaultInitialPTAName("test");
    confC.setBumpPositives(true);confC.setLearnerIdMode(Configuration.IDMode.NONE);confC.setDefaultInitialPTAName("a");
    Configuration confClone = (Configuration)confA.clone();
    equalityTestingHelper(confA, confClone, confC, confD);
   
    confClone.setDefaultInitialPTAName("avalue");// mess up the clone
    equalityTestingHelper(confA, confA, confClone, confD);
    equalityTestingHelper(confA.clone(), confA, confClone, confD);
   
    confA.setDefaultInitialPTAName("avalue");// mess up the original the same way as the clone was messed up
    equalityTestingHelper(confA, confClone, confC, confD);
View Full Code Here

   
    try {
      // Now check that hashCode and equals are affected by values of different fields.
      for(MethodAndArgs currentMethod:MethodsArgs)
      {
        Configuration
          configA = Configuration.getDefaultConfiguration().copy(),
          configB = Configuration.getDefaultConfiguration().copy();
        for(MethodAndArgs orig:MethodsArgs)
        {
          orig.method.invoke(configA, new Object[]{orig.Arg});
          orig.method.invoke(configB, new Object[]{orig.Arg});
        }
        Assert.assertEquals(configB, configA);
       
        // now test that we can serialise these
        {
          org.w3c.dom.Element xmlB = configB.writeXML(doc),xmlA=configA.writeXML(doc);
          Configuration loadedB=new Configuration();loadedB.readXML(xmlB);Configuration loadedA=new Configuration();loadedA.readXML(xmlA);
          Assert.assertEquals(loadedB, loadedA);
          Assert.assertEquals(loadedB, configA);
        }

        currentMethod.method.invoke(configB, new Object[]{currentMethod.AlternativeArg});
        String errMsg = "configurations differ: field "+currentMethod.field+" is not in use for ";
        Assert.assertFalse(errMsg+"equals",configB.equals(configA));
        Assert.assertFalse(errMsg+"equals",configA.equals(configB));
       
        {
          org.w3c.dom.Element xmlB = configB.writeXML(doc),xmlA=configA.writeXML(doc);
          Configuration loadedB=new Configuration();loadedB.readXML(xmlB);Configuration loadedA=new Configuration();loadedA.readXML(xmlA);
          Assert.assertEquals(loadedA, configA);
          Assert.assertFalse(errMsg+"equals",loadedB.equals(loadedA));
          Assert.assertFalse(errMsg+"equals",loadedB.equals(configA));
          Assert.assertFalse(errMsg+"equals",loadedA.equals(loadedB));
        }
       
        Assert.assertTrue(errMsg+"hashCode",configA.hashCode() != configB.hashCode());
      }
    } catch (Exception e) {
View Full Code Here

          assert pta.getStateNumber() == pta.getAcceptStateNumber() : "graph with negatives but onlyUsePositives is set";
       
        LearnerMarkovPassive learnerOfPairs = null;
        LearnerGraph actualAutomaton = null;
       
        final Configuration deepCopy = pta.config.copy();deepCopy.setLearnerCloneGraph(true);
        LearnerGraph ptaCopy = new LearnerGraph(deepCopy);LearnerGraph.copyGraphs(pta, ptaCopy);

        // now use pathsToMerge to compute which states can/cannot be merged together.
        LearnerGraph trimmedReference = trimUncoveredTransitions(pta,referenceGraph);
        final ConsistencyChecker checker = new MarkovClassifier.DifferentPredictionsInconsistencyNoBlacklisting();
View Full Code Here

  /** Wrong tag. */
  @Test(expected=IllegalArgumentException.class)
  public void testSerialisationFailure1()
  {
    new Configuration().readXML(doc.createElement("test"));
  }
View Full Code Here

 
  /** No data to load. */
  @Test
  public void testSerialisationEmpty()
  {
    Configuration cnf = new Configuration();cnf.readXML(doc.createElement(Configuration.configXMLTag));
    Assert.assertEquals(new Configuration(), cnf);
  }
View Full Code Here

 
  /** Old data should not affect us. */
  @Test
  public void testSerialisationOldJunk_normal()
  {
    org.w3c.dom.Element elem = new Configuration().writeXML(doc), oldData = doc.createElement(Configuration.configVarTag);
    oldData.setAttribute(Configuration.configVarAttrName, "old_junk");
    oldData.setAttribute(Configuration.configVarAttrValue, "junk");
   
    elem.appendChild(oldData);
    Configuration cnf = new Configuration();cnf.readXML(elem);
    Assert.assertEquals(new Configuration(), cnf);
  }
View Full Code Here

 
  /** Old data causes an exception to be thrown. */
  @Test
  public void testSerialisationOldJunk_strict()
  {
    final org.w3c.dom.Element elem = new Configuration().writeXML(doc), oldData = doc.createElement(Configuration.configVarTag);
    oldData.setAttribute(Configuration.configVarAttrName, "old_junk");
    oldData.setAttribute(Configuration.configVarAttrValue, "junk");
   
    elem.appendChild(oldData);
    statechum.Helper.checkForCorrectException(new whatToRun() { public void run() {
      new Configuration().readXML(elem,true);
    }}, IllegalArgumentException.class,"cannot deserialise unknown field");
  }
View Full Code Here

TOP

Related Classes of statechum.Configuration

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.