Examples of RPNIUniversalLearner


Examples of statechum.analysis.learning.RPNIUniversalLearner

    final AutoAnswers semiUser = new AutoAnswers(null);
    semiUser.loadAnswers(new StringReader(
        partA
    ),config);
   
    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

Examples of statechum.analysis.learning.RPNIUniversalLearner

  public void testAuto2()
  {
    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,
          @SuppressWarnings("unused"List<Label> question, @SuppressWarnings("unused") int responseForNoRestart,
View Full Code Here

Examples of statechum.analysis.learning.RPNIUniversalLearner

  public void testAuto3()
  {
    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,
          @SuppressWarnings("unused"List<Label> question, @SuppressWarnings("unused") int responseForNoRestart,
View Full Code Here

Examples of statechum.analysis.learning.RPNIUniversalLearner

  public void testAuto4()
  {
    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,
          @SuppressWarnings("unused"List<Label> question, @SuppressWarnings("unused") int responseForNoRestart,
View Full Code Here

Examples of statechum.analysis.learning.RPNIUniversalLearner

    public RPNIVariabilityExperiment(int choice)
    {
      learnerInitConfiguration.config.setGeneralisationThreshold(0);learnerInitConfiguration.config.setAskQuestions(false);pairChoice=choice;
      if (choice == pairchoiceMAX || choice == pairchoiceMIN) rnd = null;else rnd = new Random(choice);
     
      learner = new DummyLearner(new RPNIUniversalLearner(null, learnerInitConfiguration))
      {
        @Override
        public LearnerGraph MergeAndDeterminize(LearnerGraph original, StatePair pair)
        {// Use the old and limited version to compute the merge because the general one is too slow on large graphs and we do not need either to merge arbitrary states or to handle "incompatibles".
          return super.MergeAndDeterminize(original, pair);
View Full Code Here

Examples of statechum.analysis.learning.RPNIUniversalLearner

      listOfPairsToWrite = lw;useOptimizedMerge = optimisedMerge;
      if (lc != null) listOfPairsToCheckAgainstIterator = lc.iterator();else listOfPairsToCheckAgainstIterator = null;
      final LearnerEvaluationConfiguration bfLearnerInitConfiguration = new LearnerEvaluationConfiguration(conf);bfLearnerInitConfiguration.ifthenSequences = PaperUAS.this.learnerInitConfiguration.ifthenSequences;
      config = bfLearnerInitConfiguration.config;// our config is a copy of the one supplied as an argument.
      config.setAskQuestions(false);
      learner = new DummyLearner(new RPNIUniversalLearner(null, bfLearnerInitConfiguration))
      {
        @Override
        public LearnerGraph MergeAndDeterminize(LearnerGraph original, StatePair pair)
        {
          if (useOptimizedMerge)
View Full Code Here

Examples of statechum.analysis.learning.RPNIUniversalLearner

    // now sanity checking on the plus and minus sets
    for(String [] path:plus)
      assert AbstractOracle.USER_ACCEPTED == expected.paths.tracePathPrefixClosed(AbstractLearnerGraph.buildList(Arrays.asList(path),testConfig,converter));
    for(String [] path:minus)
      assert AbstractOracle.USER_ACCEPTED != expected.paths.tracePathPrefixClosed(AbstractLearnerGraph.buildList(Arrays.asList(path),testConfig,converter));
    Learner l = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,testConfig,null,null))
    {
      @Override
      public Pair<Integer,String> CheckWithEndUser(
          @SuppressWarnings("unused"LearnerGraph model,
          List<Label> question, @SuppressWarnings("unused") int responseForNoRestart,
          @SuppressWarnings("unused") List<Boolean> acceptedElements,
          @SuppressWarnings("unused") PairScore pairBeingMerged,
          @SuppressWarnings("unused"final Object [] moreOptions)
      {
        return new Pair<Integer,String>(expected.paths.tracePathPrefixClosed(question),null);
      }
    };
    testConfig.setLearnerIdMode(IDMode.POSITIVE_NEGATIVE);
    ByteArrayOutputStream logStream = new ByteArrayOutputStream();
    RecordProgressDecorator recorder = new RecordProgressDecorator(l,logStream,1,testConfig,useZip);
    Collection<List<Label>> testSet = new LinkedList<List<Label>>();
    recorder.writeLearnerEvaluationData(new LearnerEvaluationConfiguration(expected, testSet, testConfig, null, null));
    LearnerGraph learntStructureA = recorder.learnMachine(buildSet(plus,testConfig,converter), buildSet(minus,testConfig,converter));
   
    //System.out.println("compression rate: "+recorder.getCompressionRate());
    //System.out.println(logStream.toString()+"============");
    //System.out.println(logStream.toByteArray().length);
    LearnerGraph learntMachineNoRejects = new LearnerGraph(testConfig);
    AbstractPathRoutines.removeRejectStates(learntStructureA,learntMachineNoRejects);
    Assert.assertNull(WMethod.checkM(learntMachineNoRejects, expected));
   
    switch(kind)
    {
      case RECORDERTEST_SS:
      {// matching two simulators
        final LearnerSimulator
          simulator = new LearnerSimulator(new ByteArrayInputStream(logStream.toByteArray()),useZip,converter),
          simulator2 = new LearnerSimulator(new ByteArrayInputStream(logStream.toByteArray()),useZip,converter);
       
        LearnerEvaluationConfiguration eval1 = simulator.readLearnerConstructionData(testConfig);
        Assert.assertNull(WMethod.checkM(expected, eval1.graph));
        Assert.assertEquals(testSet, eval1.testSet);
        Assert.assertEquals(expected.config, testConfig);
        LearnerEvaluationConfiguration eval2 = simulator2.readLearnerConstructionData(testConfig);
        Assert.assertNull(WMethod.checkM(expected, eval2.graph));
        Assert.assertEquals(testSet, eval2.testSet);
        Assert.assertEquals(expected.config, testConfig);
       
        new Test_LearnerComparator(simulator,simulator2,true).learnMachine(buildSet(plus,testConfig,converter), buildSet(minus,testConfig,converter));
        break;
      }
     
      case RECORDERTEST_SL:
      {// now a simulator to a learner
        final LearnerSimulator simulator = new LearnerSimulator(new ByteArrayInputStream(logStream.toByteArray()),useZip,converter);
        LearnerEvaluationConfiguration eval1 = simulator.readLearnerConstructionData(testConfig);
        Assert.assertNull(WMethod.checkM(expected, eval1.graph));
        Assert.assertEquals(testSet, eval1.testSet);
        Assert.assertEquals(expected.config, testConfig);
 
        Learner learner2 = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,expected.config,null,null))
        {
          @Override
          public Pair<Integer,String> CheckWithEndUser(
              @SuppressWarnings("unused"LearnerGraph model,
              List<Label> question, @SuppressWarnings("unused") int responseForNoRestart,
              @SuppressWarnings("unused") List<Boolean> acceptedElements,
              @SuppressWarnings("unused") PairScore pairBeingMerged,
              @SuppressWarnings("unused"final Object [] moreOptions)
          {
            return new Pair<Integer,String>(expected.paths.tracePathPrefixClosed(question),null);
          }
        };
        new Test_LearnerComparator(learner2,simulator,true).learnMachine(buildSet(plus,testConfig,converter), buildSet(minus,testConfig,converter));
        break;
      }

      case RECORDERTEST_LL:
      {// now two learners
        Learner learnerA = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,testConfig,null,null))
        {
          @Override
          public Pair<Integer,String> CheckWithEndUser(
              @SuppressWarnings("unused"LearnerGraph model,
              List<Label> question, @SuppressWarnings("unused") int responseForNoRestart,
              @SuppressWarnings("unused") List<Boolean> acceptedElements,
              @SuppressWarnings("unused") PairScore pairBeingMerged,
              @SuppressWarnings("unused"final Object [] moreOptions)
          {
            return new Pair<Integer,String>(expected.paths.tracePathPrefixClosed(question),null);
          }
        };
        Learner learnerB = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,testConfig,null,null))
        {
          @Override
          public Pair<Integer,String> CheckWithEndUser(
              @SuppressWarnings("unused"LearnerGraph model,
              List<Label> question, @SuppressWarnings("unused") int responseForNoRestart,
View Full Code Here

Examples of statechum.analysis.learning.RPNIUniversalLearner

      int size = 4*graph.getStateNumber();
      RandomPathGenerator rpg = new RandomPathGenerator(graph, new Random(100),5);// 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<String> question, @SuppressWarnings("unused") int valueForNoRestart,
View Full Code Here

Examples of statechum.analysis.learning.RPNIUniversalLearner

    // now sanity checking on the plus and minus sets
    for(String [] path:plus)
      assert AbstractOracle.USER_ACCEPTED == expected.paths.tracePath(Arrays.asList(path));
    for(String [] path:minus)
      assert AbstractOracle.USER_ACCEPTED != expected.paths.tracePath(Arrays.asList(path));
    Learner l = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,testConfig,null,null))
    {
      @Override
      public Pair<Integer,String> CheckWithEndUser(
          @SuppressWarnings("unused"LearnerGraph model,
          List<String> question, @SuppressWarnings("unused") int responseForNoRestart,
          @SuppressWarnings("unused"final Object [] moreOptions)
      {
        return new Pair<Integer,String>(expected.paths.tracePath(question),null);
      }
    };
    testConfig.setLearnerIdMode(IDMode.POSITIVE_NEGATIVE);
    ByteArrayOutputStream logStream = new ByteArrayOutputStream();
    RecordProgressDecorator recorder = new RecordProgressDecorator(l,logStream,1,testConfig,useZip);
    Collection<List<String>> testSet = new LinkedList<List<String>>();
    recorder.writeLearnerEvaluationData(new LearnerEvaluationConfiguration(expected, testSet, testConfig, null, null));
    LearnerGraph learntStructureA = recorder.learnMachine(buildSet(plus), buildSet(minus));
   
    //System.out.println("compression rate: "+recorder.getCompressionRate());
    //System.out.println(logStream.toString()+"============");
    //System.out.println(logStream.toByteArray().length);
    LearnerGraph learntMachineNoRejects = new LearnerGraph(testConfig);
    AbstractPathRoutines.removeRejectStates(learntStructureA,learntMachineNoRejects);
    Assert.assertNull(WMethod.checkM(learntMachineNoRejects, expected));
   
    switch(kind)
    {
      case RECORDERTEST_SS:
      {// matching two simulators
        final LearnerSimulator
          simulator = new LearnerSimulator(new ByteArrayInputStream(logStream.toByteArray()),useZip),
          simulator2 = new LearnerSimulator(new ByteArrayInputStream(logStream.toByteArray()),useZip);
       
        LearnerEvaluationConfiguration eval1 = simulator.readLearnerConstructionData();
        Assert.assertNull(WMethod.checkM(expected, eval1.graph));
        Assert.assertEquals(testSet, eval1.testSet);
        Assert.assertEquals(expected.config, testConfig);
        LearnerEvaluationConfiguration eval2 = simulator2.readLearnerConstructionData();
        Assert.assertNull(WMethod.checkM(expected, eval2.graph));
        Assert.assertEquals(testSet, eval2.testSet);
        Assert.assertEquals(expected.config, testConfig);
       
        new Test_LearnerComparator(simulator,simulator2,true).learnMachine(buildSet(plus), buildSet(minus));
        break;
      }
     
      case RECORDERTEST_SL:
      {// now a simulator to a learner
        final LearnerSimulator simulator = new LearnerSimulator(new ByteArrayInputStream(logStream.toByteArray()),useZip);
        LearnerEvaluationConfiguration eval1 = simulator.readLearnerConstructionData();
        Assert.assertNull(WMethod.checkM(expected, eval1.graph));
        Assert.assertEquals(testSet, eval1.testSet);
        Assert.assertEquals(expected.config, testConfig);
 
        Learner learner2 = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,expected.config,null,null))
        {
          @Override
          public Pair<Integer,String> CheckWithEndUser(
              @SuppressWarnings("unused"LearnerGraph model,
              List<String> question, @SuppressWarnings("unused") int responseForNoRestart,
              @SuppressWarnings("unused"final Object [] moreOptions)
          {
            return new Pair<Integer,String>(expected.paths.tracePath(question),null);
          }
        };
        new Test_LearnerComparator(learner2,simulator,true).learnMachine(buildSet(plus), buildSet(minus));
        break;
      }

      case RECORDERTEST_LL:
      {// now two learners
        Learner learnerA = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,testConfig,null,null))
        {
          @Override
          public Pair<Integer,String> CheckWithEndUser(
              @SuppressWarnings("unused"LearnerGraph model,
              List<String> question, @SuppressWarnings("unused") int responseForNoRestart,
              @SuppressWarnings("unused"final Object [] moreOptions)
          {
            return new Pair<Integer,String>(expected.paths.tracePath(question),null);
          }
        };
        Learner learnerB = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,testConfig,null,null))
        {
          @Override
          public Pair<Integer,String> CheckWithEndUser(
              @SuppressWarnings("unused"LearnerGraph model,
              List<String> question, @SuppressWarnings("unused") int responseForNoRestart,
View Full Code Here

Examples of statechum.analysis.learning.RPNIUniversalLearner

    public static void main(String[] args) {
        QSMTool tool = new QSMTool();
        tool.loadConfig(args[0]);
        if (tool.showLTL) {
            Learner l = new RPNIUniversalLearner(null, tool.learnerInitConfiguration);
            LTL_to_ba ba = new LTL_to_ba(tool.learnerInitConfiguration.config, tool.learnerInitConfiguration.getLabelConverter());
            if (ba.ltlToBA(tool.learnerInitConfiguration.ifthenSequences, l.init(tool.sPlus, tool.sMinus), true,
                    GlobalConfiguration.getConfiguration().getProperty(GlobalConfiguration.G_PROPERTIES.LTL2BA))) {
                try {
                    LearnerGraph graph = Transform.ltlToIfThenAutomaton(ba.getLTLgraph().pathroutines.buildDeterministicGraph());
                    DirectedSparseGraph gr = graph.pathroutines.getGraph();
                    PathRoutines.convertPairAssociationsToTransitions(gr, graph, tool.learnerInitConfiguration.config,tool.learnerInitConfiguration.getLabelConverter());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.