On May 23, 4:22 pm, Esmail <ebo...@hotmail.com> wrote: > > Is there some sort of simple Python module that would allow me to > evaluate this type of function? > > In this particular instance I am interested in the minimum of > > x * sin(4*x) + 1.1 * sin(2*y), where x,y in range 0-10 > > though in other problems the range may not be identical for x and y.
Take a look at http://openopt.org (python-scikits-openopt on debian/ ubuntu) - a lot of optimization engines under one interface, so you can try different engines easily and without learning many interfaces. >>> import openopt >>> from numpy import * # openopt passes parameters as single vector. >>> def f((x,y)): return x * sin(4*x) + 1.1 * sin(2*y) # GLP finds global minimum - can be hard, but let's try. # I'm not constraining the effort in hope it will converge quickly. >>> opt = openopt.GLP(f, lb=array([0, 0]), ub=array([10, 10])) # 'galileo' is one of the supported GLP solvers, included out of the box. >>> sol = opt.solve('galileo', plot=True) ----------------------------------------------------- solver: galileo problem: unnamed iter objFunVal 0 3.966e+00 10 -6.190e+00 20 -7.613e+00 30 -7.613e+00 35 -7.613e+00 istop: 11 (Non-Success Number > maxNonSuccess = 15) Solver: Time Elapsed = 0.78 CPU Time Elapsed = 0.24 Plotting: Time Elapsed = 8.04 CPU Time Elapsed = 2.21 objFunValue: -7.6132332 (feasible, max constraint = 0) ### here you need to close the runtime-value graph to continue ### >>> sol.ff -7.6132331733254421 >>> sol.xf array([ 7.3418726 , 5.44153445]) That is x=7.3418726, y=5.44153445 gives f=-7.6132331733254421. Makes sense? -- http://mail.python.org/mailman/listinfo/python-list