Package statechum

Examples of statechum.Configuration


     */
  }
 
  public static void mainA(String[] args)
  {
    Configuration config = Configuration.getDefaultConfiguration();
    LearnerGraph graph = null;
    int ThreadNumber=AbstractExperiment.getCpuNumber();
    long tmStarted = new Date().getTime(),tmFinished = 0;;
    synchronized (LearnerGraph.syncObj)
    {// ensure that the calls to Jung's vertex-creation routines do not occur on different threads.
View Full Code Here


  /** This one is a reference learner. */
  public static class EDSMReferenceLearner extends LearnerThatCanClassifyPairs
  {
    private static LearnerEvaluationConfiguration constructConfiguration(LearnerEvaluationConfiguration evalCnf, int threshold)
    {
      Configuration config = evalCnf.config.copy();config.setRejectPositivePairsWithScoresLessThan(threshold);
      LearnerEvaluationConfiguration copy = new LearnerEvaluationConfiguration(config);
      copy.graph = evalCnf.graph;copy.testSet = evalCnf.testSet;
      copy.setLabelConverter(evalCnf.getLabelConverter());
      copy.ifthenSequences = evalCnf.ifthenSequences;copy.labelDetails=evalCnf.labelDetails;
      return copy;
View Full Code Here

    @SuppressWarnings("rawtypes")
  @Override
    public void update(@SuppressWarnings("unused") final Observable s, Object arg) {
      int graphNumber = graphs.size();// should match the position of the graph in the list of graphs
        if (arg instanceof AbstractLearnerGraph) {
          Configuration cloneConfig = ((AbstractLearnerGraph) arg).config.copy();
          cloneConfig.setLearnerCloneGraph(true);
          LearnerGraphND gr = new LearnerGraphND((AbstractLearnerGraph)arg,cloneConfig);
          gr.config.setLearnerCloneGraph(false);
          graphsOrig.add( gr );
            graphs.add(((AbstractLearnerGraph) arg).pathroutines.getGraph());
            layoutOptions.put(graphNumber,gr.getLayoutOptions());
View Full Code Here

    assert original.transitionMatrix.containsKey(pair.firstElem);
    assert original.transitionMatrix.containsKey(pair.secondElem);
    Map<CmpVertex,List<CmpVertex>> mergedVertices = original.config.getTransitionMatrixImplType() == STATETREE.STATETREE_ARRAY?
        new ArrayMapWithSearch<CmpVertex,List<CmpVertex>>(original.getStateNumber()):
        new HashMapWithSearch<CmpVertex,List<CmpVertex>>(original.getStateNumber());
    Configuration shallowCopy = original.config.copy();shallowCopy.setLearnerCloneGraph(false);
    LearnerGraph result = new LearnerGraph(original,shallowCopy);
    assert result.transitionMatrix.containsKey(pair.firstElem);
    assert result.transitionMatrix.containsKey(pair.secondElem);

    long pairScore = original.pairscores.computePairCompatibilityScore_internal(pair,mergedVertices);
View Full Code Here

    assert cl.graph.transitionMatrix.containsKey(pair.firstElem);
    assert cl.graph.transitionMatrix.containsKey(pair.secondElem);
    Map<CmpVertex,List<CmpVertex>> mergedVertices = cl.graph.config.getTransitionMatrixImplType() == STATETREE.STATETREE_ARRAY?
        new ArrayMapWithSearch<CmpVertex,List<CmpVertex>>(cl.graph.getStateNumber()):
        new HashMapWithSearch<CmpVertex,List<CmpVertex>>(cl.graph.getStateNumber());
    Configuration shallowCopy = cl.graph.config.copy();shallowCopy.setLearnerCloneGraph(false);
    LearnerGraph result = new LearnerGraph(cl.graph,shallowCopy);
    assert result.transitionMatrix.containsKey(pair.firstElem);
    assert result.transitionMatrix.containsKey(pair.secondElem);

    long pairScore = cl.graph.pairscores.computePairCompatibilityScore_internal(pair,mergedVertices);
View Full Code Here

   */
  public static List<Boolean> mapPathToConfirmedElements(LearnerGraph hardFacts, List<Label> path, LearnerGraph [] ifthenAutomata)
  {
    List<Boolean> result = new ArrayList<Boolean>(path.size());
   
    final Configuration shallowCopy = hardFacts.config.copy();shallowCopy.setLearnerCloneGraph(false);
   
    for(int length=0;length < path.size();++length)
    {
      List<Label> prefix = path.subList(0, length+1);
      CmpVertex pathVertex = hardFacts.getVertex(prefix);
View Full Code Here

  public static <TARGET_A_TYPE,CACHE_A_TYPE extends CachedData<TARGET_A_TYPE, CACHE_A_TYPE>>
    void convertPairAssociationsToTransitions(DirectedSparseGraph whereTo,AbstractLearnerGraph<TARGET_A_TYPE, CACHE_A_TYPE> graph,Configuration config, ConvertALabel converter)
  {
    Set<Label> alphabet = graph.pathroutines.computeAlphabet();
   
    Configuration noClone = config.copy();noClone.setLearnerCloneGraph(false);
    LearnerGraphND result = new LearnerGraphND(graph,config);
    Set<CmpVertex> rowsProcessed = new HashSet<CmpVertex>();
   
    class TransitionAnnotationClass extends EdgeAnnotation
    {
View Full Code Here

  }

  @Test
  public void testAugmentPTA_Simple() // only two traces, both accept
  {
    Configuration config = mainConfiguration.copy();config.setLearnerIdMode(Configuration.IDMode.POSITIVE_NEGATIVE);
    Set<List<Label>> plusStrings = buildSet(new String[][] { new String[] {"a","b","c"},new String[]{"a","d","c"} },config,converter);
    DirectedSparseGraph actualA = Test_Orig_RPNIBlueFringeLearner.augmentPTA(DeterministicDirectedSparseGraph.initialise(), plusStrings, true);
    DeterministicDirectedSparseGraph.numberVertices(actualA);// Numbering is necessary to ensure uniqueness of labels used by LearnerGraph constructor.
    config.setAllowedToCloneNonCmpVertex(true);
    LearnerGraph l = new LearnerGraph(config);
    LearnerGraph actualC = l.paths.augmentPTA(plusStrings, true,false);
    DeterministicDirectedSparseGraph.numberVertices(actualA);
    String expectedPTA = "A-a->B--b->C-c->End1\nB--d->C2-c->End2";
    checkM(expectedPTA,new LearnerGraph(actualA,config), config,converter);
View Full Code Here

    Assert.assertEquals(leafNumber, engine.getDebugDataMapDepth(null).size());
  }
 
  private void checkEmptyPTA(String[][] arrayPlusStrings,String [][] arrayMinusStrings, boolean expectMaxAutomataToBeTheSameAsPTA)
  {
    Configuration conf = mainConfiguration.copy();
    Set<List<Label>> plusStrings = buildSet(arrayPlusStrings,conf,converter), minusStrings = buildSet(arrayMinusStrings,conf,converter);
    DirectedSparseGraph actualA = null, actualC = null, actualD = null, actualE = null, actualF = null;
    IllegalArgumentException eA = null, eC = null, eD = null, eE = null, eF = null;
    try
    {
      actualA = Test_Orig_RPNIBlueFringeLearner.createAugmentedPTA(plusStrings, minusStrings);
    }
    catch(IllegalArgumentException e)
    {
      // ignore this - it might be expected.
      eA = e;
    }

    try
    {
      Configuration config = mainConfiguration.copy();
      RPNIUniversalLearner l = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,config,null,null));
      config.setLearnerIdMode(Configuration.IDMode.POSITIVE_NEGATIVE);
      l.init(plusStrings, minusStrings);
      actualC = l.getTentativeAutomaton().pathroutines.getGraph();
    }
    catch(IllegalArgumentException e)
    {
      // ignore this - it might be expected.
      eC = e;
    }

    try
    {
      Configuration config = mainConfiguration.copy();
      RPNIUniversalLearner l = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,config,null,null));
      config.setLearnerIdMode(Configuration.IDMode.POSITIVE_NEGATIVE);
      PTASequenceEngine engine = buildPTA(plusStrings, minusStrings);
      checkPTAConsistency(engine, plusStrings, true);if (engine.numberOfLeafNodes()>0) checkPTAConsistency(engine, minusStrings, false);
      l.init(engine,0,0);
      actualD = l.getTentativeAutomaton().pathroutines.getGraph();
    }
    catch(IllegalArgumentException e)
    {
      // ignore this - it might be expected.
      eD = e;
    }

    try
    {
      Configuration config = mainConfiguration.copy();
      RPNIUniversalLearner l = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,config,null,null));
      config.setLearnerIdMode(Configuration.IDMode.POSITIVE_NEGATIVE);
      l.init(buildPTA(plusStrings, buildSet(new String[][] {},config,converter)),0,0);
      for(List<Label> seq:minusStrings)
      {
        Set<List<Label>> negativeSeq = new HashSet<List<Label>>();negativeSeq.add(seq);
        l.getTentativeAutomaton().paths.augmentPTA(buildPTA(buildSet(new String[][] {},config,converter),negativeSeq));
      }
      actualE = l.getTentativeAutomaton().pathroutines.getGraph();
    }
    catch(IllegalArgumentException e)
    {
      // ignore this - it might be expected.
      eE = e;
    }

    try
    {
      Configuration config = mainConfiguration.copy();
      RPNIUniversalLearner l = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,config,null,null));
      config.setLearnerIdMode(Configuration.IDMode.POSITIVE_NEGATIVE);
      l.getTentativeAutomaton().initPTA();
      l.getTentativeAutomaton().paths.augmentPTA(minusStrings, false,true);
      l.getTentativeAutomaton().paths.augmentPTA(plusStrings, true,true);
      actualF = l.getTentativeAutomaton().pathroutines.getGraph();
    }
View Full Code Here

  /** Make sure that we can augment a graph with a single state which is a reject-state. */
  @Test
  public void testPTAconstruction_singleRejectState()
  {
    Configuration config = mainConfiguration.copy();
    RPNIUniversalLearner l = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,config,null,null));
    config.setLearnerIdMode(Configuration.IDMode.POSITIVE_NEGATIVE);
    // set the initial state to be reject
    l.getTentativeAutomaton().initPTA();l.getTentativeAutomaton().getVertex(new LinkedList<Label>()).setAccept(false);
    // and check how augmentPTA works with such a PTA
    for(boolean maxAutomaton:new boolean[]{true,false})
    {
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.