Linear Programming
Linear Programming
January, 2022.
▪ LP software packages are readily available ▪ Constraints are always limiting the use of the available resources.
▪ A lot of work on specialized algorithms for solving specific LP ▪ There different alternative or solutions for the problem at hand,
problems (EXCEL-SOLVER, XPRESS-MP, GAMS, LINDO, and for each solution there is a specific value for the objective
▪ Many problems can be converted to a LP formulation ▪ The preferred solution is the one that optimizes the objective and
satisfies the constraints.
1
1/16/2022
▪ Linear objective function 2. Write a verbal statement of the objective function and each
✓ Maximization constraint.
✓ Minimization 3. Define the decision variables.
▪ linear constraints 4. Describe the objective function in terms of the decision
✓ Inequalities LE or GE variables.
✓ Equation = 5. List the constraints in terms of the decision variables.
▪ Non-negativity constraints
▪ The key terms of linear programming model are resources, m, and ▪ Maximize Z = c1x1 + c2x2 + c3x3 + ……. + cnxn
activities, n, where:
✓ Cj = increase in Z that result from each unit increase in activity j ▪ Note: b1, b2, … bm Note are non negative RHS values
✓ bi = amount of resource i that is available to activity j (i = 1, 2, 3, ….., m) ▪ Non – negative variables
✓ aij = amount of resource i consumed by each unit of activity j. e.g. x1, x2 ≥ 0
2
1/16/2022
▪ The general form of allocating resources to activities ▪ Formulation of LP Problems: clearly define the decision
variables objective and constraints, objective, and constraints.
▪ An Example of LP model:
Maximize Z = 2x1 + 3x2 – 3x3
Subjected to:
3x1 - x2 + 2x3 ≤ 7
x1 - 2x3 ≤ 4
2x1 + 2x2 + x3 ≤ 8
▪ Typical resources are money, equipment, personnel, etc. 3x1 ≤ 5
▪ Sample activities include specific products, investing in particular projects, x1, x2, x3 ≥ 0
shipping goods, etc.
OTHER FORMS
1. Minimization problems
3
1/16/2022
Resource Requirements
Bowl 1 4 40 X2 is mugs
Mug 2 3 50
Maximize Z = $40x1 + $50x2
Resource 40 hrs of labor per day subject to: 1x1 + 2x2 40
Availability: 120 lbs of clay
4x1 + 3x2 120
Decision x1 = number of bowls to produce per day x1, x2 0
Variables: x2 = number of mugs to produce per day
Objective Maximize Z = $40x1 + $50x2
Function:
X1 is bowls
Resource 1x1 + 2x2 40 hours of labor
Constraints: 4x1 + 3x2 120 pounds of clay
Non-Negativity x1 0; x2 0
Constraints:
4
1/16/2022
5
1/16/2022
EXAMPLE
6
1/16/2022
EXAMPLE EXAMPLE
▪ Product 1 requires some of the production capacity in Plants 1 and ▪ The OR team began by having discussions with upper management
3, but none in Plant2. Product 2 needs only Plants 2 and 3. The to identify management’s objectives for the study. These discussions
marketing division has concluded that the company could sell as led to developing the following definition of the problem:
much of either product as could be produced by these plants.
▪ However, because both products would be competing for the same ✓ Determine what the production rates should be for the two products in
production capacity in Plant 3, it is not clear which mix of the two order to maximize their total profit, subject to the restrictions imposed by
products would be most profitable. Therefore, an OR team has been the limited production capacities available in the three plants. (Each
formed to study this question. product will be produced in batches of 20, so the production rate is defined
as the number of batches produced per week.) Any combination of
production rates that satisfies these restrictions is permitted, including
producing none of one product and as much as possible of the other.
EXAMPLE EXAMPLE
▪ The OR team also identified the data that needed to be gathered: ▪ Obtaining reasonable estimates of these quantities required enlisting
1) Number of hours of production time available per week in each plant for the help of key personnel in various units of the company. Staff in
these new products. (Most of the time in these plants already is committed the manufacturing division provided the data in the first category
to current products, so the available capacity for the new products is quite above. Developing estimates for the second category of data
limited.) required some analysis by the manufacturing engineers involved in
2) Number of hours of production time used in each plant for each batch designing the production processes for the new products. By
produced of each new product. analyzing cost data from these same engineers and the marketing
3) Profit per batch produced of each new product. (Profit per batch produced division, along with a pricing decision from the marketing division,
was chosen as an appropriate measure after the team concluded that the the accounting department developed estimates for the third
incremental profit from each additional batch produced would be roughly category.
constant regardless of the total number of batches produced. Because no
substantial costs will be incurred to initiate the production and marketing of ▪ Table below summarizes the data gathered.
these new products, the total profit from each one is approximately this ▪ The OR team immediately recognized that this was a linear
profit per batch produced times the number of batches produced.) programming problem of the classic product mix type, and the team
next undertook the formulation of the corresponding mathematical
model
7
1/16/2022
EXAMPLE EXAMPLE
▪ The gathered data for the problem Formulation as a Linear Programming Problem
To formulate the mathematical (linear programming) model for this
problem, let:
X1: number of batches of product 1 produced per week
X2: number of batches of product 2 produced per week
Z total profit per week (in thousands of dollars) from producing these
two products
Thus, x1 and x2 are the decision variables for the model. Using the
bottom row of Table, we obtain
EXAMPLE EXAMPLE
8
1/16/2022
EXAMPLE EXAMPLE
Graphical Solution – Optimal Solution The Wyndor Glass Co. problem would have no feasible solutions if the
constraint 3x1 + 5x2 50 were added to the problem.
EXAMPLE EXAMPLE
The Wyndor Glass Co. problem would have Multiple Optimal solutions if the The Wyndor Glass Co. problem would have No Optimal solutions if the only
objective function were changed to Z = 3x1 + 2x2 functional constraint were x1 4, because x2 then could be increased
indefinitely in the feasible region without ever reaching the maximum value of
Z = 3x1 + 5x2
9
1/16/2022
▪ As in this case, any problem having multiple optimal solutions will have an
infinite number of them, each with the same optimal value of the objective
function.
▪ Another possibility is that a problem has no optimal solutions. This occurs only
if (1) it has no feasible solutions or (2) the constraints do not prevent improving
the value of the objective function (Z) indefinitely in the favorable direction
(positive or negative). The latter case is referred to as having an unbounded Z.
▪ A corner-point feasible (CPF) solution is a solution that lies at a corner of the
feasible region.
▪ Relationship between optimal solutions and CPF solutions: Consider any
linear programming problem with feasible solutions and a bounded feasible
region. The problem must possess CPF solutions and at least one optimal
solution. Furthermore, the best CPF solution must be an optimal solution.
▪ If a problem has exactly one optimal solution, it must be a CPF solution.
▪ If the problem has multiple optimal solutions, at least two must be CPF
solutions.
▪ LP model formulation:
10
1/16/2022
▪ Map the feasible region (region OAPD) ▪ Plot the objective function, Z, on the same graph.
▪ A corner-point feasible (CPF) solution is a solution that lies at a
corner of the feasible region. ▪ Determine the direction for moving Z within the feasible range
▪ Any point within or on the boundary of the feasible region is a ▪ Shift the objective function line in the direction of improvement until
feasible solution
▪ Solutions: it last intersected the feasible region
✓ P (0,200) Z = 200 ▪ Consider a line for the OF for an arbitrary value of c
✓ P(50,150) Z = 250
▪ Say c=40
✓ P (100,0 ) Z = 200
✓ P(0,0) Z = 0 ▪ P(50,150) is the farthest point from the origin representing the
▪ An optimal solution is a feasible solution that has the most optimal solution Z=250
favorable value of the objective function. (largest value for
maximization and the smallest value for minimization problems).
▪ 4) unbounded solutions.
11
1/16/2022
▪ The intersection of the objective function line and the feasible ▪ This may occur when
▪ 5x1 + 5x2 ≤ 50
▪ x1 ≥ 8
▪ x2 ≥ 6
▪ A situation where the problem is under constrained. ▪ An aggregate mix of sand and gravel must contain no less than
▪ Assume the following set of constraints 20% no more than 30% of gravel. The in situ soil contains 40%
▪ 5x1 + 5x2 ≥ 50 gravel and 60% sand. Pure sand may be purchased and shipped to
site at 5 units of money/m3. A total mix of at least 1000 m3 is
▪ x1≤ 8
required. There is no charge for using in situ material.
▪ x1≥ 6
▪ The objective is to minimize the cost
12
1/16/2022
SOLUTION SOLUTION
EXERCISE
13
1/16/2022
INTRODUCTION TO SIMPLEX METHOD Algebraic Form Preparation for Simplex Method Demonstration
𝑥1 , 𝑥2 ≥ 0
▪ What will be the surpluses
▪ Conversion from ≥ to = is achieved by subtracting a nonnegative
direction
surplus variable from the left-hand side of the inequality (Excess) If the sign in equations was ≥ sign?
14
1/16/2022
EXAMPLE OF LP Demonstration
▪ If a CPF solution has no adjacent CPF solution that are better as ▪ General Simplex LP model:
measured by the objective function, then there are no better CPF ▪ min (or max) z = Σ ci xi Simplex only deals
solutions anywhere; i.e., it is optimal. ▪ s.t. Ax = b with equalities
x≥0
15
1/16/2022
▪ A total of n+m variables (n decision variables and m slack ▪ Basic feasible solution: Assume there are a total of n + m
variables) and a constraint set of m equations variables (n decision and m slack variables). Then a basic
solution is one that has m number of basic variables and n
▪ These equations can be solved uniquely for any set of m variables number of non-basic variables. All non basic variables are
zeros.
▪ Simplex method: the starting solution start by assuming all
▪ Basic feasible solution: a basic solution which is also
decision variables to be zero => Z=0 feasible is a basic feasible solution.
The Algebra Of The Simplex Method GENERAL STRUCTURE OF THE SIMPLEX METHOD
▪ Constraint boundaries ▪ In any linear programming problem that possesses at least one
▪ Feasible region optimal solution, if a CPF solution has no adjacent CPF solutions
X2 ▪ Corner-point feasible (CPF)
(0,9)
solutions that are better (as measured by the objective function), then it must
▪ Adjacent CPF solutions be an optimal solution.
(0,6) (2,6) (4,6)
▪ Edges of the feasible region
16
1/16/2022
THE SIMPLEX METHOD IN TABULAR FORM THE SIMPLEX METHOD IN TABULAR FORM
The tabular form of the simplex method records only the essential The steps of the simplex method are
information, namely,
1. Determine a starting basic feasible solution.
(1) the coefficients of the variables
2. Select an entering variable using the optimality
(2) the constants on the right-hand sides of the equations and
condition. Stop if there is no entering variable; the last
(3) the basic variable appearing in each equation.
solution is optimal. Else, go to step 3.
3. Select a leaving variable using the feasibility condition.
The tabular form of the simplex method uses a simplex tableau to
compactly display the system of equations yielding the current BF 4. Determine the new basic solution by using the
solution. appropriate Gauss-Jordan computations. Go to step 2.
▪ Entering variable: the variable entering the basis is the one with Mathematical Procedures
the most negative coefficient in the z-row. It will contribute to the
Use the simple Gauss-Jordan row operations
1. Pivot row
increase of OF most.
a. Replace the leaving variable in the Basic column with the entering
▪ The one basic variable to leave is the one which gives the variable.
minimum ratio test by applying those pivot column coef. That are
strictly positive..
New pivot row = Current (Old) pivot row ÷ Pivot element
17
1/16/2022
Maximization Problem
Maximization Problem
cj c1 c2 c3 c4 c5
Cj - Zj row Maximization Problem Minimization Problem
CB Basic x1 x2… S1 S2… A1… b θ
variable the profit will be increased if a
S1 Positive coefficient in the cost will be increased if a
0 unit of a corresponding
S2 the Cj - Zj indicate the unit of a corresponding variable
0 variable is introduced into the
S3 amount by which is introduced into the solution
0 solution
Zj
Cj - Zj the profit will be decreased if
Negative coefficient in the cost will be decreased if a
a unit of a corresponding
the Cj - Zj indicate the unit of a corresponding variable
The Cj - Zj row variable is introduced into the
amount by which is introduced into the solution
solution
• The Cj - Zj row is called a base row or the Net Evaluation Row (NER).
• Coefficients in this row represent the net marginal improvement in the value of the The current solution is
optimal if the values in
objective function Z for each unit of the respective column variable introduced into Negative or zero Positive or zero
the Cj - Zj are
the solution.
• This row determines whether the current solution is optimal or not.
18
1/16/2022
Cj 5 4 0 0 0 0 RHS ǿ
Max 5x1 + 4x2
β x1 x2 S1 S2 S3 S4
S.t 24/6 =
Pivot Row
6X1 + 4x2 ≤ 24 0 S1 6 4 1 0 0 0 24 4
leaving Variable
1x1 + 2x2 ≤ 6 Initial 0 S2 1 2 0 1 0 0 6 6/1 =6
X1, x2 ≥ 0 zj 0 0 0 0 0
cj-zj 5 4 0 0 0
Pivot column coefficient
PROBLEM
Cj 5 4 0 0 0 0 RHS
β x1 x2 S1 S2 S3 S4
0 S1 6 4 1 0 0 0 24
0 S2 1 2 0 1 0 0 6
Initial Iteration 0 S3 -1 1 0 0 1
X1 entering row0=leaving row/pivot
1 element Max. 6x1 + 5x2
0 S4 0 1 0 0 0 1 2
zj 0 0 0 0 0 x4 - (its coefficint* x1 entering row)
x4 = old
cj-zj 5 4 0 0 0
x5 = old x5 - (its coefficint* x1 entering row)
S.T
β
Cj
x1
5
x2
4
S1
0
S2
0 0 0 RHS ǿ
X1 + x2 ≤ 5
x6S3= old x6 -S4(its coefficint* x1 entering row)
5 x1 1 2/3 1/6 0 0 0 4 6 3x1 + 2x2 ≤ 12
0 S2 0 1 1/3 - 1/6 1 0 0 2 1 1/2
Initial Iteration 2
0 S3 0 1 2/3 1/6 0 1 0 5 3 X1, x2 ≥ 0
0 S4 0 1 0 0 0 1 2 2
zj 5 3 1/3 5/6 0 0 0 20
cj-zj 0 2/3 - 5/6 0 0 0
Cj 5 4 0 0 0 0 RHS ǿ
β x1 x2 S1 S2 S3 S4
5 x1 1 0 1/4 - 1/2 0 0 3
4 x2 0 1 - 1/8 3/4 0 0 1 1/2
Initial Iteration 3
0 S3 0 0 3/8 -1 1/4 1 0 -2 1/2
0 S4 0 0 1/8 - 3/4 0 1 1/2
zj 5 4 3/4 1/2 0 0 21
cj-zj 0 0 - 3/4 - 1/2 0 0
19
1/16/2022
PROBLEM
Cj 6 5 0 0 RHS ǿ
β x1 x2 S1 S2
NW = old -
Initial Iteration 1 0 S1 0 1/3 1 - 1/3 1 coef*pr
Max 6x1 + 5x2 Max z = 6x1 + 5x2 0S1 + 0S2 6 x1 1 2/3 0 1/3 4 PR =old/pc
S.t S.t zj 6 4 0 2 24
X1 + x2 ≤ 5 X1 + x2 + S1 = 5 cj-zj 0 1 0 -2
PROBLEM 1 PROBLEM 2
▪ Find all basic feasible solutions of the following system: ▪ Min. Z = 2X1 – 3X2 + 6X3
Max Z = 5x1 + 6x2 Subjected to:
S.t. 4x1 + 2x2 ≤ 200 3X1 – X2 + 2X3 ≤ 7
x1 + 3x2 ≤ 150 2X1 + 4X2 ≤ -12
x1≥ 0 x2≥ 0 -4X1 + 3X2 + 8X3 ≥ 10
X1, X2, X3 ≥ 0
20
1/16/2022
21
1/16/2022
▪ Max. x1+1/2x2 ▪ Departing variable: If the ratio is the same between two rows, and
S.t. 2x1 + x2 ≤ 4 is also the minimum among the ratios for all rows, there is a tie for
the departing variable. Here also, any one variable can be
x1 +2x2 ≤ 3
arbitrarily selected as the departing variable. This results in a
x1 ≥ 0; x2 ≥ 0
degenerate solution.
EXAMPLE
22