Changeset 996 for trunk/openopt/scikits/openopt/examples/badlyScaled.py
- Timestamp:
- 05/30/08 10:28:47 (6 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openopt/scikits/openopt/examples/badlyScaled.py
r843 r996 2 2 from scikits.openopt import * 3 3 4 f = lambda x: (x[0]-20)**2+(1e-8 * x[1] - 80)**2 # objFun 4 coeff = 1e-8 5 6 f = lambda x: (x[0]-20)**2+(coeff * x[1] - 80)**2 # objFun 5 7 c = lambda x: (x[0]-14)**2-1 # non-lin ineq constraint(s) c(x) <= 0 6 8 # for the problem involved: f_opt =25, x_opt = [15.0, 8.0e9] … … 16 18 """ 17 19 for to improve the solution we will use 18 changing either p.diffInt from default 1e-7 to [1e-7, 1 0]19 or p.scale from default None to [1, 1e- 8]20 20 changing either p.diffInt from default 1e-7 to [1e-7, 1] 21 or p.scale from default None to [1, 1e-7] 22 21 23 latter (using p.scale) is more recommended 22 because it affects xtol for those solvers 24 because it affects xtol for those solvers 23 25 who use OO stop criteria 24 26 (ralg, lincher, nsmm, nssolve and mb some others) 25 27 xtol will be compared to scaled x shift: 26 28 is || (x[k] - x[k-1]) * scale || < xtol 27 28 You can define scale and diffInt as 29 30 You can define scale and diffInt as 29 31 numpy arrays, matrices, Python lists, tuples 30 32 """ 31 p = NLP(f, x0, c=c, scale = [1, 1e-8],**someModifiedStopCriteria)33 p = NLP(f, x0, c=c, scale = [1, coeff], **someModifiedStopCriteria) 32 34 r = p.solve('ralg') 33 35 print r.ff, r.xf # "24.999996490694787 [ 1.50000004e+01 8.00004473e+09]" - much better
