I'd like to solve the following optimization problem. Given $\mathbf a, \mathbf b \in (0, \infty)^n$, find $\mathbf x \in \{0, 1\}^n$ which maximizes
$$ f (\mathbf x) = \frac{\left( \sum\limits_{i=1}^n x_i a_i \right)^2}{\sum\limits_{i=1}^n x_i b_i}.$$
Checking all $2^n$ possibilities for $\mathbf x$ is too expensive, as $n$ can be large.
Expanding the numerator and replacing each $x_i^2$ with $x_i$ yields a ratio of linear functions of binary variables. You can then linearize, as described in my answer here.