Linear Programming David Kauchak cs161 Summer 2009.

Slides:



Advertisements
Similar presentations
2.7 Linear Programming.
Advertisements

BU Decision Models Integer_LP1 Integer Optimization Summer 2013.
Solving LP Models Improving Search Special Form of Improving Search
Linear Programming (LP) (Chap.29)
Session II – Introduction to Linear Programming
Introduction to Algorithms
CCMIII U2D4 Warmup This graph of a linear programming model consists of polygon ABCD and its interior. Under these constraints, at which point does the.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2002 Lecture 8 Tuesday, 11/19/02 Linear Programming.
Water Resources Development and Management Optimization (Linear Programming) CVEN 5393 Feb 18, 2013.
Dragan Jovicic Harvinder Singh
CS 312 – Linear Programming
C&O 355 Mathematical Programming Fall 2010 Lecture 20 N. Harvey TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AA A.
Basic Feasible Solutions: Recap MS&E 211. WILL FOLLOW A CELEBRATED INTELLECTUAL TEACHING TRADITION.
Operation Research Chapter 3 Simplex Method.
Linear Programming.
1 Linear Programming Jose Rolim University of Geneva.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2006 Lecture 9 Wednesday, 11/15/06 Linear Programming.
Totally Unimodular Matrices Lecture 11: Feb 23 Simplex Algorithm Elliposid Algorithm.
Design and Analysis of Algorithms
1 Introduction to Linear and Integer Programming Lecture 9: Feb 14.
Approximation Algorithms
Chapter 10: Iterative Improvement
Linear Programming (LP)
D Nagesh Kumar, IIScOptimization Methods: M7L1 1 Integer Programming All Integer Linear Programming.
Review of Reservoir Problem OR753 October 29, 2014 Remote Sensing and GISc, IST.
Linear Programming Digital Lesson. Copyright © by Houghton Mifflin Company, Inc. All rights reserved. 2 Linear programming is a strategy for finding the.
Chapter 15 Constrained Optimization. The Linear Programming Model Let : x 1, x 2, x 3, ………, x n = decision variables Z = Objective function or linear.
C&O 355 Lecture 2 N. Harvey TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A.
1 Chapter 7 Linear Programming. 2 Linear Programming (LP) Problems Both objective function and constraints are linear. Solutions are highly structured.
Graphing Linear Inequalities in Two Variables Chapter 4 – Section 1.
Linear Programming Data Structures and Algorithms A.G. Malamos References: Algorithms, 2006, S. Dasgupta, C. H. Papadimitriou, and U. V. Vazirani Introduction.
Linear Programming: A Geometric Approach3 Graphing Systems of Linear Inequalities in Two Variables Linear Programming Problems Graphical Solution of Linear.
WOOD 492 MODELLING FOR DECISION SUPPORT Lecture 3 Basics of the Simplex Algorithm.
Warm-Up 3.4 1) Solve the system. 2) Graph the solution.
15.053Tuesday, April 9 Branch and Bound Handouts: Lecture Notes.
OR Chapter 8. General LP Problems Converting other forms to general LP problem : min c’x  - max (-c)’x   = by adding a nonnegative slack variable.
McGraw-Hill/Irwin Copyright © 2009 by The McGraw-Hill Companies, Inc. All Rights Reserved. Supplement 6 Linear Programming.
Integer Programming, Branch & Bound Method
Linear Programming: Formulations, Geometry and Simplex Method Yi Zhang January 21 th, 2010.
TU/e Algorithms (2IL15) – Lecture 12 1 Linear Programming.
Linear Programming: A Geometric Approach3 Graphing Systems of Linear Inequalities in Two Variables Linear Programming Problems Graphical Solution of Linear.
Approximation Algorithms based on linear programming.
1 Geometrical solution of Linear Programming Model.
1 LP-3 Symplex Method. 2  When decision variables are more than 2, it is always advisable to use Simplex Method to avoid lengthy graphical procedure.
(iii) Simplex method - I D Nagesh Kumar, IISc Water Resources Planning and Management: M3L3 Linear Programming and Applications.
Computational Geometry
TU/e Algorithms (2IL15) – Lecture 12 1 Linear Programming.
Chapter 4 The Simplex Algorithm and Goal Programming
Discrete Optimization
Linear Programming for Solving the DSS Problems
Linear Programming Many problems take the form of maximizing or minimizing an objective, given limited resources and competing constraints. specify the.
Module Outline Introduction The Linear Programming Model
Lap Chi Lau we will only use slides 4 to 19
2.7 Linear Programming Objectives: Use linear programming procedures to solve applications. Recognize situations where exactly one solution to a linear.
Digital Lesson Linear Programming.
ADVANCED COMPUTATIONAL MODELS AND ALGORITHMS
Chapter 5 Linear Inequalities and Linear Programming
Topics in Algorithms Lap Chi Lau.
Digital Lesson Linear Programming.
The minimum cost flow problem
The Simplex Method The geometric method of solving linear programming problems presented before. The graphical method is useful only for problems involving.
Copyright © Cengage Learning. All rights reserved.
Constrained Optimization
Linear Programming Prof. Sweta Shah.
Linear Programming.
Linear Programming CISC4080, Computer Algorithms CIS, Fordham Univ.
Copyright © Cengage Learning. All rights reserved.
CISC5835, Algorithms for Big Data
Chapter 10: Iterative Improvement
EE/Econ 458 Introduction to Linear Programming
Presentation transcript:

