Example #1
0
def test_single_request_embeddings_splittable_path_method(
        lp_objective, test_case):
    if (lp_objective in [
            vine.ViNELPObjective.ViNE_LB_DEF,
            vine.ViNELPObjective.ViNE_COSTS_DEF
    ] and test_case in vtd.COST_SPECIFIC_TEST_CASES):
        # Skip tests that require costs to enforce a unique mapping
        return

    test_data = vtd.SINGLE_REQUEST_EMBEDDING_TEST_CASES[test_case]

    scenario = vtd.get_test_scenario(test_data)

    v = vine.OfflineViNEAlgorithm(
        scenario,
        edge_embedding_model=vine.ViNEEdgeEmbeddingModel.SPLITTABLE,
        lp_objective=lp_objective,
        rounding_procedure=vine.ViNERoundingProcedure.DETERMINISTIC)
    result = v.compute_integral_solution()
    solution = result.get_solution()
    req, m = next(
        solution.request_mapping.iteritems())  # there should only be one...

    expected_mapping = test_data["expected_fractional_solution"]
    if expected_mapping is None:
        assert m is None
    else:
        assert isinstance(m, vine.SplittableMapping)
        assert m.mapping_nodes == expected_mapping["mapping_nodes"]
        assert m.mapping_edges == expected_mapping["mapping_edges"]
Example #2
0
def test_single_request_rejected_embeddings(test_case):
    test_data = vtd.SINGLE_REQUEST_REJECT_EMBEDDING_TEST_CASES[test_case]
    scenario = vtd.get_test_scenario(test_data)

    v = vine.OfflineViNEAlgorithm(
        scenario,
        edge_embedding_model=vine.ViNEEdgeEmbeddingModel.UNSPLITTABLE,
        lp_objective=vine.ViNELPObjective.ViNE_COSTS_DEF,
        rounding_procedure=vine.ViNERoundingProcedure.DETERMINISTIC)

    result = v.compute_integral_solution()
    solution = result.get_solution()
    req, m = next(
        solution.request_mapping.iteritems())  # there should only be one...

    assert m is None
Example #3
0
def test_single_request_embeddings_shortest_path_method(
        lp_objective, test_case):
    test_data = vtd.SINGLE_REQUEST_EMBEDDING_TEST_CASES[test_case]

    scenario = vtd.get_test_scenario(test_data)

    v = vine.OfflineViNEAlgorithm(
        scenario,
        edge_embedding_model=vine.ViNEEdgeEmbeddingModel.UNSPLITTABLE,
        lp_objective=lp_objective,
        rounding_procedure=vine.ViNERoundingProcedure.DETERMINISTIC)
    result = v.compute_integral_solution()
    solution = result.get_solution()
    req, m = next(
        solution.request_mapping.iteritems())  # there should only be one...

    expected_mapping = test_data["expected_integer_solution"]
    if expected_mapping is None:
        assert m is None
    else:
        assert isinstance(m, solutions.Mapping)
        assert m.mapping_nodes == expected_mapping["mapping_nodes"]
        assert m.mapping_edges == expected_mapping["mapping_edges"]