Examples of PTASequenceEngine


Examples of statechum.model.testset.PTASequenceEngine

    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();
    }
    catch(IllegalArgumentException e)
    {
View Full Code Here

Examples of statechum.model.testset.PTASequenceEngine

   * @param vertTarget the target state
   * @return sequences of inputs to follow all paths found.
   */ 
  Collection<List<String>> computePathsBetween(CmpVertex vertSource, CmpVertex vertTarget)
  {
    PTASequenceEngine engine = new PTASequenceEngine();engine.init(new PTASequenceSetAutomaton());
    PTASequenceEngine.SequenceSet initSet = engine.new SequenceSet();initSet.setIdentity();
    PTASequenceEngine.SequenceSet paths = engine.new SequenceSet();paths.setIdentity();
    computePathsSBetween(vertSource, vertTarget,initSet,paths);
    return engine.getData();
  }
View Full Code Here

Examples of statechum.model.testset.PTASequenceEngine

    Assert.assertEquals(chunkNumber, generator.getChunkNumber());

    for(int i=0;i<chunkNumber;++i)
    {
      final PTASequenceEngine currentPTA = generator.getAllSequences(i);
      Collection<List<String>> currentSequences = currentPTA.getData(PTASequenceEngine.truePred);
      Assert.assertEquals("chunk "+i+" (neg) should be of length "+(2*posOrNegPerChunk*(i+1))+" but it was "+currentSequences.size(),(2*posOrNegPerChunk*(i+1)), currentSequences.size());
      int positive = 0,negative=0;
      PTASequenceEngine positivePTA = currentPTA.filter(currentPTA.getFSM_filterPredicate());
      PTASequenceEngine negativePTA = currentPTA.filter(new FilterPredicate() {
        FilterPredicate origFilter = currentPTA.getFSM_filterPredicate();
        public boolean shouldBeReturned(Object name) {
          return !origFilter.shouldBeReturned(name);
        }
      });
      for(List<String> s:currentSequences)
        if(graph.paths.tracePath(s) >=0)
        {
          ++negative;
          Assert.assertFalse(positivePTA.containsSequence(s));Assert.assertTrue(negativePTA.containsSequence(s));
        }
        else
        {
          ++positive;
          Assert.assertTrue(positivePTA.containsSequence(s));Assert.assertFalse(negativePTA.containsSequence(s));
        }
      Assert.assertEquals(posOrNegPerChunk*(i+1), positive);Assert.assertEquals(positive,positivePTA.getData(PTASequenceEngine.truePred).size());
      Assert.assertEquals(positive,positivePTA.getData().size());// all seq are accept ones
      Assert.assertEquals(posOrNegPerChunk*(i+1), negative);Assert.assertEquals(negative,negativePTA.getData(PTASequenceEngine.truePred).size());
      Assert.assertEquals(0,negativePTA.getData().size());// all seq are reject ones
      if (previousChunk != null) currentSequences.containsAll(previousChunk);
      previousChunk= currentSequences;
    }

    try  generator.getAllSequences(-1);Assert.fail("exception not thrown"); }
View Full Code Here

Examples of statechum.model.testset.PTASequenceEngine

            outcomeUAV = new TreeMap<Integer,PTASequenceEngine>();whatToUpdate.put(uav, outcomeUAV);
          }
         
          for(Integer frame:frameNumbers)
          {
            PTASequenceEngine traceDetailsUAV = outcomeUAV.get(frame);
            if (traceDetailsUAV == null)
            {
              traceDetailsUAV = new PTASequenceEngine(learnerInitConfiguration.config.getTransitionMatrixImplType() == STATETREE.STATETREE_ARRAY);
              traceDetailsUAV.init(new Automaton());
              outcomeUAV.put(frame, traceDetailsUAV);
            }
           
            if (traces.containsKey(uav))
            {
              for(int earlierFrame:frameNumbers)
              {
                if (earlierFrame>frame)
                  break;

                Set<List<Label>> traceData = traces.get(uav).get(earlierFrame);
               
                if (traceData != null)
                {
                  SequenceSet initSeq = traceDetailsUAV.new SequenceSet();initSeq.setIdentity();((Automaton)traceDetailsUAV.getFSM()).setAccept(isAccept);
                  initSeq.cross(traceData);
                }
               }
            }
          }
View Full Code Here

