# Supply-Demand Dynamic Matching in Cloud Manufacturing Based on Hypernetwork Model
## 4 Dynamic Matching Method
### Specific Mechanism of Rematching
```
0: Initial matching scheme individual, set of nodes causing the broken match \(DELETE_{S1}\), hyper-edges at \(t\) time \(ST_{t}\), similarity data of \(i\)-th service \(sw[i]\)
0: rematch result
1:if\(DELETE_{S1}\) is not empty then
2:for\(i\) in \(DELETE_{S1}\)do
3: j_indices \(\leftarrow\) find all indexes where the individual is equal to \(i\)
4: sort_wi \(\leftarrow\) obtain the sorted set of service indexes from \(sw[i]\)
5:for\(j\) in j_indices do
6: found_alternative = False
7:for n \(\leftarrow\) 0 to len(sort_wi) do
8: if\(ST_{t}\)[sort_wi[n]][j]=1 and satisfy constraints then
9:\(individual[j]\) = sort_wi[n] /Select the optimal alternative service for the task/
10: found_alternative = True
11:breakable
12:endif
13:endfor
14:if not found_alternative then
15:\(individual[j]=-1\) /Loop ends, no alternative solution/
16:endif
17:endfor
18:endfor
19: rematch_result = individual
20:endif
21:return rematch_result
```  
**Algorithm 1** Algorithm of rematching for \(S\)  
```
0: Initial matching scheme individual, set of nodes causing the broken match \(DELETE_{T1}\), \(ADD_{T1}\), hyperedges at \(t\) time \(ST_{t}\), similarity data of \(j\)-th task \(tw[j]\)
0: rematch result
1:if\(ADD_{T1}\) is not empty then
2:for\(j\) in \(ADD_{T1}\)do
3: sort_wi \(\leftarrow\) obtain the sorted set of task indexes from \(tw[j]\)
4: found_alternative = False
5:for n \(\leftarrow\) 0 to len(sort_wi) do
6: candiS \(\leftarrow\)\(individual[\)sort_wi[n]]
7:if\(ST_{t}\)[cardiS][j][j]=1 and satisfy constraints then
8:\(individual[j]\) = candiS
9: found_alternative = True
10:breakable
11:endif
12:endfor
13:if not found_alternative then
14: imax \(\leftarrow\) find the available service that maximises the demand utility of task \(j\)
15:\(individual[j]\) = imax
16:endif
17:endfor
18: rematch_result = individual
19:endif
20:if\(DELETE_{T1}\) is not empty then
21: rematch_result \(\leftarrow\) delete the tasks \(DELETE_{T1}\) from individual
22:endif
23:return rematch_result
```  
**Algorithm 2** Algorithm of rematching for \(T\)  
```
0: Initial matching scheme individual, set of nodes causing the broken match \(DELETE_{T1}\), \(ADD_{T1}\), hyperedges at \(t\) time \(ST_{t}\), similarity data of \(j\)-th task \(tw[j]\)
0: rematch result
1:if\(ADD_{T1}\) is not empty then
2:for\(j\) in \(ADD_{T1}\)do
3: sort_wi \(\leftarrow\) obtain the sorted set of task indexes from \(tw[j]\)
4: found_alternative = False
5:for n \(\leftarrow\) 0 to len(sort_wi) do
6: candiS \(\leftarrow\)\(individual[\)sort_wi[n]]
7:if\(ST_{t}\)[cardiS][j][j]=1 and satisfy constraints then
8:\(individual[j]\) = candiS
9: found_alternative = True
10:breakable
11:endif
12:endfor
13:if not found_alternative then
14: imax \(\leftarrow\) find the available service that maximises the demand utility of task \(j\)
15:\(individual[j]\) = imax
16:endif
17:endfor
18: rematch_result = individual
19:endif
20:if\(DELETE_{T1}\) is not empty then
21: rematch_result \(\leftarrow\) delete the tasks \(DELETE_{T1}\) from individual
22:endif
23:return rematch_result
```  
**Algorithm 3** Algorithm of rematching for \(T\)  
```
0: Initial matching scheme individual, set of nodes causing the broken match \(DELETE_{T1}\), \(ADD_{T1}\), hyperedges at \(t\) time \(ST_{t}\), similarity data of \(j\)-th task \(tw[j]\)
0: rematch result
1:if\(ADD_{T1}\) is not empty then
2:for\(j\) in \(ADD_{T1}\)do
3: sort_wi \(\leftarrow\) obtain the sorted set of task indexes from \(tw[j]\)
4: found_alternative = False
5:for\(n\) in \(ADD_{T1}\)do
6: candiS \(\leftarrow\)\(individual[\)sort_wi[n]]
7:if\(ST_{t}\)[cardiS][j][j]=1 and satisfy constraints then
8:\(individual[j]\) = candiS
9: found_alternative = True
10:breakable
11:endif
12:endfor
13:if not found_alternative then
14: imax \(\leftarrow\) find the available service that maximises the demand utility of task \(j\)
15:\(individual[j]\) = imax
16:endif
17:endfor
18: rematch_result = individual
19:endif
20:if\(DELETE_{T1}\) is not empty then
21: rematch_result \(\leftarrow\) delete the tasks \(DELETE_{T1}\) from individual
22:endif
23:return rematch_result
```  
**Algorithm 4** Algorithm of rematching for \(T\)  
```
0: Initial matching scheme individual, set of nodes causing the broken match \(DELETE_{T1}\), \(ADD_{T1}\), hyperedges at \(t\) time \(ST_{t}\), similarity data of \(j\)-th task \(tw[j]\)
19: rematch result
24:if\(ADD_{T1}\) is not empty then
35: sort_wi \(\leftarrow\) obtain the sorted set of task indexes from \(tw[j]\)
4: found_alternative = False
5:for\(n\) in \(ADD_{T1}\)do
6: candiS \(\leftarrow\)\(individual[\)sort_wi[n]]
7:if\(ST_{t}\)[cardiS][j][j]=1 and satisfy constraints then
8:\(individual[j]\) = candiS
9: found_alternative = True
10:breakable
12:endif
13:endfor
14:if not found_alternative then
15: imax \(\leftarrow\) find the available service that maximises the demand utility of task \(j\)
16:\(individual[j]\) = imax
17:endif
18:endfor
19: rematch_result = individual
20:endif
21:endif
22:endfor
23:if\(DELETE_{T1}\) is not empty then
24: rematch_result \(\leftarrow\) delete the tasks \(DELETE_{T1}\) from individual
24:endif
25:return rematch_result
```  
**Algorithm 5** Algorithm of rematching for \(T\)  
```
0: Initial matching scheme individual, set of nodes causing the broken match \(DELETE_{T1}\), \(ADD_{T1}\), hyperedges at \(t\) time \(ST_{t}\), similarity data of \(j\)-th task \(tw[j]\)
26:\(j\) in \(ADD_{T1}\)do
37: sort_wi \(\leftarrow\) obtain the sorted set of task indexes from \(tw[j]\)
4: found_alternative = False
5:for\(n\) in \(ADD_{T1}\)do
6: add the sorted set of task indexes from \(tw[j]\)
7: found_alternative = False
8:for\(n\) in \(ADD_{T1}\)do
9: add the sorted set of task indexes from \(tw[j]\)
10: found_alternative = False
11:endif



## 5 Algorithms and Experiments

In this section, experiments were designed to simulate dynamic SDM scenarios to validate the effectiveness of the proposed method based on hypernetwork.