示例#1
0
                          goal=(3, 2),
                          step_cost=1,
                          walls=[(1, 1), (2, 2)])

        algo = RAOStar(model,
                       cc=0.1,
                       debugging=False,
                       cc_type='o',
                       fixed_horizon=6,
                       random_node_selection=False)

        policy_current_belief = {
            (1, 0): 1.0
        }  # initial state is: current vehicle
        s_time = time.time()
        P, G = algo.search(policy_current_belief)
        print('expanded nodes', len(G.nodes))
        print('objective:', G.root.value)
        print('Time:', time.time() - s_time)
        IPython.embed()

    elif Network:
        model = NetworkModel()

        algo = RAOStar(model,
                       cc=0.20,
                       debugging=False,
                       cc_type='o',
                       fixed_horizon=6,
                       random_node_selection=True)
示例#2
0
    if len(sys.argv) > 1:
        cc = float(sys.argv[1])

    model = Ashkan_ICAPS_Model(str(cc * 100) + "% risk")
    algo = RAOStar(model,
                   cc=cc,
                   debugging=False,
                   cc_type='e',
                   ashkan_continuous=True)

    agent_coords = [6, 9]
    agent_coords = [7, 3]

    b0 = ContinuousBeliefState(9, 1)
    b0.set_agent_coords(agent_coords[0], agent_coords[1])
    P, G = algo.search(b0)

    most_likely_policy(G, model)
    Sim = Simulator(10, 10, G, P, model, grid_size=50)

    # Convert all matrices to strings for json
    # print(G)

    gshow = graph_to_json.policy_to_json(G, 0.5, 'results/ashkan_9_1.json')

    # code to draw the risk grid
    # for i in range(11):
    #     for j in range(11):
    #         static_risk = static_obs_risk_coords(
    #             np.matrix([i, j]), np.matrix([[0.2, 0], [0, 0.2]]))
    #         dynamic_risk = dynamic_obs_risk_coords(
示例#3
0
from iterative_raostar import *

#### Run RAO star on Scenario ####
# Simulation conditions
world_size = (7, 7)  # note the boundaries are walls
goal_state = (5, 5, 90)
quad_init = (1, 1, 90, 0)  # (x,y,theta,t)
guest_init = (3, 1, 90, 0)

# note the boundary of the world (ex anything with row column 0 and the upper bound)
# is the wall
model = QuadModel(world_size, goal_state)
algo = RAOStar(model, cc=0.5, debugging=False)

b_init = {(quad_init, guest_init): 1.0}  # initialize belief state

P, G = algo.search(b_init)

# # get the policies that does not give none
# P_notNone = {}
# for i in P:
#     if P[i] != 'None':
#         P_notNone[i] = P[i]

# print(P_notNone)

# # print out the policy for each state of guest
# most_likely_policy(G, model)

gshow = graph_to_json.policy_to_json(G, 0.5, 'quadraos.json')
示例#4
0
print(agent1_vehicle.action_list[0].precondition_check(
    agent1_vehicle.name, geordi_model.current_state, geordi_model))

new_states = geordi_model.state_transitions(geordi_model.current_state,
                                            actions[0])

print('new_states', new_states)

algo = RAOStar(geordi_model,
               cc=0.01,
               debugging=False,
               cc_type='o',
               fixed_horizon=1)

b_init = {geordi_model.current_state: 1.0}
P, G = algo.search(b_init, iter_limit=5)

for keys, values in P.items():
    state, probability, depth = keys
    best_action = values

    node_info = {}
    node_info['state'] = state
    node_info['probability'] = probability
    node_info['depth'] = depth
    node_info['the_best_action'] = best_action

    # if depth == 0:
    #     if best_action == 'ActionModel(ego_forward)':
    #         result = 'forward'
    #     elif best_action == 'ActionModel(ego_merge_right)':