/usr/share/pyshared/openopt/examples/glp_2.py is in python-openopt 0.38+svn1589-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 | from openopt import GLP
from numpy import *
f = lambda x: (x[0]-1.5)**2 + sin(0.8 * x[1] ** 2 + 15)**4 + cos(0.8 * x[2] ** 2 + 15)**4 + (x[3]-7.5)**4
p = GLP(f, lb = -ones(4), ub = ones(4), maxIter = 1e3, maxFunEvals = 1e5, maxTime = 3, maxCPUTime = 3)
#optional: graphic output
#p.plot = 1
r = p.solve('pswarm', x0=[0, 0, 0, 0], plot=0, debug=1, maxIter=200)
x_opt, f_opt = r.xf, r.ff
|