Skip to content

Commit 5a80b81

Browse files
Merge pull request #633 from Quantum-Software-Development/FabianaCampanari-patch-1
Add files via upload
2 parents e240e73 + 553cf16 commit 5a80b81

File tree

1 file changed

+146
-0
lines changed

1 file changed

+146
-0
lines changed
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
## Exercise 1: Mathematical Model and Hungarian Method Solution
2+
3+
## Problem Statement
4+
5+
**Three tasks must be assigned to three machines. Each task can be performed on any machine, but with different costs. Assign each task to one machine, and each machine to one task, minimizing the total cost.**
6+
7+
### Cost Matrix
8+
9+
| | Machine 1 | Machine 2 | Machine 3 |
10+
|---------|-----------|-----------|-----------|
11+
| Task 1 | 2 | 4 | 3 |
12+
| Task 2 | 1 | 3 | 2 |
13+
| Task 3 | 5 | 2 | 4 |
14+
15+
---
16+
17+
## 1. Hungarian Method (Step by Step)
18+
19+
### **Step 1: Subtract Row Minimums**
20+
21+
Subtract the minimum value in each row from all elements in that row.
22+
23+
- Row 1 min: 2 → [0, 2, 1]
24+
- Row 2 min: 1 → [0, 2, 1]
25+
- Row 3 min: 2 → [3, 0, 2]
26+
27+
**Matrix after row subtraction:**
28+
29+
| | M1 | M2 | M3 |
30+
|---------|----|----|----|
31+
| Task 1 | 0 | 2 | 1 |
32+
| Task 2 | 0 | 2 | 1 |
33+
| Task 3 | 3 | 0 | 2 |
34+
35+
---
36+
37+
### **Step 2: Subtract Column Minimums**
38+
39+
Subtract the minimum value in each column from all elements in that column.
40+
41+
- Col 1 min: 0 → [0, 0, 3]
42+
- Col 2 min: 0 → [2, 2, 0]
43+
- Col 3 min: 1 → [0, 0, 1]
44+
45+
**Matrix after column subtraction:**
46+
47+
| | M1 | M2 | M3 |
48+
|---------|----|----|----|
49+
| Task 1 | 0 | 2 | 0 |
50+
| Task 2 | 0 | 2 | 0 |
51+
| Task 3 | 3 | 0 | 1 |
52+
53+
---
54+
55+
### **Step 3: Assignment (Cover Zeros)**
56+
57+
- Cover all zeros using the minimum number of lines (rows or columns).
58+
- Assign tasks to machines where possible (one zero per row/column).
59+
60+
**Optimal Assignment:**
61+
- Task 1 → Machine 1 (cost 2)
62+
- Task 2 → Machine 3 (cost 2)
63+
- Task 3 → Machine 2 (cost 2)
64+
65+
**Total Minimum Cost = 2 + 2 + 2 = 6**
66+
67+
---
68+
69+
## 2. Excel Solver Step-by-Step
70+
71+
### **A. Excel Table Setup**
72+
73+
#### 1. **Cost Table (A1:D4)**
74+
75+
| | B | C | D |
76+
|-----|------|------|------|
77+
| | M1 | M2 | M3 |
78+
| T1 | 2 | 4 | 3 |
79+
| T2 | 1 | 3 | 2 |
80+
| T3 | 5 | 2 | 4 |
81+
82+
#### 2. **Decision Variables Table (F1:I4)**
83+
84+
| | G | H | I |
85+
|-----|------|------|------|
86+
| | M1 | M2 | M3 |
87+
| T1 | x11 | x12 | x13 |
88+
| T2 | x21 | x22 | x23 |
89+
| T3 | x31 | x32 | x33 |
90+
91+
Each cell is 0 or 1 (to be filled by Solver).
92+
93+
#### 3. **Objective Function (K2)**
94+
95+
```
96+
97+
=SUMPRODUCT(B2:D4, G2:I4)
98+
99+
```
100+
101+
#### 4. **Row Constraints (One task per machine)**
102+
103+
- J2: `=SUM(G2:I2)` (should be 1)
104+
- J3: `=SUM(G3:I3)` (should be 1)
105+
- J4: `=SUM(G4:I4)` (should be 1)
106+
107+
#### 5. **Column Constraints (One machine per task)**
108+
109+
- G5: `=SUM(G2:G4)` (should be 1)
110+
- H5: `=SUM(H2:H4)` (should be 1)
111+
- I5: `=SUM(I2:I4)` (should be 1)
112+
113+
---
114+
115+
### **B. Solver Configuration**
116+
117+
- **Set Objective:** K2 (Minimize)
118+
- **By Changing Variables:** G2:I4
119+
- **Add Constraints:**
120+
- J2:J4 = 1
121+
- G5:I5 = 1
122+
- G2:I4 = binary
123+
124+
---PAREI AQUI !!!!___
125+
126+
### **C. Example of Solution Table**
127+
128+
| | M1 | M2 | M3 | Row Sum |
129+
|-----|----|----|----|---------|
130+
| T1 | 1 | 0 | 0 | 1 |
131+
| T2 | 0 | 0 | 1 | 1 |
132+
| T3 | 0 | 1 | 0 | 1 |
133+
|Col Sum| 1| 1 | 1 | |
134+
135+
---
136+
137+
## **Result (in English)**
138+
139+
**The optimal assignment is:**
140+
- Task 1 to Machine 1 (cost 2)
141+
- Task 2 to Machine 3 (cost 2)
142+
- Task 3 to Machine 2 (cost 2)
143+
144+
**Total minimum cost:** 6
145+
146+
-

0 commit comments

Comments
 (0)