0% found this document useful (0 votes)
16 views

268741_Class 3

Uploaded by

Matéo DICONNE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

268741_Class 3

Uploaded by

Matéo DICONNE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 51

1

LINGO Programming &


Sensitivity Analysis
BY… ASSOC. PROF. CHOMPOONOOT KASEMSET, D.ENG.

© 2020 Department of Industrial Engineering, Chiang Mai University


Computer-based Procedure 2

 Systematic Solution Procedures or Standard Algorithms are


developed using computer programming to find solutions.
 There are 2 types of algorithm:
Exact Algorithms: Give optimal solution
Heuristic Algorithms: Give near-optimal solution
 Example for OR software package; LINDO, LINGO, CPLEX, etc.

© 2020 Department of Industrial Engineering, Chiang Mai University


LINGO Modeling Language 3

Components:

SETS

Modeling

DATA

© 2020 Department of Industrial Engineering, Chiang Mai University


SETS (1) 4

 There are 2 types of sets:


Primitive set:
setname /list of members / :variables, parameters;
Examples: Student/ John, Jill, Mike, Mary/ : CGA, age;
Courses/ 1..10/;
Derived set: derived from primitive or other derived sets
setname (parent sets):variables, parameters;
Examples:
Student_Courses (Student,Courses): grade;
© 2020 Department of Industrial Engineering, Chiang Mai University
SETS (2) 5

SET Membership Conditions:


#EQ# #LE# #LT# #GE# #GT# #NE# #AND# #OR# #NOT#
Example:

© 2020 Department of Industrial Engineering, Chiang Mai University


Modeling (1) 6

 Function: Accessing Set Elements


Using Set-Looping functions
@FOR (set(index)| condition : expression);
For all members in set.

Other commands: @SUM, @MIN, @MAX


To find function in LINGO: Edit >> Paste Function
© 2020 Department of Industrial Engineering, Chiang Mai University
7

© 2020 Department of Industrial Engineering, Chiang Mai University


Modeling (2) 8

 Function: Variable Domain


Default: All variables are Non-negativity variables.
@ GIN (var) General Integers
@ BIN () Binary
@ FREE () Unrestricted in sign (+,-)
@ BND (l, u) Assign upper and lower bounds
Other functions can be found at Edit Tab >> Paste Function

© 2020 Department of Industrial Engineering, Chiang Mai University


Data (1) 9

DATA:
Parameter = list of values;
ENDDATA
 Values may be listed using space or commas to separate them
 No. of values = No. of members in set associated with parameters
Example: Recall Student Set
Student/ John, Jill, Mike, Mary/ : CGA, age;
For set age = {20, 19, 18, 21}, we can write:
age = 20, 19, 18, 21; or age = 20 19 18 21;
© 2020 Department of Industrial Engineering, Chiang Mai University
Data (2) 10

 If more than one index, the last index is enumerated first.

© 2020 Department of Industrial Engineering, Chiang Mai University


Example 1: Transportation Model 11

The Wireless Widget (WW) Company has six warehouses supplying eight vendors with their
widgets. Each warehouse has a supply of widgets that cannot be exceeded, and each
vendor has a demand for widgets that must be satisfied. WW wants to determine how many
widgets to ship from each warehouse to each vendor so as to minimize the total shipping
cost. The following data are given:

© 2020 Department of Industrial Engineering, Chiang Mai University


Example 1: Transportation Model 12

Indices: i = Warehouse (Supply Source, i = 1, 2, … , 6)


j = Vendor (Customer, j = 1, 2, … , 8)
Decision Variables: Xij = Amount of product transported from i to j
Parameters: Cij = Shipping Cost from i to j
Si = Capacity of i
Dj = Demand of j

© 2020 Department of Industrial Engineering, Chiang Mai University


Example 1: Transportation Model 13

© 2020 Department of Industrial Engineering, Chiang Mai University


Example 1: Transportation Model 14

Lingo Model:

© 2020 Department of Industrial Engineering, Chiang Mai University


LP Formulation: Multi-period Inventory Model 15

© 2020 Department of Industrial Engineering, Chiang Mai University


16

© 2020 Department of Industrial Engineering, Chiang Mai University


LP Formulation: Multi-period Work Scheduling 17

© 2020 Department of Industrial Engineering, Chiang Mai University


18

© 2020 Department of Industrial Engineering, Chiang Mai University


Importing and Exporting with Excel 19

 Create Excel File >> WIDGETS.xls or .xlsx


 For importing data,

- Define data range and identify name of


input cells for importing to Lingo
Formulas (สูตร) >> Name Manager (ตัว
จัดการชื่อ) >> Define Name (สร้าง)
or
Select all cell range and right click >>
Define Name (สร้าง)

© 2020 Department of Industrial Engineering, Chiang Mai University