Linear Programming David Kauchak cs161 Summer 2009

Administrative Questions for the last class Final Review session 8/12 3:15-5:05pm in Skilling Auditorium – questions Sample final available NP complete vs. LP problems Course evaluations

Linear programming A linear function is a function of n variables defined by A linear equality is a linear function with an equality constraint A linear inequality is a linear function with an inequality constraint

Linear programming A linear programming problem consists of two parts a linear function to maximize or minimize subject to a set of linear constraints …

For example objective function constraints

For example

the constraints define the feasible region

For example What are the values of x i that maximize the function within the feasible region?

Another example A chocolatier has two products: a basic product and a deluxe. The company makes x 1 boxes of the basic per day at a profit of $1 each and x 2 boxes of the deluxe at a profit of $6 each. The daily demand is 200 of the basic and 300 of the deluxe. The workforce can create 400 boxes of chocolate per day. How much of each should they create to maximize profits?

Another example A chocolatier has two products: a basic product and a deluxe. The company makes x 1 boxes of the basic per day at a profit of $1 each and x 2 boxes of the deluxe at a profit of $6 each. The daily demand is 200 of the basic and 300 of the deluxe. The workforce can create 400 boxes of chocolate per day. How much of each should they create to maximize profits? How many variables do we need to model the problem?

Another example A chocolatier has two products: a basic product and a deluxe. The company makes x 1 boxes of the basic per day at a profit of $1 each and x 2 boxes of the deluxe at a profit of $6 each. The daily demand is 200 of the basic and 300 of the deluxe. The workforce can create 400 boxes of chocolate per day. How much of each should they create to maximize profits? x 1 = number of boxes per day of basic x 2 = number of boxes per day of deluxe

Another example A chocolatier has two products: a basic product and a deluxe. The company makes x 1 boxes of the basic per day at a profit of $1 each and x 2 boxes of the deluxe at a profit of $6 each. The daily demand is 200 of the basic and 300 of the deluxe. The workforce can create 400 boxes of chocolate per day. How much of each should they create to maximize profits? What are the constraints?

Another example A chocolatier has two products: a basic product and a deluxe. The company makes x 1 boxes of the basic per day at a profit of $1 each and x 2 boxes of the deluxe at a profit of $6 each. The daily demand is 200 of the basic and 300 of the deluxe. The workforce can create 400 boxes of chocolate per day. How much of each should they create to maximize profits?

Another example A chocolatier has two products: a basic product and a deluxe. The company makes x 1 boxes of the basic per day at a profit of $1 each and x 2 boxes of the deluxe at a profit of $6 each. The daily demand is 200 of the basic and 300 of the deluxe. The workforce can create 400 boxes of chocolate per day. How much of each should they create to maximize profits? any others?

