Changeset 557 for branches


Ignore:
Timestamp:
09/11/12 13:29:43 (4 years ago)
Author:
mmckerns
Message:

set_valid default maxiter to 1000;
fix validation test code in paramtrans

Location:
branches/UQ/math/legacy
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/UQ/math/legacy/TEST_OUQ_1dSurr_CxCy.py

    r556 r557  
    1010# optimizer configuration parameters 
    1111####################################################################### 
    12 npop = 10 #15 #20 #32 #40  #!!! 
     12npop = 15 #10 #20 #32 #40  #!!! 
    1313maxiter = 1000 
    1414maxfun = 1e+6 
     
    108108 
    109109    # then test if valid... then impose model validity on product measure 
    110     if not c.valid_wrt_model(model, tol=target[2], xtol=target[3], \ 
    111                                                    maxiter=error[4]): 
     110    if not c.valid_wrt_model(model, ytol=target[2], xtol=target[3], \ 
     111                                                    imax=target[4]): 
    112112      c.set_valid(model, cutoff=target[2], bounds=bounds, tol=error[2], \ 
    113                          constraints=constrain, xtol=target[3], imax=target[4]) 
     113                                constraints=constrain, xtol=target[3], \ 
     114                                maxiter=error[3], imax=error[4]) 
    114115    ###################### more function-specific ##################### 
    115116    if debug: 
    116       if not c.valid_wrt_model(model, tol=target[2], xtol=target[3], \ 
    117                                                      maxiter=error[4]): 
     117      if not c.valid_wrt_model(model, ytol=target[2], xtol=target[3], \ 
     118                                                      imax=target[4]): 
    118119        print "valid_wrt_model: False" 
    119120      if not [sum(w) for w in c.wts] == [1.0] * len(c.wts): 
     
    141142      return inf  #XXX: FORCE TO SATISFY E CONSTRAINTS 
    142143 
    143     if not c.valid_wrt_model(model, tol=target[2], xtol=target[3], \ 
    144                                                    maxiter=error[4]): 
     144    if not c.valid_wrt_model(model, ytol=target[2], xtol=target[3], \ 
     145                                                    imax=target[4]): 
    145146      if debug: print "skipping model-invalidity" 
    146147      return inf  #XXX: FORCE TO SATISFY E CONSTRAINTS 
     
    173174  Cx = (2.0,0.0,0.0) #NOTE: SET THE 'wiggle' HERE! 
    174175  valid_tol = 0.0  #NOTE: SET THE 'model tolerance' HERE! 
    175   iter = 200       #NOTE: SET THE 'Cy-validation maxiter' HERE! 
    176   imax = 10        #NOTE: SET THE 'Cx-validation maxiter' HERE! 
    177   target = (y_mean,theta,Cy,Cx,imax) 
    178   error = (y_mean_error,None,valid_tol,None,iter) 
     176  imax_c = 200     #NOTE: SET THE 'max iterations to check valid' HERE! 
     177  imax_i = 10      #NOTE: SET THE 'max inner iterations to set valid' HERE! 
     178  imax_o = 50      #NOTE: SET THE 'max outer iterations to set valid' HERE! 
     179  target = (y_mean,theta,Cy,Cx,imax_c) 
     180  error = (y_mean_error,None,valid_tol,imax_o,imax_i) 
    179181  pars = (target,error) 
    180182 
     
    255257 
    256258  print "fails valid wrt model:\n%s" % \ 
    257         c.valid_wrt_model(model, xtol=Cx, tol=Cy, blamelist=True, maxiter=iter) 
     259        c.valid_wrt_model(model, xtol=Cx, ytol=Cy, blamelist=True, imax=imax_c) 
    258260  print "mean(y): %s >= %s" % (str( c.get_mean_value() ), y_mean - y_mean_error) 
    259261  print "sum_wts: %s == 1.0" % [sum(w) for w in c.wts] 
    260262 
    261263  from paramtrans import graphical_distance 
    262   Ry = graphical_distance(model, c, tol=Cy, xtol=Cx, cutoff=0.0, maxiter=0) 
     264  Ry = graphical_distance(model, c, ytol=Cy, xtol=Cx, cutoff=0.0, imax=0) 
    263265  print "vertical_distance: %s <= %s" % (Ry, Cy + max(Cx)) 
    264   Rv = graphical_distance(model, c, tol=Cy, xtol=Cx, cutoff=0.0, maxiter=iter) 
     266  Rv = graphical_distance(model, c, ytol=Cy, xtol=Cx, cutoff=0.0, imax=imax_c) 
    265267  print "graphical_distance: %s <= %s" % (Rv, Cy) 
    266268 
  • branches/UQ/math/legacy/TEST_OUQ_1dSurr_Cy.py

    r556 r557  
    108108 
    109109    # then test if valid... then impose model validity on product measure 
    110     if not c.valid_wrt_model(model, tol=target[2], xtol=target[3], \ 
    111                                                    maxiter=error[4]): 
     110    if not c.valid_wrt_model(model, ytol=target[2], xtol=target[3], \ 
     111                                                    imax=target[4]): 
    112112      c.set_valid(model, cutoff=target[2], bounds=bounds, tol=error[2], \ 
    113                          constraints=constrain, xtol=target[3], imax=target[4]) 
     113                                constraints=constrain, xtol=target[3], \ 
     114                                maxiter=error[3], imax=error[4]) 
    114115    ###################### more function-specific ##################### 
    115116    if debug: 
    116       if not c.valid_wrt_model(model, tol=target[2], xtol=target[3], \ 
    117                                                      maxiter=error[4]): 
     117      if not c.valid_wrt_model(model, ytol=target[2], xtol=target[3], \ 
     118                                                      imax=target[4]): 
    118119        print "valid_wrt_model: False" 
    119120      if not [sum(w) for w in c.wts] == [1.0] * len(c.wts): 
     
    141142      return inf  #XXX: FORCE TO SATISFY E CONSTRAINTS 
    142143 
    143     if not c.valid_wrt_model(model, tol=target[2], xtol=target[3], \ 
    144                                                    maxiter=error[4]): 
     144    if not c.valid_wrt_model(model, ytol=target[2], xtol=target[3], \ 
     145                                                    imax=target[4]): 
    145146      if debug: print "skipping model-invalidity" 
    146147      return inf  #XXX: FORCE TO SATISFY E CONSTRAINTS 
     
    173174  Cx = (0.0,0.0,0.0) #NOTE: SET THE 'wiggle' HERE! 
    174175  valid_tol = 0.0  #NOTE: SET THE 'model tolerance' HERE! 
    175   iter = 200       #NOTE: SET THE 'Cy-validation maxiter' HERE! 
    176   imax = 10        #NOTE: SET THE 'Cx-validation maxiter' HERE! 
    177   target = (y_mean,theta,Cy,Cx,imax) 
    178   error = (y_mean_error,None,valid_tol,None,iter) 
     176  imax_c = 200     #NOTE: SET THE 'max iterations to check valid' HERE! 
     177  imax_i = 10      #NOTE: SET THE 'max inner iterations to set valid' HERE! 
     178  imax_o = 50      #NOTE: SET THE 'max outer iterations to set valid' HERE! 
     179  target = (y_mean,theta,Cy,Cx,imax_c) 
     180  error = (y_mean_error,None,valid_tol,imax_o,imax_i) 
    179181  pars = (target,error) 
    180182 
     
    255257 
    256258  print "fails valid wrt model:\n%s" % \ 
    257         c.valid_wrt_model(model, xtol=Cx, tol=Cy, blamelist=True, maxiter=iter) 
     259        c.valid_wrt_model(model, xtol=Cx, ytol=Cy, blamelist=True, imax=imax_c) 
    258260  print "mean(y): %s >= %s" % (str( c.get_mean_value() ), y_mean - y_mean_error) 
    259261  print "sum_wts: %s == 1.0" % [sum(w) for w in c.wts] 
    260262 
    261263  from paramtrans import graphical_distance 
    262   Ry = graphical_distance(model, c, tol=Cy, xtol=Cx, cutoff=0.0, maxiter=0) 
     264  Ry = graphical_distance(model, c, ytol=Cy, xtol=Cx, cutoff=0.0, imax=0) 
    263265  print "vertical_distance: %s <= %s" % (Ry, Cy + max(Cx)) 
    264   Rv = graphical_distance(model, c, tol=Cy, xtol=Cx, cutoff=0.0, maxiter=iter) 
     266  Rv = graphical_distance(model, c, ytol=Cy, xtol=Cx, cutoff=0.0, imax=imax_c) 
    265267  print "graphical_distance: %s <= %s" % (Rv, Cy) 
    266268 
  • branches/UQ/math/legacy/TEST_OUQ_StStSurr_Cy.py

    r556 r557  
    108108 
    109109    # then test if valid... then impose model validity on product measure 
    110     if not c.valid_wrt_model(model, tol=target[2], xtol=target[3], \ 
    111                                                    maxiter=error[4]): 
     110    if not c.valid_wrt_model(model, ytol=target[2], xtol=target[3], \ 
     111                                                    imax=target[4]): 
    112112      c.set_valid(model, cutoff=target[2], bounds=bounds, tol=error[2], \ 
    113                          constraints=constrain, xtol=target[3], imax=target[4]) 
     113                                constraints=constrain, xtol=target[3], \ 
     114                                maxiter=error[3], imax=error[4]) 
    114115    ###################### more function-specific ##################### 
    115116    if debug: 
    116       if not c.valid_wrt_model(model, tol=target[2], xtol=target[3], \ 
    117                                                      maxiter=error[4]): 
     117      if not c.valid_wrt_model(model, ytol=target[2], xtol=target[3], \ 
     118                                                      imax=target[4]): 
    118119        print "valid_wrt_model: False" 
    119120      if not [sum(w) for w in c.wts] == [1.0] * len(c.wts): 
     
    141142      return inf  #XXX: FORCE TO SATISFY E CONSTRAINTS 
    142143 
    143     if not c.valid_wrt_model(model, tol=target[2], xtol=target[3], \ 
    144                                                    maxiter=error[4]): 
     144    if not c.valid_wrt_model(model, ytol=target[2], xtol=target[3], \ 
     145                                                    imax=target[4]): 
    145146      if debug: print "skipping model-invalidity" 
    146147      return inf  #XXX: FORCE TO SATISFY E CONSTRAINTS 
     
    173174  Cx = (0.0,0.0,0.0) #NOTE: SET THE 'wiggle' HERE! 
    174175  valid_tol = 0.0  #NOTE: SET THE 'model tolerance' HERE! 
    175   iter = 200       #NOTE: SET THE 'Cy-validation maxiter' HERE! 
    176   imax = 10        #NOTE: SET THE 'Cx-validation maxiter' HERE! 
    177   target = (y_mean,theta,Cy,Cx,imax) 
    178   error = (y_mean_error,None,valid_tol,None,iter) 
     176  imax_c = 200     #NOTE: SET THE 'max iterations to check valid' HERE! 
     177  imax_i = 10      #NOTE: SET THE 'max inner iterations to set valid' HERE! 
     178  imax_o = 50      #NOTE: SET THE 'max outer iterations to set valid' HERE! 
     179  target = (y_mean,theta,Cy,Cx,imax_c) 
     180  error = (y_mean_error,None,valid_tol,imax_o,imax_i) 
    179181  pars = (target,error) 
    180182 
     
    255257 
    256258  print "fails valid wrt model:\n%s" % \ 
    257         c.valid_wrt_model(model, xtol=Cx, tol=Cy, blamelist=True, maxiter=iter) 
     259        c.valid_wrt_model(model, xtol=Cx, ytol=Cy, blamelist=True, imax=imax_c) 
    258260  print "mean(y): %s >= %s" % (str( c.get_mean_value() ), y_mean - y_mean_error) 
    259261  print "sum_wts: %s == 1.0" % [sum(w) for w in c.wts] 
    260262 
    261263  from paramtrans import graphical_distance 
    262   Ry = graphical_distance(model, c, tol=Cy, xtol=Cx, cutoff=0.0, maxiter=0) 
     264  Ry = graphical_distance(model, c, ytol=Cy, xtol=Cx, cutoff=0.0, imax=0) 
    263265  print "vertical_distance: %s <= %s" % (Ry, Cy + max(Cx)) 
    264   Rv = graphical_distance(model, c, tol=Cy, xtol=Cx, cutoff=0.0, maxiter=iter) 
     266  Rv = graphical_distance(model, c, ytol=Cy, xtol=Cx, cutoff=0.0, imax=imax_c) 
    265267  print "graphical_distance: %s <= %s" % (Rv, Cy) 
    266268 
  • branches/UQ/math/legacy/dirac_measure.py

    r556 r557  
    521521 
    522522Additional Inputs: 
    523     tol -- maximum acceptable difference |y - F(x')|; a single value 
     523    ytol -- maximum acceptable difference |y - F(x')|; a single value 
    524524    xtol -- maximum acceptable difference |x - x'|; an iterable or single value 
    525     cutoff -- zero out distances less than cutoff; typically: tol, 0.0, or None 
     525    cutoff -- zero out distances less than cutoff; typically: ytol, 0.0, or None 
    526526 
    527527Notes: 
    528     xtol defines the n-dimensional base of a pilar of height tol, centered at 
     528    xtol defines the n-dimensional base of a pilar of height ytol, centered at 
    529529    each point. The region inside the pilar defines the space where a "valid" 
    530530    model must intersect. If xtol is not specified, then the base of the pilar 
    531531    will be a dirac at x' = x. This function performs an optimization for each 
    532     x to find an appropriate x'. While cutoff and tol are very tightly related, 
    533     they play a distinct role; tol is used to set the optimization termination 
     532    x to find an appropriate x'. While cutoff and ytol are very tightly related, 
     533    they play a distinct role; ytol is used to set the optimization termination 
    534534    for an acceptable |y - F(x')|, while cutoff is applied post-optimization. 
    535535""" 
     
    940940  from legacydata import dataset 
    941941  from paramtrans import lipschitz_distance, infeasibility, _npts 
    942   if isinstance(guess, type(None)): 
     942  if guess is None: 
    943943    message = "Requires a guess scenario, or a tuple of scenario dimensions." 
    944944    raise TypeError, message 
     
    10571057 
    10581058Inputs: 
    1059     cutoff -- acceptable model invalidity |y - F(x')| 
     1059    cutoff -- maximum acceptable model invalidity |y - F(x')|; a single value 
    10601060    model -- the model function, y' = F(x'), that approximates reality, y = G(x) 
    10611061    guess -- the scenario providing an initial guess at validity, 
     
    10831083  from numpy import sum as _sum, asarray 
    10841084  from paramtrans import graphical_distance, infeasibility, _npts 
    1085   if isinstance(guess, type(None)): 
     1085  if guess is None: 
    10861086    message = "Requires a guess scenario, or a tuple of scenario dimensions." 
    10871087    raise TypeError, message 
     
    10961096 
    10971097  # prepare bounds for solver 
    1098   bounds = None 
    1099   if kwds.has_key('bounds'): 
    1100     bounds = kwds.pop('bounds') 
     1098  bounds = kwds.pop('bounds', None) 
    11011099  # if bounds are not set, use the default optimizer bounds 
    11021100  if bounds == None: 
     
    11121110 
    11131111  # plug in the 'constraints' function:  param' = constraints(param) 
    1114   constraints = None   # default is no constraints 
    1115   if kwds.has_key('constraints'): constraints = kwds.pop('constraints') 
     1112  constraints = kwds.pop('constraints', None) # default is no constraints 
    11161113  if not constraints:  # if None (default), there are no constraints 
    11171114    constraints = lambda x: x 
    11181115 
    1119   # 'wiggle room' tolerance in x 
    1120   xtol = 0.0 # default 
    1121   if kwds.has_key('xtol'): xtol = kwds['xtol'] 
    1122   npop = 20 #None #XXX: tune npop (outer optimization)? 
    1123   if kwds.has_key('npop'): npop = kwds.pop('npop') 
    1124   maxiter = 50 #XXX: tune maxiter (outer optimization)? 
    1125   if kwds.has_key('maxiter'): maxiter = kwds.pop('maxiter') 
     1116  # 'wiggle room' tolerances 
     1117  ipop = kwds.pop('ipop', 10) #XXX: tune ipop (inner optimization)? 
     1118  imax = kwds.pop('imax', 10) #XXX: tune imax (inner optimization)? 
    11261119  # tolerance for optimization on sum(y) 
    1127   tol = 0.0 # default 
    1128   if kwds.has_key('tol'): tol = kwds.pop('tol') 
    1129   ipop = 10  #XXX: tune npop (inner optimization)? 
    1130   if kwds.has_key('ipop'): ipop = kwds.pop('ipop') 
    1131   imax = 10  #XXX: tune maxiter (inner optimization)? 
    1132   if kwds.has_key('imax'): imax = kwds.pop('imax') 
     1120  tol = kwds.pop('tol', 0.0) # default 
     1121  npop = kwds.pop('npop', 20) #XXX: tune npop (outer optimization)? 
     1122  maxiter = kwds.pop('maxiter', 1000) #XXX: tune maxiter (outer optimization)? 
    11331123 
    11341124  # if no guess was made, then use bounds constraints 
    1135   if guess == None: 
     1125  if guess is None: 
    11361126    if npop: 
    11371127      guess = bounds 
     
    11471137    points.load(rv, pts) 
    11481138    # calculate infeasibility 
    1149     Rv = graphical_distance(model, points, tol=cutoff, npop=ipop, \ 
    1150                                            maxiter=imax, **kwds) 
     1139    Rv = graphical_distance(model, points, ytol=cutoff, ipop=ipop, \ 
     1140                                                        imax=imax, **kwds) 
    11511141    v = infeasibility(Rv, cutoff) 
    11521142    # converting v to E 
  • branches/UQ/math/legacy/legacydata.py

    r547 r557  
    325325    cutoff = tol  # default is to zero out distances less than tolerance 
    326326    if kwds.has_key('cutoff'): cutoff = kwds['cutoff'] 
    327     if isinstance(cutoff, bool): 
    328       if cutoff: cutoff = tol 
    329       else: cutoff = None 
     327    if cutoff is True: cutoff = tol 
     328    elif cutoff is False: cutoff = None 
    330329 
    331330    if L == None: L = self.lipschitz 
     
    356355 
    357356Additional Inputs: 
    358     tol -- maximum acceptable difference |y - F(x')|; a single value 
     357    ytol -- maximum acceptable difference |y - F(x')|; a single value 
    359358    xtol -- maximum acceptable difference |x - x'|; an iterable or single value 
    360     cutoff -- zero out distances less than cutoff; typically: tol, 0.0, or None 
     359    cutoff -- zero out distances less than cutoff; typically: ytol, 0.0, or None 
    361360 
    362361Notes: 
    363     xtol defines the n-dimensional base of a pilar of height tol, centered at 
     362    xtol defines the n-dimensional base of a pilar of height ytol, centered at 
    364363    each point. The region inside the pilar defines the space where a "valid" 
    365364    model must intersect. If xtol is not specified, then the base of the pilar 
    366365    will be a dirac at x' = x. This function performs an optimization for each 
    367     x to find an appropriate x'. While cutoff and tol are very tightly related, 
    368     they play a distinct role; tol is used to set the optimization termination 
     366    x to find an appropriate x'. While cutoff and ytol are very tightly related, 
     367    they play a distinct role; ytol is used to set the optimization termination 
    369368    for an acceptable |y - F(x')|, while cutoff is applied post-optimization. 
    370369""" 
    371     # get tolerance in y 
    372     tol = 0.0 
    373     if kwds.has_key('tol'): tol = kwds['tol'] 
    374     cutoff = tol  # default is to zero out distances less than tolerance 
    375     if kwds.has_key('cutoff'): cutoff = kwds['cutoff'] 
    376     if isinstance(cutoff, bool): 
    377       if cutoff: cutoff = tol 
    378       else: cutoff = None 
     370    ytol = kwds.get('ytol', 0.0) # get tolerance in y 
     371    # default is to zero out distances less than tolerance 
     372    cutoff = kwds.get('cutoff', ytol) 
     373    if cutoff is True: cutoff = ytol 
     374    elif cutoff is False: cutoff = None 
    379375 
    380376    from paramtrans import graphical_distance, is_feasible 
  • branches/UQ/math/legacy/paramtrans.py

    r556 r557  
    267267  cutoff = tol  # default is to zero out distances less than tolerance 
    268268  if kwds.has_key('cutoff'): cutoff = kwds.pop('cutoff') 
    269   if isinstance(cutoff, bool): 
    270     if cutoff: cutoff = tol 
    271     else: cutoff = None 
     269  if cutoff is True: cutoff = tol 
     270  elif cutoff is False: cutoff = None 
    272271 
    273272  # calculate the distance matrix 
     
    288287 
    289288Additional Inputs: 
    290   tol = maximum acceptable difference |y - F(x')|; a single value 
     289  ytol = maximum acceptable difference |y - F(x')|; a single value 
    291290  xtol = maximum acceptable difference |x - x'|; an iterable or single value 
    292   cutoff = zero out distances less than cutoff; typically: tol, 0.0, or None 
     291  cutoff = zero out distances less than cutoff; typically: ytol, 0.0, or None 
    293292 
    294293Returns: 
     
    296295 
    297296Notes: 
    298   xtol defines the n-dimensional base of a pilar of height tol, centered at 
     297  xtol defines the n-dimensional base of a pilar of height ytol, centered at 
    299298  each point. The region inside the pilar defines the space where a "valid" 
    300299  model must intersect. If xtol is not specified, then the base of the pilar 
    301300  will be a dirac at x' = x. This function performs an optimization for each 
    302   x to find an appropriate x'. While cutoff and tol are very tightly related, 
    303   they play a distinct role; tol is used to set the optimization termination 
     301  x to find an appropriate x'. While cutoff and ytol are very tightly related, 
     302  they play a distinct role; ytol is used to set the optimization termination 
    304303  for an acceptable |y - F(x')|, while cutoff is applied post-optimization. 
    305304""" 
     
    327326 
    328327  # get tolerance in y and wiggle room in x 
    329   tol = 0.0 
    330   if kwds.has_key('tol'): tol = kwds.pop('tol') 
     328  ytol = 0.0 
     329  if kwds.has_key('ytol'): ytol = kwds.pop('ytol') 
    331330  xtol = 0.0  # default is to not allow 'wiggle room' in x  
    332331  if kwds.has_key('xtol'): xtol = kwds.pop('xtol') 
    333332 
    334   cutoff = tol  # default is to zero out distances less than tolerance 
     333  cutoff = ytol  # default is to zero out distances less than tolerance 
    335334  if kwds.has_key('cutoff'): cutoff = kwds.pop('cutoff') 
    336   if isinstance(cutoff, bool): 
    337     if cutoff: cutoff = tol 
    338     else: cutoff = None 
    339   npop = min(20, 3*nxi) #XXX: tune npop? 
    340   if kwds.has_key('npop'): npop = kwds.pop('npop') 
    341   imax = 1000 #XXX: tune maxiter? 
    342   if kwds.has_key('maxiter'): imax = kwds.pop('maxiter') 
     335  if cutoff is True: cutoff = ytol 
     336  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') 
    343341 
    344342  ######################################################################### 
    345   def radius(model, point, tol=0.0, xtol=0.0, npop=None, maxiter=None): 
     343  def radius(model, point, ytol=0.0, xtol=0.0, ipop=None, imax=None): 
    346344    """graphical distance between a single point x,y and a model F(x')""" 
    347345    # given a single point x,y: find the radius = |y - F(x')| 
     
    350348    # |x - x'| <= xtol  (for each i in x) 
    351349    # 
    352     # if npop, then DE else Powell; tol is used in VTR(tol) 
    353     # and will terminate when cost <= tol 
     350    # if ipop, then DE else Powell; ytol is used in VTR(ytol) 
     351    # and will terminate when cost <= ytol 
    354352    x,y = _get_xy(point) 
    355353    y = asarray(y) 
     
    366364    # if xtol=0, radius is difference in x,y and x,F(x); skip the optimization 
    367365    try: 
    368       if not maxiter or not max(xtol): #iterables 
     366      if not imax or not max(xtol): #iterables 
    369367        return cost(x) 
    370368    except TypeError: 
     
    381379    #XXX: edit settings? 
    382380    MINMAX = 1 #XXX: confirm MINMAX=1 is minimization 
    383     if npop: # use VTR 
    384       results = diffev2(cost, x, npop, ftol=tol, gtol=None, \ 
    385                         itermon = stepmon, maxiter=maxiter, bounds=bounds, \ 
     381    if ipop: # use VTR 
     382      results = diffev2(cost, x, ipop, ftol=ytol, gtol=None, \ 
     383                        itermon = stepmon, maxiter=imax, bounds=bounds, \ 
    386384                        full_output=1, disp=0, handler=False) 
    387385    else: # use VTR 
    388       results = fmin_powell(cost, x, ftol=tol, gtol=None, \ 
    389                             itermon = stepmon, maxiter=maxiter, bounds=bounds, \ 
     386      results = fmin_powell(cost, x, ftol=ytol, gtol=None, \ 
     387                            itermon = stepmon, maxiter=imax, bounds=bounds, \ 
    390388                            full_output=1, disp=0, handler=False) 
    391389   #solved = results[0]            # x' 
     
    400398 
    401399  #XXX: better to do a single optimization rather than for each point ??? 
    402   d = [radius(model, point, tol, xtol, npop, imax) for point in target] 
     400  d = [radius(model, point, ytol, xtol, ipop, imax) for point in target] 
    403401  return infeasibility(d, cutoff) 
    404402 
     
    543541 
    544542  print "\ntesting shortness, feasibility, validity..." 
    545   model = lambda x:x 
    546543  assert pm.short_wrt_data(b) == True 
    547544  b.lipschitz = L 
     
    552549  assert pm.short_wrt_data(b) == True 
    553550 
    554   _tol = 0.0 
    555   b.lipschitz = L 
    556   from numpy import max as nmax 
    557    
    558   self_violate = pm.valid_wrt_model(model, tol=_tol) 
    559   print "maximum violation (self): %s" % self_violate 
    560   data_violate = b.valid(model, tol=_tol) 
    561   print "maximum violation (data): %s" % data_violate 
     551  Cy = 0.1; Cx = 0.0 
     552  model = lambda x:x[0] 
     553  assert b.valid(model, ytol=Cy, xtol=Cx) == False 
     554  assert pm.valid_wrt_model(model, ytol=Cy, xtol=Cx) == False 
     555  pm.set_valid(model, cutoff=Cy, xtol=Cx) 
     556  assert pm.valid_wrt_model(model, ytol=Cy, xtol=Cx) == True 
    562557  print "...done\n" 
    563558 
  • branches/UQ/math/legacy/test_ExampleDataset.py

    r556 r557  
    6363 
    6464  # Check model validity 
    65   Rv = ex1d_data.valid(F, xtol=Cx, tol=Cy, \ 
     65  Rv = ex1d_data.valid(F, xtol=Cx, ytol=Cy, \ 
    6666                       raw=True, blamelist=False, pairs=False, all=False) 
    6767  print("valid(ytol=%s,xtol=%s):\n%s" % (Cy, Cx, Rv)) 
  • branches/UQ/math/legacy/test_ModeledDataset.py

    r556 r557  
    4343  # Check model validity 
    4444  Cx = 0.0; Cy = 1.0 
    45   Rv = data.valid(F, xtol=Cx, tol=Cy, \ 
     45  Rv = data.valid(F, xtol=Cx, ytol=Cy, \ 
    4646                       raw=False, blamelist=False, pairs=False, all=True) 
    4747  print("valid(ytol=%s,xtol=%s):\n%s" % (Cy, Cx, Rv)) 
    4848 
    4949  Cx = 0.0; Cy = 2.0 
    50   Rv = data.valid(F, xtol=Cx, tol=Cy, \ 
     50  Rv = data.valid(F, xtol=Cx, ytol=Cy, \ 
    5151                       raw=False, blamelist=False, pairs=False, all=True) 
    5252  print("valid(ytol=%s,xtol=%s):\n%s" % (Cy, Cx, Rv)) 
    5353 
    5454  Cx = 1.0; Cy = 2.0 
    55   Rv = data.valid(F, xtol=Cx, tol=Cy, \ 
     55  Rv = data.valid(F, xtol=Cx, ytol=Cy, \ 
    5656                       raw=False, blamelist=False, pairs=False, all=True) 
    5757  print("valid(ytol=%s,xtol=%s):\n%s" % (Cy, Cx, Rv)) 
    5858 
    5959  Cx = 2.0; Cy = 2.0 
    60   Rv = data.valid(F, xtol=Cx, tol=Cy, \ 
     60  Rv = data.valid(F, xtol=Cx, ytol=Cy, \ 
    6161                       raw=False, blamelist=False, pairs=False, all=True) 
    6262  print("valid(ytol=%s,xtol=%s):\n%s" % (Cy, Cx, Rv)) 
  • branches/UQ/math/legacy/test_StAlDataset.py

    r556 r557  
    5353 
    5454  # Check model validity 
    55   Rv = st_al_data.valid(F, xtol=Cx, tol=Cy, \ 
     55  Rv = st_al_data.valid(F, xtol=Cx, ytol=Cy, \ 
    5656                        raw=True, blamelist=False, pairs=False, all=False) 
    5757  print("valid(ytol=%s,xtol=%s):\n%s" % (Cy, Cx, Rv)) 
Note: See TracChangeset for help on using the changeset viewer.