Sei sulla pagina 1di 25

Unit 7

Linear Programming as a Pl Planning i Tool T l

Dr. Thomas Thompson II


Slide 1 of 27

Introduction to Assignment Problem


Let

C be an nxn matrix representing the costs of each of n workers to perform any of n jobs. jobs j . The assignment g problem is to assign p g j jobs to workers so as to minimize the total cost. cost . Since each worker can perform only one job and each job can be assigned to only one worker the assignments constitute an independent set of the matrix C.

An

arbitrary assignment is shown above in which worker a is assigned job q, worker b is assigned job s and so on on. . The total cost of this assignment is 23. Can you find a lower cost assignment? Can you find the minimal cost assignment? Remember that each assignment must be unique in its row and column column. . Slide 2 of 27

Assignment Problem

An assignment problem seeks to minimize the total cost assignment of m workers to m jobs, given that the cost of f worker k i performing f i job j b j is i cij. It assumes all workers are assigned and each job is performed. An assignment problem is a special case of a transportation problem in which all supplies and all demands d d are equal l to 1 1; hence h assignment i problems bl may be solved as linear programs. The network representation of an assignment problem with three workers and three jobs is shown on the next slide.

Slide 3 of 27

Assignment Problem

Network Representation
1

c11 c12 c13 c21 c22

c23 c31
3

c32
3

c33 WORKERS JOBS


Slide 4 of 27

Assignment Problem

Linear Programming Formulation Min cijxij ij s.t. xij = 1 j for each resource (row) i

xij = 1 for each job (column) j i xij = 0 or 1 for f all ll i and d j. Note: A modification to the rightright-hand side of the first constraint set can be made if a worker is permitted to work more than 1 job.

Slide 5 of 27

Linear Programming (LP) problems can be solved on the computer using Matlab, and many others. There are special classes of LP problems such as the assignment problem (AP). Efficient solutions methods exist to solve AP. AP AP can be formulated as an LP and solved by general purpose LP codes. However, there are many computer packages, which contain separate computer codes for these models which take advantage of the problem network structure.

Slide 6 of 27

en.wikipedia.org/wiki/ en.wikipedia.org/wiki/Hungarian_algorithm Hungarian_algorithm The Hungarian method is a combinatorial optimization algorithm l i h which hi h solves l the h assignment i problem bl in i polynomial l i l time. It was developed and published by Harold Kuhn in 1955, who g gave the name "Hungarian g method" because the algorithm was largely based on the earlier works of two Hungarian mathematicians: Dnes Knig and Jen Egervry Egervry. . James Munkres reviewed re iewed the algorithm in 1957 and observed obser ed that it is (strongly) polynomial. Since then the algorithm has been known also as KuhnKuhn-Munkres or Munkres assignment algorithm. The time complexity of the original algorithm was O(n4), however later it was noticed that it can be modified to achieve an O(n3) running time. In 2006, it was discovered that Carl Gustav Jacobi had solved the assignment problem in the 19th century, and published posthumously h l i in 1890 i in L Latin. i
Slide 7 of 27

From

Hungarian Method

The Hungarian method solves minimization assignment problems with m workers and m jobs. Special considerations can include: number of workers does not equal the number of jobs add dummy workers/jobs with 0 assignment costs as needed worker i cannot do job j assign cijj = +M maximization objective create an opportunity loss matrix subtracting all profits for each job from the maximum profit for that job before beginning the Hungarian method

Slide 8 of 27

Hungarian Method

Step 1: For each row, subtract the minimum number in that row from all numbers in that row. St 2 Step 2: For F each h column, l subtract bt t th the minimum i i number b in that column from all numbers in that column. Step 3: Draw the minimum number of lines to cover all zeroes. If this number = m, STOP an assignment can be made. Step p 4: Determine the minimum uncovered number (call it d). Subtract d from uncovered numbers. Add d to t numbers b covered db by t two li lines. Numbers covered by one line remain the same. , GO TO STEP 3. Then,
Slide 9 of 27

Hungarian Method

Finding the Minimum Number of Lines and Determining the Optimal Solution Step St 1 1: Find Fi d a row or column l with ith only l one unlined li d zero and circle it. (If all rows/columns have two or more unlined zeroes choose an arbitrary zero.) Step 2: If the circle is in a row with one zero, draw a line through its column. If the circle is in a column with one zero, draw a line through g its row. One approach, when all rows and columns have two or more zeroes, is to draw a line through one with the most zeroes, breaking g ties arbitrarily. y Step 3: Repeat step 2 until all circles are lined. If this minimum number of lines equals m, the circles provide the optimal assignment.
Slide 10 of 27

Example 1: AP
A contractor t t pays hi his subcontractors b t t a fi fixed df fee plus l mileage il f for work performed. On a given day the contractor is faced with three electrical jobs associated with various projects. Given below are projects. j the distances between the subcontractors and the p Project A B C Westside 50 36 16 Subcontractors Federated 28 30 18 Goliath 35 32 20 Universal 25 25 14 How should the contractors be assigned to minimize total costs? Note: There are four subcontractors and three projects. projects We create a dummy project Dum, which will be assigned to one subcontractor (i.e. that subcontractor will remain idle)

Slide 11 of 27

Example 1: AP

Network Representation (note the dummy project)


West.
0 28 50 36 16

Fed.
0 35

30 18

32 20

Gol Gol.
0 25

25 14 0

Univ.

Dum.
Slide 12 of 27

Example 1: AP

Initial Tableau Setup Since the Hungarian algorithm requires that there be the same number of rows as columns, add a Dummy column so that the first tableau is (the smallest elements in each row are marked red): A 50 28 35 25 B 36 30 32 25 C Dummy y 16 0 18 0 20 0 14 0

