Пример #1
0
    def test_sched_optimization(self):
        scheduler = InterleavingScheduler()

        forall_expr = scheduler.assumptions[0]  # Forall(i) GFsched_i=1

        instantiated_expr = _instantiate_expr(forall_expr, 2, False)  # GFsched_0=1 * GFsched_1=1

        result_expr = _apply_log_bit_optimization("sch", instantiated_expr, 2, scheduler)
        expected_expr = BinOp(
            "*", UnaryOp("G", UnaryOp("F", _get_is_true("sch", 0))), UnaryOp("G", UnaryOp("F", _get_is_false("sch", 0)))
        )

        result_str = _get_sorted_conjuncts_str(result_expr)
        expected_str = _get_sorted_conjuncts_str(expected_expr)

        self.assertEqual(expected_str, result_str)
Пример #2
0
    def test_sched_optimization(self):
        scheduler = InterleavingScheduler()

        forall_expr = scheduler.assumptions[0]  # Forall(i) GFsched_i=1

        instantiated_expr = _instantiate_expr(
            forall_expr, 2, False)  # GFsched_0=1 * GFsched_1=1

        result_expr = _apply_log_bit_optimization('sch', instantiated_expr, 2,
                                                  scheduler)
        expected_expr = BinOp(
            '*', UnaryOp('G', UnaryOp('F', _get_is_true('sch', 0))),
            UnaryOp('G', UnaryOp('F', _get_is_false('sch', 0))))

        result_str = _get_sorted_conjuncts_str(result_expr)
        expected_str = _get_sorted_conjuncts_str(expected_expr)

        self.assertEqual(expected_str, result_str)
Пример #3
0
    def test_sched_visual(self):
        scheduler = InterleavingScheduler()
        forall_expr = normalize_conjuncts([parse_expr("Forall(i) a_i=1"), scheduler.assumptions[0]])

        instantiated_expr = _instantiate_expr(forall_expr, 4, False)  # GFsched_0=1 * GFsched_1=1

        result_expr = _apply_log_bit_optimization("sch", instantiated_expr, 4, scheduler)
        print(
            """::test_sched_visual::
Check visually the correctness.
The original expr is Forall(i) a_i=1 * GFfair_sched_i=1,
 after scheduler_log_bit optimization and instantiation with cutoff=4
 it is expected to receive
  a_0=1 * a_1=1 * a_2=1 * a_3=1 *
  GF(sch0=0 * sch1=0) *
  GF(sch0=0 * sch1=1) *
  GF(sch0=1 * sch1=0) *
  GF(sch0=1 * sch1=1)
        """,
            result_expr,
        )
        print("The result is")
        print(result_expr)
Пример #4
0
    def test_sched_visual(self):
        scheduler = InterleavingScheduler()
        forall_expr = normalize_conjuncts(
            [parse_expr('Forall(i) a_i=1'), scheduler.assumptions[0]])

        instantiated_expr = _instantiate_expr(
            forall_expr, 4, False)  # GFsched_0=1 * GFsched_1=1

        result_expr = _apply_log_bit_optimization('sch', instantiated_expr, 4,
                                                  scheduler)
        print(
            '''::test_sched_visual::
Check visually the correctness.
The original expr is Forall(i) a_i=1 * GFfair_sched_i=1,
 after scheduler_log_bit optimization and instantiation with cutoff=4
 it is expected to receive
  a_0=1 * a_1=1 * a_2=1 * a_3=1 *
  GF(sch0=0 * sch1=0) *
  GF(sch0=0 * sch1=1) *
  GF(sch0=1 * sch1=0) *
  GF(sch0=1 * sch1=1)
        ''', result_expr)
        print('The result is')
        print(result_expr)