當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultQuery類代碼示例

本文整理匯總了Java中de.learnlib.oracles.DefaultQuery的典型用法代碼示例。如果您正苦於以下問題:Java DefaultQuery類的具體用法?Java DefaultQuery怎麽用?Java DefaultQuery使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DefaultQuery類屬於de.learnlib.oracles包,在下文中一共展示了DefaultQuery類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findCounterExample

import de.learnlib.oracles.DefaultQuery; //導入依賴的package包/類
@Override
public DefaultQuery<SymbolicMethodSymbol, SymbolicQueryOutput> 
      findCounterExample(
        MealyMachine<?, SymbolicMethodSymbol, ?, SymbolicQueryOutput> a, 
        Collection<? extends SymbolicMethodSymbol> clctn) {

  this.model = (MealyMachine<Object, SymbolicMethodSymbol, ?,
          SymbolicQueryOutput>)a;
  DefaultQuery<SymbolicMethodSymbol, SymbolicQueryOutput> ce = null;
  
  try {
    while (true) {
      ce = findCounterExampleAtDepthK();
      if (ce != null) {
        return ce;
      }
      logger.info("==== completed depth " + k);
      k++;
      if (deepEnough()) {
        return null;
      }
    }
  } catch (Terminate t) {
    return null;      
  }
}
 
開發者ID:psycopaths,項目名稱:psyco,代碼行數:27,代碼來源:IncreasingDepthExhaustiveTest.java

示例2: findCounterExampleAtDepthK

import de.learnlib.oracles.DefaultQuery; //導入依賴的package包/類
private DefaultQuery<SymbolicMethodSymbol, SymbolicQueryOutput>
      findCounterExampleAtDepthK() {
  Collection<DefaultQuery<SymbolicMethodSymbol, SymbolicQueryOutput>> 
          queries = unroll();
  for (DefaultQuery<SymbolicMethodSymbol, SymbolicQueryOutput> q : queries) {
    this.oracle.processQueries(Collections.singleton(q));
    SymbolicQueryOutput refOut = 
            this.model.computeOutput(q.getInput()).lastSymbol();

    if (!refOut.equals(q.getOutput())) {
      logger.info("================ CE: " + q.getInput() + 
              " : " + refOut +" <> " + q.getOutput());
      return q;
    }
  } 
  return null;
}
 
開發者ID:psycopaths,項目名稱:psyco,代碼行數:18,代碼來源:IncreasingDepthExhaustiveTest.java

示例3: unroll

import de.learnlib.oracles.DefaultQuery; //導入依賴的package包/類
private void unroll(Word<SymbolicMethodSymbol> prefix, Object state,
        Collection<DefaultQuery<
                SymbolicMethodSymbol, SymbolicQueryOutput>> words) {
  
  if (prefix.length() == k) {
    add(new DefaultQuery<SymbolicMethodSymbol, SymbolicQueryOutput>(prefix),
            words);
    return;
  }
  
  for (SymbolicMethodSymbol a : this.inputs) {
    Word<SymbolicMethodSymbol> next = prefix.append(a);
    SymbolicQueryOutput out = this.model.getOutput(state, a);
    if (out.equals(SymbolicQueryOutput.OK)) {
      unroll(next, this.model.getSuccessor(state, a), words);
    } else {
      add(new DefaultQuery<SymbolicMethodSymbol, SymbolicQueryOutput>(next),
              words);
    }      
  }
}
 
開發者ID:psycopaths,項目名稱:psyco,代碼行數:22,代碼來源:IncreasingDepthExhaustiveTest.java

示例4: add

import de.learnlib.oracles.DefaultQuery; //導入依賴的package包/類
private void add(DefaultQuery<SymbolicMethodSymbol, SymbolicQueryOutput> q,
        Collection<DefaultQuery<
                SymbolicMethodSymbol, SymbolicQueryOutput>> words) {

  if (this.filter == null) {
    words.add(q);
    return;
  }
  
  DefaultQuery<SymbolicMethodSymbol, Boolean> test = 
          new DefaultQuery<>(q.getInput());
  
  this.filter.processQueries(Collections.singleton(test));
  
  if (test.getOutput()) {
    words.add(q);      
  }
}
 
開發者ID:psycopaths,項目名稱:psyco,代碼行數:19,代碼來源:IncreasingDepthExhaustiveTest.java

示例5: learnModel

