## 4 Solving the Warehouse Delivery Problem
### Task Assignment and Sequencing
#### 4.3.2 Conflict Detection and Resolution
Recall that exit(\(t\),\(v\)) marks the end of path \(t\) and not necessarily \(r\)'s physical departure from vertex \(v\), and due to the difference constraint in Line 18, we know that task \(t\) must be executed by the time point exit(\(t\),\(v\)). Hence, the earliest time point that task \(t^{\prime}\) could be finished is exit(\(t\),\(v\)) + \(\kappa\). Again, combined with Line 18, this means that the execution time of \(t^{\prime}\) is after \(t\) has finished. However, the constraint does not require that task \(t^{\prime}\) be executed the instant after \(t\) is finished, and it is of course possible for there to be an arbitrary delay following \(t\)'s completion. This dependency constraint is only enforced when the paths are assigned to distinct robots. For paths that are assigned to the same robot this constraint is redundant, since the correctness of the scheduling is enforced implicitly by the path sequencing. However, here we have also imposed the additional restriction that the tasks are in a non-delivery dependency. Delivery dependencies are a special case of tasks that are assigned to the same robot, since they are known statically. This means that not only is the rule redundant for delivery dependencies, but specifying it explicitly means that its application to delivery dependencies is removed completely during grounding. In our application setting, this is the only special case we need to consider. However, in a different application setting with other dependency types that can only be executed by the same robot, we could derive a specific static predicate to capture these cases. As was the case for scheduling in the step-based encoding (Section 4.3.4), we use the binary predicate d1/2 to express the assignment of arrival and exit times. The paths corresponding to the timed walks in Table 2 are scheduled as follows. d1(arrive(t1,h1),0) d1(exit(t1,h1),0) d1(arrive(t5,h2),0) d1(arrive(t1,w3),15) d1(exit(t1,w3),15) d1(arrive(t5,w4),15) d1(arrive(t5,w4),15) d1(arrive(t1,w2),45) d1(arrive(t5,w8),30) d1(arrive(t1,w5),65) d1(arrive(t5,h2),45) d1(arrive(t5,h2),55) d1(arrive(t1,h1),80) d1(arrive(t1,h1),90) d1(arrive(t1,h2),55) d1(arrive(t2,h1),90) d1(arrive(t6,w8),70) d1(arrive(t2,h1),105) d1(arrive(t6,w7),100) d1(arrive(t6,w7),100) d1(arrive(t6,w7),100) d1(arrive(t6,w7),100) d1(arrive(t6,w7),100) d1(arrive(t6,w7),100) d1(arrive(t6,w6),120) d1(arrive(t6,w6),120) d1(arrive(t6,w6),120) d1(arrive(t6,w7),100) d1(arrive(t6,w6),120) d1(arrive(t6,w7),100) d1(arrive(t6,w6),120) d1(arrive(t6,w7),120) d1(arrive(t6,w7),120) d1(arrive(t6,w7),120) d1(arrive(t6,w7),120) d1(arrive(t6,w7),160) d1(arrive(t6,w6),160) d1(arrive(t6,w7),225) d1(arrive(t6,w7),175) d1(arrive(t6,w7),220) d1(arrive(t6,w7),220) d1(arrive(t6,w7),190) d1(arrive(t6,w7),120) d1(arrive(t6,w7),120)move in the latter along with an increasing step counter. We make this precise by mapping paths and vertices to steps as follows: Given a stable model \(X\) of logic program \(F\cup P\), we define the function \(\pi_{X}:(T\cup R)\times V\to\mathbb{N}\) recursively in the following way:

\[\pi_{X}(p,v)= \begin{cases}0&\text{if }\texttt{move}(p,v,v^{\prime})\in X, \texttt{move}(p,v^{\prime\prime},v)\
ot\in X,\texttt{path\_sequence}(p^{ \prime},p)\
ot\in X\\ \pi_{X}(p,v^{\prime})+1&\text{if }\texttt{move}(p,v^{\prime},v)\in X\\ \pi_{X}(p^{\prime},v)&\text{if }\texttt{move}(p,v,v^{\prime})\in X,\texttt{move}(p,v^{ \prime\prime},v)\
ot\in X,\texttt{path\_sequence}(p^{\prime},p)\in X\\ \end{cases} \]

for some \(v^{\prime},v^{\prime\prime}\in V\) and \(p^{\prime}\in T\cup R\) in each case. The three cases address the respective positions in a sequence of paths. The first case reflects the first position in the first path of a sequence, which means that it is the starting vertex for the corresponding robot. The second deals with intermediate moves on paths. Furthermore, the third case carries over the step count of the last vertex of the previous path to the first vertex of the current path.