## 4 Deep Learning-Based Minimum Timeline Cover
### Application of the Pointer Network
#### Coverage Loss  
The _coverage loss_ aims to ensure that each temporal edge is adequately covered by the predicted activity intervals of its associated nodes. For an edge \((u,v,t)\), let \(s_{u}\) and \(e_{u}\) denote the start and end times of the predicted interval for node \(u\), respectively, and similarly \(s_{v},e_{v}\) for node \(v\). The goal is to penalize the model when neither \(u\) nor \(v\) is active at timestamp \(t\). Mathematically, we define the following indicator functions:  
\[\delta_{u}(t)=\mathbf{1}_{\{s_{u}\leq t\leq e_{u}\}},\quad\delta_{v}(t)= \mathbf{1}_{\{s_{v}\leq t\leq e_{v}\}} \tag{12}\]  
which indicate whether timestamp \(t\) is covered by the interval of nodes \(u\) and \(v\), respectively. The total coverage loss for the graph \(G_{i}\) is given by summing the coverage loss for each edge over all edges:  
\[\text{coverage\_loss}_{G_{i}}=\sum_{(u,v,t)\in E_{i}}\mathbf{1}_{\{\delta_{u }(t)=0\&\delta_{v}(t)=0\}} \tag{13}\]  
This loss attempts to ensure that most edges are covered by at least one of the associated nodes. The direct use of indicator functions makes the coverage loss non-differentiable at the boundary points where \(s_{u}=t\) or \(e_{u}=t\). However, in the current implementation, the indicator function is implicitly relaxed using a ReLU. This smooth approximation enables the computation of gradients for the coverage loss component with respect to the start and end times. Thus, the resulting coverage loss is differentiable almost everywhere, except at points where the smooth approximations switch values (e.g., at \(s_{u}=t\)). Span Loss  
The _span loss_ aims to align the predicted start and end times with the observed activity intervals for each node. Let \(\xi_{u}\) and \(\xi_{u}\) denote the observed start and end times of node \(u\). The goal is to minimize the difference between the predicted and observed intervals. The span loss is defined as the mean squared error (MSE) between the predicted and observed intervals for each node (\(|V|=n\)):  
\[\text{span\_loss}_{G_{i}}=\frac{1}{n}\sum_{u\in V_{i}}\left((s_{u}-\xi_{u})^{2 }+(e_{u}-\xi_{u})^{2}\right) \tag{14}\]  
This loss ensures that the model learns to predict intervals that closely match the observed ones, reducing the discrepancy between the predicted activity spans and the actual activity periods. Each term in the summation of the span loss is a quadratic function of the start and end times \(s_{u}\) and \(e_{u}\). Quadratic functions are differentiable everywhere with continuous first and second derivatives. Therefore, the span loss is fully differentiable and provides smooth gradients for optimizing the alignment between the predicted and true intervals. Penalty Term  
The _penalty term_ is introduced to enforce the constraint that the start time \(s_{u}\) should always be less than or equal to the end time \(e_{u}\) for each node \(u\). This ensures that the predicted intervals are valid. The penalty term is defined as  
\[\text{penalty}_{G_{i}}=\sum_{u\in V_{i}}\text{ReLU}(s_{u}-e_{u})^{2} \tag{15}\]  
The squared penalty grows as \(s_{u}\) approaches or exceeds \(e_{u}\), thereby strongly discouraging invalid intervals. The ReLU function itself is piecewise linear and non-differentiable at \(x=0\). However, the squared ReLU term \(\text{ReLU}(s_{u}-e_{u})^{2}\) is differentiable everywhere except at the point \(s_{u}=e_{u}\), where the gradient changes abruptly. Despite this, the penalty term contributes useful gradients in almost all regions of the parameter space and ensures that the optimization process is well behaved except at a few boundary points. Total Loss for a Single Graph  
The overall loss for a single graph \(G_{i}\) can be computed as a weighted combination of the coverage loss, span loss, and the penalty term. To stabilize the gradients and avoid issues with small loss values, we apply a logarithmic transformation with a small constant \(\epsilon\) to each element of the loss.