import de.learnlib.oracles.DefaultQuery; //導入依賴的package包/類
private void learnModel() {
  this.lstar = new LStar(inputs, mqOrcale);
  this.lstar.startLearning();
  while (true) {
    this.model = this.lstar.getHypothesisModel();
    try {
      GraphDOT.write(model, inputs, System.out);
    } catch (IOException ex) {
    }
    DefaultQuery<SymbolicMethodSymbol, SymbolicQueryOutput> ce
            = this.eqTest.findCounterExample(this.model, this.inputs);

    if (ce == null) {
      break;
    }

    this.lstar.refineHypothesis(ce);
  }
}
 
開發者ID:psycopaths,項目名稱:psyco,代碼行數:20,代碼來源:InterfaceGenerator.java

示例6: processQuery

import de.learnlib.oracles.DefaultQuery; //導入依賴的package包/類
private void processQuery(
        Query<SymbolicMethodSymbol, SymbolicQueryOutput> query) {
  Word<SymbolicQueryOutput> out = getPotentialOutput(query.getInput());
  int uniformIdx = getUniformIndex(out);
  if (uniformIdx == 0) {
    query.answer(SymbolicQueryOutput.OK);
    return;
  }
    
  if (uniformIdx == out.length()) {
    this.oracle.processQueries(Collections.singleton(query));
    return;
  }
  
  Word<SymbolicMethodSymbol> prefix = query.getInput().prefix(uniformIdx);
  DefaultQuery<SymbolicMethodSymbol, SymbolicQueryOutput> dQuery = 
          new DefaultQuery<>(prefix);
  
  this.oracle.processQueries(Collections.singleton(dQuery));
  query.answer(dQuery.getOutput());
}
 
開發者ID:psycopaths,項目名稱:psyco,代碼行數:22,代碼來源:UniformOKSuffixFilter.java

示例7: findCounterExample

import de.learnlib.oracles.DefaultQuery; //導入依賴的package包/類
@Override
		public DefaultQuery<I, Word<O>> findCounterExample(A hypothesis, Collection<? extends I> inputs) {
			UniversalDeterministicAutomaton<?, I, ?, ?, ?> aut = hypothesis;
			Output<I, Word<O>> out = hypothesis;
			List<Word<I>> traces = doFindTraces(aut, out, inputs);
			for (Word<I> trace : traces) {
//				System.out.println(testStepLimit + " " + trace.length());
//				System.out.println(testStepLimit + " " + trace.length());
				if (testStepLimit == 0)
					return null;
				DefaultQuery<I, Word<O>> query = null;
				if (trace.length() < testStepLimit) {
					testStepLimit -= trace.length();
					query = new DefaultQuery<>(trace);

				} else {
					query = new DefaultQuery<>(trace.prefix((int)testStepLimit));
					testStepLimit = 0;
				}
				sulOracle.processQuery(query);
				Word<O> outputHyp = hypothesis.computeOutput(trace);
				if (!outputHyp.equals(query.getOutput())){					
					return query;	
				}
			}
			return null;
		}
 
開發者ID:mtappler,項目名稱:mut-learn,代碼行數:28,代碼來源:ReferenceLearningWithWMethod.java

示例8: refine

import de.learnlib.oracles.DefaultQuery; //導入依賴的package包/類
public boolean refine(Word<SymbolicMethodSymbol> witness) {

  DefaultQuery<SymbolicMethodSymbol, SymbolicExecutionResult> query =
          new DefaultQuery<>(witness);
  oracle.processQueries(Collections.singleton(query));    
  SymbolicExecutionResult result = query.getOutput();
  SymbolicQueryOutput out = new SymbolicQueryOutput(result);
  if (out.isUniform()) {
    return false;
  }
   
  logger.finer("Execution result:" + result);    
  // refine single symbols
  boolean refined = false;
  int ppos = 1;
  for (SymbolicMethodSymbol sms : witness) {
    int pcount = sms.getArity();

    Expression<Boolean> ok  = projectResult(result.getOk(), ppos, pcount);
    Expression<Boolean> err = projectResult(result.getError(), ppos, pcount);
    Expression<Boolean> dk  = projectResult(result.getDontKnow(), ppos, pcount);

    Expression<Boolean> refiner = refineSymbol(sms, ok, err, dk);
    if (refiner != null) {
      refined = true;
      inputs.refine(sms, refiner);
    }
    ppos += pcount;
  }
  
  return refined;
}
 
開發者ID:psycopaths,項目名稱:psyco,代碼行數:33,代碼來源:AlphabetRefiner.java

示例9: findCounterExample

