Esempio n. 1
0
 def get_explorer(ext_anns: dict,
                  static_routes=None,
                  example="paper_example.json"):
     if static_routes is None:
         static_routes = []
     parser = InputParser(get_test_input_file(example))
     parser._load_data()
     problem = parser._problems_from_data(parser.data,
                                          ext_anns_data=ext_anns)[0]
     problem.static_routes = static_routes
     return Explorer(problem)
Esempio n. 2
0
    def test_ecmp(self):
        flow = Flow(4, "XYZ")
        explorer = Explorer(
            InputParser(get_test_input_file("ecmp.json")).get_problems()[0])
        next_hops = PaperExampleFwGraphsTest.compute_next_hops(flow, explorer)
        fw_graph = PaperExampleFwGraphsTest.get_fw_graph(flow, explorer)

        self.cmp_next_hops(next_hops["XYZ"], {
            0: "R-ext_0",
            1: "R-0",
            2: "R-0",
            3: "R-0",
            4: "R-0",
            5: "R-0"
        })
        self.assertEqual(
            "[src: 4, dst: XYZ, next: [[-1], [2], [0], [1, 5], [3], [2]]]",
            str(fw_graph))
Esempio n. 3
0
    def test_asymmetric_2(self):
        flow = Flow(0, "XYZ")
        explorer = Explorer(
            InputParser(
                get_test_input_file("asymmetric_alt.json")).get_problems()[0])
        next_hops = PaperExampleFwGraphsTest.compute_next_hops(flow, explorer)
        fw_graph = PaperExampleFwGraphsTest.get_fw_graph(flow, explorer)

        self.assertEqual(explorer._igp_provider.get_igp_cost(1, 4), 6)

        self.cmp_next_hops(next_hops["XYZ"], {
            0: "R-4",
            1: "R-4",
            2: "R-4",
            3: "R-4",
            4: "R-ext_4",
            5: "R-4"
        })
        self.assertEqual(
            "[src: 0, dst: XYZ, next: [[2], [], [5], [4], [-1], [3]]]",
            str(fw_graph))
Esempio n. 4
0
                        help='print debug log to console')
    args = parser.parse_args()

    if args.debug:
        log.initialize('DEBUG')
    elif args.quiet:
        log.initialize('WARNING')
    else:
        log.initialize('INFO')

    input_file = get_relative_to_working_directory(args.input_file)
    query_file = None
    if args.query:
        query_file = get_relative_to_working_directory(args.query)

    parser = InputParser(input_file, query_file)
    problems = parser.get_problems()
    for problem in problems:
        problem.target_precision = args.precision
        explorer = Explorer(problem)
        sol = explorer.explore_all()

        log.info("explored states: {}".format(sol.num_explored))
        log.info("precision: {}".format(sol.p_explored.invert().val()))

        p_low = sol.p_property.val()
        p_up = sol.p_property.val() + sol.p_explored.invert().val()

        print("P({}) ∈ [{:8.8f}, {:8.8f}]".format(
            problem.property.get_human_readable(parser.name_resolver), p_low,
            p_up))
 def test_ecmp(self):
     problem = InputParser(get_test_input_file("ecmp.json")).get_problems()[0]
     self.compare_to_reference(problem, "ecmp.txt")
 def test_nsfnet_alt_(self):
     problem = InputParser(get_test_input_file("Nsfnet_alt.json")).get_problems()[0]
     self.compare_to_reference(problem, "Nsfnet_alt.txt")
Esempio n. 7
0
 def test_parsing_normal(self):
     parser = InputParser(get_test_input_file("example.json"))
     p = parser.get_problems()[0]
Esempio n. 8
0
 def test_parsing_properties(self):
     parser = InputParser(get_test_input_file("different_properties.json"))
     p = parser.get_problems()[0]
Esempio n. 9
0
 def test_parsing_separate_query(self):
     parser = InputParser(get_test_input_file("example_topology_only.json"),
                          get_test_input_file("example_query_only.json"))
     p = parser.get_problems()[0]
Esempio n. 10
0
def get_paper_problem():
    return InputParser(get_paper_problem_file()).get_problems()[0]
Esempio n. 11
0
 def test_overview_example(self):
     flow = Flow(3, "XYZ")
     problem = InputParser(
         get_test_input_file("overview_example.json")).get_problems()[0]
     e = Explorer(problem)
     sol = e.explore_all()