コード例 #1
0
def test_remove_node_one_agent():
    worlds = [World('1', {'p': True}), World('2', {'p': True})]
    relations = {'a': {('1', '2')}}
    ks = KripkeStructure(worlds, relations)
    ks_expected = KripkeStructure([World('2', {'p': True})], {'a': set()})
    ks.remove_node_by_name('1')
    assert ks_expected.__eq__(ks)
コード例 #2
0
def test_remove_node_trivial_case():
    worlds = [World('1', {'p': True}), World('2', {'p': True})]
    relations = {('1', '2')}
    ks = KripkeStructure(worlds, relations)
    ks_expected = KripkeStructure([World('2', {'p': True})], {})
    ks.remove_node_by_name('1')
    assert ks_expected.__eq__(ks)
コード例 #3
0
def test_eq_one_agent():
    worlds = [World('1', {'p': True}), World('2', {'p': True})]
    relations = {'a': {('1', '2')}}
    ks = KripkeStructure(worlds, relations)
    ks_expected = KripkeStructure(
        [World('1', {'p': True}),
         World('2', {'p': True})], {'a': {('1', '2')}})
    assert ks_expected.__eq__(ks)
コード例 #4
0
ファイル: test_model.py プロジェクト: Remco32/MAS
def test_solve_with_model_first_ann():
    wise_men_model = WiseMenWithHat()
    ks = wise_men_model.ks
    model = ks.solve(wise_men_model.knowledge_base[1])

    worlds_expected = [
        World('RRW', {
            '1:R': True,
            '2:R': True,
            '3:W': True
        }),
        World('RRR', {
            '1:R': True,
            '2:R': True,
            '3:R': True
        }),
        World('WRR', {
            '1:W': True,
            '2:R': True,
            '3:R': True
        }),
        World('WWR', {
            '1:W': True,
            '2:W': True,
            '3:R': True
        }),
        World('RWR', {
            '1:R': True,
            '2:W': True,
            '3:R': True
        }),
        World('WRW', {
            '1:W': True,
            '2:R': True,
            '3:W': True
        }),
    ]

    relations_expected = {
        '1': {('RRW', 'WRW'), ('RWR', 'WWR'), ('WRR', 'RRR')},
        '2': {('RWR', 'RRR'), ('WRR', 'WWR')},
        '3': {('RRR', 'RRW'), ('WRW', 'WRR')}
    }

    relations_expected.update(
        Model.add_reflexive_edges(worlds_expected, relations_expected))
    relations_expected.update(Model.add_symmetric_edges(relations_expected))
    ks_expected = KripkeStructure(worlds_expected, relations_expected)
    assert ks_expected.__eq__(model)
コード例 #5
0
def test_eq_empty_set():
    ks_one = KripkeStructure([World('2', {'p': True})], {'a': set()})
    ks_two = KripkeStructure([World('2', {'p': True})], {'a': set()})
    assert ks_one.__eq__(ks_two)