Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
Edi Muškardin edited this pageJun 19, 2024 ·26 revisions

Welcome to the AALpy Wiki!

AALpy is a light-weight active automata learning library written in pure Python.By implementing a single method and a few lines ofconfiguration, you can start learning automata.

Whether you work with regular languages or you would like to learn models ofreactive systems, AALpy supports a wide range of modeling formalisms, includingdeterministic, non-deterministic, and stochastic automata.You can use it to learndeterministic finite automata,Moore machines,andMealy machines of deterministic systems.If the system that you would like to learn shows non-deterministic orstochastic behavior, AALpy allows you to learnobservablenondeterministic finite-state machines,Markov decision processes,orstochastic Mealy machines.AALpy enables efficient learning by providing alarge set of equivalence oracles, implementing variousconformance testing strategies.

Installation

Use the package managerpip to install AALpy.

pip install aalpy

The minimum required version of Python is 3.6.
Ensure that you haveGraphviz installed and added to your path if you want to visualize models.

For manual installation, clone the master and install the following dependency.

pip install pydot# and to install the librarypython setup.py install

Documentation and Wiki

If you are interested in automata learning or would like to understand the automata learning process in more detail,please check out ourWiki. On Wiki, you will find more detailed examples on how to use AALpy.

Examples.py contains many examples demonstrating all AALpy functionality are presented.

Usage

All automata learning procedures follow this high-level approach:

The following snippet demonstrates a short example in which an automaton is eitherloaded orrandomly generated and thenlearned.

fromaalpy.utilsimportload_automaton_from_file,generate_random_deterministic_automatafromaalpy.SULsimportAutomatonSULfromaalpy.oraclesimportRandomWalkEqOraclefromaalpy.learning_algsimportrun_Lstar,run_KV# load an automaton# automaton = load_automaton_from_file('path_to_the_file.dot', automaton_type='dfa')# or randomly generate onerandom_dfa=generate_random_deterministic_automata(automaton_type='dfa',num_states=8,input_alphabet_size=5,output_alphabet_size=2)# get input alphabet of the automatonalphabet=random_dfa.get_input_alphabet()# loaded or randomly generated automata are considered as BLACK-BOX that is queried# learning algorithm has no knowledge about its structure# create a SUL instance for the automaton/system under learningsul=AutomatonSUL(random_dfa)# define the equivalence oracleeq_oracle=RandomWalkEqOracle(alphabet,sul,num_steps=5000,reset_prob=0.09)# start learning# run_KV is for the most part reacquires much fewer interactions with the system under learninglearned_dfa=run_KV(alphabet,sul,eq_oracle,automaton_type='dfa')# or run L*# learned_dfa_lstar = run_Lstar(alphabet, sul, eq_oracle, automaton_type='dfa')# save automaton to file and visualize it# save_automaton_to_file(learned_dfa, path='Learned_Automaton', file_type='dot')# orlearned_dfa.save()# visualize automaton# visualize_automaton(learned_dfa)learned_dfa.visualize()# or just print its DOT representationprint(learned_dfa)

Another example shows how easy it is to learn a regular expression with AALpy.For more details on this example, take a look at -How to learn Regex with AALpy

fromaalpy.oraclesimportStatePrefixEqOraclefromaalpy.SULsimportRegexSULfromaalpy.learning_algsimportrun_Lstarregex='abc(b|c)+(ab|c)*'alphabet= ['a','b','c']regex_sul=RegexSUL(regex)eq_oracle=StatePrefixEqOracle(alphabet,regex_sul,walks_per_state=100,walk_len=20)learned_regex=run_Lstar(alphabet,regex_sul,eq_oracle,automaton_type='dfa',print_level=2)orlearned_regex.visualize()

This code snippet results in:

Hypothesis 1 has 1 states.Hypothesis 2 has 7 states.Hypothesis 3 has 8 states.-----------------------------------Learning Finished.Learning Rounds:  3Number of states: 8Time (in seconds)  Total                : 0.05  Learning algorithm   : 0.0  Conformance checking : 0.05Learning Algorithm # Membership Queries  : 85 # MQ Saved by Caching : 120 # Steps               : 582Equivalence Query # Membership Queries  : 800 # Steps               : 18173-----------------------------------

and

Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp