Skip to content Skip to sidebar Skip to footer

How To Write The Scipy.optimize.minimize()'s Parameter

I am using scipy.optimize.minimize() to get the minimum value and it's x,y def fun(self): cols=self.maintablewidget.columnCount()-1 for k in range(3,cols): for

Solution 1:

Take a look at the documentation. Essentially if your function depends on two parameters, you need to pass them as x[0] and x[1] instead of x and y. So in the end you function will depend on a single vector parameter x.For example:

f = lambda x: np.sum((np.sqrt((x[0]-xi)**2+(x[1]-yi)**2)-d)**2)
res = optimize.minimize(f, (initial_x, initial_y))

The minimum will be in res.x and will have the form of a vector [x, y].

Post a Comment for "How To Write The Scipy.optimize.minimize()'s Parameter"