Importing and Exporting with Excel 20

For exporting data,


- Define data range and identify exported
cell name >> “VOLUME”

© 2020 Department of Industrial Engineering, Chiang Mai University


Importing and Exporting with Excel 21

 Lingo Model:

ทีอ่ ยู่ File

© 2020 Department of Industrial Engineering, Chiang Mai University


Sensitivity Analysis 22

How changes in an LP’s parameters affect the optimal solution…


A Graphical Introduction to Sensitivity Analysis:

© 2020 Department of Industrial Engineering, Chiang Mai University


A Graphical Sensitivity Analysis (1) 23

Graphical Analysis of the Effect of a Change in an Objective


Function Coefficient

If all other parameters remain unchanged,


the current basis remains optimal for
2 < c1 < 4, and Giapetto should still
manufacture 20 soldiers and 60 trains.
© 2020 Department of Industrial Engineering, Chiang Mai University
A Graphical Sensitivity Analysis (2) 24

 Graphical Analysis of the Effect of a Change in a Right-Hand Side on


the LP’s Optimal Solution
 If the value of b1 change, then as long as the point where
the finishing and carpentry constraints are binding remains
feasible, the optimal solution will still occur where the
finishing and carpentry constraints intersect.
 Thus, if all other parameters remain unchanged,
the current basis remains optimal if 80 < b1 < 120.
 Although the current basis remains optimal, the values
of the decision variables and the objective function value
change. © 2020 Department of Industrial Engineering, Chiang Mai University
A Graphical Sensitivity Analysis (3) 25

Shadow Prices:
the shadow price for the i th constraint of an LP to be the amount by
which the optimal z-value is improved—increased in a max problem
and decreased in a min problem— if the right-hand side of the i th
constraint is increased by 1.
For Max Problem:
For Min Problem:

© 2020 Department of Industrial Engineering, Chiang Mai University


The Computer and Sensitivity Analysis 26

There are two reports for sensitivity analysis:


Solution Report (Default) - Show up when the program finish solving
your model.
Range Report
To view: LINGO > Range
(Only for updated Version) To activate: LINGO > Option > Tab General
Solver > Dual Computations> Select Prices & Ranges

© 2020 Department of Industrial Engineering, Chiang Mai University


Example 1: 27

© 2020 Department of Industrial Engineering, Chiang Mai University


Example 1: Solution Report 28

© 2020 Department of Industrial Engineering, Chiang Mai University


Example 1: Range Report 29

© 2020 Department of Industrial Engineering, Chiang Mai University


Report Interpretation 30

 Solution Report:
Optimal Solution
Dual Prices (Shadow Prices)
Reduced Cost
Range Report:
Objective Function Coefficient Range
Right-hand Side Range

© 2020 Department of Industrial Engineering, Chiang Mai University


Objective Function Coefficient Ranges 31

 The range of values for an objective function coefficient for which the
current basis remains optimal.
 Within this range, the value of the decision variables remain
unchanged but the optimal Z-value may or may not changed.
 From Ex 1 Winco’s problem:
C1 : (4 - ∞) < C1 < (4+1) = -∞ < C1 < 5
C2 : (6 -0.5) < C2 < (6+0.666667) = 5.5 < C2 < 6.666667
C3 : (7 -0.5) < C3 < (7+1) = 6.5 < C3 < 8
C4 : (8 - ∞) < C4 < (8+2) = -∞ < C4 < 10
© 2020 Department of Industrial Engineering, Chiang Mai University
Example 3: 32

© 2020 Department of Industrial Engineering, Chiang Mai University


Reduced Costs and Sensitivity Analysis 33

 For any non-basic variable, the reduced cost for the variable is
the amount by which the non-basic variable’s objective
function coefficient must be improved before that variable will
become a basic variable in some optimal solution to the LP.
.

© 2020 Department of Industrial Engineering, Chiang Mai University


Right-hand Side Range 34

Similar to Objective Function Coefficient Range, RHS


Range can be interpreted from Range Report.
If the RHS remains in the range, the current basis
remains optimal, and the dual prices may be used to
determine the new Z-value.

© 2020 Department of Industrial Engineering, Chiang Mai University


Dual Prices/ Shadow Prices 35

Improvement in Z-value when the RHS of i constraint is


increased by 1 (assuming that the current basis remains
optimal).
If RHS of constraint i is increased by Δbi,

© 2020 Department of Industrial Engineering, Chiang Mai University


Example 4: 36

© 2020 Department of Industrial Engineering, Chiang Mai University


Example 4: (cont.) 37

© 2020 Department of Industrial Engineering, Chiang Mai University


Signs of Shadow Prices 38

 A > constraint will always have a nonpositive shadow price.


 A < constraint will always have a nonnegative shadow price.
 An equality constraint may have a positive, negative, or zero shadow
