Show
Ignore:
Timestamp:
07/12/08 04:00:27 (5 months ago)
Author:
dmitrey.kroshko
Message:

some changes in check user-supplied derivatives

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openopt/scikits/openopt/examples/checkDerivatives.py

    r915 r1116  
    2020    r[1,1] = 2 * x[1] 
    2121    r[1,2] = 2 * x[2] + 15 #incorrect derivative 
    22     return r     
     22    return r 
    2323p.dc = dc 
    2424 
     
    4242or 
    4343p.checkdc(x=myX) 
    44 values with difference greater than  
     44values with difference greater than 
    4545maxViolation (default 1e-5) 
    4646will be shown 
     
    4848p.checkdh(myX, maxViolation=1e-4) 
    4949p.checkdh(x=myX, maxViolation=1e-4) 
    50 """ 
    5150 
     51Note: 
     52RD is log10 of "relative difference" and is defined as int(ceil(log10( |info_user-info_numerical| / (|info_user|+|info_numerical+1e-15)))) 
    5253 
    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################################################################################# 
     55Typical output (unfortunately, in terminal or other IDEs the blank space used in strings separation can have other lengths): 
    6056 
    6157OpenOpt checks user-supplied gradient df (shape: (30,) ) 
    6258according to: 
    63 prob.diffInt = 1e-07 
    64 maxViolation = 1e-05 
    65 df num         user-supplied     numerical         difference 
    66     0             +7.000e+00     -8.000e+00     +1.500e+01 
    67     8             -2.291e+00     -1.029e+01     +8.000e+00 
     59prob.diffInt = [9.9999999999999995e-08] 
     60lines with |info_user-info_numerical| / (|info_user|+|info_numerical+1e-15) greater than maxViolation = 0.01 will be shown 
     61df num         user-supplied     numerical               RD 
     62    0             +7.000e+00     -8.000e+00              2 
     63    8             -2.291e+00     -1.029e+01              2 
    6864max(abs(df_user - df_numerical)) = 14.9999995251 
    6965(is registered in df number 0) 
    70 sum(abs(df_user - df_numerical)) = 23.0000210402 
    7166======================== 
    7267OpenOpt checks user-supplied gradient dc (shape: (2, 30) ) 
    7368according to: 
    74 prob.diffInt = 1e-07 
    75 maxViolation = 1e-05 
    76 dc num   i,j:dc[i]/dx[j]   user-supplied     numerical         difference 
    77     32             1 / 2         +1.417e+01     -8.323e-01     +1.500e+01 
     69prob.diffInt = [9.9999999999999995e-08] 
     70lines with |info_user-info_numerical| / (|info_user|+|info_numerical+1e-15) greater than maxViolation = 0.01 will be shown 
     71dc num   i,j:dc[i]/dx[j]   user-supplied     numerical               RD 
     72    32             1 / 2         +1.417e+01     -8.323e-01              2 
    7873max(abs(dc_user - dc_numerical)) = 14.9999999032 
    7974(is registered in dc number 32) 
    80 sum(abs(dc_user - dc_numerical)) = 15.0000011942 
    8175======================== 
    8276OpenOpt checks user-supplied gradient dh (shape: (2, 30) ) 
    8377according 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 
     78prob.diffInt = [9.9999999999999995e-08] 
     79lines with |info_user-info_numerical| / (|info_user|+|info_numerical+1e-15) greater than maxViolation = 0.01 will be shown 
     80dh num   i,j:dh[i]/dx[j]   user-supplied     numerical               RD 
     81    58            1 / 28         -4.474e+01     -5.974e+01              2 
    8982max(abs(dh_user - dh_numerical)) = 14.9999962441 
    9083(is registered in dh number 58) 
    91 sum(abs(dh_user - dh_numerical)) = 15.0000144464 
    9284======================== 
    9385"""