Package statechum.model.testset.PTASequenceEngine

Examples of statechum.model.testset.PTASequenceEngine.SequenceSet


      LearnerGraph learned = learn(recorder,sMinus);
      PTA_computePrecisionRecall precRec = new PTA_computePrecisionRecall(learned);
      PTASequenceEngine engine = new PTA_FSMStructure(graph);
      PosNegPrecisionRecall ptaPR = precRec.crossWith(sMinus);
      SequenceSet ptaTestSet = engine.new SequenceSet();ptaTestSet.setIdentity();
      ptaTestSet = ptaTestSet.cross(graph.wmethod.getFullTestSet(1));
      PosNegPrecisionRecall prNeg = precRec.crossWith(engine);
     
      // Columns 3 and 4
      result = result+prNeg.precision+FS+prNeg.recall;
     
View Full Code Here


                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

      public boolean isAccept(@SuppressWarnings("unused"Object elem)
      {
        return !rejectAllStates.booleanValue();
      }
    });
    SequenceSet initSeq = allSequences.new SequenceSet();initSeq.setIdentity();
    initSeq.cross(plusStrings);statesAccept.getAndSet(false);initSeq.cross(minusStrings);
   
    return allSequences;
  }
View Full Code Here

  }

  /** Checks if a PTA constructed is consistent with provided sequences. */
  private void checkPTAConsistency(PTASequenceEngine engine,Set<List<Label>> sequences, boolean accept)
  {
    SequenceSet initSeq = engine.new SequenceSet();initSeq.setIdentity();
    int leafNumber = engine.getDebugDataMapDepth(null).size();
    // Now we check the consistency
    for(List<Label> seq:sequences)
    {
      SequenceSet endOfSeq = initSeq.crossWithSequence(seq);// this is aimed to follow a path in a PTA
        // to a state which is not necessarily a tail-state (hence no use calling getDebugDataMapDepth(null),
        // but can inadvertently add a new sequence, hence we have to check that it has to happened at the end.
      Map<String,String> map = engine.getDebugDataMapDepth(endOfSeq);
      assert map.size() == 1: "expected size of 1, got "+map.size();
      String attrs = map.values().iterator().next();
View Full Code Here

  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();
      what.paths.computePathsSBetween(what.init, entry.getKey(), initSet, result);
      result.crossWithSet(entry.getValue().keySet());
    }
   
    // Now engine contains a sort of a transition cover of "what", except that only
    // transitions present in "what" will be covered. All sequences in this set have
    // initPath prepended to them, so that I can merge the result into g directly.
View Full Code Here

  }
 
  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

  }
 
  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

            }
           
          });
        }
      };
      SequenceSet minusInit = sOrigMinus.new SequenceSet();minusInit.setIdentity();minusInit.cross(minusTrainingSet);
      int totalLenOrig = 0, origNumber=0;
      for(List<String> seq:minusTrainingSet)
      {
        assert seq.size() > 1;
        assert graph.getVertex(seq) == null;// the seq is negative indeed
        assert graph.getVertex(seq.subList(0, seq.size()-1)) != null;// the -1 prefix is positive
        assert sOrigMinus.containsSequence(seq);// make sure PTA construction did not fumble.
        assert graph.paths.tracePath(seq) == seq.size()-1;// and another check that a -1 prefix is ok
        totalLenOrig+=seq.size();origNumber++;
      }
      assert sOrigMinus.getData().size() == 0;// all negatives

      /* Builds the new set. */
      PTASequenceEngine sNewMinus = rpg.getAllSequences(percent/10-1);
      int totalLenNew = 0, newNumber = 0;
      for(List<String> seq:sNewMinus.getData(PTASequenceEngine.truePred))
      {
        assert seq.size() > 1;
        assert graph.getVertex(seq) == null;
        assert graph.getVertex(seq.subList(0, seq.size()-1)) != null;
        assert graph.paths.tracePath(seq) == seq.size()-1;
        totalLenNew+=seq.size();newNumber++;
      }
      // 22,23
      String comparison = "Orig ave len: "+FS+((double)totalLenOrig)/origNumber+FS+
      // 24,25
          " new ave len: "+FS+((double)totalLenNew)/newNumber+FS+
      // 26,27
          " fudge status: "+FS+rpg.getFudgeDetails();
     
      //int numberOfMinusSequences = minusTrainingSet.size();
      assert sNewMinus.getData().size() == 0;// all negatives
     
      if (config.getLearnerToUse() == LEARNER.LEARNER_BLUEFRINGE_DEC2007)
        sMinus = sOrigMinus;
      else
        sMinus = sNewMinus;
     
     
      RPNIBlueFringeLearner l = null;
     
      if (config.getLearnerToUse() == LEARNER.LEARNER_BLUEAMBER_MAY2008)
      {
        l = new RPNIBlueAmberFringeLearner(null,config)
        {
          @Override
          protected Pair<Integer,String> checkWithEndUser(
              @SuppressWarnings("unused"LearnerGraph model,
              List<String> question,
              @SuppressWarnings("unused") final Object [] moreOptions)
          {
            questionNumber.addAndGet(1);
            return new Pair<Integer,String>(graph.paths.tracePath(question),null);
          }
        };
      }
      else
      {
        l = new RPNIBlueFringeLearnerTestComponentOpt(null,config)
        {
          @Override
          protected Pair<Integer,String> checkWithEndUser(
              @SuppressWarnings("unused"LearnerGraph model,
              List<String> question,
              @SuppressWarnings("unused") final Object [] moreOptions)
          {
            questionNumber.addAndGet(1);
            return new Pair<Integer,String>(graph.paths.tracePath(question),null);
          }
        };
      }
      RecordProgressDecorator recorder = null;
      try {
        recorder = new RecordProgressDecorator(l.getLearner(),new java.io.FileOutputStream(getFileName(FileType.LOG)),1,config,true);
      } catch (IOException e) {
        statechum.Helper.throwUnchecked("could not open log file for writing", e);
      }
      Collection<List<String>> graphTestSet = graph.wmethod.getFullTestSet(1);
      recorder.writeLearnerEvaluationData(new ProgressDecorator.LearnerEvaluationConfiguration(graph,graphTestSet,config,null));
      l.getLearner().setTopLevelListener(recorder);
      learnt = learn(recorder,sMinus);
      //learned = new LearnerGraph(config);
     
      PTASequenceEngine testSetEngine = new PTA_FSMStructure(graph);
      SequenceSet ptaTestSet = testSetEngine.new SequenceSet();ptaTestSet.setIdentity();
      ptaTestSet.cross(graphTestSet);

      PTA_computePrecisionRecall precRec = new PTA_computePrecisionRecall(learnt);
     
      PosNegPrecisionRecall ptaPR = precRec.crossWith(sMinus);
      PosNegPrecisionRecall prNeg = precRec.crossWith(testSetEngine);
View Full Code Here

    List<List<String>> stateCover = computeStateCover();
    characterisationSet = computeWSet_reducedmemory(coregraph);if (characterisationSet.isEmpty()) characterisationSet.add(Arrays.asList(new String[]{}));
    transitionCover = crossWithSet(stateCover,alphabet);transitionCover.addAll(stateCover);

    PTASequenceEngine engine = new PTA_FSMStructure(coregraph);
    SequenceSet partialPTA = engine.new SequenceSet();partialPTA.setIdentity();
    partialPTA = partialPTA.cross(stateCover);
   
    partialPTA.cross(characterisationSet);
    for(int i=0;i<=numberOfExtraStates;i++)
    {
      partialPTA = partialPTA.crossWithSet(alphabet);
      partialPTA.cross(characterisationSet);
    }
   
    return engine.getData();
  }
View Full Code Here

  }

  @Test
  public final void test_sequenceSet5_2() // a more complex composition
  {
    SequenceSet seq = en.new SequenceSet();seq.setIdentity();
    seq.crossWithSequence(labelList(new String[] {"a","b","c"})).crossWithSet(new LinkedList<Label>());
    Map<String,String> actual = getDebugDataMap(en,en.new SequenceSet().cross(TestFSMAlgo.buildList(new String[][] {// here the new sequenceSet is empty, hence whatever I do, there should be no changes
        new String[] {"a","b","c","d"},
        new String[] {"c"}
    },mainConfiguration,converter)));
    vertifyPTA(en, 1, new String[][] {
        new String[] {"a","b","c"}
View Full Code Here

TOP

Related Classes of statechum.model.testset.PTASequenceEngine.SequenceSet

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.