I want to optimize using scipy optimize, but I didn't know how to input a variable that takes only integers such as the number of things, so in that memorandum
I found the answer in the scipy formula. https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.optimize.brute.html scipy.optimize.brute (Minimize a function over a given range by brute force.) Brute force means to force, and to search for the optimum value by brute force.
scipy.optimize.brute(func, ranges, args=(), Ns=20, full_output=0, finish=<function fmin at 0x2b45cb917e60>, disp=False) However, since this finish further optimizes the surrounding area after brute force, if this is set to None, only the grid defined in ranges will be calculated and the minimum position and the value at that time will be returned to finish. Masu So, if you use this to define slice () so that only integers like (slice (0,15,1), slice (0,10,1)) are taken in ranges, the minimum value is only an integer. To find.
To be honest, I understand that you should use np.meshgrid and then use the for statement for brute force, but if it is provided as an API, unnecessary mistakes can be avoided. I think it's okay, so I'd like to use it conveniently.
Recommended Posts