I am trying to minimize the following function: \begin{align} &f(z_x,z_y)=|az_x-bz_y| \\ &\text{ s.t. } z_x,z_y \in \mathbb{Z},1 \le z_x \le N_x \text{ and } 1 \le z_y \le N_y \text{ and } a,b \in \mathbb{R}^{+}. \end{align}
There reason I find this problem difficult is that it involves several areas of mathematics: number theory (Diophantine equations), optimization with constrains.
{ Edit:} I know the following: if $a<N_y$ and $b<N_x$ then minimum is attained at $z_x= \lceil b \rfloor$ and $z_y= \lceil a \rfloor$. But there are other cases which I don't see how to solve.
{ The above is wrong. Can show a counter example}
I have been also pursuing a direction with continued fractions. So far unsuccessful.:(
Partial answer:
if $a \ge bN_y$ or $b \ge a N_x$ then minimum value is is $\min(a,b)$.
First bounty Tony was able to answer it for specific $a$ and $b$ and gave a general procedure how to do it.
Second bounty This is second bounty question. Can one find a minimum solution or a tight lower bound that is a function of $a,b, N_x,N_y$?