Пример #1
0
        #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)

    if 'Training' in problemset or problemset == 'SeqLtlRers2019':
        scores.append(check_result(ltl_answers, solutionspath))

    Path(f'results/{problemset}').mkdir(exist_ok=True, parents=True)
Пример #2
0
    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)
Пример #3
0
    NuSMVEquivalenceChecker(sul, constrpath, mappingpath),
    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/ltl/{problem}',
                                               f'{problem}'))

nusmv = NuSMVUtils(constrpath, mappingpath)

result = nusmv.run_ltl_check(hyp)

print(result)

#
# mealy_lines = mealy2nusmv_withintermediate(hyp)
# ltl_lines = rersltl2smv_withintermediate(constrpath, mappingpath)
#
# smvdir = Path(f'./smv/{problemset}')
# smvdir.mkdir(parents=True, exist_ok=True)
#
Пример #4
0

eqc.onCounterexample(onct)

#eqc = AccSeqFuzzer(sul, depth=100, num_samples=1000)
# 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
# We let it save checkpoints of every intermediate hypothesis
learner = TTTMealyLearner(teacher)  #.enable_checkpoints("checkpoints")

# 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'
    ))
statstracker.write_log()

print(
    "SUCCES",
    check_result(
        hyp,
        f'../../../rers/TrainingSeqReachRers2019/{problem}/reachability-solution-{problem}.csv'
    ))

#hyp.render_graph(render_options={'ignore_self_edges': ['error', 'invalid']})
Пример #5
0
    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'))

    print_stats()
Пример #6
0
    '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")
Пример #7
0
# 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(
        savehypothesis(f'{prefix}/hypotheses/{problemset}/{problem}',
                       f'{problem}'),
        lambda h: check_result(
            h,
            f'../../rers/{problemset}/{problem}/constraints-solution-{problem}.txt'
        )))

statstracker.write_log()

hyp.render_graph(render_options={'ignore_self_edges': ['error', 'invalid']})
Пример #8
0
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'))