Simplify an expression containing ceils and floors

56 Views Asked by At

I have an optimization problem that contains the variables $r$ and $s$ where $$r,s\in\mathbb{Z}$$ $$r\geq s\geq0$$ $c$ is a constant with $c\in\mathbb{Q}$ and $c\geq1$.

I would like to minimize the number of ceils and floors and to minimize the number of multiplications, divisions, and modulo operations involving my variables in the following expresion.

$$ \lceil\lfloor r/s \rfloor c\rceil\cdot(s-(r\ \mathrm{mod}\ s)) + \lceil\lceil r/s \rceil c\rceil\cdot(r\ \mathrm{mod}\ s) $$

If $r=0$ I assume the whole expression is equal to $0$. One thing that can be done is to write $\lceil r/s \rceil$ as $\lfloor r/s \rfloor + 1$ giving $$ \lceil\lfloor r/s \rfloor c\rceil\cdot(s-(r\ \mathrm{mod}\ s)) + \lceil(\lfloor r/s \rfloor +1)c\rceil\cdot(r\ \mathrm{mod}\ s) $$

This trades a ceil for a floor which simplifies the model since $\lfloor r/s \rfloor$ needs to be computed only once. Note that $c$ could be distributed over $\lfloor r/s \rfloor +1$ but this is not a very useful change to make, by itself, because it is cheap to compute .

Are there any more reductions that can be made?