Package statechum.model.testset

Examples of statechum.model.testset.PTASequenceEngine


    // Stores tasks to complete.
    CompletionService<Integer> runner = new ExecutorCompletionService<Integer>(executorService);
    int taskNumber = 5;
    try
    {
      PTASequenceEngine initialTracesLocker = null, initialTracesExporter = null;
     
      {
        ErlangRuntime newRuntime = new ErlangRuntime();newRuntime.startRunner();
        //testLockerLearning(cfg);
        {
          Configuration cfg = config.copy();cfg.setErlangMboxName(newRuntime.createNewRunner().getRunnerName());
          LearnerEvaluationConfiguration learnerConfig = new LearnerEvaluationConfiguration(cfg);ErlangModule.setupErlangConfiguration(learnerConfig.config,new File(ErlangExamples,"locker/locker.erl"));
          learnerConfig.config.setErlangAlphabetAnyElements(EXPANSIONOFANY.ANY_WIBBLE);
          //learnerConfig.config.setScoreForAutomergeUponRestart(1);
          ErlangOracleLearner learner = new ErlangOracleLearner(null,learnerConfig);
          initialTracesLocker = learner.GenerateInitialTraces(5);
        }
       
        {
          Configuration cfg = config.copy();cfg.setErlangMboxName(newRuntime.createNewRunner().getRunnerName());
          LearnerEvaluationConfiguration learnerConfig = new LearnerEvaluationConfiguration(cfg);ErlangModule.setupErlangConfiguration(learnerConfig.config,new File(ErlangExamples,"exporter/exporter.erl"));
          learnerConfig.config.setErlangAlphabetAnyElements(EXPANSIONOFANY.ANY_WIBBLE);
          learnerConfig.config.setUseErlangOutputs(true);learnerConfig.config.setErlangCompileIntoBeamDirectory(true);
          ErlangOracleLearner learner = new ErlangOracleLearner(null,learnerConfig);
          initialTracesExporter = learner.GenerateInitialTraces(5);
        }
      }
     
      final PTASequenceEngine initialTracesLockerFinal = initialTracesLocker, initialTracesExporterFinal = initialTracesExporter;
      for(int i=0;i< taskNumber;++i)
      {
        runner.submit(new Callable<Integer>(){
 
          @Override
View Full Code Here


    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,null);
    SequenceSet partialPTA = engine.new SequenceSet();partialPTA.setIdentity();
    partialPTA = partialPTA.cross(specfsm.wmethod.getFullTestSet(1));
    precRec.crossWith(engine);return precRec.getPosNegPrecisionRecallNum();
  }
View Full Code Here

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

   * of unrolling the THEN parts in the <em>augmentFromIfThenAutomaton</em> method below and when marking paths
   * as answered by a user below.
   */
  public boolean AugmentNonExistingMatrixWith(List<String> question, boolean accept)
  {
    PTASequenceEngine engine = coregraph.learnerCache.getQuestionsPTA();
    if (engine == null)
      throw new IllegalArgumentException("questions PTA has not been computed yet");

    NonExistingPaths nonExisting = (NonExistingPaths) engine.getFSM();
    Map<CmpVertex,Map<String,CmpVertex>> nonexistingMatrix = nonExisting.getNonExistingTransitionMatrix();
    CmpVertex currentState = coregraph.getInit();
    nonExisting.getNonExistingVertices().remove(currentState);
    for(String label:question)
    {
View Full Code Here

   
    IllegalArgumentException exORIG = null;
   
    {// testing the orig part
      LearnerGraph s = buildLearnerGraph(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, testConfig));
      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 = buildLearnerGraph(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, testConfig));
      try
      {
        s.pathroutines.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 = buildLearnerGraph(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, testConfig));
      try
      {
        Map<CmpVertex,PTASequenceEngine.SequenceSet> map = s.pathroutines.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

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

    PTASequenceEngine engine = new PTA_FSMStructure(coregraph,initialState);
    SequenceSet partialPTA = engine.new SequenceSet();partialPTA.setIdentity();
    partialPTA = partialPTA.cross(stateCover);
   
    partialPTA.cross(characterisationSet);
    for(int i=0;i<=numberOfExtraStates;i++)
View Full Code Here

  /** Checks that concatenation works for real paths, using the new routine. */
  @Test
  public final void testComputePathsSBetween16()
  {
    LearnerGraph s = buildLearnerGraph(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

    topLevelListener.init(GenerateInitialTraces(5), 0, 0);
  }

  /** This one updates alphabet hence cannot be run concurrently. */
  public PTASequenceEngine GenerateInitialTraces(int wavecount) {
    PTASequenceEngine engine = new PTASequenceEngine();
    engine.init(new ErlangMachine());

    PTASequenceEngine.SequenceSet seq = engine.new SequenceSet();
    seq.setIdentity();
    PTASequenceEngine.SequenceSet seqNext = null;

View Full Code Here

   * of unrolling the THEN parts in the <em>augmentFromIfThenAutomaton</em> method below and when marking paths
   * as answered by a user below.
   */
  public Boolean AugmentNonExistingMatrixWith(List<Label> question, boolean accept)
  {
    PTASequenceEngine engine = coregraph.learnerCache.getQuestionsPTA();
    if (engine == null)
      throw new IllegalArgumentException("questions PTA has not been computed yet");

    NonExistingPaths nonExisting = (NonExistingPaths) engine.getFSM();
    Map<CmpVertex,Map<Label,CmpVertex>> nonexistingMatrix = nonExisting.getNonExistingTransitionMatrix();
    CmpVertex currentState = coregraph.getInit();
    nonExisting.getNonExistingVertices().remove(currentState);
    for(Label label:question)
    {
View Full Code Here

    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();
       
        @Override
        public boolean shouldBeReturned(Object name) {
          return !origFilter.shouldBeReturned(name);
        }
      });
      for(List<String> s:currentSequences)
        if(graph.paths.tracePathPrefixClosed(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;
    }

    checkForCorrectException(new whatToRun() { @Override public void run() {
View Full Code Here

TOP

Related Classes of statechum.model.testset.PTASequenceEngine

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.