Package statechum.analysis.learning.rpnicore

Examples of statechum.analysis.learning.rpnicore.RandomPathGenerator$RandomLengthGenerator


    /** This method is executed on an executor thread. */
    @Override
    public void runTheExperiment()
    {
      int size = 2*graph.pathroutines.countEdges();
      RandomPathGenerator rpg = new RandomPathGenerator(graph, new Random(100),5,null);// the seed for Random should be the same for each file
      int percentPerChunk = 10;
      int nrPerChunk = size/(100/percentPerChunk);nrPerChunk+=nrPerChunk % 2;// make the number even
      rpg.generatePosNeg(2*nrPerChunk , 100/percentPerChunk);// 2* reflects the fact that nrPerChunk denotes the number of elements in both chunks (positive and negative) combined.  */
      LearnerEvaluationConfiguration evaluationConfiguration = new LearnerEvaluationConfiguration(null,null,config,null,null);
      evaluationConfiguration.setLabelConverter(experiment.getLabelConverter());
      RPNILearner learner = new RPNIUniversalLearner(null,evaluationConfiguration)
      {
        @Override
        public Pair<Integer,String> CheckWithEndUser(
            @SuppressWarnings("unused"LearnerGraph model,
            List<Label> question, @SuppressWarnings("unused") int valueForNoRestart,
            @SuppressWarnings("unused") List<Boolean> acceptedElements,
            @SuppressWarnings("unused") PairScore pairBeingMerged,
            @SuppressWarnings("unused") final Object [] moreOptions)
        {
          questionNumber.addAndGet(1);
          return new Pair<Integer,String>(graph.paths.tracePathPrefixClosed(question),null);
        }
      };
      QuestionAndRestartCounter l = new QuestionAndRestartCounter(learner);
      sPlus = rpg.getExtraSequences(percent/10-1);sMinus = rpg.getAllSequences(percent/10-1);

      LearnerGraph learnt = learn(l,sMinus);
      PTA_computePrecisionRecall precRec = new PTA_computePrecisionRecall(learnt);
      PTASequenceEngine engine = new PTA_FSMStructure(graph,null);
      precRec.crossWith(sMinus);PosNegPrecisionRecall ptaPR = precRec.getPosNegPrecisionRecallNum();
View Full Code Here


    Visualiser.updateFrame(markovD, null);
    Visualiser.updateFrame(markov, null);
   
    Visualiser.waitForKey();
    */
    final RandomPathGenerator generator = new RandomPathGenerator(cvsGraph,new Random(0),5,null);
    final int posOrNegPerChunk = 45;
    generator.generateRandomPosNeg(posOrNegPerChunk*2,1);

    System.out.println(generator.getAllSequences(0).getData(new FilterPredicate()
    {
      @Override
      public boolean shouldBeReturned(Object name) {
        return !generator.getAllSequences(0).getFSM().shouldBeReturned(name);
      }
    }));
    //System.out.println(generator.getExtraSequences(0).getData(PTASequenceEngine.truePred).size());
   
    /*
    List<List<String>> data = generator.getExtraSequences(0).getData();
    for(List<String> str:data)
      System.out.println(str);
    */
    PTA_computePrecisionRecall precRec = null;
   
    {
      precRec = new PTA_computePrecisionRecall(markovD);
      precRec.crossWith(generator.getAllSequences(0));PosNegPrecisionRecall result = precRec.getPosNegPrecisionRecallNum();
      System.out.println("Markov: precision "+result.getPosprecision()+" recall: "+result.getPosrecall());
    }

    {
      precRec = new PTA_computePrecisionRecall(edsm);
      precRec.crossWith(generator.getAllSequences(0));PosNegPrecisionRecall result = precRec.getPosNegPrecisionRecallNum();
      System.out.println("EDSM: precision "+result.getPosprecision()+" recall: "+result.getPosrecall());
    }
   
    //Visualiser.updateFrame(edsm, null);
    //Visualiser.waitForKey();
View Full Code Here

    /** This method is executed on an executor thread. */
    @Override
    public void runTheExperiment()
    {
      int size = 2*graph.pathroutines.countEdges();
      RandomPathGenerator rpg = new RandomPathGenerator(graph, new Random(100),5,null);// the seed for Random should be the same for each file
      int percentPerChunk = 10;
      int nrPerChunk = size/(100/percentPerChunk);nrPerChunk+=nrPerChunk % 2;// make the number even
      rpg.generatePosNeg(2*nrPerChunk , 100/percentPerChunk);// 2* reflects the fact that nrPerChunk denotes the number of elements in both chunks (positive and negative) combined.  */
      LearnerEvaluationConfiguration evaluationConfiguration = new LearnerEvaluationConfiguration(null,null,config,null,null);
      evaluationConfiguration.setLabelConverter(experiment.getLabelConverter());
      RPNILearner learner = new RPNIUniversalLearner(null,evaluationConfiguration)
      {
        @Override
        public Pair<Integer,String> CheckWithEndUser(
            @SuppressWarnings("unused"LearnerGraph model,
            List<Label> question, @SuppressWarnings("unused") int valueForNoRestart,
            @SuppressWarnings("unused") List<Boolean> acceptedElements,
            @SuppressWarnings("unused") PairScore pairBeingMerged,
            @SuppressWarnings("unused") final Object [] moreOptions)
        {
          questionNumber.addAndGet(1);
          return new Pair<Integer,String>(graph.paths.tracePathPrefixClosed(question),null);
        }
      };
      QuestionAndRestartCounter l = new QuestionAndRestartCounter(learner);
      sPlus = rpg.getExtraSequences(percent/10-1);sMinus = rpg.getAllSequences(percent/10-1);

      LearnerGraph learnt = learn(l,sMinus);
      PTA_computePrecisionRecall precRec = new PTA_computePrecisionRecall(learnt);
      PTASequenceEngine engine = new PTA_FSMStructure(graph,null);
      precRec.crossWith(sMinus);PosNegPrecisionRecall ptaPR = precRec.getPosNegPrecisionRecallNum();
View Full Code Here

      outcome.setValue(DOUBLE_V.ACCURACY_W, wSeq.firstElem);
    }
   
    {
      Collection<List<Label>> sequences =new LinkedHashSet<List<Label>>();
      RandomPathGenerator rpg = new RandomPathGenerator(from, new Random(0),4, from.getInit());// the seed for Random should be the same for each file
      long startTime = System.nanoTime();
      rpg.generatePosNeg((graphComplexity+1)*states , 1);
      outcome.setValue(LONG_V.DURATION_RAND,System.nanoTime()-startTime);
      sequences.addAll(rpg.getAllSequences(0).getData(PTASequenceEngine.truePred));
      sequences.addAll(rpg.getExtraSequences(0).getData(PTASequenceEngine.truePred));
      Pair<Double,Long> randSeq = compareLang(from, to, sequences);
      outcome.setValue(LONG_V.DURATION_RAND, outcome.getValue(LONG_V.DURATION_RAND)+randSeq.secondElem);
      outcome.setValue(DOUBLE_V.ACCURACY_RAND, randSeq.firstElem);
    }
   
View Full Code Here

              int extraLength=0;
              if (deterministicGraph.getStateNumber() == 1) extraLength=1;//where the diameter is zero (and due
              // to subset construction, we are not going to get unreachable states thus getStateNumber()
              // is the right way to determine this), we have to set extra length to 1 to ensure walks are generated.

              RandomPathGenerator randomPaths = new RandomPathGenerator(deterministicGraph,randomGenerator.getRandom(entryA.getKey()),
                  extraLength+config.getGdScoreComputationAlgorithm_RandomWalk_ExtraLength(),state,matrixForward.pathroutines.computeAlphabet());
              if (config.getGdScoreComputationAlgorithm_RandomWalk_PathLength() > 0)
                randomPaths.setPathLength(config.getGdScoreComputationAlgorithm_RandomWalk_PathLength());
              randomPaths.generateRandomPosNeg(config.getGdScoreComputationAlgorithm_RandomWalk_NumberOfSequences(), 1,false);
              graphwalk=new GraphAndWalk(deterministicGraph,randomPaths.getAllSequences(0));
            }
            break;
          case SCORE_TESTSET:
            graphwalk=new GraphAndWalk(deterministicGraph,deterministicGraph.wmethod.computeNewTestSet(state, config.getGdScoreComputationAlgorithm_TestSet_ExtraStates()));
            deterministicGraph.learnerCache.invalidate();// reduce memory footprint.
View Full Code Here

    /** This method is executed on an executor thread. */
    @Override
    public void runTheExperiment()
    {
      int sampleSize = (graph.getStateNumber()*4);
      RandomPathGenerator rpg = new RandomPathGenerator(graph, new Random(100),5,null);// the seed for Random should be the same for each file
      rpg.generateRandomPosNeg(sampleSize, 2)
      //Collection<List<String>> tests = graph.wmethod.getFullTestSet(1);
      config.setDebugMode(true);
      config.setAskQuestions(true);
      config.setSpeculativeQuestionAsking(true);
      config.setMinCertaintyThreshold(2);
      //config.setAskQuestions(false);
      //config.setKlimit(2);
      //config.setLearnerScoreMode(Configuration.ScoreMode.KTAILS);
      config.setLearnerScoreMode(Configuration.ScoreMode.CONVENTIONAL);
      Learner l = new AccuracyTrackerDecorator(new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,config,null,null))
      {
        @Override
        public Pair<Integer,String> CheckWithEndUser(
            @SuppressWarnings("unused"LearnerGraph model,
            List<Label> question, @SuppressWarnings("unused") int valueForNoRestart,
            @SuppressWarnings("unused") List<Boolean> acceptedElements,
            @SuppressWarnings("unused") PairScore pairBeingMerged,
            @SuppressWarnings("unused") final Object [] moreOptions)
        {
          questionNumber.addAndGet(1);
          return new Pair<Integer,String>(graph.paths.tracePathPrefixClosed(question),null);
        }
      }
      , graph);
      sMinus = rpg.getAllSequencesPercentageInterval(1);

      learn(l,sMinus);
      result = result + l.getResult();
    }
View Full Code Here

    /** This method is executed on an executor thread. */
    @Override
    public void runTheExperiment()
    {
      int size = 2*graph.pathroutines.countEdges();
      RandomPathGenerator rpg = new RandomPathGenerator(graph, new Random(100),5,null);// the seed for Random should be the same for each file
      int percentPerChunk = 10;
      int nrPerChunk = size/(100/percentPerChunk);nrPerChunk+=nrPerChunk % 2;// make the number even
      rpg.generatePosNeg(2*nrPerChunk , 100/percentPerChunk);// 2* reflects the fact that nrPerChunk denotes the number of elements in both chunks (positive and negative) combined.  */
      RPNILearner learner = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,config,null,null))
      {
        @Override
        public Pair<Integer,String> CheckWithEndUser(
            @SuppressWarnings("unused"LearnerGraph model,
            List<Label> question, @SuppressWarnings("unused") int valueForNoRestart,
            @SuppressWarnings("unused") List<Boolean> acceptedElements,
            @SuppressWarnings("unused") PairScore pairBeingMerged,
            @SuppressWarnings("unused") final Object [] moreOptions)
        {
          questionNumber.addAndGet(1);
          return new Pair<Integer,String>(graph.paths.tracePathPrefixClosed(question),null);
        }
      };
      QuestionAndRestartCounter l = new QuestionAndRestartCounter(learner);
      sPlus = rpg.getExtraSequences(percent/10-1);sMinus = rpg.getAllSequences(percent/10-1);

      LearnerGraph learnt = learn(l,sMinus);
      PTA_computePrecisionRecall precRec = new PTA_computePrecisionRecall(learnt);
      PTASequenceEngine engine = new PTA_FSMStructure(graph,null);
      precRec.crossWith(sMinus);PosNegPrecisionRecall ptaPR = precRec.getPosNegPrecisionRecallNum();
View Full Code Here

    Visualiser.updateFrame(markovD, null);
    Visualiser.updateFrame(markov, null);
   
    Visualiser.waitForKey();
    */
    final RandomPathGenerator generator = new RandomPathGenerator(cvsGraph,new Random(0),5,null);
    final int posOrNegPerChunk = 45;
    generator.generateRandomPosNeg(posOrNegPerChunk*2,1);

    System.out.println(generator.getAllSequences(0).getData(new FilterPredicate()
    {
      @Override
      public boolean shouldBeReturned(Object name) {
        return !generator.getAllSequences(0).getFSM().shouldBeReturned(name);
      }
    }));
    //System.out.println(generator.getExtraSequences(0).getData(PTASequenceEngine.truePred).size());
   
    /*
    List<List<String>> data = generator.getExtraSequences(0).getData();
    for(List<String> str:data)
      System.out.println(str);
    */
    PTA_computePrecisionRecall precRec = null;
   
    {
      precRec = new PTA_computePrecisionRecall(markovD);
      precRec.crossWith(generator.getAllSequences(0));PosNegPrecisionRecall result = precRec.getPosNegPrecisionRecallNum();
      System.out.println("Markov: precision "+result.getPosprecision()+" recall: "+result.getPosrecall());
    }

    {
      precRec = new PTA_computePrecisionRecall(edsm);
      precRec.crossWith(generator.getAllSequences(0));PosNegPrecisionRecall result = precRec.getPosNegPrecisionRecallNum();
      System.out.println("EDSM: precision "+result.getPosprecision()+" recall: "+result.getPosrecall());
    }
   
    //Visualiser.updateFrame(edsm, null);
    //Visualiser.waitForKey();
View Full Code Here

    Set<Label> origAlphabet = cvsGraph.pathroutines.computeAlphabet();
    assert origAlphabet.equals(markov.pathroutines.computeAlphabet());
    assert origAlphabet.equals(markovD.pathroutines.computeAlphabet());
    assert origAlphabet.equals(edsm.pathroutines.computeAlphabet());
    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

    protected void buildSets()
    {
      loadGraph();
      int size = graph.pathroutines.getGraph().getEdges().size()*4;// FIXME: this one ignores parallel edges
        RandomPathGenerator rpg = new RandomPathGenerator(graph, new Random(100),3,null);// the seed for Random should be the same for each file
      rpg.generatePosNeg(size, experiment.getStageNumber());
      pta = rpg.getAllSequences(percent);
    }
View Full Code Here

TOP

Related Classes of statechum.analysis.learning.rpnicore.RandomPathGenerator$RandomLengthGenerator

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.