Assume an objective function $f = g (X\_{t\_1},Y\_{t\_1}) + g (X\_{t\_2},Y\_{t\_2}) + g (X\_{t\_3},Y\_{t\_3}) + \dots+g (X\_{t\_n},Y\_{t\_n})$ where $g$ is a convex function. $X\_{t\_i}$ and $Y\_{t\_i}$ are sets of real numbers where $1 \le i \le n$ and the data points in $X\_{t\_i}$ and $Y\_{t\_i}$ arrives sequentially from a data stream. Hence, at time $t-1$, the data in $X\_{t}$ and $Y\_{t}$ is not available. 


Assume the current time-stamp is $t$ and the window size is $s$, the goal is to minimize a series of object functions $f\_t = g(X\_{t},Y\_{t}) + g(X\_{t-1},Y\_{t-1}) + \dots + g(X\_{t-s+1},Y\_{t-s+1})$ at time-stamp $t$, and compute the optimal sets of values $\bar{X}\_{[t-s+1,t]}$ and $\bar{Y}\_{[t-s+1,t]}$ to minimize the function. The data of $X$ and $Y$ arrived prior to time-stamp $t-s+1$ should be discarded and not considered in the scope in the minimization problem.


If we are at time-stamp $t+1$, window size is $s$ and minimization at time-stamp $t$ is done, data of $X\_{t-s+1}$ and $Y\_{t-s+1}$ should be discarded, but data of $X\_{[t-s+2,t]}$ and $Y\_{[t-s+2,t]}$ still needs to be used to minimize the function at time-stamp $t+1$. Is there a model to minimize function $f\_{t+1}$ by using the data $X\_{t+1}$ and $Y\_{t+1}$ arrived at $t+1$ only without reprocessing the historical data in $X\_{[t-s+2,t]}$ and $Y\_{[t-s+2,t]}$?


Update 1:


$X\_t$ and $Y\_t$ are not varying, they can be treated as observations at $t$, and there are new observations at time $t+1$ which are $X\_{t+1}$ and $Y\_{t+1}$. I have not come up with an application yet, it is just for optimization with dynamic data. In a dynamic environment, the data can be changed at different time-stamps. The goal here is to minimize a function $f\_t$ at time-stamp $t$ over most recent observations $X\_{[t-s+1,t]}$ and $\_{[t-s+1,t]}$ where $s$ is the fixed window size, and the minimization over $f\_{t+1}$, $f\_{t+1}$, $\dots$ shall be conducted over time. One naive way to do this is to re-process the whole data of $X\_{[t-s+1,t]}$ and $\_{[t-s+1,t]}$. This method may not be efficient since data of $X\_{[t-s+1,t-1]}$ and $Y\_{[t-s+1,t-1]}$ is already processed when minimizing $f\_{t-1}$. Is there a method to minimize $f\_t$ without re-scanning or re-processing the data $X\_{[t-s+1,t-1]}$ and $Y\_{[t-s+1,t-1]}$ by using some information when processing the minimization of $f\_{t-1}$?



Optimization over sliding windows
It's not clear to me from the problem description what's being optimized, so I'm going to try to rephrase the problem, then answer the rephrased version. Also, the presence of two streams ($X$ and $Y$) seems superfluous to the underlying question, so I'll just pose the question in the context of a single stream.


Let $X\_1,X\_2,...,X\_N$ be a stream of (known, fixed) real-valued numbers. Let $s$ be a window length. Let $g:\mathbb{R} \rightarrow \mathbb{R}$ be a convex function. Let
$$Z\_t=\min\_z \sum\_{i=0}^{s-1} g(X\_{t-i}-z)$$
for $t=s,s+1,...,N$. So, for example, if $g(x)=x^2$, then the sliding window is minimized at the mean; if $g(x)=|x|$, the sliding window is minimized at the median.


Question: Given $Z\_t$, can we compute $Z\_{t+1}$ with $O(1)$ work (i.e., somehow take in the new value, drop the old value, and "update" something to compute $Z\_t$)?


Note: In the particular case of $g(x)=x^2$, the answer is "yes": we just add $X\_{t+1}/s$ and subtract $X\_1/s$.


Answer: In general, no. Consider $g(x)=|x|$. Computing a sliding median window across $N$ values has complexity (exactly) $\Theta(N \log (S))$ (see [Suomela, 2014](https://arxiv.org/pdf/1406.1717.pdf)). Therefore, the amortized complexity of a single update is $\Theta(\log(S))$, not $O(1)$.