import de.learnlib.oracles.DefaultQuery; //導入依賴的package包/類
@Override
public DefaultQuery<SymbolicMethodSymbol, SymbolicQueryOutput> 
      findCounterExample(
        MealyMachine<?, SymbolicMethodSymbol, ?, SymbolicQueryOutput> a,
        Collection<? extends SymbolicMethodSymbol> clctn) {

  this.model = (MealyMachine<Object, SymbolicMethodSymbol, ?,
          SymbolicQueryOutput>) a;
  DefaultQuery<SymbolicMethodSymbol, SymbolicQueryOutput> ce = null;
  this.util = new InterpolationUtil(iSolver, cSolver, inputs, model);
  k = 2;
  try {
    while (true) {
      ce = check(k);
      if (ce != null) {
        return ce;
      }
      logger.finest(SimpleProfiler.getResults());
      logger.info("==== completed depth " + k);
      logger.fine(this.util.getCache());
      k++;
      //this.util = new InterpolationUtil(iSolver, cSolver, inputs, model);
      if (deepEnough()) {
        return null;
      }
    }

  } catch (Terminate t) {
    return null;
  }
}
 
開發者ID:psycopaths,項目名稱:psyco,代碼行數:32,代碼來源:IncreasingDepthInterpolationTest.java

示例10: check

import de.learnlib.oracles.DefaultQuery; //導入依賴的package包/類
private DefaultQuery<SymbolicMethodSymbol, SymbolicQueryOutput> check(int k) {
  logger.fine("Checking conformance for depth " + k);
  try {
    Word<SymbolicMethodSymbol> eps = Word.epsilon();
    Word<Path> empty = Word.epsilon();
    util.expand(eps, empty, k);
  } catch (CounterexampleFound ce) {
    DefaultQuery<SymbolicMethodSymbol, SymbolicQueryOutput> ret
            = new DefaultQuery<>(ce.getCounterexample());
    oracle.processQueries(Collections.singletonList(ret));
    return ret;
  }
  return null;
}
 
開發者ID:psycopaths,項目名稱:psyco,代碼行數:15,代碼來源:IncreasingDepthInterpolationTest.java

示例11: processQueries

import de.learnlib.oracles.DefaultQuery; //導入依賴的package包/類
@Override
public void processQueries(Collection<? extends 
        Query<SymbolicMethodSymbol, SymbolicQueryOutput>> clctn) {
  for (Query<SymbolicMethodSymbol, SymbolicQueryOutput> query : clctn) {
    DefaultQuery<SymbolicMethodSymbol, SymbolicQueryOutput> _query = 
            new DefaultQuery<>(query.getInput());
    this.oracle.processQueries(Collections.singleton(_query));
    if (!_query.getOutput().isUniform()) {
      throw new RefinementNeeded(_query);
    }
    query.answer(_query.getOutput());
  }
}
 
開發者ID:psycopaths,項目名稱:psyco,代碼行數:14,代碼來源:RefinementCheckOracle.java

示例12: processQuery

import de.learnlib.oracles.DefaultQuery; //導入依賴的package包/類
private void processQuery(Query<SymbolicMethodSymbol,
        SymbolicQueryOutput> q) {
 String[] test = queryToString(q.getInput());
 SymbolicQueryOutput result = table.getSimulatedResult(test);
 if (result == null) {
   DefaultQuery<SymbolicMethodSymbol, SymbolicQueryOutput> defq =
          new DefaultQuery<>(q.getInput());
   
   this.oracle.processQueries(Collections.singleton(defq));
   
   result = defq.getOutput();
   table.setResult(test, result);
 } 
 q.answer(result);   
}
 
開發者ID:psycopaths,項目名稱:psyco,代碼行數:16,代碼來源:Cache.java

示例13: learn