Westside Federated Goliath Universal

Slide 13 of 27

Example 1: AP

Step 1: Subtract minimum number in each row from all numbers in that row. Since each row has a zero, we simply i l generate the h original i i l matrix i ( (the h smallest ll elements in each column are marked red). This yields: A B C 50 36 16 28 30 18 35 32 20 25 25 14 Dummy 0 0 0 0

Westside Federated Goliath Universal

Slide 14 of 27

Example 1: AP

Step 2: Subtract the minimum number in each column from all numbers in the column. For A it is 25, for B it i 25, is 25 for f C it i is i 14, 14 for f Dummy D it i i is 0 0. Thi This yields: i ld A 25 3 10 0 B 11 5 7 0 C Dummy 2 0 4 0 6 0 0 0

Westside Federated Goliath Universal

Slide 15 of 27

Example 1: AP

Step 3: Draw the minimum number of lines to cover all zeroes (called minimum cover). Although one can "eyeball" this minimum, use the following algorithm. If a "remaining" row has only one zero, draw a line through the column. If a remaining column has only one zero in it, draw a line through the row. Since the number of lines that cover all zeros is 2 < 4 (# of rows), the current solution is not optimal. optimal A 25 3 10 0 B 11 5 7 0 C 2 4 6 0 Dummy 0 0 0 0

Westside Federated Goliath Universal

Step 4: The minimum uncovered number is 2 (circled).

Slide 16 of 27

Example 1: AP

Step 5: Subtract 2 from uncovered numbers; add 2 to all numbers at line intersections; leave all other numbers i intact. Thi gives: This i A 23 1 8 0 B 9 3 5 0 C Dummy 0 0 2 0 4 0 0 2

Westside Federated Goliath Universal

Slide 17 of 27

Example 1: AP

Step 3: Draw the minimum number of lines to cover all zeroes. Since 3 (# of lines) < 4 (# of rows), the current solution l i is i not optimal. i l A B C Dummy Westside 23 9 0 0 Federated 1 3 2 0 Goliath 8 5 4 0 Universal 0 0 0 2 Step 4: The minimum uncovered number is 1 (circled).

Slide 18 of 27

Example 1: AP

Step 5: Subtract 1 from uncovered numbers. Add 1 to numbers at intersections. Leave other numbers intact. Thi gives: This i A 23 0 7 0 B 9 2 4 0 C 0 1 3 0 Dummy 1 0 0 3

Westside Federated Goliath Universal

Slide 19 of 27

Example 1: AP
Find the minimum cover: A 23 0 7 0 B 9 2 4 0 C 0 1 3 0 Dummy 1 0 0 3

Westside Federated Goliath Universal

Step 4: The minimum number of lines to cover all 0 0's s is four. Thus, the current solution is optimal (minimum cost) assignment.

Slide 20 of 27

Example 1: AP
The optimal assignment occurs at locations of zeros such that there is exactly one zero in each row and each column: l A 23 0 7 0 B 9 2 4 0 C 0 1 3 0 Dummy 1 0 0 3

Westside Federated Goliath Universal

Slide 21 of 27

Example 1: AP
The optimal assignment is (go back to the original table for the distances): Subcontractor Project Distance Westside W t id C 16 Federated A 28 Universal B 25 Goliath (unassigned) Total Distance = 69 miles

Slide 22 of 27

Example 1: AP via LP

I our example In l the th LP formulation f l ti is: i Min z = 50x11 + 36x12 + 16x13 + 0x14 + 28x21 + 30x22 + 18x23 + 0x24 + 35x31 + 32x32 + 20x33 + 0x34 + + 25x41 + 25x42 + 14x43 + 0x44 s.t. x11 + x12 + x13 + x14 = 1 (row 1) x21 + x22 + x23 + x24 = 1 (row 2) ( ) x31 + x32 + x33 + x34 = 1 (row 3) x41 + x42 + x43 + x44 = 1 (row 4) x11 + x21 + x31 + x41 = 1 (column 1) x12 + x22 + x32 + x42 = 1 (column 2) x13 + x23 + x33 + x43 = 1 (column 3) x14 + x24 + x34 + x44 = 1 ( l (column 4) ) xij >= 0 for i = 1, 2, 3, 4 and j = 1, 2, 3, 4 (nonnegativity)

Slide 23 of 27

Example 1: AP via LP

The solver formulation is:


Th Assignment The A i t Problem P bl Distances From Contractors to Projects at: A B C 50 36 16 28 30 18 35 32 20 25 25 14 Assignment of Contractors to Projects at: A B C 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0

Contractor West Side F d Federated t d Goliath Universal

Dummy 0 0 0 0

Contractor C t t West Side Federated Goliath Universal Assigned Capacity

Dummy D 0 0 0 0 0 1

Assigned A i d Available A il bl 0 1 0 1 0 1 0 1

Total Distance:

Slide 24 of 27

Example 1: AP via LP

The solver solution is:


Th Assignment The A i t Problem P bl Distances From Contractors to Projects at: A B C 50 36 16 28 30 18 35 32 20 25 25 14 Assignment of Contractors to Projects at: A B C 0 0 1 1 0 0 0 0 0 0 1 0 1 1 1 1 1 1 69

Contractor West Side F d Federated t d Goliath Universal

Dummy 0 0 0 0

Contractor C t t West Side Federated Goliath Universal Assigned Capacity

Dummy D 0 0 1 0 1 1

Assigned A i d Available A il bl 1 1 1 1 1 1 1 1

Total Distance:

Slide 25 of 27

Potrebbero piacerti anche