예제 #1
0
def get_test_linear_request(number_of_nodes, name="test_request", demand=1.0):
    """
    Generate a simple chain as a LinearRequest object.

    :param number_of_nodes:
    :param name:
    :param demand:
    :return:
    """
    test_request = datamodel.LinearRequest(name)
    last_node = None
    for i in range(1, number_of_nodes + 1):
        new_node = "{}_node_{}".format(name, i)
        test_request.add_node(new_node, demand,
                              scenariogeneration.UNIVERSAL_NODE_TYPE)
        if last_node is not None:
            test_request.add_edge(last_node, new_node, demand)
        last_node = new_node
    return test_request
예제 #2
0
def get_example_scenario_from_paper():
    sub = datamodel.Substrate("sub1")
    request = datamodel.LinearRequest("req1")
    example_scenario = datamodel.Scenario("Sen1", sub, [request])

    sub.add_node('v1', ["FW", "DPI"], {"FW": 2, "DPI": 1}, {"FW": 1, "DPI": 1})
    sub.add_node('v2', ["FW"], {"FW": 2}, {"FW": 1})
    sub.add_node('v3', ["FW", "DPI"], {"FW": 2, "DPI": 1}, {"FW": 1, "DPI": 1})
    #           - EDGES
    sub.add_edge('v1', 'v2', capacity=2)
    sub.add_edge('v2', 'v3', capacity=2)
    sub.add_edge('v3', 'v1', capacity=2)
    # REQUEST NODES AND EDGES
    request.add_node('i1', 1, "FW", allowed_nodes=["v1", "v2", "v3"])
    request.add_node('i2', 1, "DPI", allowed_nodes=["v3", "v1"])
    request.add_node('i3', 1, "FW", allowed_nodes=["v1"])
    request.add_edge('i1', 'i2', 2)
    request.add_edge('i2', 'i3', 2)
    request.profit = 10000
    return example_scenario
def example():
    from alib import datamodel
    reader = scenariogeneration.TopologyZooReader(path="../../github-alib/data/topologyZoo")
    substrate = reader.read_from_yaml(
        dict(topology="Aarnet",
             edge_capacity=1.0,
             node_types=["t1"],
             node_capacity=1.0,
             node_type_distribution=1.0),
        include_location=True
    )
    req = datamodel.LinearRequest("example_req")
    req.add_node("i", 1.0, "t1", allowed_nodes=["1"])
    req.add_node("j", 1.0, "t1", allowed_nodes=["2", "7"])
    req.add_node("l", 1.0, "t1", allowed_nodes=["3", "5"])
    req.add_edge("i", "j", 1.0)
    req.add_edge("j", "l", 1.0)

    ext_graph = extendedgraph.ExtendedGraph(req, substrate)
    visualizer = ExtendedGraphVisualizer()
    visualizer.visualize(ext_graph, substrate=substrate, output_path="./out/test_example.png")
예제 #4
0
def test_extendedgraph_generation():
    substrate = datamodel.Substrate("sub1")
    request = datamodel.LinearRequest("linearreq1")
    # REQUEST NODES AND EDGES
    request.add_node('i', 2, "FW")
    request.add_node('j', 2, "DPI")
    request.add_node('l', 2, "FW")
    request.graph['start_node'] = 'i'
    request.graph['end_node'] = 'j'
    request.add_edge('i', 'j', 2)
    request.add_edge('j', 'l', 2)
    # SUBSTRATE: - NODES
    substrate.add_node('u', ["FW"], {"FW": 1}, {"FW": 1})
    substrate.add_node('v', ["FW"], {"FW": 1}, {"FW": 1})
    substrate.add_node('w', ["DPI"], {"DPI": 1}, {"DPI": 1})
    #           - EDGES
    #           - EDGES
    substrate.add_edge('u', 'v')
    substrate.add_edge('v', 'w')
    substrate.add_edge('u', 'w')
    # generation
    ext_graph = extendedgraph.ExtendedGraph(request, substrate)
    assert len(ext_graph.edges) == 17
    print(ext_graph)
 def setup(self):
     self.request = datamodel.LinearRequest("req1")
예제 #6
0
 def setup(self):
     self.substrate = datamodel.Substrate("sub1")
     self.request = datamodel.LinearRequest("req1")
     self.scenario = datamodel.Scenario("Sen1", self.substrate,
                                        [self.request])