import de.learnlib.oracles.DefaultQuery; //導入依賴的package包/類
public void learn() throws IOException, InterruptedException {
	LearnLogger log = LearnLogger.getLogger(Learner.class.getSimpleName());

	log.log(Level.INFO, "Using learning algorithm " + learningAlgorithm.getClass().getSimpleName());
	log.log(Level.INFO, "Using equivalence algorithm " + equivalenceAlgorithm.getClass().getSimpleName());
	
	log.log(Level.INFO, "Starting learning");
	
	SimpleProfiler.start("Total time");
	
	boolean learning = true;
	Counter round = new Counter("Rounds", "");

	round.increment();
	log.logPhase("Starting round " + round.getCount());
	SimpleProfiler.start("Learning");
	learningAlgorithm.startLearning();
	SimpleProfiler.stop("Learning");

	MealyMachine<?, String, ?, String> hypothesis = learningAlgorithm.getHypothesisModel();
	
	while(learning) {
		// Write outputs
		writeDotModel(hypothesis, alphabet, config.output_dir + "/hypothesis_" + round.getCount() + ".dot");

		// Search counter-example
		SimpleProfiler.start("Searching for counter-example");
		DefaultQuery<String, Word<String>> counterExample = equivalenceAlgorithm.findCounterExample(hypothesis, alphabet);	
		SimpleProfiler.stop("Searching for counter-example");
		
		if(counterExample == null) {
			// No counter-example found, so done learning
			learning = false;
			
			// Write outputs
			writeDotModel(hypothesis, alphabet, config.output_dir + "/learnedModel.dot");
			//writeAutModel(hypothesis, alphabet, config.output_dir + "/learnedModel.aut");
		}
		else {
			// Counter example found, update hypothesis and continue learning
			log.logCounterexample("Counter-example found: " + counterExample.toString());
			//TODO Add more logging
			round.increment();
			log.logPhase("Starting round " + round.getCount());
			
			SimpleProfiler.start("Learning");
			learningAlgorithm.refineHypothesis(counterExample);
			SimpleProfiler.stop("Learning");
			
			hypothesis = learningAlgorithm.getHypothesisModel();
		}
	}

	SimpleProfiler.stop("Total time");
	
	// Output statistics
	log.log(Level.INFO, "-------------------------------------------------------");
	log.log(Level.INFO, SimpleProfiler.getResults());
	log.log(Level.INFO, round.getSummary());
	log.log(Level.INFO, statsMemOracle.getStatisticalData().getSummary());
	log.log(Level.INFO, statsCachedMemOracle.getStatisticalData().getSummary());
	log.log(Level.INFO, statsEqOracle.getStatisticalData().getSummary());
	log.log(Level.INFO, statsCachedEqOracle.getStatisticalData().getSummary());
	log.log(Level.INFO, "States in final hypothesis: " + hypothesis.size());		
}
 
開發者ID:jderuiter,項目名稱:statelearner,代碼行數:66,代碼來源:Learner.java

示例14: findCounterExample

import de.learnlib.oracles.DefaultQuery; //導入依賴的package包/類
@Override
public DefaultQuery<SymbolicMethodSymbol, SymbolicQueryOutput> findCounterExample(
        MealyMachine<?, SymbolicMethodSymbol, ?, SymbolicQueryOutput> a,
        Collection<? extends SymbolicMethodSymbol> clctn) {

  try {
    this.hyp = (MealyMachine<Object, SymbolicMethodSymbol, Object, SymbolicQueryOutput>) a;
    //GraphDOT.write(this.hyp, inputs, System.out);

    // generate c file
    Map<String, Object> config = prepareTest();
    InputStream is = ProgramAnalysisTest.class.getResourceAsStream(
            "/gov/nasa/jpf/psyco/CEncoding.st");
    File tmpDir = Files.createTempDir();
    TemplateBasedCompiler compiler = new TemplateBasedCompiler(tmpDir);
    compiler.addDynamicSource("", "cex", config, is);

    // rename file 
    Files.move(new File(tmpDir, "cex.java"), new File(tmpDir, "cex.c"));
    logger.fine("Dir: " + tmpDir);

    // run blast
    boolean safe = runBlast(tmpDir);
    if (safe) {
      return null;
    }

    Word<SymbolicMethodSymbol> ce = Word.fromList(counterexample(tmpDir));

    DefaultQuery<SymbolicMethodSymbol, SymbolicQueryOutput> ceQuery
            = new DefaultQuery<>(ce);

    this.oracle.processQueries(Collections.singletonList(ceQuery));
    List<SymbolicQueryOutput> hypOut = new ArrayList<>();
    hyp.trace(ce, hypOut);

    logger.info("CE: " + ce);
    logger.info("SYS: " + ceQuery.getOutput());
    logger.info("HYP: " + hypOut.get(hypOut.size() - 1));
    return ceQuery;

  } catch (IOException ex) {
    throw new RuntimeException(ex);
  }

}
 
開發者ID:psycopaths,項目名稱:psyco,代碼行數:47,代碼來源:ProgramAnalysisTest.java

示例15: createCounterExample

import de.learnlib.oracles.DefaultQuery; //導入依賴的package包/類
private DefaultQuery<SymbolicMethodSymbol, SymbolicQueryOutput> createCounterExample() {
  return null;
}
 
開發者ID:psycopaths,項目名稱:psyco,代碼行數:4,代碼來源:ProgramAnalysisTest.java


注:本文中的de.learnlib.oracles.DefaultQuery類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。