2x - 4y £ -8 2x - 4y ≥ -8

1
2. Linear Programming
Objectives:
Objectives:
n Become adept at solving simple linear
programming (LP) problems graphically
n Acquire the concepts of linear
programming that can be generalized to
large problems
n Learn to use the simplex method
n Acquire the concept of a dual LP problem
n Appreciate linear programming as a tool of
operations research (OR) / management
science (MS)
3
Linear Programming
Linear programming is used to solve
problems in many diverse areas. Eg
n Airline crew scheduling
n Portfolio management
n Product mixing
n Diet and nutrition
n Military problems
n Agriculture
n Environmental studies and management
nEtc
5
Graphical Approach
Section 2.2(section 5-1 B&Z)
Graphing inequalities
n Terminology:
A straight line divides the plane into two
regions called half-planes.
half-planes.
Example 2.1
Consider the straight line given by
2x - 4y = -8
(2.3)
The two half-planes are (2.4)-(2.5)
2x - 4y £ -8
2
Linear Programming
What is a Linear Programming Problem ?
n We solve a system of linear equations
(sometime <=, sometime >=)
n We select a solution that maximizes (or
minimizes) a given linear function.
n Example (Eq
(Eq 2.1):
Objective function
maximize P = 3x1 + 2x 2
st.
2x1 + 3x 2 £ 7
4x1 + 5x 2 £ 10
Non-negativity
constraints
4
functional
constraints
x1 ,x 2 ≥ 0
Methods for solving LP
problems
n Graphically (Only for 2D problems)
n Simplex
n Interior points (not covered in 620-161)
6
Graphical Approach
Graphically the picture is as follows (Fig
(Fig 2.1):
2.1):
2x - 4y = -8
2x - 4y £ -8
y
half plane
2x - 4y ≥ -8
2
-4
half plane
x
2x - 4y ≥ -8
1
7
8
Which half-plane is feasible ?
Example 2.2 (like Ex 1, Section 5-1)
Example 2.2 (continued)
Show on a graph the half plane
2x - 4y ≥ -8
T
Show on a graph the half plane
2x - 4y ≥ -8
T
2x - 4y = -8
2x - 4y £ -8
y
y
half plane
2
2x - 4y ≥ -8
x
2x - 4y ≥ -8
0
RHS at (0,0) is equal to -8
LHS ≥ RHS
so we want the side with (0,0), because
this makes the given inequality true.
n Example 2.4 (like ex 3, section 5-1, B&Z)
Find all points (x1,x2) that satisfy the
following system (Fig
(Fig 2.2 )
x2 ≥ 0
x2
6
2x1+x2=2
-1
2
3
Sketch the region x2 < 4x1
1. Sketch the line x2 = 4x1, but note that
the line itself is not included,
included, so we just
dash the line.
2. (0,0) is on the line so we
cannot use it. Try (0,1) :
x2
LHS at (0,1) = 1
RHS at (0,1) = 0
LHS is not < RHS, so we do
not want the side with (0,1)
x2 = 4x1
x1
Now do question 1, Example Sheet 2.
12
Solving systems of
inequalities graphically
2x 1 + x 2 £ 6
x1 - 2x 2 £ 2
x1 ≥ 0
Example 2.3
10
For this example we will test the point
(0,0), ie.
ie. we will substitute x=0,
x=0, y=0 into
the inequality
11
x
-4
Test a point that is not on the line to
check which side of the line satisfies
the inequality.
LHS at (0,0) is equal to
2x - 4y ≥ -8
2
half plane
-4
9
2x - 4y = -8
x1-2x2=2
x1
n Any point in the shaded region satisfies all
the inequalities. That is, it satisfies the
system. We get a whole region of
solutions, called the feasible region.
region.
2x 1 + x 2 £ 6
x1 - 2x 2 £ 2
x1 ≥ 0
x2 ≥ 0
x2
6
2x1+x2=2
-1
2
3
x1-2x2=2
x1
2
13
Example
2.5
A host is prepared to spend up to $50 on
two types of pizza for a party.
Type A pizzas cost $10 each and type B
pizzas cost $15 each.
Many guests will find type A too spicy, so
the host decides to have at most 2 of
type A and at least 1 of type B.
Suppose the host orders xA pizzas of type
A and x B pizzas of type B.
Show all feasible points (xA,xB) on a graph.
15
Cost:
Cost: 10xA + 15xB £ 50
xB
Type:
Type: xA £ 2 , xB ≥ 1
xA=2
3 *
2 *
1
*
* (2,2)
*
*
*
0
5
1
14
Example
2.5
Cost:
Cost: 10xA + 15xB £ 50
Type:
Type:
Note also from the practicality of the
problem, we need:
xA ≥ 0, x B ≥ 0
and xA , xB integer
Corner Points
16
A corner point : intersection of two (or
more) boundary lines.
n Example 2.6 (See also ex 4, section 5-2,
B&Z)
xB=1
2
3
4
x2
xA
10xA + 15xB = 50
Since we want integer solutions, the only
feasible points are the 7 points shown (*
(*) .
Namely: (0,1), (0,2), (0,3), (1,1), (1,2), (2,1),
(2,2).
17
Corner Points
x2
6
2x1+x2=6
-1
2
2x 1 + x 2 £ 6
x1 - 2x 2 £ 2
x1 ≥ 0
x2 ≥ 0
18
Example 2.6
The corner points are (0,0), (0,6), (0,2),
(14/5, 2/5). The last point is the
intersection of x 1-2x2 = 2 and 2x1+x2 =
6, obtained by solving the system.
2x 1 + x 2 £ 6
x1 - 2x 2 £ 2
x1 ≥ 0
x2 ≥ 0
3
xA £ 2
xB ≥ 1
x1-2x2=2
x1
6
2x1+x2=6
-1
2
3
x1-2x2=2
x1
Terminology
A solution region (feasible region) of a
system or linear inequalities is bounded if
it can be enclosed within a circle,
otherwise it is unbounded.
unbounded.
The region in example 2.4 is bounded, but if
the 2nd constraint is deleted, the region
would be unbounded.
The technical term for “corner point”
point” is
extreme point.
point.
Do questions 2 and 3, example sheet 2.
3
19
Example 2.7
20
Review : Lines
(Like Example 1, Section 5-2 B&Z)
(Appendix B)
Given a straight line y = mx + c,
c, m is the
gradient and c is the y intercept.
intercept.
Consider the lines y = 1.5x+c,
1.5x+c, for c = -1,0,1.
-1,0,1.
The lines are all
parallel,
parallel, and the
bigger c is, the
“higher”
higher” the y
intercept.
21
c= 1
c= 0
c = -1
1
0
-1
Example 2.7
(continued)
Linear programming formulation:
formulation:
Let x1 be the number of hectares of crop A
planted, let x 2 be the number of hectares of
crop B planted and let P be the profit in $.
We want to
maximise P = 150x1 + 100x2
subject to:
to:
Area ( hectares):
x 1 + x2 £ 100
(1)
Seed cost:
40x
(2)
40x 1 + 20x2 £ 3200
Common sense:
x 1, x2 ≥ 0
(3)
160
(1)
100
80
100
LP Terminology
x1 and x2 are called decision variables.
variables.
P = 150x1 + 100x2 is called the objective
variable.
variable.
(1) and (2) are called (functional)
constraints.
constraints.
(3) are the non-negative constraints.
constraints.
Any feasible point of the system (1), (2) & (3)
that gives maximum P is called the
optimal solution.
solution.
24
x1 + x2 £ 100
(1)
40x
40x1 + 20x2 £ 3200 (2)
x 1 , x2 ≥ 0
(3)
(2)
22
!what
what is the optimal solution?
23
Graph of feasible region:
x2
A farmer owns a 100 hectare farm and
plans to plant at most 2 crops.
Seeds for crop A cost $40 per hectare, seeds
for crop B cost $20 per hectare.
At most $3200 can be spent on seeds.
The farmer can make a profit of $150 per
hectare of crop A and $100 per hectare of
crop B.
How many hectares of each crop should be
planted for maximum profit?
x1
What is the optimal (best) solution?
Recall:
Recall: we know that at least one
optimal solution is a corner point!
point!
x2
160
(1)
(2)
Maximise P = 150x1 + 100x2
100
80
100
x1
Strategy:
Strategy: Plot the values of P on the
(x1,x2) plane.
X2 = (P-150x1)/100 = P/100 - (150/100)x1
Gradient: 150/100 = -3/2
4
!what
what is the optimal solution?
25
x2
(1)
100
26
x2 = (P-150x1)/100
(2)
160
Gradient: -3/2
Optimal corner point
A
80
(1)
x1
100
Largest feasible P
Direction of increase in P
P=0 : x2 = -1.5x1
In short:
short:
27
x1 = 60 , x2 = 40
giving a maximum profit of
P = 150x60 + 100x40 = $13,000
Report:
Report:
Plant 60 hectares of crop A and 40
hectares of crop B for a maximum profit of
$13,000.
Help Desk
nThis straight line has gradient -3/2,
-3/2, no
matter what value P0 has.
n The intercept on the x2 axis is P0/100,
/100,
so the bigger P0 is, the bigger the
intercept is.
n We draw in these lines for different
values of P0 (dashed lines). As they all
have the same gradient, they are all
parallel.
x 2 = 150 x1 + P 0 = - 3 x1 + P 0
100
100
100
2
100
x1 + x2 £ 100
(1)
40x
40x1 + 20x2 £ 3200
(2)
A
80
100
x1
Thus, we solve the system
x1 + x2 = 100
x1=60, x2=40
40x
40x1 + 20x2 = 3200
28
The optimal solution is
29
!what
what is the optimal solution?
A: Intersection of the lines
x2
(2)
Defining (1) and (2):
160
Help Desk
Notes on how we arrived at the maximum:
n All points in the feasible region satisfy
(1), (2) and (3), but which will give the
maximum P?
n Suppose that P is given a particular value,
P0 say. So P0 = 150x1 + 100x2, where P0 is
a constant.
n This is then the equation of a straight
line:
x 2 = 150 x1 + P 0 = - 3 x1 + P 0
100
100
100
2
30
Help Desk
n Every point on one of these lines
produces the same profit, namely the P0
value for that line. These are called
constant profit lines or isoprofit lines.
n The dashed line with the largest value
for P0 that has any points in the feasible
region is the one going through point A.
x 2 = 150 x1 + P 0 = - 3 x1 + P 0
100
100
100
2
5
31
32
Help Desk
n So the optimal solution of the problem,
i.e. the point that gives the maximum P
given the constraints, is A.
Example 2.8
(See also Ex 3, Section 5-2 B&Z)
Solve the following problem graphically:
minimize g = 2y1 + y 2
Minimum
n Note that by the same sort of reasoning
we can see that the minimum of P is at
(0,0).
n So the same technique can be used for
both maximisation and minimisation
problems
33
Example 2.8
Feasible Region:
y2
(unbounded)
9
Feasible
region
2
3
y1 + 3y 2 ≥ 6
3y 1 + y 2 ≥ 9
y1, y 2 ≥ 0
y1 + 3y 2 ≥ 6
3y 1 + y 2 ≥ 9
y1, y 2 ≥ 0
34
Objective :
y2
9
2
y1
6
Example 2.8
minimize g = 2y1 + y 2
y 2 = g - 2y1
(unbounded)
Feasible
region
A
3
†
6
Gradient: -2
A: Optimal solution
y1
g=0:
g=0: y2=-2y1
35
Example 2.8
Objective :
y2
9
2
Optimal solution:
Intersection of the
lines of the two
(unbounded)
constraints
y1 + 3y 2 = 6
3y 1 + y 2 = 9
Feasible
region
A
3
y1
6
g=
51
8
36
Example 2.9
Same as Example 2.8 but maximize.
The maximum does not exist in this case.
We can just keep on going and going
within the feasible region without
reaching a maximum.
This can only happen if the feasible
region is unbounded,
unbounded, although it doesn’
doesn’t
always happen with an unbounded region.
y1 = 21
, y 2 = 98
8
6
37
Example 2.10
Same as example 2.8 but change g:
g = 3y1 + y2
Rewriting we get y2 = -3y1 + g.
g.
Notice that this is parallel to the line
defining the second constraint, so all
points along the edge of the feasible
region defined by the second
constraint are optimal.
Example 2.10
38
minimize g = 3y1 + y 2
Objective :
y2
(unbounded)
9
Feasible
region
2
3
6
y1 + 3y 2 = 6
3y 1 + y 2 = 9
y1
Optimal Solutions
39
Comment
We see that, in general, if there are
optimal solutions then at least one of
them occurs at a corner of the feasible
region.
So if the feasible region is bounded,
bounded,
another way of finding the optimal
solution is to find all the corners of the
feasible region and evaluate the
objective function at all these points,
then pick the maximum or minimum
as required.
40
Example 2.11
Maximize
subject to
z = 4x + 3y
2x + y £ 40
x,y ≥ 0
y
(2.16)
The feasible region is bounded,
with corners at (0,40), (20,0)
and (0,0).
(0,40)
At (0,40), z = 120
Feasible
region
(0,0)
(20,0)
At (20,0), z = 80
At (0,0), z = 0
x So the maximum is
120 at x = 0, y = 40
7