I'm working on a minimization problem with moderate number of variables (~10-20). I don't need several significant digits, so I have already set my WorkingPrecision->4
, which does help speed up the program, but I also don't need infinite granularity of the variables being optimized. Is there some way to set up NMinimize so that it minimizes all variables on a grid, and doesn't worry about improving the calculation by using a finer grain than the grid spacing? I had an idea to use a Mod
constraint (shown below), but it doesn't seem to work and freezes up NMinimize for a larger number of variables. Any advice would be appreciated.
A very barebones code sample of what I tried, here with just a single variable for simplicity (with a grid spacing off 0.001), though it doesn't seem to be working as I would expect - monitoring the tested variables with Reap/Sow shows they often do not lie on the grid itself.
Reap[NMaximize[{Sin[x], 0 < x < 4, Mod[x, 0.001] == 0}, x, Method -> {"DifferentialEvolution"}, StepMonitor :> Sow[x]]]