Esempio n. 1
0
def find_drone_action(state, d):
    if len(state.warehouses) == 1:
        # optimalization for scenario when there is just one warehouse
        closest_warehouses = state.warehouses[:]
    else:
        closest_warehouses = find_closest_nonempty_warehouses(state, d)

    for w in closest_warehouses:
        action = find_drone_action_for_warehouse(state, d, w)
        if action != None:
            return action

    return None
Esempio n. 2
0
def get_chunk_for_drone(state, chunked_routes, d):
    # TODO: here could be smart choosing of the chunk based on how
    # many orders will be closed by that flight

    # print("chunks: " + str(len(chunked_routes)))
    # for chunk in chunked_routes:
    #     print(str(len(chunk.routes)))

    for w in find_closest_nonempty_warehouses(state, d):
        chunks_of_w = list(filter(lambda ch: ch.w == w, chunked_routes))

        if len(chunks_of_w) > 0:
            chunk = chunks_of_w[0]
            chunked_routes.remove(chunk)
            return chunk

    return None