Largest integer value of $z=x\times{}y$ given $0<x\leq{}a$, $0<y\leq{}b$, and $z\leq{}c$

52 Views Asked by At

What would be an efficient algorithm to find largest value of $z=x\times{}y$ given $0<x\leq{}a$, $0<y\leq{}b$, and $z\leq{}c$, where $a$, $b$, $c$, $x$, $y$, and $z$ are all positive integers?

For example, if $a=8$, $b=7$, and $c=31$, then $z=30$ (corresponding to $\{x,y\}=\{5,6\}$).

1

There are 1 best solutions below

4
On

You can solve the problem via integer linear programming as follows. Let $A=\{1,\dots,a\}$ and $B=\{1,\dots,b\}$. For $i\in A$, let binary decision variable $x_i$ indicate whether $x=i$. For $j\in B$, let binary decision variable $y_j$ indicate whether $y=j$. Let decision variable $\ell$ represent $\log z$. The problem is to maximize $\ell$ subject to linear constraints \begin{align} \sum_{i \in A} x_i &= 1 \tag1\label1\\ \sum_{j \in B} y_j &= 1 \tag2\label2\\ \ell &= \sum_{i \in A} (\log i) x_i + \sum_{j \in B} (\log j) y_j \tag3\label3\\ \ell &\le \log c \tag4\label4 \end{align} Constraints \eqref{1} and \eqref{2} select exactly one value for $x$ and $y$, respectively. Constraint \eqref{3} enforces $z = x y$. Constraint \eqref{4} enforces $z \le c$.

After solving, you can recover the values of $x$, $y$, and $z$ as follows: \begin{align} x &= \sum_{i \in A} i x_i \\ y &= \sum_{j \in B} j y_j \\ z &= \exp(\ell) \end{align}