How to make function that outputs multiple minima of a function which takes arrays as input?

a1 = [array] #shape = (m,)
a2 = [array] #shape = (n,)
a  = func(a1,a2) # func returns an array of shape = (n, m)
# a is an array of shape = (n, m)
a_sol = [] # empty list
for i in a1:
    f = lambda x: float(func(np.array(i), np.array(x)))
    res = scipy.optimize.minimize_scalar(f)

Is there a way to do this without for loop? Instead of passing each element of a1 one at a time, is there a way to find the minima for all the values of a1 at once, without using the for loop?

1 answer

  • answered 2020-06-27 04:36 Igor Rivin

    from functools import partial
    func1 = partial(func, array1)

    I don't understand what you mean about your function returning an array. What does it mean to minimize an array?