旅行商问题
旅行商問題 (Travelling Salesman problem)
This problem can be stated as- "Given n number of cities and a travelling salesman has to visit each city. Then we have to find the shortest tour so that the travelling salesman can visit each and every city only once."
可以說這個問題是: “給n個城市,一個旅行推銷員必須訪問每個城市。然后我們必須找到最短的游覽,以便旅行推銷員只能訪問每個城市一次。”
This travelling salesman problem is one of the examples of NP-Complete problems.
這個旅行推銷員問題是NP-完全問題的例子之一。
In the travelling salesman problem, we are given a complete undirected graph G = (V, E) that has a non-negative integer cost c (u, v) associated with each edge (u, v) belongs to E and we must find a tour of G with minimum cost.
在旅行商問題中,我們得到一個完整的無向圖G =(V,E) ,該圖具有與每個邊(u,v)相關(guān)的非負(fù)整數(shù)成本c(u,v) ,屬于E ,我們必須找到以最低的費(fèi)用游覽G。
Let C (A) denotes the total cost of the edges in the subset A is the subset E.
令C(A)表示子集A中邊緣的總成本為子集E。
Practically, it is always cheapest to go directly from a place w, going by way of any intermediate stop V can’t be expensive. Or say, cutting out an intermediate stop never increase the cost. This can be formalized that the cost function c satisfies the triangle inequality, if for all vertices u, v, w £ V .
實(shí)際上,直接從位置w出發(fā)總是最便宜的,通過任何中間停靠點(diǎn)V都不會很昂貴。 或者說,切出一個中間停止點(diǎn)永遠(yuǎn)不會增加成本。 如果對所有頂點(diǎn)u,v,w£V ,成本函數(shù)c可以滿足三角形不等式,則可以形式化。
C (u, w) <= c (u, v) + c (v, w)
C(u,w)<= c(u,v)+ c(v,w)
This triangle inequality is natural one, and is many application it is automatically satisfied. In this problem, our tour starts from an initial state and completes after returning to original state passing through all intermediate states.
這個三角形不等式是自然的,并且在許多應(yīng)用中都可以自動滿足。 在這個問題中,我們的游覽從初始狀態(tài)開始,并在經(jīng)過所有中間狀態(tài)回到原始狀態(tài)后完成。
If the graph has n vertices, i.e., |V| = n, then the solution space S is given by S = { 1, π, 1, π: is a permutation of (2, 3, ..., n)}.
如果圖具有n個頂點(diǎn),即| V | = n ,則解空間S由S = {1,π,1,π:是(2,3,...,n)}的排列給出 。
Then |S| = (n-1)!
然后| S | =(n-1)!
The size of S can be reduced by restricting S so that (1, i1,...i2,i(n-1), 1) belongs to S if and only if (ij, ij + 1) £ E, 0 <= j <= n-1, and i0 = in = 1.
可以通過限制S來減小S的大小,使得(1,i1,... i2,i(n-1),1)屬于S,當(dāng)且僅當(dāng)(ij,ij + 1)£E,0 < = j <= n-1 , i0 = in = 1 。
State space tree for this problem, for n = 4 and initial and final states 1.
這個問題的狀態(tài)空間樹,對于n = 4以及初始狀態(tài)和最終狀態(tài)1 。
翻譯自: https://www.includehelp.com/algorithms/travelling-salesman-problem.aspx
總結(jié)
- 上一篇: c# 浮点数十六进制字符串_从C#中包含
- 下一篇: scala 环境变量_Scala变量的范