示例#1
0
def initilization():
    print('Initialize the environment')
    ParseTopologyFile.parse_aSHIIP_topology_bi_directional(
        POMDPSettings.TOPOLOGY_FILE_NAME, POMDPSettings.adjacent_matrix)
    if POMDPSettings.USER_INPUT_TARGET_NODE:
        while (True):
            print("Please enter the target node. Any number between [0-%s]" %
                  (len(POMDPSettings.adjacent_matrix) - 1))
            user_input_target_node = int(input())
            if user_input_target_node > len(POMDPSettings.adjacent_matrix) - 1:
                print("No Such Node. Please try again")
                continue
            POMDPSettings.target_node.append(
                user_input_target_node
            )  ########### Assuming one target node currently, so index will be 0
            break
    else:
        POMDPSettings.target_node = POMDPSettings.STATIC_TARGET_NODE
    print("Target Node : %s" % (POMDPSettings.target_node))

    ############################################# Now we are assuming just one target for each POMDP agent #############################
    target_resource = POMDPSettings.target_node[0]
    POMDPSettings.all_pair_shortest_path[
        target_resource] = Dijkstra.Dijkstra_algorithm_unweighted(
            target_resource, POMDPSettings.adjacent_matrix)
    # PrintLibrary.all_pair_shortest_path_print(POMDPSettings.all_pair_shortest_path)  ######## Print the shortest path knowledge #############
    print('******* End of static environment initialization ***************')
def initialization():
    create_state_space()
    # Utilities.print_space_properties() ################ Print Space Properties
    ParseTopologyFile.parse_aSHIIP_topology(POMDPSettings.TOPOLOGY_FILE_NAME,
                                            POMDPSettings.adjacent_matrix)
    # Utilities.print_Topology(POMDPSettings.adjacent_matrix)
    ###################### What is the target node and find distance matrix of these nodes to other nodes #############################
    while (True):
        print("Please enter the target node. Any number between [0-%s]" %
              (len(POMDPSettings.adjacent_matrix) - 1))
        user_input_target_node = int(input())
        if user_input_target_node > len(POMDPSettings.adjacent_matrix) - 1:
            print("No Such Node. Please try again")
            continue
        POMDPSettings.target_node.append(
            user_input_target_node
        )  ########### Assuming one target node currently, so index will be 0
        break
    print("Target Node : %s" % (POMDPSettings.target_node))
    Utilities.generate_inital_probability()
    print("Initial Belief %s" % (POMDPSettings.initial_belief_position))
    POMDPSettings.all_pair_shortest_path[POMDPSettings.target_node[0]] = \
        Dijkstra.Dijkstra_algorithm_unweighted(POMDPSettings.target_node[0],POMDPSettings.adjacent_matrix)
    POMDPModules.generate_initial_state()