Skip to content Skip to sidebar Skip to footer

Two Dimensional Optimization (minimization) In Python (using Scipy.optimize)

I am trying to optimize (minimize) a two dimensional function E(n,k) defined as follows: error=lambda x,y,w: (math.log(abs(Tformulated(x,y,w))) - math.log(abs(Tw[w])))**2 + (math.a

Solution 1:

Here's a simplest example:

from scipy.optimize import fmin

defminf(x):
  return x[0]**2 + (x[1]-1.)**2print fmin(minf,[1,2])

[out]:

Optimization terminated successfully.
         Currentfunctionvalue: 0.000000
         Iterations: 44Function evaluations: 82
[ -1.61979362e-059.99980073e-01]

A possible gotcha here is that the minimization routines are expecting a list as an argument. See the docs for all the gory details. Not sure if you can minimize complex-valued functions directly, you might need to consider the real and imaginary parts separately.

Post a Comment for "Two Dimensional Optimization (minimization) In Python (using Scipy.optimize)"