170 likes | 561 Views
BRANCH-AND-BOUND STRATEGY. 呂卓燃. BRANCH AND BOUND STRATEGE. 用來找出最短路徑的問題 e.g. A multi-stage graph searching problem. Find a shortest path from V 0 to V 3. A TREE-REPRESENTATION. 一般的解法. V 0. 1. 2. 3. V 1.1. V 1.2. V 1.3. 5. 3. 4. 3. 2. 7. V 2.1. V 2.3. V 2.1. V 2.2. V 2.2.
E N D
BRANCH AND BOUND STRATEGE • 用來找出最短路徑的問題 • e.g. • A multi-stage graph searching problem. • Find a shortest path from V0 to V3.
A TREE-REPRESENTATION 一般的解法 V0 1 2 3 V1.1 V1.2 V1.3 5 3 4 3 2 7 V2.1 V2.3 V2.1 V2.2 V2.2 V2.3 4 1 4 1 1 1 V3 V3 V3 V3 V3 V3 10 5 11 7 5 10
SOLVED BY BRANCH –AND-BOUND FIND A SHORTEST PATH 用 branch and bound 的策略可找到最短路徑為5, 因此,第一條路徑 6 已經大於 5,就不用接下去做, 用這樣的方式可以執行節省時間 V0 a 1 2 3 V1.1 V1.2 V1.3 b c d 5 3 4 3 2 7 V2.1 V2.3 V2.1 V2.2 V2.2 V2.3 e f h i j k 6>5 6>5 7>5 9>5 1 1 V3 V3 g l 5 5
PERSONNEL ASSIGNMENT PROBLEM • A linearly ordered set of persons P={P1, P2, …, Pn} where P1<P2<…<Pn • A partially ordered set of jobs J={J1, J2, …, Jn} • Suppose that Pi and Pj are assigned to jobs f(Pi) and f(Pj) respectively. If f(Pi) ≤ f(Pj), then Pi ≤ Pj. Cost Cij is the cost of assigning Pi to Jj. We want to find a feasible assignment with the minimum cost. i.e. • Xij = 1 if Pi is assigned to Jj • Xij = 0 otherwise. • Minimize ∑i,j CijXij
TOPOLOGICALLY SORTED • 假設在 G=(V,E),對於任何 (Vi , Vj ) 為 G 的有向邊, 也就是存在一條路徑從 Vi 到 Vj ,則在走訪G的所有 頂點時,頂點 Vi 一定會在 Vj 的前面,這種走訪順序 就稱為拓樸排序。 • 拓樸排序的作法為: • 選擇一個入邊數為0的頂點輸出 • 將所有屬於該頂點的邊刪除
TOPOLOGICALLY SORTED範例 • http://www.jcc.jx.cn/xinwen3/news/kj/flash/2009/0426/1302.htm
J1, J1 J2, J2 J3, J4 ↓ J1, ↘ J2, ↓ J4, J3 J3 J4 J1, J3, J2, J4 J2, J1, J3, J4 J2, J1, J4 J3 假設J={ J1,J2,J3,J4} P={ P1,P2,P3,P4 } 一開始可以選 J1 和 J2 假如先選 J1 A partial ordering of jobs 把 J1 所連結的邊刪除 接著可以選 J2 和 J3 ,假設先選J2 再把J2連結的邊刪除 最後輸出J3和J4 All the topologically sorted sequence 依照上訴的步驟, 可以再選出以下幾組方式
ALL POSSIBLE SOLUTIONS CAN BE REPRESENTED BY A SOLUTION TREE • 可把剛剛拓普排序的結果建成 Tree 0 1 2 2 3 1 3 4 2 4 3 4 3 4 3 4
Cost matrix (-12)直覺上的意思是,第一個人分配到這四份工作 最少要付出12元,那麼我就先給第一個人12元, 其他(-26), (-3),(-10)也是一樣的意思。 Reduced cost matrix (-12) (-26) (-3) (-10) (-3)
A reduced cost matrix can be obtained: subtract a constant from each row and each column respectively such that each row and each column contains at least one zero. • Total cost subtracted:12+26+3+10+3 = 54 • This is a lower bound of our solution.
AN ENUMERATION TREE ASSOCIATED WITH THE REDUCED COST MATRIX 0 54 Person assigned 1 2 58 71 1 2 3 1 72 71 64 2 76 78 86 70 68 3 4 2 4 3 3 81 78 91 70 73 4 3 4 3 4 4
Bounding of subsolutions 54 Person assigned 0 58 71 1 1 2 Node to be terminated 64 2 1 70 68 4 3 3 70 73 3 4 4
Why subtract costs from matrix 0 Person assigned 0 1 2 19 29 1 2 3 1 59 55 51 2 66 68 76 60 58 3 4 2 4 3 3 81 78 91 70 73 4 3 4 3 4 4