price.
 To see why this is true, observe that adding points to an LP’s feasible
region can only improve the optimal z-value or leave it the same.
Eliminating points from an LP’s feasible region can only make the
optimal z-value worse or leave it the same.

© 2020 Department of Industrial Engineering, Chiang Mai University


Sensitivity Analysis and Slack and Excess 39

Variables
 For any inequality constraint, the product of the values of the constraint’s slack or
excess variable and the constraint’s shadow price must equal 0. This implies that
any constraint whose slack or excess variable is > 0 will have a zero shadow price.
It also implies that any constraint with a nonzero shadow price must be binding
(have slack or excess equal to 0).

© 2020 Department of Industrial Engineering, Chiang Mai University


Example 2: 40

© 2020 Department of Industrial Engineering, Chiang Mai University


Example 2: (cont.) 41

© 2020 Department of Industrial Engineering, Chiang Mai University


Practice: Aggregate Planning: 42

QUARTER SALES FORECAST (LB)


Spring 80,000
Summer 50,000
Fall 120,000
Winter 150,000
Hiring cost= $100 per worker
Firing cost = $500 per worker
Inventory carrying cost = $0.50 pound per quarter
Regular production cost per pound = $2.00
Production per employee = 1,000 pounds per quarter
Beginning work force = 100 workers

© 2020 Department of Industrial Engineering, Chiang Mai University


Level Production Strategy 43

Level production
(50,000 + 120,000 + 150,000 + 80,000)
= 100,000 pounds
4

SALES PRODUCTION
QUARTER FORECAST PLAN INVENTORY
Spring 80,000 100,000 20,000
Summer 50,000 100,000 70,000
Fall 120,000 100,000 50,000
Winter 150,000 100,000 0
400,000 140,000
Cost of Level Production Strategy
(400,000 X $2.00) + (140,000 X $.50) = $870,000

© 2020 Department of Industrial Engineering, Chiang Mai University


Chase Demand Strategy 44

SALES PRODUCTION WORKERS WORKERS WORKERS


QUARTER FORECAST PLAN NEEDED HIRED FIRED
Spring 80,000 80,000 80 0 20
Summer 50,000 50,000 50 0 30
Fall 120,000 120,000 120 70 0
Winter 150,000 150,000 150 30 0
100 50
Cost of Chase Demand Strategy
(400,000 X $2.00) + (100 x $100) + (50 x $500) = $835,000

© 2020 Department of Industrial Engineering, Chiang Mai University


LP MODEL 45
Minimize Z = $100 (H1 + H2 + H3 + H4)
+ $500 (F1 + F2 + F3 + F4)
+ $0.50 (I1 + I2 + I3 + I4)
+ $2 (P1 + P2 + P3 + P4)
Subject to
P1 - I1 = 80,000 (1)
Demand I1 + P2 - I2 = 50,000 (2)
constraints I2 + P3 - I3 = 120,000 (3)
I3 + P4 - I4 = 150,000 (4)
Production 1000 W1 = P1 (5)
constraints 1000 W2 = P2 (6)
1000 W3 = P3 (7)
1000 W4 = P4 (8)
100 + H1 - F1 = W1 (9)
Work force W1 + H2 - F2 = W2 (10)
constraints W2 + H3 - F3 = W3 (11)
W3 + H4 - F4 = W4 (12)

© 2020 Department of Industrial Engineering, Chiang Mai University


Result: 46

Quarter Sales Production Inventory Workers Workers Workers


Forecast Plan Needed Hired Fired
Spring 80,000
Summer 50,000
Fall 120,000
Winter 150,000
Total 400,000

Total Cost =

© 2020 Department of Industrial Engineering, Chiang Mai University


Question: 47

 1. When holding cost increase to $0.58 pound per quarter.


 2. When holding cost increase to $1.00 pound per quarter.
 3. When sale forecast of Summer increase to 70,000.
 4. When sale forecast of Winter reduce to 90,000.
 5. When hiring and firing costs are equal as $200.

© 2020 Department of Industrial Engineering, Chiang Mai University


Using LINGO for Preemptive GP 48

1st Step: Find the solution of 1st Goal

© 2020 Department of Industrial Engineering, Chiang Mai University


Using LINGO for Preemptive GP 49

2nd Step: After got solution from the 1st step, adding
the solution of 1st to be the additional constraint and
solve the model again for the 2nd Goal.

© 2020 Department of Industrial Engineering, Chiang Mai University


Using LINGO for Preemptive GP
3rd Step: After got the solution of the second step,
adding the solution of the 2nd goal as one addition
constraint when solving the third goal.

© 2020 Department of Industrial Engineering, Chiang Mai University


Q&A 51

© 2020 Department of Industrial Engineering, Chiang Mai University

You might also like