1 / 41

整數線性規劃模型建立

整數線性規劃模型建立. 使用二元變數 The use of binary variables in constraints. 一個變數之決策結果分為 “ yes ” / “ no ” , “ good ” / “ bad ” 等 . 皆為二元分類 說明. 許多現實模型中至少一個決策變數為整數值 整數模型之分類 純整數線性模型 Pure integer (AILP) : 所有決策變數皆為整數 二元整數線性模型 Binary (BILP) : 所有決策變數皆為二元數 (0 或 1) 混合整數線性模型 Mixed integer (MILP) : 有些變數非整數或二元值.

kahlilia
Download Presentation

整數線性規劃模型建立

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 整數線性規劃模型建立

  2. 使用二元變數The use of binary variables in constraints • 一個變數之決策結果分為 “yes”/“no”, “good”/“bad”等.皆為二元分類 • 說明

  3. 許多現實模型中至少一個決策變數為整數值 • 整數模型之分類 • 純整數線性模型Pure integer (AILP):所有決策變數皆為整數 • 二元整數線性模型Binary (BILP) :所有決策變數皆為二元數(0或 1) • 混合整數線性模型Mixed integer (MILP) :有些變數非整數或二元值

  4. 典型範例 (Prototype Example) • Decision Variables • Objective Function Z=Total Net Present Values of these decisions Max Z= 9X1 + 5X2 + 6 X3 + 4X4

  5. Constraint Models 6X1+3X2+5X3 +2X4£ 10 X3 + X4£ 1 X3£ X1 X4£ X2 Constraint Descriptions 1. 4項設備之總資金最多為$10 2. 該公司最多建造一間倉庫 (互斥決策, Mutually Exculsive) 3.公司僅考慮在建廠的城市增設新倉庫 (附屬方案, Contigent Decision)

  6. Math Model Max Z= 9X1+5X2+ 6X3 + 4X4 S.T. 6X1+3X2+ 5X3 + 2X4 £ 10 X3 + X4 £ 1 - X1 +X3 £ 0 - X2 + X4 £ 0 Xj £ 1 X j  0 X1 , X2 , X3 , X4 integers X1 , X2 , X3 , X4 binary

  7. 範例說明 • 二元變數Yi表示某家工廠是否要建 (Yi = 1)或不建 (Yi = 0) 需求Requirement二元Binary表示法 1. 三家工廠中至少兩家 工廠要被建立 Y1 + Y2 + Y3 ³ 2 2. 若工廠1要建,則工廠2不能建 Y1 + Y2£ 1 3. 若工廠1要建,則工廠2也要建 Y1– Y2£ 0 4. 一間工廠要建, 但不可以兩間工廠同時建 Y1+ Y2 = 1 5. 兩者都要或都不要建 Y1– Y2 =0 6. 工廠建設不可超過$17百萬 其中個別成本為 $5, $8, $10百萬 5Y1+8Y2+10Y3£ 17

  8. 若工廠1 不建則 Y1 = 0 限制式變為 6x1 + 9X2 £ 0, 且 X1 = 0 , X2 = 0 若工廠1 建立則 Y1 = 1. 限制式變為 6x1 + 9X2 £ 2000 補充範例一 (見講義) • 工廠1生產鋼材可以製造兩種產品: • 產品 1需要 6磅重鋼材,產品 2需要 9磅重鋼材 • 若工廠1被建後,將有2000磅重鋼材可以利用 • 此產品是否生產取決於工廠1是否建立,表示式如下 6X1 + 9X2£ 2000Y1

  9. 補充範例二:固定費用模型(見講義)(Fixed-Charge Model) 某工廠製造三種類型衣服:Shirts, Shorts, Pants。該廠必須租用機器來製造不同類型之衣服, -機器租金分別如下:Shirts用機器每週租金為$200,Shorts用機器每週租金為$150,Pants用機器每週租金為$100 - 製造衣服所需要勞力與布料的資料,以及其單位售價與單位製造成本分別如下表所示:

  10. X1= number of shirts produced per week • Decision Variables X2= number of shorts produced per week X3= number of pants produced per week • Weekly Profits = Weekly Sales Revenue- Weekly Production Cost - Weekly Renting (Setup) Cost • Objective Function • Z = (12X1 + 8X2 + 15X3)- (6X1 + 4X2 + 8X3)- (200y1 + 150y2 + 100y3) • =6X1+4X2+ 7X3 - 200y1- 150y2 -100y3

  11. Constraints: C1: At most 150 hours of labors can be used per week 6X1 + 2X2 + 6X3 <= 150 C2: At most 160 units of cloth can be used per week 4X1 + 3X2 + 4X3 <= 160 • Math Model Max Z= 6X1+4X2+ 7X3 -200y1-150y2-100y3 S.T. 3X1 + 2X2 + 6X3 £ 150 4X1 + 3X2 + 4X3 £ 160 X1 , X2 , X3 integers y1 , y2 , y3 binary 以LP求解得到: X1 = 30 X2 = 0 X3 = 10 y1 = 0 y2 = 0 y3 = 0

  12. We have X1 <= M*y1 X2 <= M*y2 X3 <= M*y2 加入: If Xi>0, then yi=1 • Constraints: • Math Model Max Z= 6X1+4X2+ 7X3 -200y1-150y2-100y3 S.T. 3X1 + 2X2 + 6X3 £ 150 4X1 + 3X2 + 4X3 £ 160 X1 £ M y1 X2 £ M y2 X3 £ M y3 X1 , X2 , X3 integers y1 , y2 , y3 binary 以LP求解得到: X1* = 0 X2*= 0 X3* = 25 y1 = 0 y2 = 0 y3 = 1 With Z*=75

  13. 補充範例三:集合覆蓋模型(見講義)(Set Covering Model) 某縣有六個重要鄉鎮,該縣政府計畫興建消防隊,因此希望決定建立最少的消防隊數以確保每個城市至少有一對消防隊伍能在15分鐘的車程內。各鄉鎮間與其他鄉鎮的車程時間以下表所示,試建立IP最佳化模式使得消防隊數為最小。

  14. Decision Variables • Objective Function • Min Z = X1 + X2 + X3 + X4 + X5 + X6

  15. Math Model Min Z= X1+X2+ X3 +X4 + X5 +X6 S.T. X1+X2 1 X1+X2 +X6 1 X3 +X4  1 X3 +X4 + X5  1 X4 + X5 +X6  1 X2 + X5 +X6 1 X1 , X2 , X3 , X4 , X5 , X6 binary 以LP求解得到: X1* = 0 X2*= 1 X3* = 0 X4* = 1 X5*= 0 X6* = 0 With Z*=2

  16. 補充範例四:專案選擇模型(見講義)(Project Selection Model) • 專案選擇模型由一群二元變數表示”“go/no-go”的決定 • 模型中包含元件有: • 預算Budget • 空間Space • 優先順序Priority conditions

  17. A市議會─專案選擇 • A市議會的目標是最大化選民之支持度下合理分派預算 • 資料中包含成本costs,可利用資源,計畫優順序.

  18. 民調之結果 X1 X2 X3 X4 X5 X6 X7 X8 X9 A市議會─專案選擇

  19. A市議會─專案選擇 • 決策變數 : Xj- 一組二元決策變數; if a project j is selected (Xj=1) or not (Xj=0) for j=1,2,..,9 • 目標函數: 使經費之計畫總點數最大化 • 限制式: See the mathematical model.

  20. The Mathematical Model 最大預算不能超過 $900,000 Max 4176X1+1774X2+ 2513X3+1928X4+3607X5+962X6+2829X7+1708X8+3003X9 S.T. 400X1+ 350X2+ 50X3+ 100X4+ 500X5+90X6+ 220X7+ 150X8+ 140X9 £ 900 7X1+ X3+ 2X5+ X6+ 8X7+ 3X8+ 2x9 ³ 10 X1+ X2+ X3+ X4 £ 3 X3+ X5 = 1 X7 - X8 = 0 X7 - X9³ 0 x8 - x9³ 0 工作創造限制式:至少十個工作數量 4個警察計畫中至多3個限制式通過 互斥性:警車與消防車購其一 共同必要性:體育與音樂同時恢復或不恢復 體育與音樂須在電腦設備購買前通過 (Xi = 0,1 for i=1, 2…, 9)

  21. 6X1 + 2X2 + 6X3 <= 150 X1 + 3X2 + 4X3 <= 100 +M 6X1 + 2X2 + 6X3 <= 150+M X1 + 3X2 + 4X3 <= 100 or 整數規劃模式彙整 • 二選一限制式(Either-Or Constraints) Either 6X1 + 2X2 + 6X3 <= 150 or X1 + 3X2 + 4X3 <= 100 6X1 + 2X2 + 6X3 <= 150 + My X1 + 3X2 + 4X3 <= 100 +M(1-y) y = 0 or 1 (y is called Auxiliary Variable)

  22. 整數規劃模式彙整 2. N個限制式滿足k個 (k out of N Constraints) F1 (X1 ,X2 , ……,Xn ) = d1 F2 (X1 ,X2 , ……,Xn ) = d2 F3 (X1 ,X2 , ……,Xn ) = d3 …. Fn (X1 ,X2 , ……,Xn ) = dn F1 (X1 ,X2 , ……,Xn ) = d1 + M(1-y1) F2 (X1 ,X2 , ……,Xn ) = d2 + M(1-y2 ) F3 (X1 ,X2 , ……,Xn ) = d3 + M(1-y3 ) …. Fn (X1 ,X2 , ……,Xn ) = dn + M(1-yn )

  23. 5X1 + 3X2 + 3X3 - X4  10 + M(1-y1) 2X1 + 5X2 - X3 + 3X4  10 + M(1-y2) -X1 + 3X2 + 5X3 + 3X4  10 + M(1-y3) 3X1 - X2 + 3X3 + 5X4  10 + M(1-y4) y1 + y2 + y3 + y4  2 , y1 , y2 , y3 , y4 binary X1 + X2 + X3 + X4  4 + M(1-y1) 3X1 - X2 - X3 + X4  3 + M(1-y2) y1 + y2  1 , y1 , y2 binary 課堂練習:(p.11-77) 習題11.3-3 (1) 下列兩不等式最少有一成立 : X1 + X2 + X3 + X4  4 3X1 - X2 - X3 + X4  3 (2) 下列四項不等式至少兩項成立 : 5X1 + 3X2 + 3X3 - X4  10 2X1 + 5X2 - X3 + 3X4  10 -X1 + 3X2 + 5X3 + 3X4  10 3X1 - X2 + 3X3 + 5X4  10

  24. 6X1 + 2X2 = 5y1+10y2+15y3 y1+y2+y3 =1, y1 , y2 , y3 Binary 整數規劃模式彙整 3. 函數有N個可能值 (Function with N Possible Values) F1 (X1 ,X2 , ……,Xn ) = d1 or F1 (X1 ,X2 , ……,Xn ) = d2 or F1 (X1 ,X2 , ……,Xn ) = d3 …. or F1 (X1 ,X2 , ……,Xn ) = dn 課堂練習: 6X1 + 2X2 = 5 or 10 or 15

  25. 整數規劃模式彙整 4. Fixed-Charge Problem 若產品 j 之生產成本,包含固定成本Kj與變動成本Cj,令Xj為產品之生產數量,則其生產成本函數為 : • Math Model Min Z= ∑ kj yj + Cj Xj S.T. Xj £ M yj X1 , X2 , ….., Xj integers y1 , y2 ,….., yj binary

  26. 課本例題一 (產品混合問題) (p.11-22) • Decision Variables • Objective Function Z=Total Profits of these decisions X1= number of Product 1 produced per week X2= number of Product 1 produced per week X3= number of Product 1 produced per week Max Z= 5X1 + 7X2 + 3X3

  27. Constraint Models 3X1+4X2+2X3£ 30 4X1+6X2+2X3 £ 40 X1 £ 7 X2£ 5 X3£ 9 Constraint Descriptions 1. 生產工時限制 2. 可銷售件數限制

  28. Constraint Models X1 £ M y1 X2£ M y2 X3£ M y3 y1 + y2 + y3 £ 2 3X1+4X2+2X3£ 30 + M(1-y4) 4X1+6X2+2X3 £ 40 + M(1-y5) y4 + y5 = 1 Constraint Description 3. 三種新產品最多可以生產兩 種 (利用輔助二元變數) 加入: If Xi>0, then yi=1 If Xi=0, then yi=0 i= 1,2,3 4. 兩工廠中只能選擇一個工廠 生產 (Either-or Constraints)

  29. Math Model Max Z= 5X1+7X2+ 3X3 S.T. X1 £ 7 X2£ 5 X3£ 9 X1 -M y1 £ 0 X2 -M y2 £ 0 X3 -M y3 £ 0 y1 + y2 + y3 £2 3X1 +4X2 +2X3£ 30 + M(1-y4) 4X1 +6X2 +2X3 £ 40 + M(1-y5) y4 + y5 = 1 X1 , X2 , X3 , integers y1 , y2 , y3 , y4 , y5binary

  30. Two Fallacies of IP • Having finite number of feasible solutions ensures that the problem is solvable?? • BIP with n variables →2n solutions to be considered • Exponential Growth of the difficulty of the problem • Best algorithms cannot be guaranteed to solve even relatively small problems

  31. Two Fallacies of IP (2) Removing feasible solutions for LP will make it easier to solve??? • All feasible solutions are corner-point feasible (CPF) solutions that are optimal for the overall problem. • CPF is the key to the remarkable efficiency of the simplex method

  32. Computational Difficulty for IP • Number of integer variables • Any special structure in the problem Pitfalls for IP • Rounding may cause infeasibility • Rounding solution will not be the optimal solution [Definition] LP relaxation The LP problem obtained by omitting all integers or binary constraints on variables.

  33. Solution Methods for LIP • Enumerations (Heuristic Algorithms) • Try all possible computations • Efficient for large problems • Cannot guarantee to find an optimal solution • Meta-heuristic • e.g. Tabu Search, Simulated Annealing, Genetic Algorithm etc. al.

  34. Optimal solution for IP problem: X*1 = 0 X*2 = 6 With Z = 12 Solution Methods for LIP 2. Branch & Bound (i) Observation: if the optimal solution of the LP relaxation of a pure IP are integers, then the optimal solution for the LP relaxation is also optimal solution for the IP. [Example 1] Max Z= 3X1+2X2 s.t.2X1 + X2 £ 6 X1 , X2 ≥ 0, integers Optimal solution for LP relaxation : X*1 = 0 X*2 = 6 With Z = 12

  35. Branch & Bound (Divide & Conquer) [Example 2] Max Z= 8X1+5X2 s.t. X1 + X2 £ 6 9X1 + 5X2 £ 45 X1 , X2 ≥ 0, integers Sub-problem 1 Optimal LP solution for LP relaxation (Sub-problem 1): X*1 = 3.75 X*2 = 2.25 With Z = 165/4 t=1

  36. Sub-problem 2: Sub-problem 3: Sub-problem 1 + X1≥ 4 Sub-problem 1 + X1≤ 3 Optimal LP solution for LP relaxation (Sub-problem 2): X*1 = 4 X*2 = 9/5 With Z =41 t=2

  37. t=3 Optimal LP solution for LP relaxation (Sub-problem 4 is fathomed w with infeasible solution) t=4 Sub-problem 4: Sub-problem 5: Optimal LP solution for LP relaxation (Sub-problem 5) X*1 = 40/9 X*2 = 1 With Z =365/9 Sub-problem 1 + X1≥ 4 + X2 ≥ 2 Sub-problem 1 + X1≥ 4 + X2 ≤ 1 LIFO rules 作 分枝動作 t=4

  38. t=6 t=5 Sub-problem 6: Sub-problem 7: Optimal LP solution for LP relaxation (Sub-problem 7) X*1 = 5 X*2 = 0 With Z =40 Fathomed with LB = 37 → 40 Optimal LP solution for LP relaxation (Sub-problem 7) X*1 = 4 X*2 = 1 With Z =37 Fathomed with Lower Bound (LB) = 37 Sub-problem 5 + X1≥ 5 Sub-problem 5 + X1≤ 4 t =6 t =5 Candidate solution with LB =40 Candidate solution with LB=37

  39. t=7 Sub-problem 3: Optimal LP solution for LP relaxation (Sub-problem 3) X*1 = 3 X*2 = 3 With Z =39 < LB =40 Fathomed with Z < LB Sub-problem 1 + X1≤ 3

  40. Branch & Bound (Conclusion) • Step 1: • If it is not necessary to branch on a sub-problem, it is fathomed • Fathomed Conditions: (1) Sub-problem is infeasible (2) Sub-problem yields an optimal solution (3) the optimal z-value for the sub-problem < current LB • Step 2: when to eliminate a sub-problem? • The sub-problem is infeasible • The z-value for the sub-problem < current LB

  41. Branching on sub-problem 9 could never yield a z-value greater than LB=42 Optimal Solution [Example 3] (Knapsack Problem) Max Z= 16X1+ 22X2 + 12X3+ 8X4 s.t. 5X1 + 7X2 +4X3 + 3X4 £ 14 X1 ,X2 , X 3 , X4 binary X4=0

More Related