Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from FuncDesigner import *
- x = oovar()
- f = sin(x + 5000000)/(x+5000000)
- S = 10000000
- cons = [x>=0, x<=S]
- startPoint = {x:0.1}
- S = oosystem()
- r = S.minimize(f, startPoint, solver='interalg', fTol = 0.000000001, constraints = cons, iprint = -1)
- print('value %e at point %e' %(r.ff, r(x)))
- # obvious upper bound:
- # sin(x+ 5000000)<=1, x+5000000 >= 5000000, thus sin(x + 5000000)/(x+5000000) <= 1.0/5000000
- # in the same way sin(x + 5000000)/(x+5000000) >= -1.0/5000000
- print(1.0/5000000 - abs(r.ff))
- # maximization:
- #value 1.994124e-07 at point 7.317041e+03
- #[ 5.87598607e-10]
- # minimization:
- #value -1.991849e-07 at point 1.143669e+03
- #[ 8.15073300e-10]
- # distances to analitically calculated guaranteed bounds less than 1e-9,
- # and distance to exact optimum is even less
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement