本文整理汇总了Java中net.automatalib.words.impl.SimpleAlphabet类的典型用法代码示例。如果您正苦于以下问题:Java SimpleAlphabet类的具体用法?Java SimpleAlphabet怎么用?Java SimpleAlphabet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SimpleAlphabet类属于net.automatalib.words.impl包,在下文中一共展示了SimpleAlphabet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TLSSUL
import net.automatalib.words.impl.SimpleAlphabet; //导入依赖的package包/类
public TLSSUL(TLSConfig config) throws Exception {
alphabet = new SimpleAlphabet<String>(Arrays.asList(config.alphabet.split(" ")));
tls = new TLSTestService();
tls.setTarget(config.target);
tls.setHost(config.host);
tls.setPort(config.port);
tls.setCommand(config.cmd);
tls.setRequireRestart(config.restart);
tls.setReceiveMessagesTimeout(config.timeout);
tls.setKeystore(config.keystore_filename, config.keystore_password);
tls.setConsoleOutput(config.console_output);
if(config.version.equals("tls10")) {
tls.useTLS10();
}
else {
tls.useTLS12();
}
tls.start();
}
示例2: shouldGetOneTestResult
import net.automatalib.words.impl.SimpleAlphabet; //导入依赖的package包/类
@Test
public void shouldGetOneTestResult() throws NotFoundException, JsonProcessingException {
// given
ObjectMapper objectMapper = new ObjectMapper();
Alphabet<String> sigma = new SimpleAlphabet<>();
sigma.add("0");
sigma.add("1");
LearnerResult learnerResult = new LearnerResult();
learnerResult.setProject(project);
learnerResult.setTestNo(RESULT_ID);
learnerResult.setSigma(AlphabetProxy.createFrom(sigma));
given(learnerResultDAO.get(admin, PROJECT_ID, RESULT_ID, false)).willReturn(learnerResult);
// when
Response response = target("/projects/" + PROJECT_ID + "/results/" + RESULT_ID).request()
.header("Authorization", adminToken).get();
// then
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
assertEquals(objectMapper.writeValueAsString(learnerResult), response.readEntity(String.class));
}
示例3: getOutputAlphabet
import net.automatalib.words.impl.SimpleAlphabet; //导入依赖的package包/类
protected Alphabet<String> getOutputAlphabet(FastMealy<Symbol,String> hypothesis) {
Collection<FastMealyState<String>> allStates = hypothesis.getStates();
Stream<String> outputStream = inputAlphabet.stream().
flatMap(i -> allStates.stream().map(s -> hypothesis.getOutput(s, i))).distinct();
SimpleAlphabet<String> outputAlphabet = new SimpleAlphabet<>();
outputStream.forEach(o -> outputAlphabet.add(o));
return outputAlphabet;
}
示例4: SocketSUL
import net.automatalib.words.impl.SimpleAlphabet; //导入依赖的package包/类
public SocketSUL(SocketConfig config) throws Exception {
alphabet = new SimpleAlphabet<String>(Arrays.asList(config.alphabet.split(" ")));
// Initialise test service
socket = new Socket(config.hostname, config.port);
out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
}
示例5: SCSUL
import net.automatalib.words.impl.SimpleAlphabet; //导入依赖的package包/类
public SCSUL(SCConfig config) throws Exception {
// Initialise test service
scTestService = new SmartcardTestService();
scTestService.loadAPDUDictionary(config.apdu_file);
if(config.alphabet != null)
alphabet = new SimpleAlphabet<String>(Arrays.asList(config.alphabet.split(" ")));
else
alphabet = new SimpleAlphabet<String>(scTestService.getAPDUDictionary().keySet());
if(config.prefix != null)
prefix = config.prefix.split(" ");
}
示例6: loadEquivalenceAlgorithm
import net.automatalib.words.impl.SimpleAlphabet; //导入依赖的package包/类
public void loadEquivalenceAlgorithm(String algorithm, SimpleAlphabet<String> alphabet, SUL<String, String> sul) throws Exception {
//TODO We could combine the two cached oracle to save some queries to the SUL
// Create the equivalence oracle
//eqOracle = new SULOracle<String, String>(sul);
// Add a logging oracle
logEqOracle = new MealyLogOracle<String, String>(sul, LearnLogger.getLogger("equivalence_queries"));
// Add an oracle that counts the number of queries
statsEqOracle = new MealyCounterOracle<String, String>(logEqOracle, "equivalence queries to SUL");
// Use cache oracle to prevent double queries to the SUL
//cachedEqOracle = MealyCacheOracle.createDAGCacheOracle(alphabet, statsEqOracle);
// Count the number of queries to the cache
statsCachedEqOracle = new MealyCounterOracle<String, String>(statsEqOracle, "equivalence queries to cache");
// Instantiate the selected equivalence algorithm
switch(algorithm.toLowerCase()) {
case "wmethod":
equivalenceAlgorithm = new WMethodEQOracle.MealyWMethodEQOracle<String, String>(config.max_depth, statsCachedEqOracle);
break;
case "modifiedwmethod":
equivalenceAlgorithm = new MealyModifiedWMethodEQOracle<String, String>(config.max_depth, statsCachedEqOracle);
break;
case "wpmethod":
equivalenceAlgorithm = new WpMethodEQOracle.MealyWpMethodEQOracle<String, String>(config.max_depth, statsCachedEqOracle);
break;
case "randomwords":
equivalenceAlgorithm = new MealyRandomWordsEQOracle<String, String>(statsCachedEqOracle, config.min_length, config.max_length, config.nr_queries, new Random(config.seed));
break;
default:
throw new Exception("Unknown equivalence algorithm " + config.eqtest);
}
}
示例7: writeAutModel
import net.automatalib.words.impl.SimpleAlphabet; //导入依赖的package包/类
public static void writeAutModel(MealyMachine<?, String, ?, String> model, SimpleAlphabet<String> alphabet, String filename) throws FileNotFoundException {
// Make use of LearnLib's internal representation of states as integers
@SuppressWarnings("unchecked")
MealyMachine<Integer, String, ?, String> tmpModel = (MealyMachine<Integer, String, ?, String>) model;
// Write output to aut-file
File autFile = new File(filename);
PrintStream psAutFile = new PrintStream(autFile);
int nrStates = model.getStates().size();
// Compute number of transitions, assuming the graph is complete
int nrTransitions = nrStates * alphabet.size();
psAutFile.println("des(" + model.getInitialState().toString() + "," + nrTransitions + "," + nrStates + ")");
Collection<Integer> states = tmpModel.getStates();
for(Integer state: states) {
for(String input: alphabet) {
String output = tmpModel.getOutput(state, input);
Integer successor = tmpModel.getSuccessor(state, input);
psAutFile.println("(" + state + ",'" + input + " / " + output + "', " + successor + ")");
}
}
psAutFile.close();
}
示例8: writeDotModel
import net.automatalib.words.impl.SimpleAlphabet; //导入依赖的package包/类
public static void writeDotModel(MealyMachine<?, String, ?, String> model, SimpleAlphabet<String> alphabet, String filename) throws IOException, InterruptedException {
// Write output to dot-file
File dotFile = new File(filename);
PrintStream psDotFile = new PrintStream(dotFile);
GraphDOT.write(model, alphabet, psDotFile);
psDotFile.close();
//TODO Check if dot is available
// Convert .dot to .pdf
Runtime.getRuntime().exec("dot -Tpdf -O " + filename);
}
示例9: createAlphabet
import net.automatalib.words.impl.SimpleAlphabet; //导入依赖的package包/类
/**
* Create an Alphabet based on the proxy.
*
* @return An Alphabet with all the proxy input symbols.
*/
@Transient
@JsonIgnore
public Alphabet<String> createAlphabet() {
Set<String> inputs = edges.stream().map(CompactMealyTransitionProxy::getInput)
.collect(Collectors.toSet());
Alphabet<String> alphabet = new SimpleAlphabet<>(inputs);
return alphabet;
}
示例10: shouldCreateCorrectLearner
import net.automatalib.words.impl.SimpleAlphabet; //导入依赖的package包/类
@Test
public void shouldCreateCorrectLearner() {
Alphabet<String> sigma = new SimpleAlphabet<>();
sigma.add("a");
sigma.add("b");
SULOracle<String, String> oracle = mock(SULOracle.class);
algorithm.createLearner(sigma, oracle);
}
示例11: createTestLearnResults
import net.automatalib.words.impl.SimpleAlphabet; //导入依赖的package包/类
private List<LearnerResult> createTestLearnResults() {
List<LearnerResult> results = new LinkedList<>();
for (long i = 0; i < TEST_RESULT_AMOUNT; i++) {
Alphabet<String> sigma = new SimpleAlphabet<>();
sigma.add("0");
sigma.add("1");
LearnerResult learnerResult = new LearnerResult();
learnerResult.setProject(project);
learnerResult.setTestNo(i);
learnerResult.setSigma(AlphabetProxy.createFrom(sigma));
results.add(learnerResult);
} return results;
}
示例12: getAlphabet
import net.automatalib.words.impl.SimpleAlphabet; //导入依赖的package包/类
public SimpleAlphabet<String> getAlphabet() {
return alphabet;
}
示例13: getAlphabet
import net.automatalib.words.impl.SimpleAlphabet; //导入依赖的package包/类
public SimpleAlphabet<String> getAlphabet() {
// Get alphabet from the SmartcardService's APDU dictionary
return alphabet;
}
示例14: loadLearningAlgorithm
import net.automatalib.words.impl.SimpleAlphabet; //导入依赖的package包/类
public void loadLearningAlgorithm(String algorithm, SimpleAlphabet<String> alphabet, SUL<String, String> sul) throws Exception {
// Create the membership oracle
//memOracle = new SULOracle<String, String>(sul);
// Add a logging oracle
logMemOracle = new MealyLogOracle<String, String>(sul, LearnLogger.getLogger("learning_queries"));
// Count the number of queries actually sent to the SUL
statsMemOracle = new MealyCounterOracle<String, String>(logMemOracle, "membership queries to SUL");
// Use cache oracle to prevent double queries to the SUL
//cachedMemOracle = MealyCacheOracle.createDAGCacheOracle(alphabet, statsMemOracle);
// Count the number of queries to the cache
statsCachedMemOracle = new MealyCounterOracle<String, String>(statsMemOracle, "membership queries to cache");
// Instantiate the selected learning algorithm
switch(algorithm.toLowerCase()) {
case "lstar":
learningAlgorithm = new ExtensibleLStarMealyBuilder<String, String>().withAlphabet(alphabet).withOracle(statsCachedMemOracle).create();
break;
case "dhc":
learningAlgorithm = new MealyDHC<String, String>(alphabet, statsCachedMemOracle);
break;
case "kv":
learningAlgorithm = new KearnsVaziraniMealy<String, String>(alphabet, statsCachedMemOracle, true, AcexAnalyzers.BINARY_SEARCH);
break;
case "ttt":
AcexLocalSuffixFinder suffixFinder = new AcexLocalSuffixFinder(AcexAnalyzers.BINARY_SEARCH, true, "Analyzer");
learningAlgorithm = new TTTLearnerMealy<String, String>(alphabet, statsCachedMemOracle, suffixFinder);
break;
case "mp":
learningAlgorithm = new MalerPnueliMealy<String, String>(alphabet, statsCachedMemOracle);
break;
case "rs":
learningAlgorithm = new RivestSchapireMealy<String, String>(alphabet, statsCachedMemOracle);
break;
default:
throw new Exception("Unknown learning algorithm " + config.learning_algorithm);
}
}
示例15: AbstractLearnerThread
import net.automatalib.words.impl.SimpleAlphabet; //导入依赖的package包/类
/**
* Constructor.
*
* @param user
* @param learnerResultDAO {@link #learnerResultDAO}.
* @param context The context to use.
* @param result {@link #result}.
* @param configuration {@link #configuration}.
*/
public AbstractLearnerThread(User user, LearnerResultDAO learnerResultDAO,
ConnectorContextHandler context,
LearnerResult result,
T configuration) {
this.user = user;
this.learnerResultDAO = learnerResultDAO;
this.result = result;
this.configuration = configuration;
this.abstractAlphabet = new SimpleAlphabet<>(
result.getSymbols().stream()
.map(Symbol::getName)
.sorted(String::compareTo)
.collect(Collectors.toList())
);
this.finished = false;
this.maxConcurrentQueries = context.getMaxConcurrentQueries();
this.currentQueries = new ArrayList<>();
// prepare the mapped sul.
symbolMapper = new SymbolMapper(result.getSymbols());
final ContextExecutableInputSUL<ContextExecutableInput<ExecuteResult, ConnectorManager>, ExecuteResult, ConnectorManager>
ceiSUL = new ContextExecutableInputSUL<>(context);
final SUL<String, String> mappedSUL = SULMappers.apply(symbolMapper, ceiSUL);
this.sul = new AlexSUL<>(mappedSUL);
this.multiSULOracle = new MultiSULOracle<>(sul);
// monitor which queries are being processed.
monitorOracle = new QueryMonitorOracle<>(multiSULOracle);
monitorOracle.addPostProcessingListener(queries -> {
List<DefaultQueryProxy> currentQueries = new ArrayList<>();
queries.forEach(query -> currentQueries.add(DefaultQueryProxy.createFrom(new DefaultQuery<>(query))));
this.currentQueries = currentQueries;
});
// create the concrete membership oracle.
this.mqOracle = new DelegationOracle<>();
if (result.isUseMQCache()) {
this.mqOracle.setDelegate(MealyCacheOracle.createDAGCacheOracle(this.abstractAlphabet, monitorOracle));
} else {
this.mqOracle.setDelegate(monitorOracle);
}
// create the learner.
this.learner = result.getAlgorithm().createLearner(abstractAlphabet, mqOracle);
}