# Petri Net Toolbox for Multi-Robot Planning under Uncertainty
## 3 Materials and Methods
### Model Design
The automated model composition is detailed in Algorithm 1. This algorithm produces as output an extended GPSNR \(G^{ext}\) and takes as input:  
1. The topological map \(\mathit{TopoMap}\) that the robots will use to navigate. This must be a directed topological map with \(\mathit{nodes}\), directed \(\mathit{edges}\) and weights that can optionally be assigned to \(\mathit{edges}\). These \(\mathit{edge}\) weights represent the average time to travel between the two connecting nodes. 2. A function \(\mathit{TopoActions:TopoElements\to G_{actions}}\), where \(\mathit{TopoElements}\) is a set with all the topological map nodes and edges. \(G_{actions}=\{G_{action}\),...,\(G_{action}\)\(\}\) is a set with all the actions that the system can execute, modeled as GSPNRs. Thus, this function specifies the action models that the system can perform in each topological map node plus the navigation action that is executed when traversing the edge between two nodes. 3. A vector \(\mathit{Pos}=[r1_{node},\ldots,rn_{node}]\) that contains the starting node of each robot in the topological map. ```
1:Input:\(\mathit{TopoMap}\),\(\mathit{TopoActions}\),\(\mathit{Pos}\)
2:\(G^{ext}=\langle P,T_{I},T_{T},W^{+},W^{-},F,m_{0},r_{P},r_{T}\rangle\)
3:fornode in \(\mathit{TopoMap}\)do
4:\(NodeActionList\gets\mathit{TopoActions}(node)\)\(\triangleright\) get all the available actions in \(\mathit{node}\)
5:for\(\mathit{action\_model}\) in \(NodeActionList\)do
6:for\(\mathit{place}\),\(transition\) in \(\mathit{action\_model}\)do
7:\(place\leftarrow\) replace \(\langle\rangle\) for \(\mathit{node}\) name
8:\(transition\leftarrow\) replace \(\langle\rangle\) for \(\mathit{node}\) name
9:\(F(transition)=F_{\mathit{action\_model}}(transition)\)
10:\(W^{+}(transition)\gets W^{+}_{\mathit{action\_model}}(transition)\)
11:\(W^{-}(transition)\gets W^{-}_{\mathit{action\_model}}(transition)\)
12:endfor
13:\(T_{T}\gets T_{T}\cup T^{\mathit{action\_model}}_{T}\)
14:\(T_{I}\gets T_{I}\cup T^{\mathit{action\_model}}_{I}\)
15:\(P\gets P\cup P_{\mathit{action\_model}}\)
16:\(P\gets P\cup P_{\mathit{action\_model}}\)
17:endfor
18:endfor
19:foredge in \(\mathit{TopoMap}\)do
20:\(\mathit{source}\),\(\mathit{target}\),\(\mathit{duration}\leftarrow\mathit{edge}\)
21:\(\mathit{action\_model}\leftarrow\mathit{TopoActions}(edge)\)
22:forplace,\(transition\) in \(\mathit{action\_model}\)do
23:\(place\leftarrow\) replace \(\langle 1\rangle\) for \(\mathit{source}\) and \(\langle 2\rangle\) for \(\mathit{target}\)
24:\(transition\leftarrow\) replace \(\langle 1\rangle\) for \(\mathit{source}\) and \(\langle 2\rangle\) for \(\mathit{target}\)
25:if\(transition\in T^{\mathit{action\_model}}_{T}\)then
26:\(F(transition)=1/\mathit{duration}\)
27:\(T_{T}\gets T_{T}\cup\{transition\}\)
28:else
29:\(F(transition)=0\)
30:\(T_{I}\gets T_{I}\cup\{transition\}\)
31:endif
32:\(W^{+}(transition)\gets W^{+}_{\mathit{action\_model}}(transition)\)
33:\(W^{-}(transition)\gets W^{-}_{\mathit{action\_model}}(transition)\)
34:endfor
35:\(P\gets P\cup P_{\mathit{action\_model}}\)
36:endfor
37:for\(r_{\mathit{node}}\) in \(\mathit{Pos}\)do
38:\(m_{0}(r_{\mathit{node}})=m_{0}(r_{\mathit{node}})+1\)
39:endfor
```  
**Algorithm 1** Algorithm that builds an extended GSPNR from action models and a topological map. Overall, Algorithm 1 replicates and merges, for each topological map node and edge, the action models provided by the \(\mathit{TopoActions}\) function. This is visible in the code blocks in lines 1-16 and 17-34. First, the algorithm goes through all the nodes of the topological map adding and merging the action models of each action available in that node. Then, it connects the action models in each node using the navigation action model defined for each edge. The navigation action model is mandatory when there is more than one node in the topological map. The places with the same name are merged into one single place and the transitions are redirected to it. The \(\mathit{TopoActions}\) function defines the actions that can be executed in each node and edge of the topological map.