Examples of statechum.model.testset.PTASequenceEngine

   
    IllegalArgumentException exORIG = null;
   
    {// testing the orig part
      LearnerGraph s = new LearnerGraph(TestFSMAlgo.buildGraph(machine, testName), testConfig);
      PTASequenceEngine engine = new PTASequenceEngine();engine.init(new PTASequenceSetAutomaton());
      PTASequenceEngine.SequenceSet initSet = engine.new SequenceSet();initSet.setIdentity();
      PTASequenceEngine.SequenceSet paths = engine.new SequenceSet();
      if (initSeq != null) initSet=initSet.cross(TestFSMAlgo.buildSet(initSeq));
      try
      {
        s.paths.ORIGcomputePathsSBetween(s.findVertex(FirstState), s.findVertex(SecondState),initSet,paths);
        Map<String,String> actual = engine.getDebugDataMapDepth(paths);
        Assert.assertTrue("expected: "+expected+", actual: "+actual, expected.equals(actual));
      }
      catch(IllegalArgumentException ex)
      { exORIG = ex; }
     
    }

    IllegalArgumentException exNew = null;
   
    {// testing the new part
      LearnerGraph s = new LearnerGraph(TestFSMAlgo.buildGraph(machine, testName), testConfig);
      PTASequenceEngine engine = new PTASequenceEngine();engine.init(new PTASequenceSetAutomaton());
      PTASequenceEngine.SequenceSet initSet = engine.new SequenceSet();initSet.setIdentity();
      PTASequenceEngine.SequenceSet paths = engine.new SequenceSet();
      if (initSeq != null) initSet=initSet.cross(TestFSMAlgo.buildSet(initSeq));
      try
      {
        s.paths.computePathsSBetween(s.findVertex(FirstState), s.findVertex(SecondState),initSet,paths);
        Map<String,String> actual = engine.getDebugDataMapDepth(paths);
        Assert.assertTrue("expected: "+expected+", actual: "+actual, expected.equals(actual));
      }
      catch(IllegalArgumentException ex)
      { exNew = ex; }
    }

    IllegalArgumentException exCaching = null;
   
    {// testing the latest part with caching.
      LearnerGraph s = new LearnerGraph(TestFSMAlgo.buildGraph(machine, testName), testConfig);
      PTASequenceEngine engine = new PTASequenceEngine();engine.init(new PTASequenceSetAutomaton());
      PTASequenceEngine.SequenceSet initSet = engine.new SequenceSet();initSet.setIdentity();
      if (initSeq != null) initSet=initSet.cross(TestFSMAlgo.buildSet(initSeq));
      try
      {
        Map<CmpVertex,PTASequenceEngine.SequenceSet> map = s.paths.computePathsSBetween_All(s.findVertex(FirstState), engine,initSet);
        PTASequenceEngine.SequenceSet pathsToSecondState = map.get(s.findVertex(SecondState));
        if (pathsToSecondState == null)
          throw new IllegalArgumentException("path from state "+FirstState+" to state "+SecondState+" was not found");

        Map<String,String> actual = engine.getDebugDataMapDepth(pathsToSecondState);
       
        // The one below only compares keysets because computePathsSBetween_All builds an entire tree and
        // consequently most vertices will not be leaf ones.
        Assert.assertTrue("expected: "+expected+", actual: "+actual, expected.keySet().equals(actual.keySet()));
      }
View Full Code Here

Examples of statechum.model.testset.PTASequenceEngine

  /** Checks that concatenation works for real paths, using the new routine. */
  @Test
  public final void testComputePathsSBetween16()
  {
    LearnerGraph s = new LearnerGraph(TestFSMAlgo.buildGraph(complexGraphA, "ComputePathsSBetween_complexGraphA"), testConfig);
    PTASequenceEngine engine = new PTASequenceEngine();engine.init(new PTASequenceSetAutomaton());
    PTASequenceEngine.SequenceSet initSet = engine.new SequenceSet();initSet.setIdentity();
    PTASequenceEngine.SequenceSet pathsA = engine.new SequenceSet();
    s.paths.ORIGcomputePathsSBetween(s.findVertex("F"), s.findVertex("D"),initSet,pathsA);
    PTASequenceEngine.SequenceSet pathsB = engine.new SequenceSet();
    s.paths.ORIGcomputePathsSBetween(s.findVertex("B"), s.findVertex("C"),pathsA,pathsB);
    PTASequenceEngine.SequenceSet pathsC = engine.new SequenceSet();
    s.paths.ORIGcomputePathsSBetween(s.findVertex("C"), s.findVertex("A"),pathsB,pathsC);
    Map<String,String> actual = engine.getDebugDataMapDepth(pathsC),expected = TestFSMAlgo.buildStringMap(
      new Object[][] {
        new Object[]{new String[] {"a","d","b"}, PTASequenceEngine.DebugDataValues.booleanToString(true, true)},
        new Object[]{new String[] {"a","b","b"}, PTASequenceEngine.DebugDataValues.booleanToString(true, true)},
        new Object[]{new String[] {"b","d","b"}, PTASequenceEngine.DebugDataValues.booleanToString(true, true)},
        new Object[]{new String[] {"b","b","b"}, PTASequenceEngine.DebugDataValues.booleanToString(true, true)}
View Full Code Here

Examples of statechum.model.testset.PTASequenceEngine

    return whatToG.get(what.init);
  }

  public static void addToGraph_tmp(LearnerGraph g, List<String> initPath, LearnerGraph what)
  {
    PTASequenceEngine engine = new PTASequenceEngine();
    engine.init(new PTASequenceSetAutomaton());   
    SequenceSet initSet = engine.new SequenceSet();initSet.setIdentity();initSet.crossWithSequence(initPath);
   
    for(Entry<CmpVertex,Map<String,CmpVertex>> entry:what.transitionMatrix.entrySet())
    {// for all states in our new machine, compute paths to them.
      SequenceSet result = engine.new SequenceSet();
View Full Code Here

Examples of statechum.model.testset.PTASequenceEngine

    System.out.println(pr.getPosprecision()+", "+pr.getPosrecall()+", "+pr.getNegprecision()+", "+pr.getNegrecall());
  }
 
  public static PosNegPrecisionRecall compare(LearnerGraph specfsm, LearnerGraph imp){
    PTA_computePrecisionRecall precRec = new PTA_computePrecisionRecall(imp);
    PTASequenceEngine engine = new PTA_FSMStructure(specfsm);
    SequenceSet partialPTA = engine.new SequenceSet();partialPTA.setIdentity();
    partialPTA = partialPTA.cross(specfsm.wmethod.getFullTestSet(1));
    return precRec.crossWith(engine);
  }
View Full Code Here

Examples of statechum.model.testset.PTASequenceEngine

    return precRec.crossWith(engine);
  }
 
  public static PosNegPrecisionRecall compare(Collection<List<String>> tests, LearnerGraph specfsm, LearnerGraph imp){
    PTA_computePrecisionRecall precRec = new PTA_computePrecisionRecall(imp);
    PTASequenceEngine engine = new PTA_FSMStructure(specfsm);
    SequenceSet partialPTA = engine.new SequenceSet();partialPTA.setIdentity();
    partialPTA = partialPTA.cross(tests);
    return precRec.crossWith(engine);
  }
View Full Code Here

Examples of statechum.model.testset.PTASequenceEngine

        "A5-c->A51-c->A52"
        , "testBuildPTAofQuestions1",config,converter);
    StatePair pair = new StatePair(graph.findVertex("A1"),graph.findVertex("A2"));
    LearnerGraph merged = MergeStates.mergeAndDeterminize_general(graph, pair);
    compareGraphs(buildLearnerGraph("A1-a->B1-b->A1-c->C-d-#R4 / C-c->CC / CC-f-#R3 / CC-e->D", "expected",config,converter),merged);
    PTASequenceEngine questions = ComputeQuestions.getQuestionPta(pair, graph, merged, null);
    LearnerGraph updatedGraphExpected = new LearnerGraph(graph,config),
      updatedGraphActual = ComputeQuestions.constructGraphWithQuestions(pair, graph, merged);

    for(List<Label> path:questions.getData())
      updatedGraphExpected.paths.augmentPTA(path,merged.paths.getVertex(path).isAccept(),false,null);

    Set<List<Label>> expectedQuestions = TestFSMAlgo.buildSet(new String[][] {
        new String[]{"c", "d"},
        new String[]{"c", "c", "e"},
        new String[]{"c", "c", "f"}
    },config,converter), actualQuestions = new LinkedHashSet<List<Label>>();actualQuestions.addAll(questions.getData());
    Assert.assertEquals(expectedQuestions,actualQuestions);
    //updatedGraphExpected.paths.augmentPTA(asList("c", "d"),false,false,null);
    //updatedGraphExpected.paths.augmentPTA(asList("c", "c", "e"),true,false,null);
    //updatedGraphExpected.paths.augmentPTA(asList("c", "c", "f"),false,false,null);
    compareGraphs(updatedGraphExpected,updatedGraphActual);                                              
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.