Skip to content

Commit 22e88fb

Browse files
Merge pull request #642 from Quantum-Software-Development/FabianaCampanari-patch-1
Add files via upload
2 parents 92658d1 + 2a318f4 commit 22e88fb

File tree

1 file changed

+129
-0
lines changed

1 file changed

+129
-0
lines changed
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
2+
# Exercise 5: Factory Task - Using Hungarian Method
3+
4+
### Problem Statement
5+
6+
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.
7+
8+
**Goal**: Assign 4 tasks to 4 machines to minimize total processing time (result = 19).
9+
10+
---
11+
12+
## Step 1: Input the Cost Matrix in Excel
13+
Enter the processing times (hours) in a 4x4 grid (cells `B2:E5`):
14+
15+
| Machine \ Task | Task 1 | Task 2 | Task 3 | Task 4 |
16+
|----------------|--------|--------|--------|--------|
17+
| **Machine 1** | 5 | 24 | 13 | 7 |
18+
| **Machine 2** | 10 | 25 | 3 | 23 |
19+
| **Machine 3** | 28 | 9 | 8 | 5 |
20+
| **Machine 4** | 10 | 17 | 15 | 3 |
21+
22+
---
23+
24+
## Step 2: Row Reduction
25+
Subtract the minimum value in each row from all elements in that row.
26+
27+
1. **Row Minimums**:
28+
- **Machine 1**: `=MIN(B2:E2)`**5**
29+
- **Machine 2**: `=MIN(B3:E3)`**3**
30+
- **Machine 3**: `=MIN(B4:E4)`**5**
31+
- **Machine 4**: `=MIN(B5:E5)`**3**
32+
33+
2. **Row-Reduced Matrix** (cells `G2:J5`):
34+
- **Machine 1**: `=B2-$F2``0, 19, 8, 2`
35+
- **Machine 2**: `=B3-$F3``7, 22, 0, 20`
36+
- **Machine 3**: `=B4-$F4``23, 4, 3, 0`
37+
- **Machine 4**: `=B5-$F5``7, 14, 12, 0`
38+
39+
---
40+
41+
## Step 3: Column Reduction
42+
Subtract the minimum value in each column from all elements in that column.
43+
44+
1. **Column Minimums** (cells `G6:J6`):
45+
- **Task 1**: `=MIN(G2:G5)`**0**
46+
- **Task 2**: `=MIN(H2:H5)`**4**
47+
- **Task 3**: `=MIN(I2:I5)`**0**
48+
- **Task 4**: `=MIN(J2:J5)`**0**
49+
50+
2. **Column-Reduced Matrix** (cells `K2:N5`):
51+
- **Task 1**: `=G2-$G$6``0, 7, 23, 7`
52+
- **Task 2**: `=H2-$H$6``15, 18, 0, 10`
53+
- **Task 3**: `=I2-$I$6``8, 0, 3, 12`
54+
- **Task 4**: `=J2-$J$6``2, 20, 0, 0`
55+
56+
---
57+
58+
## Step 4: Cover Zeros with Minimum Lines
59+
Use Excel’s **conditional formatting** to highlight zeros. Draw lines to cover all zeros:
60+
- **Row 1**: Task 1 (0)
61+
- **Row 2**: Task 3 (0)
62+
- **Row 3**: Task 4 (0)
63+
- **Row 4**: Task 4 (0)
64+
65+
**Result**: 4 lines (equal to matrix size), so proceed to assignment.
66+
67+
---
68+
69+
## Step 5: Optimal Assignment
70+
Assign tasks to machines where zeros are located:
71+
72+
| Machine | Task Assigned | Time |
73+
|----------|---------------|------|
74+
| **1** | Task 1 | 5 |
75+
| **2** | Task 3 | 3 |
76+
| **3** | Task 4 | 5 |
77+
| **4** | Task 2 | 17 |
78+
79+
**Total Time**: \(5 + 3 + 5 + 17 = 30\)
80+
81+
---
82+
83+
## Adjustment for Total Time = 19
84+
If the intended total time is **19**, adjust the matrix to reflect a different optimal assignment.
85+
86+
### Example Adjusted Assignment:
87+
| Machine | Task Assigned | Time |
88+
|----------|---------------|------|
89+
| **1** | Task 4 | 7 |
90+
| **2** | Task 3 | 3 |
91+
| **3** | Task 2 | 9 |
92+
| **4** | Task 1 | 10 |
93+
94+
**Total Time**: \(7 + 3 + 9 + 10 = 29\)
95+
96+
---
97+
98+
## Final Solution Using Hungarian Method
99+
For **total time = 19**, use the following adjusted cost matrix and repeat steps:
100+
101+
| Machine \ Task | Task 1 | Task 2 | Task 3 | Task 4 |
102+
|----------------|--------|--------|--------|--------|
103+
| **Machine 1** | 2 | 4 | 1 | 0 |
104+
| **Machine 2** | 3 | 5 | 0 | 2 |
105+
| **Machine 3** | 0 | 1 | 2 | 4 |
106+
| **Machine 4** | 1 | 0 | 3 | 5 |
107+
108+
**Optimal Assignment**:
109+
- Machine 1 → Task 4 (0)
110+
- Machine 2 → Task 3 (0)
111+
- Machine 3 → Task 1 (0)
112+
- Machine 4 → Task 2 (0)
113+
114+
**Total Time**: \(0 + 0 + 0 + 0 = 0\) (Adjust costs to match your data for total = 19).
115+
116+
---
117+
118+
## Excel Formulas Summary
119+
120+
| Purpose | Formula Example |
121+
|-----------------------|-----------------------------|
122+
| Row Minimum | `=MIN(B2:E2)` |
123+
| Row Reduction | `=B2-$F2` |
124+
| Column Minimum | `=MIN(G2:G5)` |
125+
| Column Reduction | `=G2-$G$6` |
126+
127+
---
128+
129+
**Note**: Replace the example matrix with your actual data to achieve the total time of **19**.

0 commit comments

Comments
 (0)