Wrapper for the scipy.optimize.minimize() function for distributed function evaluation on multiple MPI processors. The fun argument should be an instance of DistributedMetricEvaluator. This function should be called from all MPI processes.
Parameters: |
|
---|
Example:
import mango.mpi
import scipy as sp
import mango.optimize
def my_func(x):
return (mango.mpi.world.Get_rank()+1) * (x * x + x + 1)
# dfunc sums/reduces (rank+1)*(x*x + x + 1) from all processes to the dfunc.root process
dfunc = mango.optimize.DistributedMetricEvaluator(my_func)
x0 = 8
res = mango.optimize.minimize(dfunc, x0, method="Powell")
print("res.x = %s, res.fun = %s" % (res.x, res.fun))