Exemplo n.º 1
0
def test_api_solve_dsa():

    dcop = dcop_graphcoloring_3()
    # Agents
    dcop.add_agents(create_agents('a', [1, 2, 3], capacity=50))

    assignment = solve(dcop, 'dsa', 'adhoc', timeout=3)
Exemplo n.º 2
0
def test_api_solve_dpop():

    dcop = dcop_graphcoloring_3()
    # Agents
    dcop.add_agents(create_agents('a', [1, 2, 3], capacity=50))

    assignment = solve(dcop, 'dpop', 'oneagent', timeout=3)

    assert assignment['v1'] == 'R'
    assert assignment['v2'] == 'G'
    assert assignment['v3'] == 'R'
Exemplo n.º 3
0
def test_solve_max(toy_pb):

    variables, constraints = toy_pb

    dcop = DCOP(name="toy",
                variables={v.name: v
                           for v in variables},
                constraints={c.name: c
                             for c in constraints},
                objective="max")
    dcop.add_agents(create_agents("a", [1, 2, 3, 4]))

    assignment = solve(dcop, "syncbb", "oneagent")

    # Note: this is supposed to be exactly the same pb as bellow
    assert assignment == {"vA": "G", "vB": "R", "vC": "R", "vD": "G"}
Exemplo n.º 4
0
def test_solve_min(toy_pb):

    variables, constraints = toy_pb

    dcop = DCOP(name="toy",
                variables={v.name: v
                           for v in variables},
                constraints={c.name: c
                             for c in constraints},
                objective="min")
    dcop.add_agents(create_agents("a", [1, 2, 3, 4]))

    assignment = solve(dcop, "syncbb", "oneagent")

    # Note: this is exactly the same pb as in the file bellow
    # dcop = load_dcop_from_file(["/pyDcop/tests/instances/graph_coloring_tuto.yaml"])

    assert assignment == {"vA": "G", "vB": "G", "vC": "G", "vD": "G"}