- Timestamp:
- 07/12/08 04:00:27 (5 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openopt/scikits/openopt/examples/checkDerivatives.py
r915 r1116 20 20 r[1,1] = 2 * x[1] 21 21 r[1,2] = 2 * x[2] + 15 #incorrect derivative 22 return r 22 return r 23 23 p.dc = dc 24 24 … … 42 42 or 43 43 p.checkdc(x=myX) 44 values with difference greater than 44 values with difference greater than 45 45 maxViolation (default 1e-5) 46 46 will be shown … … 48 48 p.checkdh(myX, maxViolation=1e-4) 49 49 p.checkdh(x=myX, maxViolation=1e-4) 50 """51 50 51 Note: 52 RD is log10 of "relative difference" and is defined as int(ceil(log10( |info_user-info_numerical| / (|info_user|+|info_numerical+1e-15)))) 52 53 53 # if you'll use solvers that use derivatives, 54 # they will hardly converge to feasible point 55 # because of the bugs in calculating derivatives made: 56 # r = p.solve('ralg') 57 58 """ 59 Typical output: 54 ################################################################################# 55 Typical output (unfortunately, in terminal or other IDEs the blank space used in strings separation can have other lengths): 60 56 61 57 OpenOpt checks user-supplied gradient df (shape: (30,) ) 62 58 according to: 63 prob.diffInt = 1e-0764 maxViolation = 1e-05 65 df num user-supplied numerical difference66 0 +7.000e+00 -8.000e+00 +1.500e+0167 8 -2.291e+00 -1.029e+01 +8.000e+0059 prob.diffInt = [9.9999999999999995e-08] 60 lines with |info_user-info_numerical| / (|info_user|+|info_numerical+1e-15) greater than maxViolation = 0.01 will be shown 61 df num user-supplied numerical RD 62 0 +7.000e+00 -8.000e+00 2 63 8 -2.291e+00 -1.029e+01 2 68 64 max(abs(df_user - df_numerical)) = 14.9999995251 69 65 (is registered in df number 0) 70 sum(abs(df_user - df_numerical)) = 23.000021040271 66 ======================== 72 67 OpenOpt checks user-supplied gradient dc (shape: (2, 30) ) 73 68 according to: 74 prob.diffInt = 1e-0775 maxViolation = 1e-05 76 dc num i,j:dc[i]/dx[j] user-supplied numerical difference77 32 1 / 2 +1.417e+01 -8.323e-01 +1.500e+0169 prob.diffInt = [9.9999999999999995e-08] 70 lines with |info_user-info_numerical| / (|info_user|+|info_numerical+1e-15) greater than maxViolation = 0.01 will be shown 71 dc num i,j:dc[i]/dx[j] user-supplied numerical RD 72 32 1 / 2 +1.417e+01 -8.323e-01 2 78 73 max(abs(dc_user - dc_numerical)) = 14.9999999032 79 74 (is registered in dc number 32) 80 sum(abs(dc_user - dc_numerical)) = 15.000001194281 75 ======================== 82 76 OpenOpt checks user-supplied gradient dh (shape: (2, 30) ) 83 77 according to: 84 prob.diffInt = 1e-07 85 maxViolation = 1e-05 86 dh num i,j:dh[i]/dx[j] user-supplied numerical difference 87 29 0 / 29 -2.137e+02 -2.137e+02 -1.820e-05 88 58 1 / 28 -4.474e+01 -5.974e+01 +1.500e+01 78 prob.diffInt = [9.9999999999999995e-08] 79 lines with |info_user-info_numerical| / (|info_user|+|info_numerical+1e-15) greater than maxViolation = 0.01 will be shown 80 dh num i,j:dh[i]/dx[j] user-supplied numerical RD 81 58 1 / 28 -4.474e+01 -5.974e+01 2 89 82 max(abs(dh_user - dh_numerical)) = 14.9999962441 90 83 (is registered in dh number 58) 91 sum(abs(dh_user - dh_numerical)) = 15.000014446492 84 ======================== 93 85 """
