Sie sind auf Seite 1von 34

Introduction to Linear Programming

73-220
Lecture 03
TA’s Office Hours

● Melissa Li: Tue/Thur 11:30am-1:00pm.


● Li Miao: Fri 10:00-11:30pm.
● TA room: OB326.
Agenda
● Review of Last Class
– Break-even analysis: algebraic, graphical, Excel
● Introduction to Linear Programming
– Characteristics of a linear programming model
– Maximization problem
– Minimization problem
● Next Class
Mathematical Programming Problem
● A mathematical programming problem is one that
seeks to optimize an objective function subject to
constraints.

● Types of mathematical programming problems


– Linear Programming
– Integer Programming
– Goal Programming
– Non-linear Programming
Linear Programming (LP) Problem
● If both the objective function and the constraints are linear, the
problem is referred to as a linear programming problem.
● Linear functions are functions in which each variable appears
in a separate term raised to the first power and is multiplied by
a constant (which could be 0).
– Note some variations of linear relations: 3/x + 4/y > 0 can be
transformed to a linear constraint, but 3/x + 4/6 > 2 cannot (the reason
is that the interaction term xy cannot be eliminated here).
● Linear constraints are linear functions that are restricted to be
“< (less than or equal to)", “= (equal to)", or “> (greater than
or equal to)" a constant.
– Note that Management Scientist uses <, =, > for the three types of
constraints. However, that is not accurate. Should be <, =, >.
● In Excel Solver modeling format, an LP model can be
completely characterized by sumproduct functions.
Assumptions of Linear Programming
● Proportionality Assumption
– Contribution of a variable is proportional to its value.

● Additivity Assumptions
– Contributions of variables are independent.

● Divisibility Assumption
– Decision variables can take fractional values.

● Certainty Assumption
– Each parameter is known with certainty.
Characteristics of LPs
● Objective function and constraints are linear
functions.
– Understand a relationship is linear or not.
● Constraint types are ≤, = , or ≥.
– Again, don’t be fooled by the Management Scientist
input format.
● Variables can assume any fractional value.
● Decision variables are non-negative.
● Maximize or minimize a single objective.
Prelude to Linear Programming
8 small 6 large
blocks blocks

Table: Chair:
Profit = Profit =
$16 each $10 each
Select product mix to maximize profit using the available
resources. DO NOT MAKE MORE THAN 5 TABLES
Linear Programming
● Formulate as an LP
– Decision Variables, Objective Function, Constraints
● Solution Methods
– Computer: Excel Solver (today)
– Simplex (Not covered)
» Move from one corner point to another
» Theoretical basis to solve an LP model.
– Graphical (next class)
» Graph Constraints, Objective function
» Find a solution
Linear Programming Formulation

● Step 1: Determine Decision Variables


● Step 2: Determine Objective Function
● Step 3: Determine Constraints

1
Step 1: Decision Variables
● The best way to determine the decision variables
is to put oneself in the shoes of the decision maker
and then ask the question “What do I need to
know in order to make this thing work?”
● Decision Variables
– T = # of tables
– C = # of chairs
– Note:
» Define decision variables explicitly.
» Always keep in mind the unit of the decision
variables. Here it is the # of T or C.

1
Step 2: Objective Function

● Specify the problem objective to measure


the performance that we are going to
optimize. Here it is the profit contribution.

● Objective Function
– Maximize profit = 16T + 10C

1
Step 3: Constraints
● Determine the Constraints
– Note that the left-hand side (LHS) and right-hand side (RHS) units
must agree with each other. This is a good way to verify whether
your constraints make sense or not.

– There are only 6 large blocks


– 2T + C ≤ 6

– There are only 8 small blocks


– 2T + 2C ≤ 8

– No more than 5 tables


– T≤5

– Implicit Constraints (nonnegativity requirement, for every LP and


integer programming model)
– T, C ≥ 0

1
LP Formulation
● Decision variables
– T: # of tables to make
– C: # of chairs to make
● Maximize z = 16T + 10C
● Subject to
– 2T + C < = 6 (large block constraint)
– 2T + 2C < = 8 (small block constraint)
– T<=5 (no more than 5 tables)
– T,C > = 0