Another example A chocolatier has two products: a basic product and a deluxe. The company makes x 1 boxes of the basic per day at a profit of $1 each and x 2 boxes of the deluxe at a profit of $6 each. The daily demand is 200 of the basic and 300 of the deluxe. The workforce can create 400 boxes of chocolate per day. How much of each should they create to maximize profits? What function are we trying to maximize/minimize?

Another example A chocolatier has two products: a basic product and a deluxe. The company makes x 1 boxes of the basic per day at a profit of $1 each and x 2 boxes of the deluxe at a profit of $6 each. The daily demand is 200 of the basic and 300 of the deluxe. The workforce can create 400 boxes of chocolate per day. How much of each should they create to maximize profits?

Another example

Another example Where is the feasibility region?

Another example Where is the maximum within the feasibility region?

Another example c = 2100 c = 1800 c = 1500 c = 1200 c = 900 c = 600

Another example c = 2100 c = 1800 c = 1500 c = 1200 c = 900 c = 600 to maximize, move as far in this direction as the constraints allow

Solutions to LPs A solution to an LP is a vertex on the feasibility polygon the very last feasible point in the direction of improving objective function c = 2100 c = 1800 c = 1500 c = 1200 c = 900 c = 600

Solutions to LPs A solution to an LP is a vertex on the feasibility polygon the very last feasible point in the direction of improving objective function Except…

Solutions to LPs A solution to an LP is a vertex on the feasibility polygon the very last feasible point in the direction of improving objective function Except…

Solutions to LPs A solution to an LP is a vertex on the feasibility polygon the very last feasible point in the direction of improving objective function Except…

Solutions to LPs A solution to an LP is a vertex on the feasibility polygon the very last feasible point in the direction of improving objective function Except… linear program is infeasible

Solutions to LPs A solution to an LP is a vertex on the feasibility polygon the very last feasible point in the direction of improving objective function Except… linear program is unbounded

More products The chocolatier decides to introduce a third product line called premium with a profit of $13. We still can only produce 400 units per day. The deluxe and premium products require the same packaging machinery. Deluxe uses one unit and premium uses 3 units. We have a total of 600 units a day of this packaging material. what changes?

More products The chocolatier decides to introduce a third product line called premium with a profit of $13. We still can only produce 400 units per day. The deluxe and premium products require the same packaging machinery. Deluxe uses one unit and premium uses 3 units. We have a total of 600 units a day of this packaging material. Introduce a new variable x 3

More products The chocolatier decides to introduce a third product line called premium with a profit of $13. We still can only produce 400 units per day. The deluxe and premium products require the same packaging machinery. Deluxe uses one unit and premium uses 3 units. We have a total of 600 units a day of this packaging material. Introduce a new constraint

More products The chocolatier decides to introduce a third product line called premium with a profit of $13. We still can only produce 400 units per day. The deluxe and premium products require the same packaging machinery. Deluxe uses one unit and premium uses 3 units. We have a total of 600 units a day of this packaging material. Introduce a new constraint

More products The chocolatier decides to introduce a third product line called premium with a profit of $13. We still can only produce 400 units per day. The deluxe and premium products require the same packaging machinery. Deluxe uses one unit and premium uses 3 units. We have a total of 600 units a day of this packaging material.

More products The chocolatier decides to introduce a third product line called premium with a profit of $13. We still can only produce 400 units per day. The deluxe and premium products require the same packaging machinery. Deluxe uses one unit and premium uses 3 units. We have a total of 600 units a day of this packaging material. modify existing constraints

More products The chocolatier decides to introduce a third product line called premium with a profit of $13. We still can only produce 400 units per day. The deluxe and premium products require the same packaging machinery. Deluxe uses one unit and premium uses 3 units. We have a total of 600 units a day of this packaging material. Anything else?

More products The chocolatier decides to introduce a third product line called premium with a profit of $13. We still can only produce 400 units per day. The deluxe and premium products require the same packaging machinery. Deluxe uses one unit and premium uses 3 units. We have a total of 600 units a day of this packaging material. modify the objective function

More products The chocolatier decides to introduce a third product line called premium with a profit of $13. We still can only produce 400 units per day. The deluxe and premium products require the same packaging machinery. Deluxe uses one unit and premium uses 3 units. We have a total of 600 units a day of this packaging material. What does the feasibility region look like?

