- Timestamp:
- 09/11/12 19:05:10 (4 years ago)
- Location:
- branches/UQ/math/legacy
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/UQ/math/legacy/TEST_OUQ_StAlData.py
r556 r558 112 112 not c.short_wrt_self(data.lipschitz, tol=error[2]): 113 113 c.set_feasible(data, error[2], bounds=bounds, constraints=constrain) 114 # npop=20, maxiter=200) 114 115 ###################### more function-specific ##################### 115 116 if debug: -
branches/UQ/math/legacy/dirac_measure.py
r557 r558 954 954 955 955 # prepare bounds for solver 956 bounds = None 957 if kwds.has_key('bounds'): 958 bounds = kwds['bounds'] 956 bounds = kwds.pop('bounds', None) 959 957 # if bounds are not set, use the default optimizer bounds 960 if bounds ==None:958 if bounds is None: 961 959 lower_bounds = []; upper_bounds = [] 962 960 for n in pts: # bounds for n*x in each dimension (x2 due to weights) … … 971 969 # plug in the 'constraints' function: param' = constraints(param) 972 970 # constraints should impose_mean(y,w), and possibly sum(weights) 973 constraints = None # default is no constraints 974 if kwds.has_key('constraints'): constraints = kwds['constraints'] 971 constraints = kwds.pop('constraints', None) # default is no constraints 975 972 if not constraints: # if None (default), there are no constraints 976 973 constraints = lambda x: x 977 974 975 _self = kwds.pop('with_self', True) # default includes self in shortness 976 if _self is not False: _self = True 978 977 # tolerance for optimization on sum(y) 979 npop = 40 #XXX: tune npop? 980 if kwds.has_key('npop'): npop = kwds.pop('npop') 981 tol = 0.0 # default 982 if kwds.has_key('tol'): tol = kwds.pop('tol') 978 tol = kwds.pop('tol', 0.0) # default 979 npop = kwds.pop('npop', 20) #XXX: tune npop? 980 maxiter = kwds.pop('maxiter', 1000) #XXX: tune maxiter? 983 981 984 982 # if no guess was made, then use bounds constraints 985 if guess ==None:983 if guess is None: 986 984 if npop: 987 985 guess = bounds 988 986 else: # fmin_powell needs a list params (not bounds) 989 987 guess = [(a + b)/2. for (a,b) in bounds] 990 991 _self = True # default is to include self in measuring shortness992 if kwds.has_key('with_self'): _self = kwds['with_self']993 if _self != False: _self = True994 988 995 989 # construct cost function to reduce sum(lipschitz_distance) … … 1012 1006 1013 1007 # construct and configure optimizer 1014 debug = True#False #!!!1015 max iter = 1000; maxfun = 1e+61008 debug = False #!!! 1009 maxfun = 1e+6 1016 1010 crossover = 0.9; percent_change = 0.9 1017 1011 ftol = abs(tol); gtol = None … … 1098 1092 bounds = kwds.pop('bounds', None) 1099 1093 # if bounds are not set, use the default optimizer bounds 1100 if bounds ==None:1094 if bounds is None: 1101 1095 lower_bounds = []; upper_bounds = [] 1102 1096 for n in pts: # bounds for n*x in each dimension (x2 due to weights) -
branches/UQ/math/legacy/legacydata.py
r557 r558 320 320 of any element less than the cutoff. 321 321 """ 322 # get tolerance in y 323 tol = 0.0 324 if kwds.has_key('tol'): tol = kwds['tol'] 325 cutoff = tol # default is to zero out distances less than tolerance 326 if kwds.has_key('cutoff'): cutoff = kwds['cutoff'] 322 tol = kwds.get('tol', 0.0) # get tolerance in y 323 # default is to zero out distances less than tolerance 324 cutoff = kwds.get('cutoff', tol) 327 325 if cutoff is True: cutoff = tol 328 326 elif cutoff is False: cutoff = None 329 327 330 if L ==None: L = self.lipschitz331 if data ==None: data = self328 if L is None: L = self.lipschitz 329 if data is None: data = self 332 330 from paramtrans import lipschitz_distance, is_feasible 333 331 # calculate the shortness -
branches/UQ/math/legacy/paramtrans.py
r557 r558 208 208 from numpy import asarray 209 209 d = infeasibility(distance, cutoff) > 0.0 210 if len(asarray(d).shape) ==0:210 if len(asarray(d).shape) is 0: 211 211 return not d 212 212 return -d … … 226 226 distance = array(distance) 227 227 # zero-out all distances less than tolerated 228 if cutoff !=None:229 if len(distance.shape) ==0:228 if cutoff is not None: 229 if len(distance.shape) is 0: 230 230 return 0.0 if distance <= cutoff else distance 231 231 distance[distance <= cutoff] = 0.0 … … 263 263 264 264 # get tolerance in y 265 tol = 0.0 266 if kwds.has_key('tol'): tol = kwds.pop('tol') 265 tol = kwds.pop('tol', 0.0) 267 266 cutoff = tol # default is to zero out distances less than tolerance 268 267 if kwds.has_key('cutoff'): cutoff = kwds.pop('cutoff') … … 326 325 327 326 # get tolerance in y and wiggle room in x 328 ytol = 0.0 329 if kwds.has_key('ytol'): ytol = kwds.pop('ytol') 330 xtol = 0.0 # default is to not allow 'wiggle room' in x 331 if kwds.has_key('xtol'): xtol = kwds.pop('xtol') 327 ytol = kwds.pop('ytol', 0.0) 328 xtol = kwds.pop('xtol', 0.0) # default is to not allow 'wiggle room' in x 332 329 333 330 cutoff = ytol # default is to zero out distances less than tolerance … … 335 332 if cutoff is True: cutoff = ytol 336 333 elif cutoff is False: cutoff = None 337 ipop = min(20, 3*nxi) #XXX: tune ipop? 338 if kwds.has_key('ipop'): ipop = kwds.pop('ipop') 339 imax = 1000 #XXX: tune imax? 340 if kwds.has_key('imax'): imax = kwds.pop('imax') 334 ipop = kwds.pop('ipop', min(20, 3*nxi)) #XXX: tune ipop? 335 imax = kwds.pop('imax', 1000) #XXX: tune imax? 341 336 342 337 #########################################################################
Note: See TracChangeset
for help on using the changeset viewer.