コード例 #1
0
        walk = shortest_path(all_pair, node, exit)[1:]
        cost = len(path) * d_cost + len(walk) * w_cost
        if cost < best_cost:
            best_node = node
            best_cost = cost
            prev_path = path
    return best_node, prev_path, 0


if __name__ == "__main__":

    # row, column, parking_row, parking_column
    row, column, parking_row, parking_column = 4, 4, 10, 20

    print("-- generate graph --", datetime.datetime.now())
    nodeset, d_size, p_size, n_size = generate_graph(row, column, parking_row,
                                                     parking_column)
    total_spots = d_size + p_size + n_size

    # nodeset = load_spot_graph("spot_graph")
    # total_spots = 179

    enter_node = nodeset[0]

    # center
    total_row = (1 + parking_column + 2) * row + 1
    total_col = (1 + parking_row + 2) * column + 1
    exit_node = nodeset[int(total_row / 2) * total_col + int(total_col / 2)]

    # drive cost of one spot distance
    d_cost = 1.63
    # walk cost of one spot distance
コード例 #2
0
ファイル: search6.py プロジェクト: liuruilinspy/ParkingModel
        for time, p_list in items:
            p_equal_to_time = reduce(lambda x, y: x * y, p_list)
            p_less_than_time = (1 - saving_time_pr_cdf[-1][1]) if len(saving_time_pr_cdf) > 0 else 1
            # saving_time = best_cost - time
            saving_time_pr_cdf.append((best_cost - time, 1 - (p_equal_to_time * p_less_than_time)))
        t = [saving_time_pr_cdf[0]] + [(y[0], y[1] - x[1]) for x, y in zip(saving_time_pr_cdf, saving_time_pr_cdf[1:])]
        exp[next_node] = sum(list(x*y for x, y in t))
    return exp


if __name__ == "__main__":

    # nodeset = load_spot_graph("spot_graph")
    # row, column, parking_row, parking_column
    row, column, parking_row, parking_column = 2, 2, 5, 10
    nodeset, d_size, p_size, n_size = generate_graph(2, 2, 2, 3)

    enter_node = nodeset[0]
    exit_node = nodeset[len(nodeset) - 1]
    p_available = 0.5

    x = 0.2

    # drive cost of one spot distance
    d_cost = 1
    # walk cost of one spot distance
    w_cost = 4
    # u turn cost of one spot distance
    u_cost = 8