You are on page 1of 24

Chapter 3 Introduction to LP - Part 2

Professor Heesang Lee


SKK University
3.5 Spreadsheet Solution – SW1
 Cell LP 를 위한 개념
 Cell 이름  Data cells
 C4  열 먼저 , 행 다음
 Range  중간에 : 사용
 Target cell
 1, 2 차원 range  Output cells
 ctrl C, V, X 작동  Changing cells
 참조  Solver
 기본적으로 상대 참조
 절대참조 : $ 를 앞에 붙임
 내장 함수
 =sum, =product, …
 =average, =MAX, …
 =sumproduct
 =sumif
2/24
HSLee@SKKU
Loading Solver
 Standard with 2019+ Excel version
 파일 메뉴에서 옵션 탭 선택
 창이 뜨면 추가기능 탭에서 아래 비활성 응용 프로그램 “해찾기 추가 기능”으로
이동
 해찾기 기능을 체크 . 확인
 설치되면 데이터 메뉴 중 해찾기가 나타남
 Standard with 2007 Excel version
 Home 스위치에서
 Excel 옵션 탭
 추가기능 – 해찾기 – Excel 추가기능 이동 – 해찾기 기능을 체크 . 확인
 설치되면 데이터 메뉴 중 해찾기가 나타남
 Standard with old version of Excel
 Insert MS Office or Excel master CD
 Click on “Add/Delete” components
 Open “Add-In” tools
 Click on “Solver” or “add all”
 Click “OK”
 Solver should now appear in the “Tools” menu

3/24
HSLee@SKKU
3.5 Spreadsheet Fig. 3.16
 범위 (range) 이름 이용
 범위 이름 (range name) 은 범위 지정한 블록 단위의 셀을 묘사하는 내용으로 결정
 Wyndor 문제의 자료 셀에 주어진 이름은 : ProfitPerBatch (C4:D4), HoursUsedPerUnitProduced (C7:D9),
HoursAvailable (G7:G9) 등등
 범위 이름은 단어간에 빈 칸을 허용하지 않고 , 각 단어는 대문자로 시작

 범위 이름을 입력하려면
 이름을 지정할 셀 , 셀 범위 또는 인접하지 않은 선택 영역을 선택 , 수식 입력줄의 왼쪽 끝에서 이름
상자를 클릭 , 선택 영역을 참조하는 데 사용할 이름을 입력
 이름에는 255 자까지 사용할 수 있음 . 이름을 만드는 추가 규칙에 대한 자세한 내용은 이름의 구문 규칙에
대한 자세한 정보 섹션을 참고 . Enter 키를 입력

4/24
HSLee@SKKU
3.5 Spreadsheet Fig. 3.16
 제약식 반영 Data Cell
Data cells
E7 = C7*C12 + D7*D12 (A11*x1 + A12*x2)
Target cell

 E8 = C8*C12 + D8*D12 (A21*x1 + A22*x2) Output cells


 E9 = C9*C12 + D9*D12 (A31*x1 + A32*x2) Changing cells
 목적함수 작성 Target Cell
 G12 = SUMPRODUCT(C4:D4, C12:D12) (c1*x1 + c2*x2)
 또는 TotalProfit = SUMPRODUCT(ProfitPerBatch, BatchesProduced)

Changing Cells
Output Cells
5/24
HSLee@SKKU
3.5 Spreadsheet Fig. 3.16

6/24
HSLee@SKKU
3.5 Spreadsheet
Fig. 3.17

데이터 Tab 에서 해찾기를 부름

7/24
HSLee@SKKU
3.5 Spreadsheet Fig. 3.18

8/24
HSLee@SKKU
3.5 Spreadsheet Fig. 3.19

9/24
HSLee@SKKU
3.5 Spreadsheet Fig. 3.20

10/24
HSLee@SKKU
3.5 Spreadsheet Fig. 3.21

11/24
HSLee@SKKU
3.5 Spreadsheet Fig. 3.22

12/24
Excel for Radiation Therapy
Min 0.4 x1 + 0.5 x2
s.t. 0.3 x1 + 0.1 x2  2.7
0.5 x1 + 0.5 x2 = 6
Mary's Radiation Therapy Problem 0.6 x1 + 0.4 x2  6
x1 , x2  0
Fraction of Entry Dose Range Name Cells

Absorbed by Area (Average) Total Restriction on DosageRestriction G7:G9

Beam 1 Beam 2 Dosage Total Average EntryDosage C11:D11

Healthy Anatomy 0.4 0.5 5.25 Dosage (Kilorads) FractionAbsorbed C6:D9

Critical Tissues 0.3 0.1 2.7 <= 2.7 TotalDosage E6:E9

Tumor Region 0.5 0.5 6 = 6 TotalDosageToHealthyAnatomy E6

Center of Tumor 0.6 0.4 6.3 >= 6

Entry Dosage (kilorads) 7.5 4.5

13/24
HSLee@SKKU
Regional Planning of Kibbutzim: Excel
Maximize Z = 1,000(x1 + x2 + x3) + 750(x4 + x5 + x6) + 250(x7 + x8 + x9)

Southern Confederation of Kibbutzim Regional Planning Problem

Sugar
Beets Cotton Sorghum Range Name Cells
Net Return (per acre) $1,000 $750 $250 AcresPlanted C10:E12
CropsPlanted C13:E13
Water Consumption (per
acre) 3 2 1 MaximumQuota C15:E15
Total NetReturn C4:E4
Acres
Planted Acres Usable Proportion Water Water TotalAcresPlanted F10:F12
Sugar Re- Alloca-
Beets Cotton Sorghum Planted Land Used quired tion TotalNetReturn I15
Kibbutz 1 133.333 100 0 233.333 <= 400 0.583 600 <= 600 UsableLand H10:H12
Kibbutz 2 100 x1 250 x4 0 x7 350 <= 600 0.583 800 <= 800 WaterAllocation M10:M12
Kibbutz 3 25 x2 150 x5 0 x8 175 <= 300 0.583 375 <= 375 WaterConsumption C6:E6
Total Crops Planted x3 x6 x9 (all con-
(acres) 258.333 500 0 strained =) WaterRequired K10:K12
<= <= <=

Total
Net
Maximum Quota (acres) 600 500 325 Return $633,333.33

14/24
HSLee@SKKU
Spreadsheet Formulation for Save-It Co.
Maximize Profit = 5.5(xA1 + xA2 + xA3 + xA4) + 4.5(xB1 + xB2 + xB3 + xB4) + 3.5(xC1 + xC2 + xC3 + xC4)
Restriction on treatment cost:
3(xA1 + xB1 + xC1) + 6(xA2 + xB2 + xC2) + 4(xA3 + xB3 + xC3) + 5(xA4 + xB4 + xC4) = 30,000
B C D E F G H I J K L M
3 Grade A Grade B Grade C Rest. on amount:
4 Unit Amalg. Cost $3.00 $2.50 $2.00 xA1 + xB1 + xC1 ≥ 1,500 Total Treatment Cost $30,000
5 Unit Selling Price $8.50 $7.00 $5.50 xA2 + xB2 + xC2 ≥ 1,000 =
6 Unit Profit $5.50 $4.50 $3.50 xA3 + xB3 + xC3 ≥ 2,000 Treatment Funds Available $30,000 Availability of Materi-
7 xA4 + xB4 + xC4 ≥ 500 als:
8 xA1 + xB1 + xC1 ≤ 3,000
9 Material Allocation Unit Total xA2 + xB2 + xC2 ≤ 2,000
10 (pounds of material used for each product grade) Treament Minimum Material xA3 + xB3 + x C3 ≤ 4,000
Amount
11 Grade A Grade B Grade C Cost to Treat Treated xA4 + xB4 +Available
xC4 ≤ 1,000
12 Material 1 412.3 2,587.7 0 $3 1,500 <= 3,000 <= 3,000
13 Material 2 859.6 517.5 0 $6 1,000 <= 1,377 <= 2,000
14 Material 3 447.4 1,552.6 0 $4 2,000 <= 2,000 <= 4,000
15 Material 4 429.8 517.5 0 $5 500 <= 947 <= 1,000
16 Total Products 2,149.1 5,175.4 0
17 Mixture
18 Mixture Specifications Percents
19 Grade A, Material 1 412.3 <= 644.7 30% of Grade A
20 Total Profit $35,110 Grade A, Material 2 859.6 >= 859.6 40% of Grade A
21 Grade A, Material 3 447.4 <= 1,074.6 50% of Grade A
22 Grade A, Material 4 429.8 = 429.8 20% of Grade A
23
24 Grade B, Material 1 2,587.7 <= 2,587.7 50% of Grade B
25 Grade B, Material 2 517.5 >= 517.5 10% of Grade B
26 Grade B, Material 4 517.5 = 517.5 10% of Grade B
27
28 Grade C, Material 1 0.0 <= 0.0 70% of Grade C

xA1 ≤ 0.3 (xA1 + xA2 + xA3 + xA4)


xA2 ≥ 0.4 (xA1 + xA2 + xA3 + xA4)
xA3 ≤ 0.5 (xA1 + xA2 + xA3 + xA4)
xA4 = 0.2 (xA1 + xA2 + xA3 + xA4)
xB1 ≤ 0.5 (xB1 + xB2 + xB3 + xB4)
15/24
xB2 ≥ 0.1 (xB1 + xB2 + xB3 + xB4)
HSLee@SKKU xB4 = 0.1 (xB1 + xB2 + xB3 + xB4)
x ≤ 0.7 (x + x + x + x )
Figure 4.3 Union Airways Personnel Scheduling Problem
Min $170 x1 + $160 x2 + $175 x3 + $180 x4 + $195 x5
x1 ≥ 48
x1 + x2 ≥ 79
x1 + x2 ≥ 65
x1 + x2 + x3 ≥ 87
x2 + x3 ≥ 64
x3 + x4 ≥ 73
x3 + x4 ≥ 82
x4 ≥ 43
B C D E F G H Ix4 + x5 ≥ 52J
3 6am-2pm 8am-4pm Noon-8pm 4pm-midnight 10pm-6am x5 ≥ 15
4 Shift Shift Shift Shift Shift
5 Cost per Shift $170 $160 $175 $180 $195
6 Total Minimum
7 Time Period Shift Works Time Period? (1=yes, 0=no) Working Needed
8 6am-8am 1 0 0 0 0 48 >= 48
9 8am-10am 1 1 0 0 0 79 >= 79
10 10am- 12pm 1 1 0 0 0 79 >= 65
11 12pm-2pm 1 1 1 0 0 118 >= 87
12 2pm-4pm 0 1 1 0 0 70 >= 64
13 4pm-6pm 0 0 1 1 0 82 >= 73
14 6pm-8pm 0 0 1 1 0 82 >= 82
15 8pm-10pm 0 0 0 1 0 43 >= 43
16 10pm-12am 0 0 0 1 1 58 >= 52
17 12am-6am 0 0 0 0 1 15 >= 15
18
19 6am-2pm 8am-4pm Noon-8pm 4pm-midnight 10pm-6am
20 Shift Shift Shift Shift Shift Total Cost
21 Number Working 48 31 39 43 15 $30,610

16/24
HSLee@SKKU
Distribution Network: EXCEL Spreadsheet model
F1- F2- DC- W1- W2- Actual Re-
Requirement F1-F2 DC F1-W1 DC W2 W2 W1 flow quired

F1 1 1 1 50 = 50

F2 -1 1 40 = 40
DC -1 -1 1 0 = 0
W1 -1 1 -1 -30 = -30
W2 -1 -1 1 -60 = -60
Capacity 10 80
Unit Cost ($100) 2 4 9 3 1 3 2 490

Solution 0 40 10 40 80 0 20

17/24
HSLee@SKKU
Distribution Network: EXCEL Spreadsheet model

=SUMIF(B$5:B$11,I5,D$5:D$11)-SUMIF(C$5:C$11,I5,D$5:D$11)

=SUMIF(B$5:B$11,I6,D$5:D$11)-
SUMIF(C$5:C$11,I6,D$5:D$11)

18/24
HSLee@SKKU
3.6 Large Models Modeling Languages
 Citgo had 3,000 functional constraints and
15,000 decision variables
 Need for a modeling language

 You can learn MPL and Lingo

19/24
HSLee@SKKU
LINDO & LINGO – SW2
(see 부록 4.1 in pages 154 ~ 157)

 LINGO can be downloaded from the textbook


web site
 https://www.lindo.com/index.php/ls-downloads/try-lingo 에 가서
윈도우 /MAC OS 에 맞게 ( 대부분 Windows 64 Bit) 버전 20.0 을
다운 받음
 설치 후에는 license key 입력 없이 데모 버전으로 사용 ( 데모
버전은 변수 300 개 , 제약식 150 개까지 가능 )
 설치 후 lingo document 를 열거나 사용자가 코딩 후 사용

20/24
HSLee@SKKU
Using LINGO to Solve LPs
 Use a plain text file as input file:
 no super/subscripts
 case insensitive

Title is optional.
Begin with “Max = obj function” or “Min = obj function”

End each sentence with ;

Objective function is given as a sum of terms. Each term has

 a coefficient constant (number) and


 a variable name (beginning with a letter)

(Ex) “3 * x11”  3 is a coefficient and x11 is a variable name

21/24
HSLee@SKKU
Using LINGO to Solve LPs
 Below the objective function is the system command “Sub-
ject to” followed by a series of constraints.
 Each constraint consists of LHS, (in)equality sign, and
RHS.
 LHS is a sum of terms like the objective function
 Use “>” or “>=“ for “”
(Note) By continuity assumption, “>” is interpreted as “>=“.
 Use and < or “<=“ for “”
 Do not use “/” as a notation for division
(Ex) “x1/x2 > 2”  “x1 - 2 x2 > 0”
 RHS must be a single constant (number) term. No variable should
be in the RHS.
(Ex) “x1 > 2 x2” will cause an error message. 22/24
HSLee@SKKU
Wyndor Glass Co. Problem. LINGO model
! Wyndor Glass Co. Problem. LINGO model;
! X1 = batches of product 1 per week;
! X2 = batches of product 2 per week;
! Profit, in 1000 of dollars;
[Profit]
MAX = 3*X1 + 5*X2;
! Production time;
[Plant1] X1 <= 4;
[Plant2] 2*X2 <= 12;
[Plant3] 3*X1 + 2*X2 <= 18;

23/24
HSLee@SKKU
Homework
 Problem 3.5.4
 Problem 3.5.5 (a), (b), (c) & (e) (not (d))
 Problem 3.6.1 (a), (b), & (d) (not (c))

24/24
HSLee@SKKU

You might also like