Пример #1
0
def test_compute_cmv():
    parameters = Params.Parameters(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                                   1, 1, 1, 1)
    num_points = 5
    points = [
        Point2D.Point2D(0.0, 1.0),
        Point2D.Point2D(1.0, 0.0),
        Point2D.Point2D(2.0, 0.0),
        Point2D.Point2D(3.0, 0.0),
        Point2D.Point2D(3.0, 4.0)
    ]

    interceptor_system = lip.Decide(num_points, points, parameters,
                                    Con.Connector.ANDD, None)

    interceptor_system.parameters.radius2 = 10
    interceptor_system.parameters.radius2 = 1.5
    interceptor_system.parameters.nPTS = 5
    interceptor_system.parameters.dist = 1.5
    interceptor_system.parameters.area2 = 4
    expected = [
        True, True, True, True, False, False, False, True, True, True, True,
        False, False, False, False
    ]

    # Testing if all cmv values are correctly set
    interceptor_system.compute_cmv()
    assert sum(interceptor_system.cmv) == sum(expected)
Пример #2
0
def test_compute_fuv():
    # Creates a boolean array of length 15, The element FUV[i] is 1 if:
    # --- PUV[i] is 0
    # --- all elements in PUM are true

    parameters = Params.Parameters(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                                   1, 1, 1, 1)
    num_points = 1
    points = [Point2D.Point2D(0.0, 1.0)]

    interceptor_system = lip.Decide(num_points, points, parameters,
                                    Con.Connector.ANDD, None)

    interceptor_system.puv = [1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1]
    interceptor_system.pum = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
                              [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
                              [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
                              [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
                              [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
                              [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
                              [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
                              [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
                              [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
                              [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
                              [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
                              [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
                              [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
                              [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
                              [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]
    expected = [1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1]

    # Testing if an fuv value is correctly set
    interceptor_system.compute_fuv()
    assert interceptor_system.fuv[0] == expected[0]
Пример #3
0
def test_lic11(points, num_points, g_pts, expected):
    parameters = Params.Parameters(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                                   1, 1, 1, 1)
    interceptor_system = lip.Decide(num_points, points, parameters,
                                    Con.Connector.ANDD, None)

    interceptor_system.parameters.g_pts = g_pts
    assert interceptor_system.lic_11() == expected
Пример #4
0
def test_within_circle(p1, p2, p3, radius, expected):
    parameters = Params.Parameters(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                                   1, 1, 1, 1)
    interceptor_system = lip.Decide(3, [
        Point2D.Point2D(0.0, 0.0),
        Point2D.Point2D(1.0, 0.0),
        Point2D.Point2D(1.0, 1.0)
    ], parameters, Con.Connector.ANDD, None)
    assert interceptor_system.within_circle(p1, p2, p3, radius) == expected
Пример #5
0
def test_lic1(points, radius1, expected):
    num_points = 3
    parameters = Params.Parameters(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                                   1, 1, 1, 1)
    interceptor_system = lip.Decide(num_points, points, parameters,
                                    Con.Connector.ANDD, None)

    interceptor_system.parameters.radius1 = radius1
    assert interceptor_system.lic_1() == expected
Пример #6
0
def test_lic7(points, num_points, k_pts, length1, expected):
    parameters = Params.Parameters(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                                   1, 1, 1, 1)
    interceptor_system = lip.Decide(num_points, points, parameters,
                                    Con.Connector.ANDD, None)

    interceptor_system.parameters.k_pts = k_pts
    interceptor_system.parameters.length1 = length1
    assert interceptor_system.lic_7() == expected
Пример #7
0
def test_lic6(points, num_points, n_pts, dist, expected):
    parameters = Params.Parameters(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                                   1, 1, 1, 1)
    interceptor_system = lip.Decide(num_points, points, parameters,
                                    Con.Connector.ANDD, None)

    interceptor_system.parameters.n_pts = n_pts
    interceptor_system.parameters.dist = dist
    assert interceptor_system.lic_6() == expected
Пример #8
0
def test_lic10(points, num_points, e_pts, f_pts, area1, expected):
    parameters = Params.Parameters(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                                   1, 1, 1, 1)
    interceptor_system = lip.Decide(num_points, points, parameters,
                                    Con.Connector.ANDD, None)

    interceptor_system.parameters.e_pts = e_pts
    interceptor_system.parameters.f_pts = f_pts
    interceptor_system.parameters.area1 = area1
    assert interceptor_system.lic_10() == expected
Пример #9
0
def test_lic9(points, num_points, c_pts, d_pts, epsilon, expected):
    parameters = Params.Parameters(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                                   1, 1, 1, 1)
    interceptor_system = lip.Decide(num_points, points, parameters,
                                    Con.Connector.ANDD, None)

    interceptor_system.parameters.c_pts = c_pts
    interceptor_system.parameters.d_pts = d_pts
    interceptor_system.parameters.epsilon = epsilon
    assert interceptor_system.lic_9() == expected
Пример #10
0
def test_lic8(points, num_points, a_pts, b_pts, radius1, expected):
    parameters = Params.Parameters(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                                   1, 1, 1, 1)
    interceptor_system = lip.Decide(num_points, points, parameters,
                                    Con.Connector.ANDD, None)

    interceptor_system.parameters.a_pts = a_pts
    interceptor_system.parameters.b_pts = b_pts
    interceptor_system.parameters.radius1 = radius1
    assert interceptor_system.lic_8() == expected
Пример #11
0
def test_decide():
    parameters = Params.Parameters(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                                   1, 1, 1, 1)
    interceptor_system = lip.Decide(0, None, parameters, Con.Connector.ANDD,
                                    None)
    interceptor_system.fuv = [
        True, True, True, True, True, True, True, True, True, True, True, True,
        True, True, True
    ]

    assert interceptor_system.launch_decision()
Пример #12
0
def test_lic2(epsilon, expected):
    num_points = 4
    points = [
        Point2D.Point2D(-1.0, -1.0),
        Point2D.Point2D(0.0, 0.0),
        Point2D.Point2D(1.0, 0.0),
        Point2D.Point2D(1.0, -1.0)
    ]
    parameters = Params.Parameters(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                                   1, 1, 1, 1)
    interceptor_system = lip.Decide(num_points, points, parameters,
                                    Con.Connector.ANDD, None)

    interceptor_system.parameters.epsilon = epsilon
    assert interceptor_system.lic_2() == expected
Пример #13
0
def test_lic4(q_pts, q_uads, expected):
    num_points = 4
    points = [
        Point2D.Point2D(1.0, 1.0),
        Point2D.Point2D(1.0, -1.0),
        Point2D.Point2D(-1.0, 1.0),
        Point2D.Point2D(-1.0, -1.0)
    ]
    parameters = Params.Parameters(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                                   1, 1, 1, 1)
    interceptor_system = lip.Decide(num_points, points, parameters,
                                    Con.Connector.ANDD, None)

    interceptor_system.parameters.q_pts = q_pts
    interceptor_system.parameters.q_uads = q_uads
    assert interceptor_system.lic_4() == expected
Пример #14
0
def test_lic3(area1, expected):
    num_points = 5
    points = [
        Point2D.Point2D(1.0, 1.0),
        Point2D.Point2D(1.0, 0.0),
        Point2D.Point2D(0.0, 0.0),
        Point2D.Point2D(-3.0, 3.0),
        Point2D.Point2D(-3.0, 0.0)
    ]
    parameters = Params.Parameters(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                                   1, 1, 1, 1)
    interceptor_system = lip.Decide(num_points, points, parameters,
                                    Con.Connector.ANDD, None)

    interceptor_system.parameters.area1 = area1
    assert interceptor_system.lic_3() == expected
Пример #15
0
def test_lic0(length1, expected):
    num_points = 5
    points = [
        Point2D.Point2D(0.0, 0.0),
        Point2D.Point2D(1.0, 1.0),
        Point2D.Point2D(3.0, 5.0),
        Point2D.Point2D(10.0, 10.0),
        Point2D.Point2D(20.0, 20.0)
    ]

    parameters = Params.Parameters(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                                   1, 1, 1, 1)
    interceptor_system = lip.Decide(num_points, points, parameters,
                                    Con.Connector.ANDD, None)

    interceptor_system.parameters.length1 = length1
    assert interceptor_system.lic_0() == expected
Пример #16
0
def test_compute_pum():
    cmv = [1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1]
    lcm = [
        [
            Con.Connector.ANDD, Con.Connector.ANDD, Con.Connector.ORR,
            Con.Connector.ANDD, Con.Connector.NOTUSED, Con.Connector.ANDD,
            Con.Connector.ORR, Con.Connector.ANDD, Con.Connector.NOTUSED,
            Con.Connector.ANDD, Con.Connector.ORR, Con.Connector.ANDD,
            Con.Connector.NOTUSED, Con.Connector.NOTUSED, Con.Connector.NOTUSED
        ],
        [
            Con.Connector.ANDD, Con.Connector.ANDD, Con.Connector.ORR,
            Con.Connector.ANDD, Con.Connector.NOTUSED, Con.Connector.ANDD,
            Con.Connector.ORR, Con.Connector.ANDD, Con.Connector.NOTUSED,
            Con.Connector.ANDD, Con.Connector.ORR, Con.Connector.ANDD,
            Con.Connector.NOTUSED, Con.Connector.NOTUSED, Con.Connector.NOTUSED
        ],
        [
            Con.Connector.ANDD, Con.Connector.ANDD, Con.Connector.ORR,
            Con.Connector.ANDD, Con.Connector.NOTUSED, Con.Connector.ANDD,
            Con.Connector.ORR, Con.Connector.ANDD, Con.Connector.NOTUSED,
            Con.Connector.ANDD, Con.Connector.ORR, Con.Connector.ANDD,
            Con.Connector.NOTUSED, Con.Connector.NOTUSED, Con.Connector.NOTUSED
        ],
        [
            Con.Connector.ANDD, Con.Connector.ANDD, Con.Connector.ORR,
            Con.Connector.ANDD, Con.Connector.NOTUSED, Con.Connector.ANDD,
            Con.Connector.ORR, Con.Connector.ANDD, Con.Connector.NOTUSED,
            Con.Connector.ANDD, Con.Connector.ORR, Con.Connector.ANDD,
            Con.Connector.NOTUSED, Con.Connector.NOTUSED, Con.Connector.NOTUSED
        ],
        [
            Con.Connector.ANDD, Con.Connector.ANDD, Con.Connector.ORR,
            Con.Connector.ANDD, Con.Connector.NOTUSED, Con.Connector.ANDD,
            Con.Connector.ORR, Con.Connector.ANDD, Con.Connector.NOTUSED,
            Con.Connector.ANDD, Con.Connector.ORR, Con.Connector.ANDD,
            Con.Connector.NOTUSED, Con.Connector.NOTUSED, Con.Connector.NOTUSED
        ],
        [
            Con.Connector.ANDD, Con.Connector.ANDD, Con.Connector.ORR,
            Con.Connector.ANDD, Con.Connector.NOTUSED, Con.Connector.ANDD,
            Con.Connector.ORR, Con.Connector.ANDD, Con.Connector.NOTUSED,
            Con.Connector.ANDD, Con.Connector.ORR, Con.Connector.ANDD,
            Con.Connector.NOTUSED, Con.Connector.NOTUSED, Con.Connector.NOTUSED
        ],
        [
            Con.Connector.ANDD, Con.Connector.ANDD, Con.Connector.ORR,
            Con.Connector.ANDD, Con.Connector.NOTUSED, Con.Connector.ANDD,
            Con.Connector.ORR, Con.Connector.ANDD, Con.Connector.NOTUSED,
            Con.Connector.ANDD, Con.Connector.ORR, Con.Connector.ANDD,
            Con.Connector.NOTUSED, Con.Connector.NOTUSED, Con.Connector.NOTUSED
        ],
        [
            Con.Connector.ANDD, Con.Connector.ANDD, Con.Connector.ORR,
            Con.Connector.ANDD, Con.Connector.NOTUSED, Con.Connector.ANDD,
            Con.Connector.ORR, Con.Connector.ANDD, Con.Connector.NOTUSED,
            Con.Connector.ANDD, Con.Connector.ORR, Con.Connector.ANDD,
            Con.Connector.NOTUSED, Con.Connector.NOTUSED, Con.Connector.NOTUSED
        ],
        [
            Con.Connector.ANDD, Con.Connector.ANDD, Con.Connector.ORR,
            Con.Connector.ANDD, Con.Connector.NOTUSED, Con.Connector.ANDD,
            Con.Connector.ORR, Con.Connector.ANDD, Con.Connector.NOTUSED,
            Con.Connector.ANDD, Con.Connector.ORR, Con.Connector.ANDD,
            Con.Connector.NOTUSED, Con.Connector.NOTUSED, Con.Connector.NOTUSED
        ],
        [
            Con.Connector.ANDD, Con.Connector.ANDD, Con.Connector.ORR,
            Con.Connector.ANDD, Con.Connector.NOTUSED, Con.Connector.ANDD,
            Con.Connector.ORR, Con.Connector.ANDD, Con.Connector.NOTUSED,
            Con.Connector.ANDD, Con.Connector.ORR, Con.Connector.ANDD,
            Con.Connector.NOTUSED, Con.Connector.NOTUSED, Con.Connector.NOTUSED
        ],
        [
            Con.Connector.ANDD, Con.Connector.ANDD, Con.Connector.ORR,
            Con.Connector.ANDD, Con.Connector.NOTUSED, Con.Connector.ANDD,
            Con.Connector.ORR, Con.Connector.ANDD, Con.Connector.NOTUSED,
            Con.Connector.ANDD, Con.Connector.ORR, Con.Connector.ANDD,
            Con.Connector.NOTUSED, Con.Connector.NOTUSED, Con.Connector.NOTUSED
        ],
        [
            Con.Connector.ANDD, Con.Connector.ANDD, Con.Connector.ORR,
            Con.Connector.ANDD, Con.Connector.NOTUSED, Con.Connector.ANDD,
            Con.Connector.ORR, Con.Connector.ANDD, Con.Connector.NOTUSED,
            Con.Connector.ANDD, Con.Connector.ORR, Con.Connector.ANDD,
            Con.Connector.NOTUSED, Con.Connector.NOTUSED, Con.Connector.NOTUSED
        ],
        [
            Con.Connector.ANDD, Con.Connector.ANDD, Con.Connector.ORR,
            Con.Connector.ANDD, Con.Connector.NOTUSED, Con.Connector.ANDD,
            Con.Connector.ORR, Con.Connector.ANDD, Con.Connector.NOTUSED,
            Con.Connector.ANDD, Con.Connector.ORR, Con.Connector.ANDD,
            Con.Connector.NOTUSED, Con.Connector.NOTUSED, Con.Connector.NOTUSED
        ],
        [
            Con.Connector.ANDD, Con.Connector.ANDD, Con.Connector.ORR,
            Con.Connector.ANDD, Con.Connector.NOTUSED, Con.Connector.ANDD,
            Con.Connector.ORR, Con.Connector.ANDD, Con.Connector.NOTUSED,
            Con.Connector.ANDD, Con.Connector.ORR, Con.Connector.ANDD,
            Con.Connector.NOTUSED, Con.Connector.NOTUSED, Con.Connector.NOTUSED
        ],
        [
            Con.Connector.ANDD, Con.Connector.ANDD, Con.Connector.ORR,
            Con.Connector.ANDD, Con.Connector.NOTUSED, Con.Connector.ANDD,
            Con.Connector.ORR, Con.Connector.ANDD, Con.Connector.NOTUSED,
            Con.Connector.ANDD, Con.Connector.ORR, Con.Connector.ANDD,
            Con.Connector.NOTUSED, Con.Connector.NOTUSED, Con.Connector.NOTUSED
        ]
    ]
    parameters = Params.Parameters(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                                   1, 1, 1, 1)
    num_points = 5
    points = [
        Point2D.Point2D(0.0, 1.0),
        Point2D.Point2D(1.0, 0.0),
        Point2D.Point2D(2.0, 0.0),
        Point2D.Point2D(3.0, 0.0),
        Point2D.Point2D(3.0, 4.0)
    ]

    interceptor_system = lip.Decide(num_points, points, parameters,
                                    Con.Connector.ANDD, None)

    interceptor_system.cmv = cmv
    interceptor_system.lcm = lcm
    expected = [1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1]

    # Testing if a pum value is correctly set
    interceptor_system.compute_cmv()
    assert interceptor_system.pum[0] == expected[0]