1 線性規劃與整數規劃模式 linear and integer programming models chapter 2

62
1 線線線線線線線線線線線 線線線線線線線線線線線 Linear and Integer Linear and Integer Programming Models Programming Models Chapter 2

Post on 19-Dec-2015

260 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

1

線性規劃與整數規劃模式線性規劃與整數規劃模式Linear and Integer Linear and Integer

Programming ModelsProgramming Models

線性規劃與整數規劃模式線性規劃與整數規劃模式Linear and Integer Linear and Integer

Programming ModelsProgramming Models

Chapter 2

Page 2: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

2

• 線性規劃模型 (Linear Programming model) 是在一組「線性」的限制式 (a set of linear constraints) 之下,尋找極大化 (maximize) 或極小化 (minimize)一個特定的目標函數 (objective function)

• 線性規劃模型由下列三個部分組成 :– 一組決策變數 (A set of decision variables)– 一個特定的目標函數 (An objective function)– 一組「線性」的限制式 (A set of constraints)

2.1 2.1 線性規劃簡介 線性規劃簡介 Introduction to Linear ProgrammingIntroduction to Linear Programming

Page 3: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

3

線性規劃簡介 線性規劃簡介 Introduction to Linear ProgrammingIntroduction to Linear Programming

• 線性規劃重要性–許多現實問題本身就適用線性規劃模型 –已存在許多有效的求解技巧–已存在許多著名的成功應用實例

• Manufacturing• Marketing• Finance (investment)• Advertising• Agriculture

Page 4: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

4

• 線性規劃重要性– 線性規劃套裝軟體之所產生的結果提供有用的「如果…則」 “ what… if” 的分析資訊

線性規劃簡介 線性規劃簡介 Introduction to Linear ProgrammingIntroduction to Linear Programming

Page 5: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

5

線性規劃模型之假設線性規劃模型之假設 Assumptions for Linear ProgrammingAssumptions for Linear Programming

– 參數具有「確定性」 (certainty)– 目標函數與限制式符合「固定規模報酬」之假設

(constant returns to scale)

– 「疊加性」之假設:決策變數間沒有互動性 ,即某函數之總價值只能藉由線性加總求得

– 「連續性」 (Continuity) 之假設變數值必須再某一個可行範圍內

1 1 單位產品單位產品 $4$4 ,,3Hrs3Hrs 生產生產

500500 單位產品單位產品$4*500=$2000$4*500=$2000,, 3*500=1,500Hrs3*500=1,500Hrs生產生產

Page 6: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

6

典型範例 典型範例 The Galaxy Industries Production Problem The Galaxy Industries Production Problem

• Galaxy 生產兩種玩具模型 :– 宇宙光 Space Ray. – 射擊手 Zapper.

• 資源限制 (Resources)– 1000 磅特殊塑膠化合物 (special plastic)– 每週 40 小時生產時間 (40 hrs of production

time per week)

Page 7: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

7

• 市場需求 (Marketing requirement)– 每週總產量至多 700 打– Space Rays 週產量不能過 Zappers 350 打以上

• 技術係數 (Technological inputs) (Table 2.2) – Space Rays 每打需要 2 pounds 塑膠與 3 分鐘

生產時間– Zappers 每打需要 1pound 塑膠與 4 分鐘生產

時間

典型範例 典型範例 The Galaxy Industries Production ProblemThe Galaxy Industries Production Problem

Page 8: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

8

• 生產需求 : – Space Ray 每打利潤 (profit) $8, Zappers 每打利潤 (profit) $5

– 盡量多生產 Space Ray ,剩餘資源再生產Zapper

• 目前生產計畫 :

Space Rays = 450 dozenZapper = 100 dozenProfit = $4100 per week

典型範例 典型範例 The Galaxy Industries Production ProblemThe Galaxy Industries Production Problem

8(450) + 5(100)

Page 9: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

9

管理是尋求一個生產排程為了是能增加公司的利潤 Management is seeking a production schedule that will

increase the company’s profit.

Page 10: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

10

線性規劃模式可以提供一種深入與聰明之方法來解決此問題

A linear programming model can provide an insight and an

intelligent solution to this problem.

Page 11: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

11

• 決策變數決策變數 ((Decisions variables)::

– X1 = 每週生產的 Space Rays 打數– X2 = 每週生產的 Zappers 打數

• 目標函數目標函數 ((Objective Function):

– 極大化每週總利潤

典型範例線性規劃模式典型範例線性規劃模式The Galaxy Linear Programming ModelThe Galaxy Linear Programming Model

Page 12: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

12

Max 8X1 + 5X2 ( 每週總利潤 )subject to2X1 + 1X2 1000 ( 塑膠原料 ,Plastic)

3X1 + 4X2 2400 ( 生產時間 ,Production Time)

X1 + X2 700 ( 最大產量 ,Total production)

X1 - X2 350 ( 組合 )

Xj> = 0, j = 1,2 ( 非負值 ,Nonnegativity)

典型範例線性規劃模式典型範例線性規劃模式The Galaxy Linear Programming ModelThe Galaxy Linear Programming Model

Page 13: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

13

2.3 2.3 線性規劃模式圖形分析 線性規劃模式圖形分析 Graphical Analysis of Linear Graphical Analysis of Linear ProgrammingProgramming

滿足模型全部限制式的所有點集合稱為

The set of all points that satisfy all the constraints of the model is called a

可行區域可行區域FEASIBLE FEASIBLE REGIONREGION

Page 14: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

14

圖形表示法 (graphical presentation)

―所有限制式所有限制式 (all the constraints)(all the constraints)

―目標函數目標函數 (objective function)(objective function)

―可行點可行點 (three types of feasible points)(three types of feasible points)

Page 15: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

15

The non-negativity constraints( 非負限制式 )

X2

X1

圖形分析 圖形分析 – – 可行區域可行區域Graphical Analysis – the Feasible RegionGraphical Analysis – the Feasible Region

Page 16: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

16

1000

500

Feasible

X2

Infeasible

Production Time 限制式3X1+4X2 2400

Total production 限制式 X1+X2 700 ( 多餘 )

500

700

Plastic 限制式2X1+X2 1000

X1

700

圖形分析 圖形分析 – – 可行區域可行區域Graphical Analysis – the Feasible RegionGraphical Analysis – the Feasible Region

Page 17: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

17

1000

500

Feasible

X2

Infeasible

Production Time 限制式3X1+4X22400

Total production 限制式 X1+X2 700 ( 多餘 )

500

700

Mix 限制式X1-X2 350

Plastic 限制式2X1+X2 1000

X1

700

圖形分析 圖形分析 – – 可行區域 可行區域 (p. 67~68)(p. 67~68)Graphical Analysis – the Feasible RegionGraphical Analysis – the Feasible Region

• 可行點 (feasible points) 有三種內部點 Interior points. 邊界點 Boundary

points.端點 Extreme points.

Page 18: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

18

以圖形求解是為了尋求最佳解以圖形求解是為了尋求最佳解Solving Graphically for an Solving Graphically for an

Optimal SolutionOptimal Solution

Page 19: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

19

尋求最佳解圖解程序 尋求最佳解圖解程序 (p.71)(p.71)The search for an optimal solutionThe search for an optimal solution

由任一個 profit 開始 , say profit = $1,250.

往利潤增加方向移動 increase the profit, if possible...

持續平行移動到無法增加為止 continue until it becomes infeasible

Optimal Profit =$4360

500

700

1000

500

X2

X1

紅色線段 Profit =$1250

Page 20: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

20

最佳解 最佳解 (p.69)(p.69) Summary of the optimal solutionSummary of the optimal solution

Space Rays X1 * = 320 dozen

Zappers X2 * = 360 dozen

Profit Z * = $4360

– 此最佳解使用了所有的塑膠原料 (plastic) 與生產時間 (production hours).

2X1 + 1X2 = 1000 ( 塑膠原料 ,Plastic)

3X1 + 4X2 = 2400 ( 生產時間 ,Production Time)

Excel試算表

束縛方程式 (Binding Constraints): 等式被滿足之限制式

Page 21: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

21

最佳解 最佳解 (p.70~71)(p.70~71) Summary of the optimal solutionSummary of the optimal solution

– 總產量 (Total production) 680 打 (not 700 打 )

– Space Rays 產量只超過 Zappers 40 打

非束縛方程式 (Non-Binding Constraints) :最佳點不在其等式之限制式

寬鬆 (Slack) :限制式右邊與左邊的差額,代表資源的剩餘數量

X1 + X2 = 680 < 700 ( 總產量 )X1 - X2 = -40 < 350 ( 產品組合 )

總產量有 700-680=20 的寬鬆產品組合有 350-(-40) = 390 的寬鬆

Page 22: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

22

– 若一個線性規劃問題有一組最佳解,此最佳解一定發生在”端點”上 ( 端點最佳解之候選人 ,True/False)

– 兩個束縛方程式的交點形成一個”端點”或”角點”

端點與最佳解 端點與最佳解 (p.72)(p.72)Extreme points and optimal solutionsExtreme points and optimal solutions

端點:可行區域的角點 2X1+ X2 = 1000

X1-X2 = 350 之解(450,100)

(320,360)

2X1+ X2 = 10003X1+4X2 = 2400 之解

(0,600)

3X1+4X2 = 2400 X1 = 0 之解

Page 23: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

23

• 若多重最佳解存在,則目標函數必定平行其中一個限制式

多重最佳解多重最佳解Multiple optimal solutionsMultiple optimal solutions

•多重最佳解之任何加權平均值亦為一組最佳解

X1=(350,0) 最佳解 1

X2=(0,600)最佳解 2

X=αX1+(1-α)X2 , α∈[0,1] 亦為最佳解

目標函數 Z

Page 24: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

24

2.4 2.4 最佳解敏感性分析之角色最佳解敏感性分析之角色 The Role of Sensitivity Analysis The Role of Sensitivity Analysis

of the Optimal Solution (p.75)of the Optimal Solution (p.75)

• 輸入參數之變動對於最佳解之敏感度為何 ?

• 從事敏感性分析之原因:–輸入參數可能只是估計值或最佳估計值–模型建立在一個動態環境,因此有些參數可能變動

–“如果 ..會” (“What-if”)分析可以提供經濟地與作業地資訊 .

Page 25: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

25

• 最佳範圍 (Range of Optimality) (p.76)

– 當其他因素保持不變時,在不改變最佳解之情況下,目

標函數某係數可以變動多少 ?– (p.77)最佳解將不會改變,若

• 目標函數係數仍在最佳範圍內• 不改變其他輸入參數

– 目標函數某係數乘上一個非零正數,則目標函數會改變 .

(1) (1) 目標函數係數之敏感性分析目標函數係數之敏感性分析Sensitivity Analysis of Sensitivity Analysis of

Objective Function Coefficients.Objective Function Coefficients.

Page 26: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

26

600

1000

500 800

X2

X1Max 8X

1 + 5X2

Max 4X1 + 5X

2

Max 3.75X1 + 5X

2

Max 2X1 + 5X

2

目標函數係數之敏感性分析目標函數係數之敏感性分析Sensitivity Analysis of Sensitivity Analysis of

Objective Function Coefficients.Objective Function Coefficients.

最佳解仍為(320,360)

(320,360)C1 係數 =2 ,最佳解為 (0,600)而 (320,360) 不再是最佳解

(0,600)

減少 C1 係數由 8→3.75

Page 27: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

27

600

1000

400 600 800

X2

X1

Max8X1 + 5X

2

Max 3.75X1 + 5X

2

Max 10 X

1 + 5X2

C1 係數的最佳範圍 : [3.75, 10]

目標函數係數之敏感性分析目標函數係數之敏感性分析Sensitivity Analysis of Sensitivity Analysis of

Objective Function Coefficients.Objective Function Coefficients.

增加 C1 係數,由 8→10最佳解仍包含 (320,360)

(320,360) 同理, C2 係數的最佳範圍 : [4, 10.67] (Can you find it ?)

Page 28: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

28

― 一個變數 Xj =0 的縮減成本 RCj為目標函數係數需要增加量的負值 (-Zj) ,使得最佳解中該變數為正數 (Xj >0)

― 縮減成本 RCj為此變數 Xj 每增加一單位(Xj=1) ,目標函數會改變的值

C1=2 X*=(0,600) X1=0→C1=3.75 X*=(320,360) X1=320>0 RC1 =-∆Z1=-(3.75-2)=-1.75

縮減成本 縮減成本 Reduced cost (p.78)Reduced cost (p.78)

Page 29: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

29

600

1000

500 800

X2

X1

Max 3.75X1 + 5X

2

Max 2X1 + 5X

2

目標函數係數之敏感性分析目標函數係數之敏感性分析縮減成本 縮減成本 (p.79)(p.79)

(1,599.25)Z=2998.25

(0,600)Z=3000

X1 ≥1

∆X1=1 ( 由X1=0→X1=1)∆Z=2998.25-3000 = -1.75 RC1 =-1.75

Page 30: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

30

• 問題:– 若其他參數不變之前提下,若右手值變動一個單位,對於目標函數之最佳解有何影響 ?

– 多少變動單位 ( 增加或減少 ) ,可以保持目前最佳解

(2) (2) 右手邊數值 之敏感性分析 右手邊數值 之敏感性分析 (p.78) (p.78) Sensitivity Analysis of Sensitivity Analysis of Right-Hand Side ValuesRight-Hand Side Values

Page 31: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

31

• 發現:– 任意變動束縛函數 (Binding Constraints)之右手值,都會改變目前最佳解

– 非束縛函數 (Non-Binding Constraints)之右手值,當變動數量少於寬鬆 (slack)或剩餘(surplus)量時,都不會改變目前最佳解

– 此結果可以由影子價格 (Shadow Price) 來解釋

右手邊數值 之敏感性分析 右手邊數值 之敏感性分析 Sensitivity Analysis of Sensitivity Analysis of Right-Hand Side ValuesRight-Hand Side Values

Page 32: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

32

影子價格 影子價格 Shadow Prices (p.80)Shadow Prices (p.80)

• 若其他輸入參數不變之前提下,限制式的影子價格 是當其對應的右手值增加一個單位時,對最佳目標函數值的變動量

Page 33: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

33

1000

500

X2

X1

500

2X1 + 1x

2 <=1000

最佳解由(320,360)→(320.8,359.4)

Production time限制式

X*=(320,360) Z*= $4360

2X1 + 1x

2 <=1001

X* =(320.8,359.4) Z* = $4363.4

當右手值增加 ( 例如由 1000→1001) 則可行區域擴大

影子價格影子價格 Shadow Price – Shadow Price – 圖形表示 圖形表示 graphical demonstrationgraphical demonstration

Plastic 限制式

Shadow price = 4363.40 – 4360.00 = 3.40

Page 34: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

34

可行性範圍 可行性範圍 Range of Feasibility (p.81)Range of Feasibility (p.81)

• 若其他輸入參數不變之前提下–右手值的可行性範圍是影子價格依然不變的 右手值可以變動的範圍 .

–在可行性範圍內,目標函數之改變量 Change in objective value = [ 影價 Shadow price]*[ 右手值變量 Change in the right hand side value]

Page 35: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

35

塑膠的可行性範圍 塑膠的可行性範圍 Range of Feasibility Range of Feasibility (p.81) (p.81)

1000

500

X2

X1

500

2X1 + 1x

2 <=1000

塑膠原料的數量可以增加到一個新限制式成為 Binding 為止

Plastic 限制式

此處為不可行解Production time限制式

Total Production限制式X1 + X2 700 Total Production 成為

新的束縛限制式(New Binding Constraint)

Page 36: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

36

塑膠的可行性範圍 塑膠的可行性範圍 Range of FeasibilityRange of Feasibility

1000

500

X2

X1

600

Plastic 限制式

Production time限制式3X1+4X2 ≤ 2400

請注意看:請注意看:當塑膠數量增加時最佳解的變化當塑膠數量增加時最佳解的變化

Total Production限制式X1+X2 ≤ 700 塑膠的可行性範圍塑膠的可行性範圍 上限上限

= 2X1 + 1X2 = 2X1 + 1X2 =2*(400)+300=1100=2*(400)+300=1100

X1+ X2 = 700X1+ X2 = 7003X1+4X2 = 2400 3X1+4X2 = 2400 之解 之解 X*=(400,300)X*=(400,300) 為最佳解為最佳解

2X1 + 1x

2 1000

Page 37: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

37

塑膠的可行性範圍 塑膠的可行性範圍 Range of FeasibilityRange of Feasibility

1000

500

X2

X1

600

Plastic 限制式2X1 + 1X2 1000

請注意看:請注意看:當塑膠數量減少時最佳解的變化當塑膠數量減少時最佳解的變化

XX11 = 0 = 0 成為新的束縛限制式

Infeasiblesolution

3X3X11+ 4X+ 4X22 = 2400 = 2400XX1 1 = 0 = 0 之解 之解 X*=(0,600)X*=(0,600) 為最佳解為最佳解

塑膠的可行性範圍塑膠的可行性範圍 下限下限 =2X=2X1 1 + 1X+ 1X22

= 2*(0)+1*600=600= 2*(0)+1*600=600

Production time限制式3X1+4X2 ≤ 2400

Page 38: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

38

– 已投入成本 (Sunk costs): 未被包括在目標函數係數之計算當中的資源成本 - Shadow Price 為該資源額外一單位的價值

– 淨利潤可以將已投入成本 $3800 由目標函數值中扣除

影子價格的正確解釋 影子價格的正確解釋 The correct The correct interpretation of shadow prices (p.83)interpretation of shadow prices (p.83)

1000 磅塑膠每磅 $3 → Total Cost = $3000Production Time $20/hr → Total Cost =$20*40=$800 不管一週實際使用多少塑膠與 Production Time ,$3000+$800=$3800 都必須支付,故為已投入成本

Page 39: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

39

– 已包括成本 (Included costs): 被包括在目標函數係數之計算當中的資源成本─ Shadow Price 為高於該資源之現有單位價值之額外的價值

– 見 p.84 表格 2.5 說明

影子價格的正確解釋 影子價格的正確解釋 The correct The correct interpretation of shadow prices (p.83)interpretation of shadow prices (p.83)

塑膠每磅 $3 → 塑膠影價每磅 =$3.4 →管理者願意為額外塑膠磅數多支付 $6.8( 已包括成本 )

Production Time $0.33/min (or $20/hr) ,Production Time 影價每分鐘 =$0.4 →管理者願意為額外 Production Time 多支付 $0.73

Page 40: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

40

其他後最佳性變動 其他後最佳性變動 (p.84)(p.84)Other Post - Optimality Changes Other Post - Optimality Changes

• 加入一個新限制式 (Addition of a constraint)

• 刪除一個限制式 (Deletion of a constraint)

決定最佳解是否滿足此限制式Yes, the solution is still optimalNo, re-solve the problem (the new objective function is worse than the original one)

決定刪除的限制式是否為束縛限制式•Yes, re-solve the problem (the new objective function is better than the original one)•No, the solution is still optimal

Page 41: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

41

其他後最佳性變動 其他後最佳性變動 (p.84)(p.84)Other Post - Optimality Changes Other Post - Optimality Changes

• 刪除變數 (Deletion of a variable)

• 增加變數 (Addition of a variable)─ 考慮淨邊際利潤

(Net Marginal Profit)

決定被刪除變數在最佳解中是否為 0Yes, the solution is still optimalNo, re-solve the problem (the new objective function is worse than the original one)

Page 42: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

42

其他後最佳性變動 其他後最佳性變動 (p.85)(p.85)Other Post - Optimality Changes Other Post - Optimality Changes 【範例 】 X3= 新產品大水槍產量 每一個大水槍需 3lb 塑膠與5min 生產時間 每打利潤 $10

Max 8X1 + 5X2+ 10X3 ( 每週總利潤 )subject to

2X1 + 1X2 + 3X3 ≤ 1000 ( 塑膠原料 ,Plastic ,Shadow Price = $3.4)3X1 + 4X2 + 5X3 ≤ 2400 ( 生產時間 ,Production Time, SP = $0.4) X1 + X2 +X3 ≤ 700 ( 最大產量 ,Total production, SP = $0) X1 - X2 ≤ 350 ( 組合 , SP = $0) Xj> = 0, j = 1,2,3 ( 非負值 ,Nonnegativity)

淨邊際利潤 =$10-($3.4*(3)+$0.4*(5)+$0*(1)+$0*(0)) = -$2.2 <0 大水槍不具生產價值

X*=(320,360,0) 仍為最佳解

Page 43: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

43

其他後最佳性變動 其他後最佳性變動 (p.85)(p.85)Other Post - Optimality Changes Other Post - Optimality Changes

• 左手係數的變動 (Changes in the left - hand side

coefficients.)

目前解仍

為最佳

No Yes

最佳解與影子

價格都會變動

模型需重解

束縛限制式

Yes

目前解是否

為最佳

No

Page 44: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

44

2.5 2.5 使用使用 Excel Solver Excel Solver 尋找最佳解尋找最佳解與分析結果與分析結果• 點選 Galaxy.xls,可見輸入試算表• 點選工具 \ 規劃求解 (Solver),可見下列對話視窗 .

Equal To:

By Changing cells這些儲存格包含 決策變數

$B$4:$C$4

加入限制式按此鍵…

Set Target cell $D$6此儲存格包含 目標函數值

$D$7:$D$10 $F$7:$F$10

所有具有相同方向之限制式必須包含在一個” Excel 限制式” .

Page 45: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

45

使用使用 Excel SolverExcel Solver

•點選 Galaxy.xls,可見輸入試算表.

Equal To:

$D$7:$D$10<=$F$7:$F$10

By Changing cells這些儲存格包含 決策變數

$B$4:$C$4

Set Target cell $D$6此儲存格包含 目標函數值

點選 “選項 /Option”並勾選”線性規劃”與 “非負” .

Page 46: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

46

• 點選 Galaxy.xls,可見輸入試算表

Equal To:

$D$7:$D$10<=$F$7:$F$10

By Changing cells$B$4:$C$4

Set Target cell $D$6

使用 使用 Excel SolverExcel Solver

按 Solve 以求最佳解

Page 47: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

47

Space Rays ZappersDozens 320 360

Total LimitProfit 8 5 4360

Plastic 2 1 1000 <= 1000Prod. Time 3 4 2400 <= 2400

Total 1 1 680 <= 700Mix 1 -1 -40 <= 350

GALAXY INDUSTRIES

使用使用 Excel Solver – Excel Solver – 最佳解最佳解

Page 48: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

48

Space Rays ZappersDozens 320 360

Total LimitProfit 8 5 4360

Plastic 2 1 1000 <= 1000Prod. Time 3 4 2400 <= 2400

Total 1 1 680 <= 700Mix 1 -1 -40 <= 350

GALAXY INDUSTRIES

使用使用 Excel Solver – Excel Solver – 最佳解最佳解

Solver 能提供分析報告與最佳解

Page 49: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

49

使用使用 Excel Solver –Excel Solver – 解答報表 解答報表 Answer Answer ReportReport

Microsoft Excel 9.0 Answer ReportWorksheet: [Galaxy.xls]GalaxyReport Created: 11/12/2001 8:02:06 PM

Target Cell (Max)Cell Name Original Value Final Value

$D$6 Profit Total 4360 4360

Adjustable CellsCell Name Original Value Final Value

$B$4 Dozens Space Rays 320 320$C$4 Dozens Zappers 360 360

ConstraintsCell Name Cell Value Formula Status Slack

$D$7 Plastic Total 1000 $D$7<=$F$7 Binding 0$D$8 Prod. Time Total 2400 $D$8<=$F$8 Binding 0$D$9 Total Total 680 $D$9<=$F$9 Not Binding 20$D$10 Mix Total -40 $D$10<=$F$10 Not Binding 390

Page 50: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

50

使用使用 Excel Solver –Excel Solver – 敏感性分析報敏感性分析報表表 Sensitivity ReportSensitivity Report

Microsoft Excel Sensitivity ReportWorksheet: [Galaxy.xls]Sheet1Report Created:

Adjustable CellsFinal Reduced Objective Allowable Allowable

Cell Name Value Cost Coefficient Increase Decrease$B$4 Dozens Space Rays 320 0 8 2 4.25$C$4 Dozens Zappers 360 0 5 5.666666667 1

ConstraintsFinal Shadow Constraint Allowable Allowable

Cell Name Value Price R.H. Side Increase Decrease$D$7 Plastic Total 1000 3.4 1000 100 400$D$8 Prod. Time Total 2400 0.4 2400 100 650$D$9 Total Total 680 0 700 1E+30 20$D$10 Mix Total -40 0 350 1E+30 390

Page 51: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

51

• 不可行性 (Infeasibility): 一模型中無可行點 (p.96)

• 無窮性 (Unboundness): 一模型中可行解存在,但目標函數沒有限制。目標函數值為無限大 ( 在極大化問題 ) 或無限小 ( 在極小化問題 ) (p.98)

• 多重解 (Alternate solution): 一模型中有一個以上的可行點使目標函數為最佳 (p.98)

無單一最佳解之模型無單一最佳解之模型

Page 52: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

52

1

No point, simultaneously,

lies both above line and

below lines and

.

1

2 32

3

不可行模型 不可行模型 Infeasible ModelInfeasible Model

Page 53: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

53

不可行模型 不可行模型 Solver Solver 呈現之結果呈現之結果

Solver 呈現無法找到可行解之結果

Page 54: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

54

無窮性Unbounded solutionUnbounded solution

可行區域

Maximize

目標函數

Page 55: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

55

無窮性模型 無窮性模型 Solver Solver 呈現之結果呈現之結果Solver 呈現 Set Cell 值無法收斂之結果

Page 56: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

56

• Solver 沒有提醒”多重最佳解”存在的情形• 有”多重最佳解”的 LP 模型,則某個變數 Xj 的目標函數的 allowable increase or allowable decrease 為 0.

• 以 Solver 尋找多重最佳解的程序如下: (p.99)

– 觀察到某個變數 Xj中

多重最佳解模型 多重最佳解模型 Solver Solver 呈現之結果呈現之結果

Allowable increase = 0, 或Allowable decrease = 0.

Page 57: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

57

• 加入一個限制式 :Objective function = Current optimal value.

– If Allowable increase = 0, change the objective to Maximize Xj

– If Allowable decrease = 0, change the objective to Minimize Xj

Excel試算表

多重最佳解模型 多重最佳解模型 Solver Solver 呈現之結果呈現之結果

Page 58: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

58

成本最小化問題成本最小化問題

• 海軍海上糧食 : Texfoods, Calration.

• 最小化海上糧食總成本• 維持維他命 A , D 與鐵之基本需求

Page 59: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

59

• 決策變數 (Decision variables)– X1 (X2) -- The number of two-ounce portions of

Texfoods (Calration) product used in a serving.

• The ModelMinimize 0.60X1 + 0.50X2Subject to

20X1 + 50X2 100 Vitamin A 25X1 + 25X2 100 Vitamin D 50X1 + 10X2 100 Iron X1, X2 0

Cost per 2 oz.

% Vitamin Aprovided per 2 oz.

% required

成本最小飲食問題成本最小飲食問題

Page 60: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

60

10

2 44 5

Feasible RegionFeasible Region

Vitamin “D” constraint

Vitamin “A” constraint

The Iron constraint

成本最小飲食問題成本最小飲食問題 – – 圖解法圖解法

Page 61: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

61

• Summary of the optimal solution– Texfood product = 1.5 portions (= 3 ounces)

Calration product = 2.5 portions (= 5 ounces) – Cost =$ 2.15 per serving. – The minimum requirement for Vitamin D and iron are met with

no surplus. – The mixture provides 155% of the requirement for Vitamin A.

成本最小飲食問題成本最小飲食問題

Excel試算表

Page 62: 1 線性規劃與整數規劃模式 Linear and Integer Programming Models Chapter 2

62

• 線性規劃軟體可以求解大型線性模型• 大多數線性規劃軟體使用的技巧

– 單形法 (Simplex Method) ( 原理部分見補充CD3)

– 內點法 (Interior Point Method)

• 整數線性規劃軟體使用的技巧– 如切面法 (Cutting Plane Method)– 分支界限法 (Branch and Bound Point Method)

( 原理部分見補充 CD3)

LPLP 程式的代數解法程式的代數解法