Package statechum.model.testset

Examples of statechum.model.testset.PTASequenceEngine


    checkForCorrectException(new whatToRun() { @Override public void run() {
      generator.getExtraSequences(1);
    }},IllegalArgumentException.class,"is out of range");
    Assert.assertTrue("PTA is not empty",generator.getExtraSequences(0).containsAsLeaf(Arrays.asList(new String[]{})));
    final PTASequenceEngine currentPTA = generator.getAllSequences(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);
      }
    });
   
    {
      Collection<List<String>> currentPos = positivePTA.getData(PTASequenceEngine.truePred);
      Assert.assertEquals(1,currentPos.size());
      Assert.assertEquals(Arrays.asList(new String[]{"a"}), currentPos.iterator().next());
    }
   
    {
      Collection<List<String>> currentNeg = negativePTA.getData(PTASequenceEngine.truePred);
      Assert.assertEquals(1,currentNeg.size());
      Assert.assertEquals(Arrays.asList(new String[]{"b"}), currentNeg.iterator().next());
    }   
   
  }
View Full Code Here


   
   
    RandomPathGenerator rpg = new RandomPathGenerator(targetMachine, new Random(100),5,null);// the seed for Random should be the same for each file
    rpg.generatePosNeg(2*nrPerChunk , 100/percentPerChunk);
    for(int i=0;i<10;i++){
      final PTASequenceEngine samples = rpg.getAllSequences(i);
     
      PTASequenceEngine.FilterPredicate posPredicate = samples.getFSM_filterPredicate();
      PTASequenceEngine.FilterPredicate negPredicate = new FilterPredicate() {
        FilterPredicate origFilter = samples.getFSM_filterPredicate();
        public @Override boolean shouldBeReturned(Object name) {
          return !origFilter.shouldBeReturned(name);
        }
      };
     
      sPlus = new HashSet<List<Label>>();
      sMinus = new HashSet<List<Label>>();
      sPlus.addAll(samples.getData(posPredicate));
      sMinus.addAll(samples.getData(negPredicate));
      /*
      RPNIUniversalLearner lr=new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,learnerInitConfiguration.config,learnerInitConfiguration.ifthenSequences,null));
      LearnerGraph ifthen = Transform.buildIfThenAutomata(learnerInitConfiguration.ifthenSequences, lr.init(sPlus, sMinus),
          learnerInitConfiguration.config).toArray(new LearnerGraph[0])[0];
      Visualiser.updateFrame(ifthen, null);
View Full Code Here

    generator.generateRandomPosNeg(posOrNegPerChunk*2,chunkNumber,false);

    Collection<List<String>> previousChunk = null;
    for(int i=0;i<chunkNumber;++i)
    {
      final PTASequenceEngine currentPTA = generator.getAllSequences(i);
      Collection<List<String>> currentSequences = currentPTA.getData(PTASequenceEngine.truePred);
      Assert.assertTrue(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.assertTrue(posOrNegPerChunk*(i+1) > positive);Assert.assertEquals(positive,positivePTA.getData(PTASequenceEngine.truePred).size());
      Assert.assertEquals(positive,positivePTA.getData().size());// all seq are accept ones
      Assert.assertTrue(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;
    }
  }
View Full Code Here

         
        default:
          throw new IllegalArgumentException("invalid type "+config.getGdScoreComputationAlgorithm()+" of score computation algorithm used");
        }
 
        PTASequenceEngine
          testSequencesA = stateToCorrespondingGraph.get(stateA).testSequences,
          testSequencesB = stateToCorrespondingGraph.get(stateB).testSequences;

        /*
        System.out.println("States: "+stateA+" and "+stateB+", total outgoing: "+totalOutgoing+", graphs: "+
View Full Code Here

            outcomeUAV = new TreeMap<Integer,PTASequenceEngine>();whatToUpdate.put(uav, outcomeUAV);
          }
         
          for(Integer frame:frameNumbers)
          {
            PTASequenceEngine traceDetailsUAV = outcomeUAV.get(frame);
            if (traceDetailsUAV == null)
            {
              traceDetailsUAV = new PTASequenceEngine();
              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

    final RandomPathGenerator generator = new RandomPathGenerator(cvsGraph,new Random(0),5,null);
    final int posOrNegPerChunk = 50;
    generator.generateRandomPosNeg(posOrNegPerChunk*2,1);
    Collection<List<Label>> sequences = cvsGraph.wmethod.getFullTestSet(1);//generator.getAllSequences(0).getData(PTASequenceEngine.truePred);

    PTASequenceEngine walkEngine = new PTA_FSMStructure(cvsGraph,null);
    SequenceSet ptaWalk = walkEngine.new SequenceSet();ptaWalk.setIdentity();
    ptaWalk = ptaWalk.cross(sequences);
   
   
   
View Full Code Here

 
    }

    public LearnerGraph learn(String UAV, String seed,int frameNumber)
    {
      PTASequenceEngine engine = collectionOfTraces.get(seed).tracesForUAVandFrame.get(UAV).get(frameNumber);
      LearnerGraph outcome = null;
      outcome = learner.learnMachine(engine,0,0);
      return outcome;
    }
View Full Code Here

      return learner.learnMachine(new LinkedList<List<Label>>(), new LinkedList<List<Label>>());
    }
   
    public LearnerGraph learn(PTASequenceEngine engineArg, boolean useNegatives)
    {
      PTASequenceEngine engine = null;
      if (!useNegatives)
      {
        PTASequenceEngine positives = new PTASequenceEngine();positives.init(new Automaton());
          SequenceSet initSeq = positives.new SequenceSet();initSeq.setIdentity();
          initSeq.cross(engineArg.getData());
          engine = positives;
      }
      else
View Full Code Here

   
   
    RandomPathGenerator rpg = new RandomPathGenerator(targetMachine, new Random(100),5,null);// the seed for Random should be the same for each file
    rpg.generatePosNeg(2*nrPerChunk , 100/percentPerChunk);
    for(int i=0;i<10;i++){
      final PTASequenceEngine samples = rpg.getAllSequences(i);
     
      PTASequenceEngine.FilterPredicate posPredicate = samples.getFSM_filterPredicate();
      PTASequenceEngine.FilterPredicate negPredicate = new FilterPredicate() {
        FilterPredicate origFilter = samples.getFSM_filterPredicate();
        public @Override boolean shouldBeReturned(Object name) {
          return !origFilter.shouldBeReturned(name);
        }
      };
     
      sPlus = new HashSet<List<Label>>();
      sMinus = new HashSet<List<Label>>();
      sPlus.addAll(samples.getData(posPredicate));
      sMinus.addAll(samples.getData(negPredicate));
      /*
      RPNIUniversalLearner lr=new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,learnerInitConfiguration.config,learnerInitConfiguration.ifthenSequences,null));
      LearnerGraph ifthen = Transform.buildIfThenAutomata(learnerInitConfiguration.ifthenSequences, lr.init(sPlus, sMinus),
          learnerInitConfiguration.config).toArray(new LearnerGraph[0])[0];
      Visualiser.updateFrame(ifthen, 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

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.