order_type='ce count')) # Store found counterexamples def onct(ctex): ct.add(ctex) ct.save(f'counterexamples_{problem}_nomutation.p') eqc.onCounterexample(onct) # Set up the teacher, with the system under learning and the equivalence checker teacher = Teacher(sul, eqc) # Set up the learner who only talks to the teacher learner = TTTMealyLearner(teacher) # learner.enable_checkpoints('checkpoints3') # learner.load_checkpoint('/home/tom/projects/lstar/experiments/counterexampletracker/checkpoints3/cZsmSu/2020-05-06_20:00:33:790987') # Get the learners hypothesis hyp = learner.run( show_intermediate=False, render_options={'ignore_self_edges': ['error', 'invalid']}, on_hypothesis=lambda x: check_result( x, f'../../rers/TrainingSeqReachRers2019/{problem}/reachability-solution-{problem}.csv' )) print( "SUCCES", check_result( hyp,
SmartWmethodEquivalenceCheckerV2(sul, horizon=horizon, stop_on={'invalid_input'}, stop_on_startswith={'error'}), #NuSMVEquivalenceChecker(sul, constrpath, mappingpath, n_unrolls=10), # SmartWmethodEquivalenceCheckerV2(sul, # horizon=horizon, # stop_on={'invalid_input'}, # stop_on_startswith={'error'}) ) # Set up the teacher, with the system under learning and the equivalence checker teacher = Teacher(sul, eqc) # Set up the learner who only talks to the teacher learner = TTTMealyLearner(teacher) # Get the learners hypothesis hyp = learner.run( show_intermediate=False, on_hypothesis=savehypothesis(f'hypotheses/{problemset}/{problem}', f'{problem}') ) end_learning = datetime.now() # hyp.render_graph() nusmv = NuSMVUtils(constrpath, mappingpath) ltl_answers = nusmv.run_ltl_check(hyp)
'test_query': 0, 'state_count': 0, 'error_count': 0, 'errors': set() }, log_path=logdir.joinpath(f'{problem}_{now}_afl_wtraces.log'), write_on_change={'state_count', 'error_count'}) sul = RERSSOConnector(path) afl_dir = f'/home/tom/projects/lstar/experiments/learningfuzzing/{problemset}/{problem}' bin_path = f'/home/tom/projects/lstar/experiments/learningfuzzing/{problemset}/{problem}/{problem}' eqc = StackedChecker( AFLEquivalenceCheckerV2(sul, afl_dir, bin_path, feedback='w_traces'), SmartWmethodEquivalenceCheckerV2(sul, horizon=horizon, stop_on={'invalid_input'}, stop_on_startswith={'error'})) # Set up the teacher, with the system under learning and the equivalence checker teacher = Teacher(sul, eqc) # Set up the learner who only talks to the teacher learner = TTTMealyLearner(teacher) # Get the learners hypothesis hyp = learner.run(show_intermediate=False, render_options={'ignore_self_edges': ['error', 'invalid']}, on_hypothesis=savehypothesis( f'hypotheses/afl_plain/{problem}', f'{problem}'))
eqc = StackedChecker( SmartWmethodEquivalenceCheckerV2(sul, horizon=horizon, stop_on={'invalid_input'}, stop_on_startswith={'error'}), NuSMVEquivalenceChecker(sul, constrpath, mappingpath, n_unrolls=10), # SmartWmethodEquivalenceCheckerV2(sul, # horizon=horizon, # stop_on={'invalid_input'}, # stop_on_startswith={'error'}) ) # Set up the teacher, with the system under learning and the equivalence checker teacher = Teacher(sul, eqc) # Set up the learner who only talks to the teacher learner = TTTMealyLearner(teacher) # Get the learners hypothesis hyp = learner.run(show_intermediate=False, ) #hyp.render_graph() nusmv = NuSMVUtils(constrpath, mappingpath) ltl_answers = nusmv.run_ltl_check(hyp) if 'Training' in problemset: check_result(ltl_answers, solutionspath)
ct = CounterexampleTracker() eqc = SmartWmethodEquivalenceChecker(sul, horizon=3) eqc = StackedChecker( GeneticEquivalenceChecker(sul, ct, pop_n=10000), SmartWmethodEquivalenceChecker(sul, horizon=3, order_type='ce count') ) eqc.onCounterexample(lambda ce: ct.add(ce)) teacher = Teacher(sul, eqc) # We are learning a mealy machine learner = TTTMealyLearner(teacher) def print_stats(hyp=None): print("Member queries:", teacher.member_query_counter) print("Equivalence queries:", teacher.equivalence_query_counter) print("Test queries:", teacher.test_query_counter) hyp = learner.run( show_intermediate=False, on_hypothesis=print_stats ) #learner.DTree.render_graph() hyp.render_graph(tempfile.mktemp('.gv'))
'ignore_edges': ['error'] }) # Use the W method equivalence checker eqc = SmartWmethodEquivalenceChecker( mm, #horizon=3, m=len(mm.get_states()), stop_on={'error'}, order_type='ce count') eqc.onCounterexample(lambda x: print('Counterexample:', x)) teacher = Teacher(mm, eqc) # We are learning a mealy machine learner = TTTMealyLearner(teacher) hyp = learner.run(show_intermediate=False #render_options={'ignore_self_edges': ['error', 'invalid']}, ) #hyp.render_graph(tempfile.mktemp('.gv')) learner.DTree.render_graph() hyp.render_graph(render_options={ 'ignore_self_edges': ['error', 'invalid'], #'ignore_edges': ['error'] }) assert len(hyp.get_states()) == len(mm.get_states()) print("done")
ctpath = Path(f'{prefix}/counterexamples') ctpath.mkdir(exist_ok=True, parents=True) def onct(ctex): ct.add(ctex) ct.save(ctpath.joinpath(f'counterexamples_{problem}.p')) eqc.onCounterexample(onct) # Set up the teacher, with the system under learning and the equivalence checker teacher = Teacher(sul, eqc) # Set up the learner who only talks to the teacher learner = TTTMealyLearner(teacher) def stack(*args): def chained(hypothesis): for function in args: function(hypothesis) return chained # Get the learners hypothesis hyp = learner.run( show_intermediate=False, render_options={'ignore_self_edges': ['error', 'invalid']}, on_hypothesis=stack(
from equivalencecheckers.wmethod import WmethodEquivalenceChecker from learners.TTTmealylearner import TTTMealyLearner from suls.mealymachine import MealyState, MealyMachine from teachers.teacher import Teacher # Set up an example mealy machine s1 = MealyState('1') s2 = MealyState('2') s3 = MealyState('3') s1.add_edge('a', 'nice', s2) s1.add_edge('b', 'B', s1) s2.add_edge('a', 'nice', s3) s2.add_edge('b', 'back', s1) s3.add_edge('a', 'A', s3) s3.add_edge('b', 'back', s1) mm = MealyMachine(s1) # Use the W method equivalence checker eqc = WmethodEquivalenceChecker(mm, m=len(mm.get_states())) teacher = Teacher(mm, eqc) # We are learning a mealy machine learner = TTTMealyLearner(teacher) hyp = learner.run() hyp.render_graph(tempfile.mktemp('.gv')) learner.DTree.render_graph(tempfile.mktemp('.gv'))