Package statechum.analysis.learning.observers.ProgressDecorator

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


  /** For a maximal automaton, a reject-path overrides an accept-one. This is a test with a single-state graph. */
  @Test
  public void testPTAconstruction_singleRejectState_max()
  {
    Configuration config = mainConfiguration.copy();
    RPNIUniversalLearner l = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,config,null,null));
    config.setLearnerIdMode(Configuration.IDMode.POSITIVE_NEGATIVE);
    l.getTentativeAutomaton().initPTA();
    for(List<Label> sequence:buildSet(new String[][] { new String[]{} },config,converter))
      l.getTentativeAutomaton().paths.augmentPTA(sequence, false,true,null);
    for(List<Label> sequence:buildSet(new String[][] { },config,converter))
View Full Code Here


    }

    try
    {
      Configuration config = mainConfiguration.copy();
      RPNIUniversalLearner l = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,config,null,null));
      config.setLearnerIdMode(Configuration.IDMode.POSITIVE_NEGATIVE);
      l.init(plusStrings, minusStrings);
      actualC = l.getTentativeAutomaton();
    }
    catch(IllegalArgumentException e)
    {
      // ignore this - it might be expected.
      eC = e;
    }
   
    try
    {
      Configuration config = mainConfiguration.copy();
      RPNIUniversalLearner l = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,config,null,null));
      config.setLearnerIdMode(Configuration.IDMode.POSITIVE_NEGATIVE);
      PTASequenceEngine engine = buildPTA(plusStrings, minusStrings);
      checkPTAConsistency(engine, plusStrings, true);if (engine.numberOfLeafNodes()>0) checkPTAConsistency(engine, minusStrings, false);
      l.init(engine,0,0);
      actualD = l.getTentativeAutomaton();
    }
    catch(IllegalArgumentException e)
    {
      // ignore this - it might be expected.
      eD = e;
    }

    try
    {
      Configuration config = mainConfiguration.copy();
      RPNIUniversalLearner l = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,config,null,null));
      config.setLearnerIdMode(Configuration.IDMode.POSITIVE_NEGATIVE);
      l.init(buildPTA(plusStrings, buildSet(new String[][] {},config,converter)),0,0);
      for(List<Label> seq:minusStrings)
      {  Set<List<Label>> negativeSeq = new HashSet<List<Label>>();negativeSeq.add(seq);
        l.getTentativeAutomaton().paths.augmentPTA(buildPTA(buildSet(new String[][] {},config,converter),negativeSeq));
      }
      actualE = l.getTentativeAutomaton();
    }
    catch(IllegalArgumentException e)
    {
      // ignore this - it might be expected.
      eE = e;
    }

    try
    {
      Configuration config = mainConfiguration.copy();
      RPNIUniversalLearner l = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,config,null,null));
      config.setLearnerIdMode(Configuration.IDMode.POSITIVE_NEGATIVE);
      l.getTentativeAutomaton().initPTA();
      l.getTentativeAutomaton().paths.augmentPTA(minusStrings, false,true);
      l.getTentativeAutomaton().paths.augmentPTA(plusStrings, true,true);
      actualF = l.getTentativeAutomaton();
View Full Code Here

    for(boolean max:new boolean[]{true,false})
    {
      final boolean maxAutomaton = max;
      Configuration config = mainConfiguration.copy();
      final RPNIUniversalLearner l = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,config,null,null));
      config.setLearnerIdMode(Configuration.IDMode.POSITIVE_NEGATIVE);
      l.getTentativeAutomaton().initPTA();
      l.getTentativeAutomaton().paths.augmentPTA(minusStrings, false,maxAutomaton);
      l.getTentativeAutomaton().paths.augmentPTA(plusStrings, true,maxAutomaton);
     
View Full Code Here

    SquareBagPlot gr_diff_to_f = new SquareBagPlot("f-measure","diff-based measure",new File("diff-to-f.pdf"),0,1,true);

    Set<Integer> allFrames = collectionOfTraces.get(UAVAllSeeds).tracesForUAVandFrame.get(UAVAllSeeds).keySet();
    Classifier classifiers[] = loadClassifierFromArff(arffName);
    ProgressIndicator progress = new ProgressIndicator("UAS", allFrames.size()*classifiers.length);
    LearnerEvaluationConfiguration initConfiguration = new LearnerEvaluationConfiguration(learnerInitConfiguration.config);
    initConfiguration.setLabelConverter(learnerInitConfiguration.getLabelConverter());// we do not copy if-then automata here because we do not wish to augment from if-then on every iteration because our properties are pairwise and this permits augmentation to be carried out first thing and not any more.
    initConfiguration.config.setUseConstraints(false);// do not use if-then during learning (refer to the explanation above)
   
    LearnerGraph [] ifthenAutomata = Transform.buildIfThenAutomata(learnerInitConfiguration.ifthenSequences, null, referenceGraph, learnerInitConfiguration.config, learnerInitConfiguration.getLabelConverter()).toArray(new LearnerGraph[0]);
    System.out.println(new Date().toString()+" learning commencing.");
    final Integer frame=6;
      //for(final Integer frame:allFrames)
      {
        LearnerGraph initPTA = new LearnerGraph(initConfiguration.config);initPTA.paths.augmentPTA(collectionOfTraces.get(UAVAllSeeds).tracesForUAVandFrame.get(UAVAllSeeds).get(frame));
        Transform.augmentFromIfThenAutomaton(initPTA, null, ifthenAutomata, initConfiguration.config.getHowManyStatesToAddFromIFTHEN());// we only need  to augment our PTA once (refer to the explanation above).
        System.out.println("total states : "+initPTA.getStateNumber()+", "+initPTA.getAcceptStateNumber()+" accept-states");

        final Set<Label> alphabetForIfThen = referenceGraph.pathroutines.computeAlphabet();
        Label uniqueLabel = AbstractLearnerGraph.generateNewLabel("Waypoint_Selected", initConfiguration.config,initConfiguration.getLabelConverter());

        /*
        for(int i=0;i<classifiers.length;++i)
        {
          {
View Full Code Here

   }

   public LearnerGraph writeArff(final int ifDepth, LearnerGraph referenceGraph, String whereToWrite) throws Exception
  {
   
    LearnerEvaluationConfiguration initConfiguration = new LearnerEvaluationConfiguration(learnerInitConfiguration.config);
    initConfiguration.setLabelConverter(learnerInitConfiguration.getLabelConverter());// we do not copy if-then automata here because we do not wish to augment from if-then on every iteration because our properties are pairwise and this permits augmentation to be carried out first thing and not any more.
      LearnerGraph initialPTA = new LearnerGraph(initConfiguration.config);
    initialPTA.paths.augmentPTA(collectionOfTraces.get(UAVAllSeeds).tracesForUAVandFrame.get(UAVAllSeeds).get(maxFrameNumber));
    /*
    try {
      initialPTA.storage.writeGraphML("resources/automaton_to_learn_arff_from.xml");
    } catch (IOException e1) {
      e1.printStackTrace();
    }
    */
    LearnerGraph [] ifthenAutomata = Transform.buildIfThenAutomata(learnerInitConfiguration.ifthenSequences, null, referenceGraph, initConfiguration.config, initConfiguration.getLabelConverter()).toArray(new LearnerGraph[0]);
    initConfiguration.config.setUseConstraints(false);// do not use if-then during learning (refer to the explanation above)
   
    System.out.println(new Date().toString()+" Graph loaded: "+initialPTA.getStateNumber()+" states, adding at most "+ initConfiguration.config.getHowManyStatesToAddFromIFTHEN()+" if-then states");
    Transform.augmentFromIfThenAutomaton(initialPTA, null, ifthenAutomata, initConfiguration.config.getHowManyStatesToAddFromIFTHEN());// we only need  to augment our PTA once (refer to the explanation above).
    System.out.println(new Date().toString()+" if-then states added, now "+initialPTA.getStateNumber()+" states");
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

*/
public class Test_CheckLearnerAgainstLog {
  public void check(String logFileName) throws FileNotFoundException
  {
    final LearnerSimulator simulator = new LearnerSimulator(new java.io.FileInputStream(logFileName),true);
    final LearnerEvaluationConfiguration eval1 = simulator.readLearnerConstructionData();
    final org.w3c.dom.Element nextElement = simulator.expectNextElement(ELEM_KINDS.ELEM_INIT.name());
    final ProgressDecorator.InitialData initial = simulator.readInitialData(nextElement);
    simulator.setNextElement(nextElement);
    RPNIBlueFringeLearner learner2 = new RPNIBlueFringeLearnerTestComponentOpt(null,eval1.config)
    {
View Full Code Here

 
  @Test
  public void TestConstructIfThenForInfeasible3()
  {
    LearnerGraph graph = FsmParser.buildLearnerGraph("A-b->A-a->B-a->C-a->A / D-e->D", "TestConstructPairsOfInfeasibleTransitions3", mainConfiguration,converter);
    LearnerEvaluationConfiguration evaluationConfiguration = new LearnerEvaluationConfiguration(mainConfiguration);
    PairQualityLearner.addIfThenForPairwiseConstraints(evaluationConfiguration, PairQualityLearner.computeInfeasiblePairs(graph));
    Assert.assertEquals(3,evaluationConfiguration.ifthenSequences.size());
    Iterator<String> ifthenIterator = evaluationConfiguration.ifthenSequences.iterator();
    Assert.assertEquals(QSMTool.cmdIFTHENAUTOMATON +" "+PairQualityLearner.pairwiseAutomata+"_a A- !a ->A-a->B - a ->B / B- !a ->A / C -e-#D/ B == THEN == C",ifthenIterator.next());
    Assert.assertEquals(QSMTool.cmdIFTHENAUTOMATON +" "+PairQualityLearner.pairwiseAutomata+"_b A- !b ->A-b->B - b ->B / B- !b ->A / C -e-#D/ B == THEN == C",ifthenIterator.next());
View Full Code Here

      {// 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();
        TestFSMAlgo.checkM(expected, new FSMStructure(eval1.graph,null));
        Assert.assertEquals(testSet, eval1.testSet);
        LearnerEvaluationConfiguration eval2 = simulator2.readLearnerConstructionData();
        TestFSMAlgo.checkM(expected, new FSMStructure(eval2.graph,null));
        Assert.assertEquals(testSet, eval2.testSet);
       
        new Test_LearnerComparator(simulator,simulator2,false).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();
        TestFSMAlgo.checkM(expected, new FSMStructure(eval1.graph,null));
        Assert.assertEquals(testSet, eval1.testSet);
 
        RPNIBlueFringeLearnerTestComponentOpt learner2 = new RPNIBlueFringeLearnerTestComponentOpt(null)
        {
View Full Code Here

          }
        }
      }
      while(pickUniqueFromInitial && uniqueFromInitial == null);
     
      LearnerEvaluationConfiguration learnerEval = new LearnerEvaluationConfiguration(config);learnerEval.setLabelConverter(converter);
      final Collection<List<Label>> testSet = PaperUAS.computeEvaluationSet(referenceGraph,states*3,states*alphabet);
     
      for(int attempt=0;attempt<2;++attempt)
      {// try learning the same machine a few times
        LearnerGraph pta = new LearnerGraph(config);
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.