0
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)
    a_sol.append(res)

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?

tripleee
  • 175,061
  • 34
  • 275
  • 318

1 Answers1

0
from functools import partial

func1 = partial(func, array1)
scipy.optimize.minimize(func1)

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

Igor Rivin
  • 4,632
  • 2
  • 23
  • 35