1
Methods of Solution

● Computer – Excel Solver (later today)


– Only Excel solver solution is introduced here.
As for how to use Management Scientist, please
refer to Appendix 2.1 on Pages 86-87 in the
textbook.
● Simplex (Not covered)
● Graphical (next class)

1
Slack and Surplus Variables
● A linear program in which all the variables are non-negative
and all the constraints are equalities is said to be in standard
form.

● Standard form is attained by adding slack variables to "less than


or equal to" constraints, and by subtracting surplus variables
from "greater than or equal to" constraints.

● Slack and surplus variables represent the difference between the


left- and right-hand sides of the constraints.

● The coefficients of slack and surplus variables in the objective


function equal 0, i.e., the introduction of slack and/or surplus
variables does not affect the objective function.
1
Lego Example: Standard Form
Max. z = 16T + 10C Max z = 16T +10C+0s1+0s2+0s3
Subject to Subject to
2T + C < = 6 2T + C +s1= 6
2T + 2C < = 8 2T + 2C+ s2 = 8
T <= 5 T + s3 = 5
T, C >= 0 T, C >= 0

Slack variables

1
Method 1 – Computer Solution
● Computer programs designed to solve LP problems
are now widely available.
● Most large LP problems can be solved with just a
few minutes of computer time.
● Small LP problems usually require only a few
seconds.
● Linear programming solvers are now part of many
spreadsheet packages, such as Microsoft Excel.
● Please go through the short tutorial re how to use
Excel Solver given in Appendix 2.3 (pp 88-93) in the
textbook.

1
Interpretation of Computer Output

● In this chapter we will discuss the following


output:
– objective function value
– values of the decision variables
● Later on in the sensitivity analysis part, we will
discuss how an optimal solution is affected by a
change in:
– a coefficient of the objective function
» Associated with the concept of reduced cost and range of
optimality.
– the right-hand side value of a constraint
» Associated with the concept of shadow price and range of
feasibility.

1
Spreadsheet Model of Lego Problem

Raw data of the spreadsheet model (A good way to


set up a spreadsheet model is to separate data from
your model):
Data
Table Chair Available
Profit 16 10
Small 2 2 8
Large 2 1 6
Table max 1 0 5

2
Spreadsheet Model
● The spreadsheet model: Please refer to Appendix 2.3 on
pp 88-93 for a quick tutorial.
Decision variable Table Chair
UnitProduced 2 2

Objective function Total Profit


Max 52

Constraints Used Available


