Changeset 1162

Show
Ignore:
Timestamp:
07/25/08 12:27:25 (4 months ago)
Author:
dmitrey.kroshko
Message:

some changes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openopt/scikits/openopt/Kernel/objFunRelated.py

    r1156 r1162  
    317317            for fun in getattr(p.user, derivativesType): 
    318318                tmp = atleast_1d(fun(*(x,)+getattr(p.args, funcType))) 
    319                 if not ((tmp.size == p.n  and nFuncs == 1) or (tmp.ndim>1 and tmp.shape[1] == p.n))
     319                if mod(tmp.size, p.n) != 0
    320320                    if funcType=='f': 
    321321                        p.err('incorrect user-supplied (sub)gradient size of objective function') 
  • trunk/openopt/scikits/openopt/Kernel/ooCheckGradient.py

    r1128 r1162  
    1 from numpy import hstack, ceil, floor, log10, inf, tile, argmax, abs, asfarray, ravel 
     1from numpy import hstack, ceil, floor, log10, inf, tile, argmax, abs, asfarray, ravel, any 
    22from string import rjust, ljust 
    33class autocreate: 
     
    8181 
    8282    print('OpenOpt checks user-supplied gradient ' + fun_ + ' (shape: ' + str(info_user.shape) + ' )') 
    83     print('according to prob.diffInt = ' + str(p.diffInt))#TODO: ADD other parameters: allowed epsilon, maxDiffLines etc 
    84     print('lines with 1 - info_user/info_numerical greater than maxViolation = '+ str(p.maxViolation) + ' will be shown') 
     83    print('according to:') 
     84    print('    prob.diffInt = ' + str(p.diffInt))#TODO: ADD other parameters: allowed epsilon, maxDiffLines etc 
     85    print('    |1 - info_user/info_numerical| <= prob.maxViolation = '+ str(p.maxViolation)) 
    8586 
    86     if (abs(Diff) >= p.maxViolation).any(): 
     87    if any(abs(Diff) >= p.maxViolation): 
    8788        ss = '    ' 
    8889        if fun_ in doubleColumn: 
     
    116117    ind_max = argmax(diff_d) 
    117118    val_max = diff_d[ind_max] 
    118     print('max(abs('  + fun_ + '_user - ' + fun_ + '_numerical)) = ' + str(val_max)) 
    119     print('(is registered in '+ fun_+ ' number ' + str(ind_max) + ')') 
     119    if any(abs(Diff) >= p.maxViolation): 
     120        print('max(abs('  + fun_ + '_user - ' + fun_ + '_numerical)) = ' + str(val_max)) 
     121        print('(is registered in '+ fun_+ ' number ' + str(ind_max) + ')') 
     122    else: 
     123        print('derivatives are equal') 
    120124    #print('sum(abs('  + fun_ + '_user - ' + fun_ + '_numerical)) = ' + str(p.norm(d[:,2],1))) 
    121125