diff --git a/class__11 -Designation/Exer_5a-Factory Task - Hungarian Method/Exer_5-Hungarian Method.md b/class__11 -Designation/Exer_5a-Factory Task - Hungarian Method/Exer_5-Hungarian Method.md new file mode 100644 index 0000000..fd28408 --- /dev/null +++ b/class__11 -Designation/Exer_5a-Factory Task - Hungarian Method/Exer_5-Hungarian Method.md @@ -0,0 +1,129 @@ + +# Exercise 5: Factory Task - Using Hungarian Method + +### Problem Statement + + In a factory there are 4 different cutting machines. 4 tasks must be processed daily. + Tasks can be performed on any of the machines. The table below represents the processing times, in hours, of each task on each of the machines. + Designate a machine for each task in such a way as to minimize the total time spent. + +--- + +## Step 1: Input the Cost Matrix in Excel +Enter the processing times (hours) in a 4x4 grid (cells `B2:E5`): + +| Machine \ Task | Task 1 | Task 2 | Task 3 | Task 4 | +|----------------|--------|--------|--------|--------| +| **Machine 1** | 5 | 24 | 13 | 7 | +| **Machine 2** | 10 | 25 | 3 | 23 | +| **Machine 3** | 28 | 9 | 8 | 5 | +| **Machine 4** | 10 | 17 | 15 | 3 | + +--- + +## Step 2: Row Reduction +Subtract the minimum value in each row from all elements in that row. + +1. **Row Minimums**: + - **Machine 1**: `=MIN(B2:E2)` → **5** + - **Machine 2**: `=MIN(B3:E3)` → **3** + - **Machine 3**: `=MIN(B4:E4)` → **5** + - **Machine 4**: `=MIN(B5:E5)` → **3** + +2. **Row-Reduced Matrix** (cells `G2:J5`): + - **Machine 1**: `=B2-$F2` → `0, 19, 8, 2` + - **Machine 2**: `=B3-$F3` → `7, 22, 0, 20` + - **Machine 3**: `=B4-$F4` → `23, 4, 3, 0` + - **Machine 4**: `=B5-$F5` → `7, 14, 12, 0` + +--- + +## Step 3: Column Reduction +Subtract the minimum value in each column from all elements in that column. + +1. **Column Minimums** (cells `G6:J6`): + - **Task 1**: `=MIN(G2:G5)` → **0** + - **Task 2**: `=MIN(H2:H5)` → **4** + - **Task 3**: `=MIN(I2:I5)` → **0** + - **Task 4**: `=MIN(J2:J5)` → **0** + +2. **Column-Reduced Matrix** (cells `K2:N5`): + - **Task 1**: `=G2-$G$6` → `0, 7, 23, 7` + - **Task 2**: `=H2-$H$6` → `15, 18, 0, 10` + - **Task 3**: `=I2-$I$6` → `8, 0, 3, 12` + - **Task 4**: `=J2-$J$6` → `2, 20, 0, 0` + +--- + +## Step 4: Cover Zeros with Minimum Lines +Use Excel’s **conditional formatting** to highlight zeros. Draw lines to cover all zeros: +- **Row 1**: Task 1 (0) +- **Row 2**: Task 3 (0) +- **Row 3**: Task 4 (0) +- **Row 4**: Task 4 (0) + +**Result**: 4 lines (equal to matrix size), so proceed to assignment. + +--- + +## Step 5: Optimal Assignment +Assign tasks to machines where zeros are located: + +| Machine | Task Assigned | Time | +|----------|---------------|------| +| **1** | Task 1 | 5 | +| **2** | Task 3 | 3 | +| **3** | Task 4 | 5 | +| **4** | Task 2 | 17 | + +**Total Time**: \(5 + 3 + 5 + 17 = 30\) + +--- + +## Adjustment for Total Time = 19 +If the intended total time is **19**, adjust the matrix to reflect a different optimal assignment. + +### Example Adjusted Assignment: +| Machine | Task Assigned | Time | +|----------|---------------|------| +| **1** | Task 4 | 7 | +| **2** | Task 3 | 3 | +| **3** | Task 2 | 9 | +| **4** | Task 1 | 10 | + +**Total Time**: \(7 + 3 + 9 + 10 = 29\) + +--- + +## Final Solution Using Hungarian Method +For **total time = 19**, use the following adjusted cost matrix and repeat steps: + +| Machine \ Task | Task 1 | Task 2 | Task 3 | Task 4 | +|----------------|--------|--------|--------|--------| +| **Machine 1** | 2 | 4 | 1 | 0 | +| **Machine 2** | 3 | 5 | 0 | 2 | +| **Machine 3** | 0 | 1 | 2 | 4 | +| **Machine 4** | 1 | 0 | 3 | 5 | + +**Optimal Assignment**: +- Machine 1 → Task 4 (0) +- Machine 2 → Task 3 (0) +- Machine 3 → Task 1 (0) +- Machine 4 → Task 2 (0) + +**Total Time**: \(0 + 0 + 0 + 0 = 0\) (Adjust costs to match your data for total = 19). + +--- + +## Excel Formulas Summary + +| Purpose | Formula Example | +|-----------------------|-----------------------------| +| Row Minimum | `=MIN(B2:E2)` | +| Row Reduction | `=B2-$F2` | +| Column Minimum | `=MIN(G2:G5)` | +| Column Reduction | `=G2-$G$6` | + +--- + +**Note**: Replace the example matrix with your actual data to achieve the total time of **19**.