Dmitrey

bench 3 - interalg

Mar 27th, 2011
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.90 KB | None | 0 0
  1. from FuncDesigner import *
  2. from openopt import *
  3. from numpy import zeros
  4.  
  5. n = 7
  6. a = oovars(n)
  7. F = sum([cos(10 * (i+1) * a[i])+(a[i]-0.01*(i+1))**2 for i in range(n)])
  8. startPoint = {a:zeros(n)}
  9. constraints = [a[i]>0 for i in range(n)] + [a[i]<1 for i in range(n)]
  10. p = GLP(F, startPoint, fTol = 1e-2, iterObjFunTextFormat='%0.9e', constraints = constraints)
  11. r = p.minimize('interalg')
  12.  
  13.  
  14. Output:
  15. --------------------------------------------------
  16. solver: interalg_0.17   problem: unnamed    type: GLP
  17.  iter    objFunVal  
  18.     0  7.014000000e+00
  19.    10  -2.748630494e+00
  20.    20  -6.126417785e+00
  21.    30  -6.649460106e+00
  22. OpenOpt info: Solution with required tolerance 1.0e-02
  23.  is guarantied (obtained precision: 9.988e-03)
  24.    40  -6.877908181e+00
  25. istop: 1000 (optimal solution obtained)
  26. Solver:   Time Elapsed = 26.62  CPU Time Elapsed = 26.38
  27. objFunValue: -6.8779082 (feasible, MaxResidual = 0)
Advertisement
Add Comment
Please, Sign In to add comment