390 likes | 883 Views
What is Linear Programming ? A simple example. Components of a linear programming problem. Feasible, infeasible and optimal solutions. Linear Programming – Introduction. Linear Programming. Linear Programming (LP) is a tool for solving optimization problems.
E N D
What is Linear Programming ? • A simple example. • Components of a linear programming problem. • Feasible, infeasible and optimal solutions. Linear Programming – Introduction
Linear Programming • Linear Programming (LP) is a tool for solving optimization problems. • Simplex algorithm: A tool for solving LP problems (Dantzig 1947). • LP has been used to solve optimization problems in various industries, e.g. forestry, banking, trucking etc.
An Example Example 1: • A company makes 2 types of wooden toys: dolls and trucks. • A doll sells for $27, uses $10 of raw material and increases other costs by $14. A truck sells for $21, uses $9 of raw material and increases other costs by $10. • A doll requires 2 hours of painting and 1 hour of carpentry work. A truck requires 1 hour of painting and 1 hour of carpentry work. • Each week only 100 painting hours and 80 carpentry hours are available. Raw material supply is unlimited. • Demand for trucks is unlimited, but at most 40 dolls can be sold per week. • Formulate a LP problem to maximize the company’s profit.
Decision Variables • Decision variables : should completely define the decisions to be made. • x1 = no. of dolls produced per week • x2 = no. of trucks produced per week
Objective Function • In any LP problem the decision maker wants to maximize (usually revenue or profit) or minimize (usually costs) some function of the decision variables. • The function to be maximized or minimized is called the objective function. • What is the objective in Example 1? • Maximize • profit = revenues – costs • Costs • Fixed costs: does not depend on decision variables (e.g. rent) • Variable costs: raw material costs + other variable costs. • Revenues • weekly revenues from dolls + weekly revenues from trucks.
Objective Function • Revenues = weekly revenues from dolls + weekly revenues from trucks. • = (selling price per doll * no. of dolls per week) + (selling price per truck * no. of trucks per week) • = 27*x1 + 21*x2.
Objective Function • Weekly raw material costs = • 10 x1 + 9 x2 • Other weekly variable costs = • = 14 x1 + 10 x2 • So, profits = • (27 x1 + 21 x2) – (10 x1 +9 x2) – (14 x1 + 10 x2) • = 3x1 +2x2 • Therefore, objective function = • Maximize z = 3*x1 +2*x2 • The coefficient of a decision variable in the objective function is called an objective function coefficient. • The variable z is used to represent the objective function value of any LP.
Constraints • Constraints : restrictions that limit the values of the decision variables. • Constraints for Example 1: • c1) No more than 100 hours of painting time can be used per week. • c2) No more than 80 hours of carpentry time can be used per week. • c3) Due to limited demand, at most 40 dolls should be produced per week.
Constraint c1 • c1) No more than 100 hours of painting time can be used per week. • Total painting hours per week = • (painting hours per doll * no. of dolls per week) + (painting hours per truck * no. of trucks per week) • = 2 * x1 + 1 * x2 = 2 x1 + x2 • c1: 2 x1 + x2< 100 (2) • The coefficient of a decision variable in a constraint is often called a technological coefficient
Constraint c2 • c2) No more than 80 hours of carpentry time can be used per week. • Total carpentry hours per week = • (carpentry hours per doll * no. of dolls per week) + (carpentry hours per truck * no. of trucks per week) • = 1 * x1 + 1 * x2 = x1 + x2 • c2: x1 + x2 < 80 (3)
Constraint c3 • c3) Due to limited demand, at most 40 dolls should be produced per week. • No. of dolls per week = x1 • Maximum no. of dolls produced per week = 40 • c3: x1< 40 (4)
Sign Restrictions • Can the decision variable assume only non-negative values or both positive and negative values? • If a decision variable (xi)can take only non-negative values, we add sign restriction xi> 0. • Otherwise we say xi is unrestricted in sign (urs).
LP Formulation for Example 1 • Maximize z = 3*x1 +2*x2 (1) Objective function • subject to (s.t.) • 2*x1 + x2< 100 (2) painting constraint • x1 + x2< 80 (3)carpentry constraint • x1< 40 (4) demand constraint • x1> 0 (5) sign restriction • x2> 0 (6) sign restriction
Some Definitions Definition 1: • A function f(x1, x2,…, xn) of x1, x2,…, xn is a linear functionif and only if for some set of constants c1, c2,…, cn, f(x1, x2,…, xn) = c1x1+c2x2+…+cnxn • For example, f(x1, x2) = 2x1 + x2is a linear function of x1 and x2, but f(x1, x2) = x12 x2is not a linear function of x1 and x2 Definition 2: • For any linear function f and any number b, the inequalities f(x1, x2,…, xn)≤ b and f(x1, x2,…, xn) ≥ b are linear inequalities. • Thus, 2x1 + 3x2 ≤ 3 and 2x1 + x2 ≥ 3 are linear inequalities, but x12x2≥3 is not a linear inequality.
Some Definitions (cont’d) Definition 3: A linear programming problem (LP) is an optimization problem for which we do the following: 1. We attempt to maximize ( or minimize) a linearfunction of the decision variables. The function that is to be maximized or minimized is called the objective function. 2. The values of the decision variables must satisfy a set of constraints. Each constraint must be a linear equation or linear inequality. 3. A sign restriction is associated with each variable. For any variable xi, the sign restriction specifies either that xi must be nonnegative ( xi ≥ 0) or that xi may be unrestricted in sign (urs)
Feasible Region • The feasible region for an LP is the set of points satisfying all its constraints and sign restrictions. • Is the point (x1 = 40, x2 = 20 ) in the feasible region for Example 1: • Put these values (of x1 and x2) in each constraint (2)-(6) and check if the constraint is satisfied for each case. • Ans: (x1 = 40, x2 = 20 ) is in the feasible region. • Is the point (x1 = 15, x2 = 70 ) in the feasible region of Example 1: • No, it violates (3) • Is the point (x1 = 40, x2 = -20 ) in the feasible region of Example 1: • No, it violates (6), i.e. sign restriction on x2. • Any point that is not in an LP’s feasible region is called an infeasible point.
Optimal Solution • For a maximization (minimization) problem, an optimal solution to an LP is a point in the feasible region with the largest (smallest) objective function value. • Most LPs have one optimal solution. • Some LPs have no optimal solution; some have an infinite number of solutions. • What is the objective function value for (x1 = 30, x2 = 40 ) ? • Is this optimal ? • What is the objective function value for (x1 = 40, x2 = 20 ) ? • Is this optimal ? • What is the objective function value for (x1 = 20, x2 = 60 ) ? • Is this optimal ?
Graphical Solution • Any LP with only 2 variables can be solved graphically. • Consider a constraint: 2*x1 + 3*x2< 6 (c1) • The set of points on or below the line 2*x1 + 3*x2 = 6 satisfies (c1) • In 2 dimensions, the set of points satisfying a linear inequality f(x1, x2) ~ b, includes the points on the line f(x1, x2) = b and all points on ONE side of it. x2 5 4 3 2 1 1 2 3 4 5 x1
Feasible Solution for Example 1 x2 • constraints 2 – 6 • only points in first quadrant satisfy sign restrictions. • (2) is satisfied by all lines on or below line AB • (3) is satisfied by all lines on or below CD • (4) is satisfied by all points to the left of EF • Feasible region is bounded by polygon DGFEH. B 100 80 D G 60 40 20 F C H A x1 10 20 30 40 50 60 70 80 E
Optimal Solution for Example 1 x2 • Optimal solution is the point in the feasible region with the largest value of z=3x1+2x2 • Draw a single isoprofit (isocost for min problem) line, z =60 • Generate other isoprofit lines by moving parallel to the drawn isoprofit line, such as z=100 • Point G is the last isoprofit line to intersect the feasible region. And the optimal value is 180 B 100 80 D G 60 40 20 F C E A x1 10 20 30 40 50 60 70 80 Z = 60, 100, 180
Some Assumptions • Proportionality Assumption: • The contribution of the objective function from each decision variable is proportional to the value of the decision variable. • The contribution of each variable to the left-hand side of each constraint is proportional to the value of the variable. • Additivity Assumption: • The contribution to the objective function for any variable is independent of the values of the other decision variables. • The contribution of a variable to the left-hand side of each constraint is independent of the values of the variables.
Some Assumptions (cont’d) • Divisibility Assumption: • each decision variable allowed to assume fractional values • E.g. , in Example 1, it implies that it is acceptable to produce 1.5 dolls, or 1.63 trucks. • If divisibility is not valid, rounding off each variable in the optimal LP solution to an integer may yield a reasonable solution. • Certainty Assumption: • each parameter ( objective function coefficient, right-hand side, and technological coefficient ) is known with certainty. • E.g if we were unsure of the exact amount of carpentry hours required to build a truck, the Certainty Assumption would be violated.
Infeasible LP x2 • It is possible for an LP’s feasible region to be empty (contain no points). • This results in an infeasible LP. • An infeasible LP has no optimal solution • e.g. in Example 1, suppose the company is required to make at least 90 trucks per week. • x2> 90 (7) B 100 I J 80 D G 60 40 20 F C A x1 10 20 30 40 50 60 70 80 E
Unbouned LP x2 • For a max (or min) problem, the LP is unbounded if it is possible to find points in the feasible region with arbitrarily large (or small) objective values. • Should not occur in a correctly formulated LP • e.g. in Example 1, suppose there is no restriction on the amount of labour available. • remove constraints (2) and (3) B 100 80 D G 60 40 20 F C A x1 10 20 30 40 50 60 70 80 E
Your Turn ... Example 2: • A company sells luxury goods and wants to reach High-income Men (HM) and High-income Women (HW), by advertising on comedy shows and football games. • A 1-minute spot on a comedy show is seen by 7M HW and 2M HM. • A 1-minute spot on football game is seen by 2M HW and 12M HM. • A 1-minute comedy ad costs $50,000 and a 1-minute football ad costs $100,000. • The company wants to reach at least 28M HW and 24M HM. • Formulate a LP problem to minimize the company’s advertising costs.
Variables & Objective • x1 = no. 1-minute comedy ads purchased • x2 = no. 1-minute football ads purchased • Total cost = cost of comedy ads + cost of football adds • (cost per comedy ad * no. of comedy ads)+(cost per football ad * no. of football ads) • 50,000 x1 + 100,000 x2 • 50 x1 + 100 x2 (in thousands of dollars) • objective function: min z = 50 x1+ 100 x2 (8)
Constraints • c1) must reach at least 28 million HW • no. of HW = (HW per comedy add * no. of comedy ads)+ (HW per football add * no. of football ads) • = 7 x1 + 2 x2> 28 (9) in millions of viewers • c2) must reach at least 24 million HM • no. of HM = (HM per comedy add * no. of comedy ads)+ (HM per football add * no. of football ads) • = 2 x1 + 12 x2> 24 (10) in millions of viewers sign restrictions: x1> 0 ; x2> 0;
LP Formulation • Min z = 50 x1 + 100 x2 • s.t. • 7x1 + 2x2> 28 • 2 x1 + 12 x2> 24 • x1, x2> 0
Graphical Solution x2 • c1 satisfied by point on or above line AB 7x1 + 2x2 = 28 • c2 satisfied by point on or above line CD 2x1 + 12 x2 = 24 • unbounded feasible region • isocost line through (x1 = 4, x2 = 4); z = 600 • E is last point in feasible region to intersect isocost line • E = (x1 = 3.6, x2 = 1.4); optimal z = 320 14 B 12 10 8 6 (4,4) 4 2 E D C x1 2 A 4 6 8 10 12 14 16 Z=320, Z=600
A word of caution ... • Some assumptions may not be accurate in the real world. • proportionality: e.g. each comedy ad must add exactly 7M HW and 2M HM. • empirical evidence shows advertising yields diminishing returns after a certain point. • additivity: e.g. total viewers = viewers from comedy ads + viewers from football adds. • in reality there will be some overlap, same person may see more than 1 type of commercial; so, effectiveness of a comedy ad actually depends on the no. of football ads etc.
A word of caution (cont’d) • Some assumptions may not be accurate in the real world. • divisibilty: does it make sense to buy 3.6 comedy ads or 1.4 football adds? • If not, divisibilty assumption is violated and the problem should be considered an integer programming problem. • certainty: can we know for sure exactly how many viewers are reached by each type of commercial? • Despite these drawbacks, LP can be used effectively to solve real world optimization problems.
Your Turn ... Example 3: • A company makes glass windows and doors. A batch of windows requires 1 hour in plant#1 and 3 hours in plant#3, and generates $3000 in profits. A batch of doors requires 2 hours in plant#2 and 2 hours in plant#3, and generates $5000 in profits. The company can sell as many products as they make. • A total of 4 hours are available in plant#1 per day. • A total of 12 hours are available in plant#2 per day. • A total of 18 hours are available in plant#3 per day. • Formulate a LP to maximize the company’s profits.
Variables & Objective • x1 = no. of batches of windows made • x2 = no. of batches of doors made • Total profit = profit from windows + profit from doors • (profit per batch* no. of batches of windows)+(profit per batch* no. of batches of doors) • 3,000 x1 + 5,000 x2 • 3 x1 + 5 x2 (in thousands of dollars) • objective function: max z = 3 x1+ 50 x2 (11)
Constraints • c1) At most 4 hours are available in plant#1 • = x1< 4 (12) • c2) At most 12 hours are available in plant#2 • = 2 x2<12 (13)(or equivalently, x2<6) • c3) At most 18 hours are available in plant#3 • = 3 x1 +2 x2<18 (14) sign restrictions: x1> 0 ; x2> 0;
LP Formulation • Max z = 3 x1 + 5 x2 • s.t. • x1< 4 • x2< 6 • 3 x1 +2 x2< 18 • x1, x2> 0
Graphical Solution x2 • c1 satisfied by point on left of line AB x1 = 4 • c2 satisfied by point on or below line CD x2 = 6 • c3satisfied by point on or below line CD 3x1+2 x2 = 18 • bounded feasible region • isoprofit line through (x1 = 0, x2 = 2); z = 3x1+5x2 = 10 • isoprofit line through (x1 = 0, x2 = 4); z = 3x1+5x2 = 20 • G is last point in feasible region to intersect isoprofit line • G = (x1 = 2, x2 = 6); optimal z = 36 14 B 12 10 F 8 G D C 6 4 Z=36 2 x1 2 4 6 8 10 12 14 16 A E