Package statechum.analysis.learning.observers.ProgressDecorator

Examples of statechum.analysis.learning.observers.ProgressDecorator.LearnerEvaluationConfiguration


    Assert.assertEquals(18,locker.pathroutines.countEdges());
  }

  public void testExporterLearning(Configuration configToUse)
  {
    LearnerEvaluationConfiguration learnerConfig = new LearnerEvaluationConfiguration(configToUse);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);
    learner.GenerateInitialTraces();
    LearnerGraph exporter = learner.learnMachine();
View Full Code Here


      {
        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
          public Integer call() throws Exception {
            ErlangRuntime newRuntime = new ErlangRuntime();newRuntime.startRunner();
            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);
            learner.init(initialTracesLockerFinal, 0, 0);
           
            Assert.assertEquals(237,learner.getTentativeAutomaton().getStateNumber());
            Assert.assertEquals(11,learner.getTentativeAutomaton().pathroutines.computeAlphabet().size());
            Assert.assertEquals(236,learner.getTentativeAutomaton().pathroutines.countEdges());
            LearnerGraph locker = learner.learnMachine();
            Assert.assertEquals(6,locker.getStateNumber());
            Assert.assertEquals(11,locker.pathroutines.computeAlphabet().size());
            Assert.assertEquals(51,locker.pathroutines.countEdges());
           
            return 0;
          }});
        runner.submit(new Callable<Integer>(){
 
          @Override
          public Integer call() throws Exception {
            ErlangRuntime newRuntime = new ErlangRuntime();newRuntime.startRunner();
            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);
            learner.init(initialTracesExporterFinal,0,0);
            LearnerGraph exporter = learner.learnMachine();
View Full Code Here

 
  @Test
  /** Tests that types of functions can be overridden, rather important for testing using OTP15 where typer works rather better than in OTP16. */
  public void testLearnFrequencyServer() throws IOException
  {
    LearnerEvaluationConfiguration learnerConfig = new LearnerEvaluationConfiguration(config);
    ErlangModule.setupErlangConfiguration(learnerConfig.config,new File(ErlangExamples+"/frequency/frequencyBroken.erl"));
    learnerConfig.config.setErlangAlphabetAnyElements(EXPANSIONOFANY.ANY_WIBBLE);learnerConfig.config.setTransitionMatrixImplType(STATETREE.STATETREE_SLOWTREE);
    learnerConfig.config.setErlangInitialTraceLength(3);
    learnerConfig.config.setErlangStripModuleNamesFromFunctionsInNonGenModules(true);
   
    ErlangModule mod = ErlangModule.loadModule(learnerConfig.config);
    OtpErlangTuple startFunType=mod.sigTypes.get("frequencyBroken:start/0");
    Map<String,OtpErlangTuple> override = new TreeMap<String,OtpErlangTuple>();
    override.put("frequencyBroken:start/0", new OtpErlangTuple(new OtpErlangObject[]{startFunType.elementAt(0),startFunType.elementAt(1),startFunType.elementAt(2),startFunType.elementAt(3),
        ErlangLabel.parseText("{'Func',[],[],{'Any',[]}}")}));
    mod.rebuildSigs(learnerConfig.config, override);
    mod.behaviour.generateAlphabet(config);
    ErlangOracleLearner learner = new ErlangOracleLearner(null,learnerConfig);
    LearnerGraph frequencyE = new LearnerGraph(learnerConfig.config);
    learner.init(learner.GenerateInitialTraces(learnerConfig.config.getErlangInitialTraceLength()),0,0);
   
    LearnerGraph frequencyRaw = learner.learnMachine();
    Synapse.StatechumProcess.convertLabelsToStrings(frequencyRaw, frequencyE);
    config.setLabelKind(LABELKIND.LABEL_STRING);config.setTransitionMatrixImplType(STATETREE.STATETREE_SLOWTREE);
    LearnerGraph frequency = new LearnerGraph(config);Synapse.StatechumProcess.parseStatemachine(Synapse.StatechumProcess.constructFSM(frequencyE), frequency, null, true);
    //System.out.println(Synapse.StatechumProcess.constructFSM(frequencyE).elementAt(2));
    LearnerGraph freq2=new LearnerGraph(config);
    Synapse.StatechumProcess.parseStatemachine(ErlangLabel.parseText("{statemachine,['P1000','N1000','P1001','P1002','P1005'],["+
"{'P1000','allocate/0,[],{ok,\\'AnyWibble\\'}','N1000'},"+
"{'P1000','allocate/0,[],{ok,\\'WibbleA\\'}','N1000'},"+
"{'P1000','allocate/0,[],{ok,\\'WobbleA\\'}','N1000'},"+
"{'P1000','deallocate/1,[\\'AnyWibble\\'],\\'AnyWibble\\'','N1000'},"+
"{'P1000','deallocate/1,[\\'AnyWibble\\'],ok','N1000'},"+
"{'P1000','init/0,[],{reply,ok}','N1000'},"+
"{'P1000','init/0,[],{reply,{ok,\\'AnyWibble\\'}}','N1000'},"+
"{'P1000','start/0,[],\\'AnyWibble\\'','N1000'},"+
"{'P1000','start/0,[],true','P1001'},"+
"{'P1000','stop/0,[],\\'AnyWibble\\'','N1000'},"+
"{'P1000','stop/0,[],ok','N1000'},"+
"{'P1001','allocate/0,[],{ok,\\'AnyWibble\\'}','N1000'},"+
"{'P1001','allocate/0,[],{ok,\\'WibbleA\\'}','P1002'},"+
"{'P1001','allocate/0,[],{ok,\\'WobbleA\\'}','N1000'},"+
"{'P1001','deallocate/1,[\\'AnyWibble\\'],\\'AnyWibble\\'','N1000'},"+
"{'P1001','deallocate/1,[\\'AnyWibble\\'],ok','P1001'},"+
"{'P1001','init/0,[],{reply,ok}','N1000'},"+
"{'P1001','init/0,[],{reply,{ok,\\'AnyWibble\\'}}','N1000'},"+
"{'P1001','start/0,[],\\'AnyWibble\\'','N1000'},"+
"{'P1001','start/0,[],true','N1000'},"+
"{'P1001','stop/0,[],\\'AnyWibble\\'','N1000'},"+
"{'P1001','stop/0,[],ok','P1000'},"+
"{'P1002','allocate/0,[],{ok,\\'AnyWibble\\'}','N1000'},"+
"{'P1002','allocate/0,[],{ok,\\'WibbleA\\'}','N1000'},"+
"{'P1002','allocate/0,[],{ok,\\'WobbleA\\'}','P1005'},"+
"{'P1002','deallocate/1,[\\'AnyWibble\\'],\\'AnyWibble\\'','N1000'},"+
"{'P1002','deallocate/1,[\\'AnyWibble\\'],ok','P1002'},"+
"{'P1002','init/0,[],{reply,ok}','N1000'},"+
"{'P1002','init/0,[],{reply,{ok,\\'AnyWibble\\'}}','N1000'},"+
"{'P1002','start/0,[],\\'AnyWibble\\'','N1000'},"+
"{'P1002','start/0,[],true','N1000'},"+
"{'P1002','stop/0,[],\\'AnyWibble\\'','N1000'},"+
"{'P1002','stop/0,[],ok','P1000'},"+
"{'P1005','allocate/0,[],{ok,\\'AnyWibble\\'}','N1000'},"+
"{'P1005','allocate/0,[],{ok,\\'WibbleA\\'}','N1000'},"+
"{'P1005','allocate/0,[],{ok,\\'WobbleA\\'}','N1000'},"+
"{'P1005','init/0,[],{reply,ok}','N1000'},"+
"{'P1005','init/0,[],{reply,{ok,\\'AnyWibble\\'}}','N1000'},"+
"{'P1005','start/0,[],\\'AnyWibble\\'','N1000'},"+
"{'P1005','start/0,[],true','N1000'},"+
"{'P1005','stop/0,[],\\'AnyWibble\\'','N1000'},"+
"{'P1005','stop/0,[],ok','P1000'}"+
"],"+
"'P1000',"+
"['init/0,[],{reply,{ok,\\'AnyWibble\\'}}','deallocate/1,[\\'AnyWibble\\'],\\'AnyWibble\\'','stop/0,[],ok','stop/0,[],\\'AnyWibble\\'','start/0,[],\\'AnyWibble\\'','allocate/0,[],{ok,\\'WibbleA\\'}','start/0,[],true','deallocate/1,[\\'AnyWibble\\'],ok','init/0,[],{reply,ok}','allocate/0,[],{ok,\\'WobbleA\\'}','allocate/0,[],{ok,\\'AnyWibble\\'}']"+
        "}"),
        freq2,learnerConfig.getLabelConverter(),true);
   
    DifferentFSMException ex = WMethod.checkM(frequency, freq2);
    if (ex != null)
      Assert.assertNull(ex.getMessage(),ex);
    Assert.assertEquals(frequency.getStateNumber(),freq2.getStateNumber());
View Full Code Here

    for(String [] path:plus)
      assert AbstractOracle.USER_ACCEPTED == expected.paths.tracePathPrefixClosed(AbstractLearnerGraph.buildList(Arrays.asList(path),config,getLabelConverter()));
    for(String [] path:minus)
      assert AbstractOracle.USER_ACCEPTED != expected.paths.tracePathPrefixClosed(AbstractLearnerGraph.buildList(Arrays.asList(path),config,getLabelConverter()));
    // Visualiser.getVisualiser()
    Learner l = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,testConfig,null,null))
    {
      @Override
      public LearnerGraph MergeAndDeterminize(LearnerGraph original, StatePair pair)
      {
        // Check that compatibility score computation gives the same response as if we did merge and computed a difference between the number of states.
View Full Code Here

      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,
View Full Code Here

  {
    try {
      Configuration config = Configuration.getDefaultConfiguration().copy();
      final java.io.FileInputStream inputStream = new java.io.FileInputStream(logFileName);
      final LearnerSimulator simulator = new LearnerSimulator(inputStream,true,null);// not using a converter
      final LearnerEvaluationConfiguration evalData = simulator.readLearnerConstructionData(config);
      final org.w3c.dom.Element nextElement = simulator.expectNextElement(StatechumXML.ELEM_INIT.name());
      final ProgressDecorator.InitialData initial = simulator.readInitialData(nextElement);
      simulator.setNextElement(nextElement);
 
      RPNILearner learner2 = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,evalData.config,null,null))
      {
        @Override
        public Pair<Integer,String> CheckWithEndUser(
            @SuppressWarnings("unused"LearnerGraph model,
            List<Label> question,  @SuppressWarnings("unused") int answerForNoRestart,
View Full Code Here

    final java.io.FileInputStream inputStream = new java.io.FileInputStream(logFileName);
    final LearnerSimulator simulator = new LearnerSimulator(inputStream,true,null);
    Configuration config = Configuration.getDefaultConfiguration().copy();
    config.setLegacyXML(true);
    final LearnerEvaluationConfiguration evalData = simulator.readLearnerConstructionData(config);
    evalData.config.setTransitionMatrixImplType(STATETREE.STATETREE_SLOWTREE);
   
    // Now we need to choose learner parameters based on the kind of file we are given
    // (given the pace of Statechum evolution, I cannot expect all the correct options
    // to be stored in log files).
    evalData.config.setScoreCompatibilityScoreComputationBugEmulation(true);
    if (logFileName.contains(Configuration.LEARNER.LEARNER_BLUEFRINGE_MAY2008.name()))
    {
      evalData.config.setUseAmber(false);evalData.config.setUseLTL(false);
      evalData.config.setSpeculativeQuestionAsking(false);
      evalData.config.setIgnoreDepthInTheChoiceOfRepresentatives(true);evalData.config.setIgnoreVertexAttributesInLogReplay(true);
    }
    else    
      if (logFileName.contains(Configuration.LEARNER.LEARNER_BLUEAMBER_MAY2008.name()))
      {
        evalData.config.setUseAmber(true);evalData.config.setUseLTL(false);
        evalData.config.setSpeculativeQuestionAsking(false);
        evalData.config.setIgnoreDepthInTheChoiceOfRepresentatives(true);evalData.config.setIgnoreVertexAttributesInLogReplay(true);
      }
      else
        if (logFileName.contains(Configuration.LEARNER.LEARNER_BLUEFRINGE_DEC2007.name()))
        {// we'd like to make sure that the initial configuration is loaded with the correct configuration values.
          evalData.config.setInitialIDvalue(1);
          VertexID.comparisonKind = ComparisonKind.COMPARISON_LEXICOGRAPHIC_ORIG;
          evalData.config.setUseAmber(false);evalData.config.setUseLTL(false);
          evalData.config.setSpeculativeQuestionAsking(false);
          evalData.config.setDefaultInitialPTAName("Init");
          evalData.config.setIgnoreDepthInTheChoiceOfRepresentatives(true);evalData.config.setIgnoreVertexAttributesInLogReplay(true);
        }
        else
          Assert.fail("unknown type of log file");

    final org.w3c.dom.Element nextElement = simulator.expectNextElement(StatechumXML.ELEM_INIT.name());
    final ProgressDecorator.InitialData initial = simulator.readInitialData(nextElement);
    if (evalData.labelDetails != null)
    {
      initial.plus.addAll(evalData.labelDetails.getSPlus());initial.minus.addAll(evalData.labelDetails.getSMinus());
    }
    simulator.setNextElement(nextElement);

    Learner learner2 = null;

    if (logFileName.contains(Configuration.LEARNER.LEARNER_BLUEFRINGE_DEC2007.name()))
    {// have to patch the learner.
     
      learner2 = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,evalData.config,null,null))
      {
        /* (non-Javadoc)
         * @see statechum.analysis.learning.observers.DummyLearner#init(java.util.Collection, java.util.Collection)
         */
        @Override
        public LearnerGraph init(Collection<List<Label>> plus,  Collection<List<Label>> minus)
        {
          return super.init(plus, minus);
        }

        /* (non-Javadoc)
         * @see statechum.analysis.learning.RPNIUniversalLearner#ComputeQuestions(statechum.analysis.learning.PairScore, statechum.analysis.learning.rpnicore.LearnerGraph, statechum.analysis.learning.rpnicore.LearnerGraph)
         */
        @Override
        public List<List<Label>> ComputeQuestions(PairScore pair,  LearnerGraph original, LearnerGraph tempNew)
        {
          return ArrayOperations.sort(ComputeQuestions.computeQS_origReduced(pair,original,tempNew));
        }

        /* (non-Javadoc)
         * @see statechum.analysis.learning.RPNIUniversalLearner#MergeAndDeterminize(statechum.analysis.learning.rpnicore.LearnerGraph, statechum.analysis.learning.StatePair)
         */
        @Override
        public LearnerGraph MergeAndDeterminize(LearnerGraph original,  StatePair pair)
        {
          return MergeStates.mergeAndDeterminize(original,pair);
        }
       
        @Override
        public Pair<Integer,String> CheckWithEndUser(
            @SuppressWarnings("unused"LearnerGraph model,
            List<Label> question, @SuppressWarnings("unused") int answerForNoRestart,
            @SuppressWarnings("unused") List<Boolean> acceptedElements,
            @SuppressWarnings("unused") PairScore pairBeingMerged,
            @SuppressWarnings("unused"final Object [] moreOptions)
          {
            return new Pair<Integer,String>(evalData.graph.paths.tracePathPrefixClosed(question),null);
          }
       
        @Override
        public void AugumentPTA_and_QuestionPTA(LearnerGraph pta, RestartLearningEnum ptaKind,
            List<Label> sequence, boolean accepted, JUConstants newColour)
        {
          topLevelListener.AugmentPTA(pta, ptaKind, sequence, accepted, newColour);
        }
      };
       
    }
    else
    if (logFileName.contains(Configuration.LEARNER.LEARNER_BLUEFRINGE_MAY2008.name()) ||
        logFileName.contains(Configuration.LEARNER.LEARNER_BLUEAMBER_MAY2008.name())
     )
    {// have to patch the learner.
     
      learner2 = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,evalData.config,null,null))
      {
        /* (non-Javadoc)
         * @see statechum.analysis.learning.observers.DummyLearner#init(java.util.Collection, java.util.Collection)
         */
        @Override
 
View Full Code Here

      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,
View Full Code Here

        java.io.FileInputStream is = null;java.io.FileOutputStream os = null;
        try
        {
          is = new java.io.FileInputStream(sourceFile);
          LearnerSimulator simulator = new LearnerSimulator(is,true,null);// not using a converter
          LearnerEvaluationConfiguration evaluationData = simulator.readLearnerConstructionData(null);
          evaluationData.config.setGdFailOnDuplicateNames(false);evaluationData.graphNumber=graphsInFile;
          final org.w3c.dom.Element nextElement = simulator.expectNextElement(StatechumXML.ELEM_INIT.name());
          final ProgressDecorator.InitialData initial = simulator.readInitialData(nextElement);
          simulator.setNextElement(nextElement);
          Configuration recorderConfig = evaluationData.config.copy();recorderConfig.setCompressLogs(true);recorderConfig.setGdMaxNumberOfStatesInCrossProduct(0);
View Full Code Here

    //Visualiser.updateFrame(new LearnerGraph(FsmParser.buildGraph("A-e->A-c->B-b->C-p->G-e->A\nB-a->D-a->E-a->D\nE-b->F-p->G\n"+
    //"B-e->A\nC-e->A\nD-e->A\nE-e->A\nF-e->A\nG-e->A\n","testAutoAnswers0"),Configuration.getDefaultConfiguration()),null);
    config.setGdFailOnDuplicateNames(false);
    config.setLearnerIdMode(IDMode.POSITIVE_NEGATIVE);

    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 responseForNoRestart,
View Full Code Here

TOP

Related Classes of statechum.analysis.learning.observers.ProgressDecorator.LearnerEvaluationConfiguration

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.