Let's say I define the following function in SAGE
$$ f(x,y,z,w)=|x+y-\lfloor x+y\rceil|+|y-z-\lfloor y-z \rceil|+|z+w-\lfloor z+w \rceil | + |w-x-\lfloor w-x \rceil | - |x|-|y|-|z|-|w|, $$ and want to find the maximum of $f$ for $x \in I_x, y \in I_y, z \in I_z, w \in I_w$, some predefined intervals. I am aware of the function
minimize_constrained,
which can be used to minimise multivariate differentiable functions, but since the rounding function is non-differentiable, SAGE returns an error. Is there any way to get SAGE to maximise such a function (or any linear function involving rounding) without having to consider each interval piecewise?
I don't think you should be using optimizers that depend on gradients here. For example, in Python you could so something like that using a global optimizer like differential evolution:
Which gives the results:
So your problem comes probably from the solver you used. I don't know what types of solvers are available in sagemath, though.