Feasibility region For n variables, the feasibility region is a polyhedron in R n (i.e. n-dimensional space) Each constraint defines a R n-1 plane and the inequality a half-space on one side of the plane adapted from figure 7.2 of [1]

Feasibility region For n variables, the feasibility region is a polyhedron in R n (i.e. n-dimensional space) Each constraint defines a R n-1 plane and the inequality a half-space on one side of the plane

Feasibility region For n variables, the feasibility region is a polyhedron in R n (i.e. n-dimensional space) Each constraint defines a R n-1 plane and the inequality a half-space on one side of the plane

Feasibility region For n variables, the feasibility region is a polyhedron in R n (i.e. n-dimensional space) Each constraint defines a R n-1 plane and the inequality a half-space on one side of the plane

Feasibility region For n variables, the feasibility region is a polyhedron in R n (i.e. n-dimensional space) Each constraint defines a R n-1 plane and the inequality a half-space on one side of the plane

Feasibility region For n variables, the feasibility region is a polyhedron in R n (i.e. n-dimensional space) Each constraint defines a R n-1 plane and the inequality a half-space on one side of the plane

Vector/matrix form

c: [1, 6, 13] A: [ 1, 0, 0

Vector/matrix form c: [1, 6, 13] A: [ 1, 0, 0

Vector/matrix form c: [1, 6, 13] A: [ 1, 0, 0 0, 1, 0

Vector/matrix form c: [1, 6, 13] A: [ 1, 0, 0 0, 1, 0

Vector/matrix form c: [1, 6, 13] A: [ 1, 0, 0 0, 1, 0 1, 1, 1

Vector/matrix form c: [1, 6, 13] A: [ 1, 0, 0 0, 1, 0 1, 1, 1

Vector/matrix form c: [1, 6, 13] A: [ 1, 0, 0 0, 1, 0 1, 1, 1 0, 1, 3 ] b: [200, 300, 400, 600]

Standard form An LP is in standard form if It is a maximization problem the constraints are all ≤ and all variables are non-negative, i.e. have constraints of the form

Converting an LP into standard form LP is minimize instead of maximize

Converting an LP into standard form LP contains constraints of the form:

Converting an LP into standard form LP contains constraints of the form:

Converting an LP into standard form LP contains variable without a non-negative bound constraint replace all occurrences of x i with -x’ i in the objective and constraints

Converting an LP into standard form LP contains variable without a non-negative bound constraint substitute x’ i for x i and change constraints and objective appropriately (i.e. x i – b i ), including introducing a new variable in the objective function

Converting an LP into standard form LP contains variable without a non-negative bound constraint replace all occurrences of x i with x i + - x i - in the objective and constraints

Solving linear programs As we noted before, if a solution exists, a vertex of the feasibility space is an optimal solution Because the objective function is linear, we can use a hill-climbing or greedy approach by starting at one vertex and moving to an adjacent vertex that improves the object function When we’re on top of the “hill”, i.e. we cannot move to a better neighboring vertex, we’re done The simplex method does exactly this

Simplex method Start: [0,0] Objective score:

Simplex method Start: [0,0] Objective score: 0

Simplex method Adjacent vertices [0, 300] [200, 0] Objective score:

Simplex method Adjacent vertices [0, 300] [200, 0] Objective score: 300 Objective score: 200 either option improves the score

Simplex method Adjacent vertices [100, 300] Objective score: 400 improvement

Simplex method Adjacent vertices [200, 200] Objective score: 400 No improvement, so we’re done

Another simplex example Start at [0,0,0] Adjacent vertices [0,0,0] - 0

Another simplex example Start at [0,0,0] Adjacent vertices [200,0,0] [0,300,0] [0,0,200] [0,0,0] - 0

Another simplex example [200,0,0] Adjacent vertices [200,200,0] [200,0,200] [200,0,0] - 200

Another simplex example [200,200,0] Adjacent vertices [200,0,200] [100,300,0] [200,200,0]

Another simplex example [200,0,200] Adjacent vertices [0,0,200] [0,300,100] [200,0,200]

Another simplex example [0,300,100] Adjacent vertices [0,0,200] [0,300,100] [100,300,0] [0,300,0] All others are lower, optimum found

Simplex algorithm let v be any vertex in the feasibility region While there is a neighbor v’ of v with better objective value set v = v’ 3 tasks to work out: determine a starting vertex check whether current vertex is optimal determine where to move next

What defines a vertex? A vertex is specified by a set of n inequalities (i.e. at the intersection of n hyperplanes) adapted from figure 7.12 of [1]

What defines a vertex? A vertex is specified by a set of n inequalities (i.e. at the intersection of n hyperplanes) adapted from figure 7.12 of [1]

What defines a vertex? A vertex is specified by a set of n inequalities (i.e. at the intersection of n hyperplanes) adapted from figure 7.12 of [1]

Can we define neighbors with respect to constraints? Two vertices are neighbors if they share n-1 defining constraints adapted from figure 7.12 of [1]

Determining the starting vertex We’ll assume that the origin is in the feasible region and start here

Is the origin the optimal solution? Assuming the origin is feasible Is the origin a vertex?

Is the origin the optimal solution? Assuming the origin is feasible Is the origin a vertex? When is the origin an optimal vertex? if all c i ≤ 0

Determining where to move next If some c i > 0 then the origin is not optimal We can increase the value of x i and it will increase the objective function How much can we increase x i ? Until we hit another constraint (i.e. a vertex)

For example Is [0, 0] a feasible vertex? Yes. We have x ≥ 0 and all b i are positive

For example Is it optimal? no, both c i are positive

For example How far can we increase x 2 ? x 2 = 3 This gives us a new vertex at [0, 3]

Simplex algorithm continued We’ve shown how to check for optimality and move to a new vertex when we are at the origin After we’ve moved to a new vertex, now what? Idea: we can transform the problem so that the new point is at the origin The details are beyond the scope of this class, but see pg. 215 of [1] for more details

Simplex algorithm let v be any vertex in the feasibility region transform the LP so that v is the origin while a c i exists such that c i > 0 (i.e. a better solution/vertex exists) pick some such c i and increase x i until a constraint is tight (i.e. increasing x i further would move out of the feasibility space set v = v’ transform the LP so that v is the origin

Running time let v be any vertex in the feasibility region transform the LP so that v is the origin while a c i exists such that c i > 0 (i.e. a better solution/vertex exists) pick some such c i and increase x i until a constraint is tight (i.e. increasing x i further would move out of the feasibility space set v = v’ transform the LP so that v is the origin Given an LP, we have n variables, m inequality constraints and n constraints of the form x ≥ 0

Running time let v be any vertex in the feasibility region transform the LP so that v is the origin while a c i exists such that c i > 0 (i.e. a better solution/vertex exists) pick some such c i and increase x i until a constraint is tight (i.e. increasing x i further would move out of the feasibility space set v = v’ transform the LP so that v is the origin What is the per iteration cost?

Running time let v be any vertex in the feasibility region transform the LP so that v is the origin while a c i exists such that c i > 0 (i.e. a better solution/vertex exists) pick some such c i and increase x i until a constraint is tight (i.e. increasing x i further would move out of the feasibility space set v = v’ transform the LP so that v is the origin O(nm) m constraints with up to n variables to determine how far we can move c i Solve: For each constraint: for all x fixed but x i

Running time let v be any vertex in the feasibility region transform the LP so that v is the origin while a c i exists such that c i > 0 (i.e. a better solution/vertex exists) pick some such c i and increase x i until a constraint is tight (i.e. increasing x i further would move out of the feasibility space set v = v’ transform the LP so that v is the origin O(nm)

Running time let v be any vertex in the feasibility region transform the LP so that v is the origin while a c i exists such that c i > 0 (i.e. a better solution/vertex exists) pick some such c i and increase x i until a constraint is tight (i.e. increasing x i further would move out of the feasibility space set v = v’ transform the LP so that v is the origin How many iterations?

Running time let v be any vertex in the feasibility region transform the LP so that v is the origin while a c i exists such that c i > 0 (i.e. a better solution/vertex exists) pick some such c i and increase x i until a constraint is tight (i.e. increasing x i further would move out of the feasibility space set v = v’ transform the LP so that v is the origin O(vertices) How many vertices? Each vertex is defined by n constraints and we have m + n constraints: exponential!

Running time of simplex Worst case is exponential There are theoretical examples that can be created where the running time is exponential In practice, the algorithm is much faster

Other LP solvers Many other LP algorithms exist ellipsoid algorithm interior point methods (many of these) Both of the above algorithms are O(polynomial time) State of the art run-times are a toss up between interior point methods and simplex solvers

Another example Carpet company: From our analysts, we’re given carpet demand estimates for the next calendar year: d 1,d 2, …,d n. The company has 30 employees, each of which makes 20 carpets per month and gets paid $2000/mo. The demand fluctuates from month to month. We can handle this demand in three ways: Overtime: Overtime costs 80% more than regular pay. Workers can put in at most 30% overtime Hiring and firing, at a cost of $320 and $400 respectively per worker Store extra carpets at a cost of $8 per carpet per month. We must end the year without any stored carpets.

What is the profit for a month? Carpet company: From our analysts, we’re given carpet demand estimates for the next calendar year: d 1,d 2, …,d n. The company has 30 employees, each of which makes 20 carpets per month and gets paid $2000/mo. The demand fluctuates from month to month. We can handle this demand in three ways: Overtime: Overtime costs 80% more than regular pay. Workers can put in at most 30% overtime Hiring and firing, at a cost of $320 and $400 respectively per worker Store extra carpets at a cost of $8 per carpet per month. We must end the year without any stored carpets. profit = revenue - cost revenue = carpets_sold * price cost = employees * overtime * hirings * firings * storage * 8

Defining variables Carpet company: From our analysts, we’re given carpet demand estimates for the next calendar year: d 1,d 2, …,d n. The company has 30 employees, each of which makes 20 carpets per month and gets paid $2000/mo. The demand fluctuates from month to month. We can handle this demand in three ways: Overtime: Overtime costs 80% more than regular pay. Workers can put in at most 30% overtime Hiring and firing, at a cost of $320 and $400 respectively per worker Store extra carpets at a cost of $8 per carpet per month. We must end the year without any stored carpets. profit = revenue - cost revenue = carpets_sold * price cost = employees * overtime * hirings * firings * storage * 8 w i = number of employees during month i x i = carpets made in month i o i = number of carpets made with overtime h i = number of hirings at beginning of month i f i = number of firings at beginning of month i s i = number of carpets stored in month i c i = carpets sold in month i

Constraints Carpet company: From our analysts, we’re given carpet demand estimates for the next calendar year: d 1,d 2, …,d n. The company has 30 employees, each of which makes 20 carpets per month and gets paid $2000/mo. The demand fluctuates from month to month. We can handle this demand in three ways: Overtime: Overtime costs 80% more than regular pay. Workers can put in at most 30% overtime Hiring and firing, at a cost of $320 and $400 respectively per worker Store extra carpets at a cost of $8 per carpet per month. We must end the year without any stored carpets. w i = number of employees during month i x i = carpets made in month i o i = number of carpets made with overtime h i = number of hirings at beginning of month i f i = number of firings at beginning of month i s i = number of carpets stored in month i c i = carpets sold in month i Constraints on carpets sold?

Constraints Carpet company: From our analysts, we’re given carpet demand estimates for the next calendar year: d 1,d 2, …,d n. The company has 30 employees, each of which makes 20 carpets per month and gets paid $2000/mo. The demand fluctuates from month to month. We can handle this demand in three ways: Overtime: Overtime costs 80% more than regular pay. Workers can put in at most 30% overtime Hiring and firing, at a cost of $320 and $400 respectively per worker Store extra carpets at a cost of $8 per carpet per month. We must end the year without any stored carpets. w i = number of employees during month i x i = carpets made in month i o i = number of carpets made with overtime h i = number of hirings at beginning of month i f i = number of firings at beginning of month i s i = number of carpets stored in month i How many carpets are made a month? c i = carpets sold in month i

Constraints Carpet company: From our analysts, we’re given carpet demand estimates for the next calendar year: d 1,d 2, …,d n. The company has 30 employees, each of which makes 20 carpets per month and gets paid $2000/mo. The demand fluctuates from month to month. We can handle this demand in three ways: Overtime: Overtime costs 80% more than regular pay. Workers can put in at most 30% overtime Hiring and firing, at a cost of $320 and $400 respectively per worker Store extra carpets at a cost of $8 per carpet per month. We must end the year without any stored carpets. w i = number of employees during month i x i = carpets made in month i o i = number of carpets made with overtime h i = number of hirings at beginning of month i f i = number of firings at beginning of month i s i = number of carpets stored in month i How many workers do we have each month? c i = carpets sold in month i

Constraints Carpet company: From our analysts, we’re given carpet demand estimates for the next calendar year: d 1,d 2, …,d n. The company has 30 employees, each of which makes 20 carpets per month and gets paid $2000/mo. The demand fluctuates from month to month. We can handle this demand in three ways: Overtime: Overtime costs 80% more than regular pay. Workers can put in at most 30% overtime Hiring and firing, at a cost of $320 and $400 respectively per worker Store extra carpets at a cost of $8 per carpet per month. We must end the year without any stored carpets. w i = number of employees during month i x i = carpets made in month i o i = number of carpets made with overtime h i = number of hirings at beginning of month i f i = number of firings at beginning of month i s i = number of carpets stored in month i How many carpets are stored? c i = carpets sold in month i

Constraints Carpet company: From our analysts, we’re given carpet demand estimates for the next calendar year: d 1,d 2, …,d n. The company has 30 employees, each of which makes 20 carpets per month and gets paid $2000/mo. The demand fluctuates from month to month. We can handle this demand in three ways: Overtime: Overtime costs 80% more than regular pay. Workers can put in at most 30% overtime Hiring and firing, at a cost of $320 and $400 respectively per worker Store extra carpets at a cost of $8 per carpet per month. We must end the year without any stored carpets. w i = number of employees during month i x i = carpets made in month i o i = number of carpets made with overtime h i = number of hirings at beginning of month i f i = number of firings at beginning of month i s i = number of carpets stored in month i c i = carpets sold in month i

Constraints Carpet company: From our analysts, we’re given carpet demand estimates for the next calendar year: d 1,d 2, …,d n. The company has 30 employees, each of which makes 20 carpets per month and gets paid $2000/mo. The demand fluctuates from month to month. We can handle this demand in three ways: Overtime: Overtime costs 80% more than regular pay. Workers can put in at most 30% overtime Hiring and firing, at a cost of $320 and $400 respectively per worker Store extra carpets at a cost of $8 per carpet per month. We must end the year without any stored carpets. w i = number of employees during month i x i = carpets made in month i o i = number of carpets made with overtime h i = number of hirings at beginning of month i f i = number of firings at beginning of month i s i = number of carpets stored in month i c i = carpets sold in month i Any other constraints?

Maximizing profit profit = revenue - cost revenue = carpets_sold * price cost = employees * overtime * hirings * firings * storage * 8 Revenue?

Maximizing profit profit = revenue - cost revenue = carpets_sold * price cost = employees * overtime * hirings * firings * storage * 8 Cost?

Objective function profit = revenue - cost revenue = carpets_sold * price cost = employees * overtime * hirings * firings * storage * 8

The solution Given our problem formulation, we can plug it into a solver (or write our own) and we’ll get a solution back if one exists Are we done? Our solution may have non-integer values. How do we sell.3 of a carpet? If the variable values are large, we can round and we won’t be too far away from optimal If the variable values are small, then we need to be more careful about our rounding decisions Integer (linear) programming is the linear programming problem with integer solutions Like the 0-1 knapsack problem vs. the fractional knapsack problem, the fractional problem is easier Integer programming is NP-complete

Uses operational problems network flow planning microeconomics

Beyond LPs Convex optimization f i (c 1 x + c 2 y) = c 1 f i (x) + c 2 f i (y)

References [1] Algorithms (2008). Sanjoy Dasgupta, Christos Papadimitiou and Umesh Vazirani.