Small 8 <= 8
Large 6 <= 6
Table max 2 <= 5
Note: Press CTRL+` to switch views between
formulas and values.
2
Solver Dialogue Window
In Excel go to Tools>solver (Solver must be installed in your Excel. To determine
whether your Excel has this add-in, visit the FAQ area on the course website).
A new window called solver parameters opens up.
Type label reference or range name for the objective function in set target cell as
this gives you the objective function formula.
Type label reference or range name of decision variables in the By changing cells.

2
Add Constraints
In the Solver dialogue window, clicking on “Add” invokes the
following “Add Constraint” dialogue window. You are required
to identify the left-hand side and right-hand side ranges, as well
as the type of the constraint (<, >, =, int, bin. For LP models,
only the first three types, int refers integer and bin refers binary,
which are for integer program models only). If you need add
another constraint, click on “Add”; if you input all constraints,
click on “OK” to return to the main dialogue window.

2
Solver Option:
Click on Options
on the right of the
main Solver
dialogue, you will
see the window
here. Place check
marks beside
Assume Linear
Model and
Assume Non-
negative, and
click on OK to
return to Solver
main window.
2
Answer Report
Click on Solve in the Solver main dialogue window, Solver will solve
the model and you may keep solver solution, and Answer and
Sensitivity Reports by highlighting the right report on the right box.
Microsoft Excel 10.0 Answer Report
Worksheet: [Lecture3.xls]Sheet1
Report Created: 9/19/2004 10:16:45 PM

Target Cell (Max)


Cell Name Original Value Final Value
$B$13 TotalProfit 52 52

Adjustable Cells
Cell Name Original Value Final Value
$B$9 UnitProduced Table 2 2
$C$9 UnitProduced Chair 2 2

Constraints
Cell Name Cell Value Formula Status Slack
$B$16 Small Used 8 $B$16<=$D$16
Binding 0
$B$17 Large Used 6 $B$17<=$D$17
Binding 0
$B$18 Table max Used 2 $B$18<=$D$18
Not Binding 3

2
Optimal Solution
● Three parts: decision variables, values of
decision variables, value of objective function
● Decision variables: basic (non-zero value),
non-basic (zero)
● Basic variables are “in the solution”; non-
basic are not

2
No Feasible Solution?
● Data entry error?
– Review spreadsheet; walk thru with someone
● Formulation error?
– Review formulation; walk thru with someone
● Truly infeasible?

2
Production Example
Ebel Mining Company owns two different mines that
produce a given kind of ore. The mines are located in
different parts of the country and hence have different
production quantities and ore qualities. After crushing
the ore is graded into 3 classes: high grade, medium grade
and low grade. Ebel has contracted to provide its parent
company with at least 12 tons of high grade, 8 tons of
medium grade and 24 tons of low grade ore per week. It
costs Ebel $20,000 per day to run the first mine and $16,000
per day to run the second. However, in a day’s operation, the
first mine produces 6 tons of high grade, 2 tons of medium
grade and 4 tons of low grade ore. The second produces 2
tons of high and medium grade per day and 12 tons of low
grade ore. How many days a week should each mine be
operated to fulfill Ebel’s commitment most economically?
2
Production Example
Decision Variables:
X1- # of days to run mine 1
X2 – # of days to run mine 2

Objective function
Minimize z=20,000X1 + 16,000X2

Constraints
High grade: 6X1 + 2X2 >= 12
Medium Grade: 2X1 + 2X2 >= 8
Low Grade: 4X1 + 12X2 >= 24
X1, X2 >= 0

2
Guidelines for Building “Good”
Spreadsheet Models
● Enter the Data First
– Any spreadsheet model is driven by the data
– It is easier (and usually better) to build the model
around the data
● Organize and Clearly Identify the Data
– Relevant data should be grouped (e.g. in tabular
form)
– All data should be labeled
– Units should be identified
● Enter Each Piece of Data into One Cell Only
– Refer to the original data as needed
– This makes the model much easier to modify (only
need to change data in one place) 3
Guidelines for Building “Good”
Spreadsheet Models
● Separate Data from Formulas
– Avoid putting numbers directly in formulas
– Put numbers in data cells and refer to them as needed
– This makes all data visible and easier to modify
● Keep It Simple
– Avoid “power functions” of Excel if possible
– Break out complicated formulas into subtotals
● Use Range Names
– Refer to data cells and blocks of cells using Excel’s
range name feature
– Range names make formulas and the Solver model
much easier to read
– Care must be taken not to overuse range names and to
make sure they remain correctly defined. 3
Guidelines for Building “Good”
Spreadsheet Models
● Use Relative and Absolute References to
Simplify Copying Formulas
– Whenever multiple related formulas will be
needed, try to enter the formula just once, and
then use Excel’s fill commands to replicate the
formula.
– This makes the model easer to build and also
reduces typos.
● Use Borders, Shading, and Colors to
Distinguish Cell Types
● Show Entire Model on Spreadsheet
– All data should be visible.
– All constraints should be on the spreadsheet (not 3
Three Tests for a “Good”
Spreadsheet Model
● You should be able to immediately
identify the data cells, changing
cells, and target cell.
● All elements of the model should
be visible on the spreadsheet
(including all constraints). You
should not have to look in the
Solver dialogue box to figure out
the model.
● Each equation should be simple 3
Next Class
● Homework:
– Review the Lego example discussed in class and work on the
production example in the lecture notes
– Understand the basic three-step approach to formulating an LP
model.
– Go through Appendix 2.1 and/or 2.3 in the textbook and learn how to
solve an LP model by using Solver and/or Management Scientist.

● Read Chapter 2 – Linear Programming (Graphical solution)

● Bring to class
– Notes for next class

YOU LEARN DECISION ANALYSIS BY DOING DECISION


ANALYSIS!!

Das könnte Ihnen auch gefallen