TITLE: "Most Similar Vector Problem" on an Integer Lattice?
QUESTION [9 upvotes]: I am currently working on problem that I think could be expressed as an integer lattice problem.
Given $u \in \mathbb{R}^n$ and a bounded integer lattice $L = \mathbb{Z}^n \cap [-M,M]^n$ I would like to find an integer vector $v \in L$ that minimizes the angle between $u$ and $v$. That is, I would like $$v \in \text{argmax}_{w \in L} \frac{u.w}{\|u\|\|w\|}$$
Here, the objective is maximizing the cosine of the angle between $u$ and $w$ (i.e. minimizing the angle between $u$ and $w$). The vectors $u$ and $w$ are said to be "similar" if this quantity is close to 1.
I am wondering:

Is this problem related to a well-known integer lattice problem (e.g. a closest vector problem)?
Could this problem be solved using existing lattice algorithms (e.g. the LLL algorithm?)

REPLY [6 votes]: Writing up the comment: You just need to "pixelate" the line by finding all lattice boxes that it crosses:
Then the answer vector $v$ must connect to one of the corners of the shaded boxes. Instead of first collecting the boxes, try the following zig-zag algorithm: start from the origin and poll the up and right nearest lattice points. One of them is closer to your vector $u$, so pick that one. Again, looking up and right, pick the closer vertex. Repeating this procedure will give you a list of distances for each point reached. Pick the minimum distance and that's your answer. This algorithm is $O(Mn)$, and perhaps can be sped up by someone more clever than me.