列车路线跟踪系统 [英] Train route tracking system

查看:70
本文介绍了列车路线跟踪系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我希望在用户选择源和目的地时显示列车查找应用程序。我打算使用.net(WEB API)&用于项目的SQL Server。目前我已经设计了下表。但我无法弄清楚找到路线的算法。站点在主表中进行定制,下面提到的表是用于存储路由的表。序列用于确定所选节点中的路线是什么是下一站。





1.每个站点都有上下火车[A - B& BA]

2.有时用户可能需要选择两列或更多列车才能完成旅程。



我有什么试过:



Hello,

I am hoping to build an train finding application when user pick source and destination will show a train to take. I am planning to use .net (WEB API) & SQL Server for the project. Currently i have designed the below Table. But I can't figure out an algorithm to find routes. Stations are per-defied in a master table and below mentioned table is the table use to store the route. Sequence is used to determine within a route in a selected node what is the next stop.


1. Every station has up and down trains [A - B & B-A]
2. Some times user may have to pick two or more trains to complete his journey.

What I have tried:

DECLARE @TrainTimeTable TABLE( 
    ID              INT,
    RoutID          INT, -- Route id (ABC to DEF)
    Sequance        INT, -- determine the next station of the same route
    BeforeStation   INT, - A
    CurrentStation  INT, - B
    [Arr.Time]      TIME, 
    [Dep.Time]      TIME
)

推荐答案

Quote:

查看旅行商问题,分支和绑定算法...

Look into the traveling salesman problem, branch and bound algorithms ...



抱歉不同意,它不是TSP。

旅游推销员问题 - 维基百科 [ ^ ]



这更像是扭曲的最短路径问题。

Dijkstra算法 - 维基百科 [ ^ ]



在SQL中你无法做到这一点。你必须从服务器加载数据并应用算法。

你必须定义什么是最短路径,可能是在给定的开始时间从a点到B点的最快方式。这是您需要定义的成本函数。


Sorry to disagree, it is not a TSP.
Travelling salesman problem - Wikipedia[^]

It is more like the shortest path problem with a twist.
Dijkstra's algorithm - Wikipedia[^]

There is no way you can do this in SQL. You have to load the data from the server and apply algorithm.
You have to define what is the shortest path, probably something like the fastest way to go from point a to point B for a given starting time. That is the "cost function"that you need to define.


这篇关于列车路线跟踪系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