Package statechum.analysis.learning.rpnicore

Examples of statechum.analysis.learning.rpnicore.LearnerGraph


        questions = trimSet(questions);
        Iterator<List<String>> questionIt = questions.iterator();
        while(questionIt.hasNext()){
          List<String> question = questionIt.next();
          boolean accepted = DeterministicDirectedSparseGraph.isAccept(pair.getQ());// Q is the blue vertex
          Pair<Integer,String> response = checkWithEndUser(new LearnerGraph(model,Configuration.getDefaultConfiguration()),question,new Object[0]);// zero means "yes", everything else is "no"
          questionCounter++;
          pair.getQ().removeUserDatum(JUConstants.HIGHLIGHT);
          pair.getR().removeUserDatum(JUConstants.HIGHLIGHT);
          if(response.firstElem == USER_ACCEPTED){
            sPlus.add(question);
View Full Code Here


    config.setAttenuationK(0.333);// make sure this configuration is different from the default one.
    Assert.assertFalse(config.getAttenuationK() == defaultK);// and make sure that the two are indeed not the same.
    anotherconfig = Configuration.getDefaultConfiguration().copy();
    Assert.assertFalse(config.equals(anotherconfig));
   
    graph = new LearnerGraph(FsmParser.buildGraph("A-a->A-b->B-a->C", "TestWriteReadLearnerEvaluation"),config);
    testData = TestFSMAlgo.buildList(new String[][]{
        new String[]{ "a","this is a test","3"},
        new String[]{},
        new String[]{"more data"}
    });
View Full Code Here

  public final void testLearnerEvaluation5()
  {
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    RecordProgressDecorator dumper = new RecordProgressDecorator(null,output,1,Configuration.getDefaultConfiguration(),false);
    Element learnerConfig = dumper.writeLearnerEvaluationConfiguration(new LearnerEvaluationConfiguration(graph,testData,anotherconfig,ltl,labels));
    learnerConfig.appendChild(new LearnerGraph(FsmParser.buildGraph("A-a->A", "testLoadInit_fail7"),Configuration.getDefaultConfiguration())
    .storage.createGraphMLNode(dumper.doc));
    dumper.topElement.appendChild(learnerConfig);dumper.close();xmlData = output.toString();
   
    final LearnerSimulator loader = new LearnerSimulator(new ByteArrayInputStream(xmlData.getBytes()),false);
    checkForCorrectException(new whatToRun() { public @Override void run() {
View Full Code Here

  }
 
  public static LearnerGraph mergeStatesForUnique(LearnerGraph pta, Label unique)
  {
    List<StatePair> pairs = new LinkedList<StatePair>();
    LearnerGraph sourcePta = new LearnerGraph(pta,pta.config);
    List<CmpVertex> whatToMerge = constructPairsToMergeWithOutgoing(sourcePta,unique);
    for(CmpVertex vert:whatToMerge)
      pairs.add(new StatePair(sourcePta.getInit(),vert));
    List<AMEquivalenceClass<CmpVertex,LearnerGraphCachedData>> verticesToMerge = new ArrayList<AMEquivalenceClass<CmpVertex,LearnerGraphCachedData>>();
   
    if (sourcePta.pairscores.computePairCompatibilityScore_general(null, pairs, verticesToMerge) < 0)
      throw new IllegalArgumentException("failed to merge states corresponding to a unique outgoing transition "+unique);
    LearnerGraph outcome = MergeStates.mergeCollectionOfVertices(sourcePta, null, verticesToMerge);
    outcome.pathroutines.updateDepthLabelling();
    return outcome;
  }
View Full Code Here

    */

    @Override
    public LearnerGraph init(Collection<List<Label>> plus,  Collection<List<Label>> minus)
    {
      LearnerGraph graph = super.init(plus,minus);
      LearnerGraph.copyGraphs(initialPTA, graph);
      return initialPTA;
    }
View Full Code Here

   * @return graph loaded from XML file.
   */
  @Override
  public synchronized LearnerGraph MergeAndDeterminize(LearnerGraph original, StatePair pair)
  {
    LearnerGraph result = null, copyOfResult = null;
    // First, we call the expected method
    if (Thread.currentThread() == secondThread)
    {
      result = whatToCompareWith.MergeAndDeterminize(original, pair);
      copyOfResult = new LearnerGraph(result,result.config);// since a tread which produced result may exit and modify the graph, we have to take a copy of it.
      mPair = pair;mGraph = copyOfResult;
    }
    else
    {
      result = decoratedLearner.MergeAndDeterminize(original, pair);
      copyOfResult = new LearnerGraph(result,result.config);
    }
    syncOnCallOf(KIND_OF_METHOD.M_MERGEANDDETERMINIZE);

    if (Thread.currentThread() != secondThread)
    {// checking, considering that acceptance conditions are not stored in XML.
View Full Code Here

   * @param plus value loaded from XML
   * @param minus value loaded from XML
   */
  @Override
  public synchronized LearnerGraph init(Collection<List<String>> plus,  Collection<List<String>> minus) {
    LearnerGraph result = null, copyOfResult = null;
    // First, we call the expected method
    if (Thread.currentThread() == secondThread)
    {
      result = whatToCompareWith.init(plus, minus);
      copyOfResult = new LearnerGraph(result,result.config);
      iGraph = copyOfResult;
    }
    else
    {
      result = decoratedLearner.init(plus, minus);
      copyOfResult = new LearnerGraph(result,result.config);
    }
    syncOnCallOf(KIND_OF_METHOD.M_INIT);

    if (Thread.currentThread() != secondThread)
    {// second thread, checking.
View Full Code Here

  protected Boolean cResult = null;
 
  @Override
  public boolean AddConstraints(LearnerGraph graph, LearnerGraph outcome, StringBuffer counterExampleHolder)
  {
    LearnerGraph copyOfOutcome = null;
    boolean result = false;
   
    // First, we call the expected method
    if (Thread.currentThread() == secondThread)
    {
      result = whatToCompareWith.AddConstraints(graph,outcome,counterExampleHolder);
      copyOfOutcome = new LearnerGraph(outcome,outcome.config);
      cGraph = copyOfOutcome;cResult = result;
    }
    else
    {
      result = decoratedLearner.AddConstraints(graph,outcome,counterExampleHolder);
      copyOfOutcome = new LearnerGraph(outcome,outcome.config);
    }
    syncOnCallOf(KIND_OF_METHOD.M_ADDCONSTRAINTS);
   
    if (Thread.currentThread() != secondThread)
    {// second thread, checking.
View Full Code Here

        }
       
      },"other learner");
      secondThread.setDaemon(true);// ensures termination of the second thread when I kill the main thread.
      secondThread.start();
      LearnerGraph result = null;
      try
      {
        result = runLearner(decoratedLearner);
        syncOnCallOf(KIND_OF_METHOD.M_FINISHED);
      }
View Full Code Here

    Configuration testConfig = Configuration.getDefaultConfiguration().copy();
    testConfig.setGdFailOnDuplicateNames(false);
    if (forceGDfallback) testConfig.setGdMaxNumberOfStatesInCrossProduct(0);
    testConfig.setCompressLogs(useCompression);
    final DirectedSparseGraph g = FsmParser.buildGraph(fsmString, name);
    final LearnerGraph expected = new LearnerGraph(g,testConfig);
   
    // now sanity checking on the plus and minus sets
    for(String [] path:plus)
      assert AbstractOracle.USER_ACCEPTED == expected.paths.tracePathPrefixClosed(Arrays.asList(path));
    for(String [] path:minus)
      assert AbstractOracle.USER_ACCEPTED != expected.paths.tracePathPrefixClosed(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") List<Boolean> acceptedElements,
          @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<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)
    {
View Full Code Here

TOP

Related Classes of statechum.analysis.learning.rpnicore.LearnerGraph

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.