Exemple #1
0
def verification_of_successors(s, list_of_states, option="mild"):
    if option == "heavy":
        Q = polytope(PI(s.n), np.ones((2 * s.n, 1)))
        for state_X in list_of_states:
            state_X.successor_flag = {}
            state_X.successor_flag["Boolean-H"] = subset_polytope(
                post_polytope(s, state_X), state_X.successor[0].polytope)
            state_X.successor_flag["Epsilon"] = successor_check(s, state_X)
            i = state_X.mode
            T = np.dot(s.A[i], state_X.G) + np.dot(s.B[i],
                                                   state_X.successor[2])
            d = np.dot(s.A[i], state_X.x) + np.dot(
                s.B[i], state_X.successor[1]) + s.c[i]
            state_X.successor_flag["Boolean-Td"] = subset_transformed_polytope(
                T, d, Q, state_X.successor[0].polytope)
            state_X.successor_flag["Td in H"] = subset_transformed_polytope(
                state_X.G, state_X.x, Q, state_X.polytope)
    elif option == "mild":
        Q = polytope(PI(s.n), np.ones((2 * s.n, 1)))
        for state_X in list_of_states:
            state_X.successor_flag = {}
            i = state_X.mode
            T = np.dot(s.A[i], state_X.G) + np.dot(s.B[i],
                                                   state_X.successor[2])
            d = np.dot(s.A[i], state_X.x) + np.dot(
                s.B[i], state_X.successor[1]) + s.c[i]
            state_X.successor_flag["Boolean-Td"] = subset_transformed_polytope(
                T, d, Q, state_X.successor[0].polytope)
            state_X.successor_flag["Td in H"] = subset_transformed_polytope(
                state_X.G, state_X.x, Q, state_X.polytope)
for i in s.modes:
    s.F[i] = np.array([[1, -1]]).T
    s.f[i] = np.array([[4, 4]]).T

s.Pi = np.array([[1, 0], [0, 1], [-1, 0], [0, -1]])

s.l[0] = np.array([-0.12, -1]).reshape(2, 1)
s.u[0] = np.array([0.1, 1]).reshape(2, 1)

s.l[1] = np.array([0.1, -1]).reshape(2, 1)
s.u[1] = np.array([0.12, 1]).reshape(2, 1)

s.l[2] = np.array([-0.12, -1]).reshape(2, 1)
s.u[2] = np.array([-0.1, 1]).reshape(2, 1)

s.vertices = vertices_cube(2)
"""
These are polytopes for each mode 
"""
s.mode_polytope = {}
for mode in s.modes:
    p = polytope(s.H[mode], s.h[mode])
    p.anchor = anchor_point(p)
    s.mode_polytope[mode] = p

s.weight = {}
s.weight[0] = 100 / 12
s.weight[1] = 1

s.goal = state(
    np.array([0, 0]).reshape(2, 1), np.array([[0., 0], [0, 0.0]]), 0, 0, 0, 10)