예제 #1
0
def test_dyn_vmp(request_id):
    req = create_test_request(request_id)
    sub = get_test_substrate()
    alg = treewidth_model.DynVMPAlgorithm(req, sub)

    alg.preprocess_input()
    m = alg.compute_valid_mapping()
    assert set(m.mapping_nodes.keys()) == set(req.nodes)
    assert set(m.mapping_edges.keys()) == set(req.edges)
예제 #2
0
def test_dyn_vmp_with_allowed_nodes_restrictions(request_id):
    req = create_test_request(request_id)

    sub = get_test_substrate()

    # add some restrictions
    for i in req.nodes:
        num_allowed = random.randint(1, 2)
        req.node[i]["allowed_nodes"] = random.sample(list(sub.nodes),
                                                     num_allowed)

    alg = treewidth_model.DynVMPAlgorithm(req, sub)

    alg.preprocess_input()
    m = alg.compute_valid_mapping()
    assert set(m.mapping_nodes.keys()) == set(req.nodes)
    assert set(m.mapping_edges.keys()) == set(req.edges)
예제 #3
0
def test_dyn_vmp_with_larger_scenario():
    sub = create_test_substrate_topology_zoo()

    req = create_random_test_request(sub,
                                     min_number_nodes=8,
                                     max_number_nodes=12,
                                     probability=0.25,
                                     edge_resource_factor=10,
                                     node_resource_factor=0.1)
    # add some restrictions
    for i in req.nodes:
        num_allowed = random.randint(1, 2)
        req.node[i]["allowed_nodes"] = random.sample(list(sub.nodes),
                                                     num_allowed)

    alg = treewidth_model.DynVMPAlgorithm(req, sub)

    alg.preprocess_input()
    m = alg.compute_valid_mapping()
    assert set(m.mapping_nodes.keys()) == set(req.nodes)
    assert set(m.mapping_edges.keys()) == set(req.edges)