简体   繁体   English

如何创建自动车辆路线模拟?

[英]How to create an automated vehicle routing simulation?

I want to create a vehicle routing optimization program. 我想创建一个车辆路线优化程序。 I will have multiple vehicles travelling and delivering items by finding the shortest path from A to B. At first I will simply output results. 通过查找从A到B的最短路径,我将有多辆车辆在行驶和运送物品。首先,我将简单地输出结果。 I may later create a visual representation of the program. 稍后我可以创建程序的直观表示。

It has been suggested to me that I will find it easiest to do this in Python. 有人建议我在Python中最容易做到这一点。

I have to do this task, but it seems very daunting. 我必须执行此任务,但是看起来非常艰巨。 I am not the best programmer yet, but not a beginner either, I am good at maths and a quick learner. 我还不是最好的程序员,但也不是初学者,我擅长数学和快速学习。

Any advice on how to break down this task would be really helpful. 关于如何分解此任务的任何建议将非常有帮助。 Should I use Python? 我应该使用Python吗? Any Python modules that will be particularly suited to this task? 是否有任何特别适合此任务的Python模块?

Psuedo code for A* algorithm from http://en.wikipedia.org/wiki/A*_search_algorithm 来自http://en.wikipedia.org/wiki/A*_search_algorithm的 A *算法的伪代码

function A*(start,goal)
closedset := the empty set    // The set of nodes already evaluated.
openset := {start}    // The set of tentative nodes to be evaluated, initially containing the start node
came_from := the empty map    // The map of navigated nodes.

g_score[start] := 0    // Cost from start along best known path.
// Estimated total cost from start to goal through y.
f_score[start] := g_score[start] + heuristic_cost_estimate(start, goal)

while openset is not empty
    current := the node in openset having the lowest f_score[] value
    if current = goal
        return reconstruct_path(came_from, goal)

    remove current from openset
    add current to closedset
    for each neighbor in neighbor_nodes(current)
        if neighbor in closedset
            continue
        tentative_g_score := g_score[current] + dist_between(current,neighbor)

        if neighbor not in openset or tentative_g_score < g_score[neighbor] 
            came_from[neighbor] := current
            g_score[neighbor] := tentative_g_score
            f_score[neighbor] := g_score[neighbor] + heuristic_cost_estimate(neighbor, goal)
            if neighbor not in openset
                add neighbor to openset

return failure

function reconstruct_path(came_from,current)
    total_path := [current]
    while current in came_from:
        current := came_from[current]
        total_path.append(current)
    return total_path

This is the most common and pratical way to find the shortest path. 这是找到最短路径的最普通和实用的方法。 It basically scans the surrounding area until the start point and check point are met and it stops at any barriers 它基本上会扫描周围的区域,直到达到起点和检查点,并在任何障碍处停止

And depending on how hefty your program is python is not the best because of its slower execution speeds compared with other languages. 而且取决于python程序的繁重程度并不是最佳选择,因为与其他语言相比,它的执行速度较慢。 If your looking for simplicity python is your best friend. 如果您寻求简单性,python是您最好的朋友。

I used networkx the other day, and it was superb. 前几天我使用networkx,它很棒。 Very easy to use, and very quick. 非常易于使用,而且非常快捷。

So you'll need to get your data into some kind of usable format, and then run your algorithms through this. 因此,您需要将数据转换为某种可用格式,然后通过该格式运行算法。

Python is often a good choice for scripting and pulling together pieces of data and analysing them! 对于编写脚本并将数据片段汇总并进行分析,Python通常是一个不错的选择!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM