Let $S = \{x \in \mathbb{R}^n | |x_{i+1} - x_i | \leq 1\}$, i.e. each successive component differs from the last by at most one. Then $S$ is convex but unbounded. Given some other point $x \in \mathbb{R}^n$, I would like to find the point $s \in S$ that minimizes its euclidean distance to $x$.
I am looking for an algorithm that ideally takes into account the specific structure of $S$, and ideally can be performed in time polynomial in $n$.
Thanks!
Like @LinAlg said, it indeed is your lucky day, but it is even luckier than you thought :)
Let $D$ be the 'forward-difference' matrix, that is, $D x$ is the vector $(x_2 - x_1, x_3 - x_2, \dots, x_n - x_{n-1})^T$. The problem you are attempting to solve is $$ \min_{s \in \mathbb{R}^n} \quad \|s - x\|_2^2 \quad \text{ s.t. }\quad \|D s\|_\infty \leq 1 $$
Note, that the matrix $D$ very sparse. You have the following options: