Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from numpy import arange
- from FuncDesigner import *
- from openopt import NSP
- y = oovar('y')
- N = 150
- x = [oovar() for i in range(N)]
- koeffs = 1.07 ** arange(1, N+1) #
- objective = sum([abs(x[i]) * koeffs[i] for i in range(N)]) + abs(y-15) + abs(y+15) + y**2
- startPoint = {y:80}
- for i in range(N):
- startPoint[x[i]] = cos(1+i)
- p = NSP(objective, startPoint, maxIter = 1e5)
- r = p.solve('ralg')
- '''
- PyPy 1.8 time: 118 sec
- CPython 2.7 time: 267 sec
- for nVars ~1-40 performance is almost same,
- for nVars 50-150 PyPy performance is 1.5-2 times better
- for vectorized problems
- x = oovar()
- objective = sum(abs(x) * koeffs) + abs(y-15) + abs(y+15) + y**2
- startPoint = {x: cos(1+arange(N)), y:80}
- PyPy performance is some percents slower than CPython
- '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement