- Timestamp:
- 11/05/12 14:23:44 (4 years ago)
- Location:
- branches/UQ/math/legacy
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/UQ/math/legacy/MINMAX_StAlData.py
r575 r585 84 84 # generate primary constraints function 85 85 def constraints(rv): 86 rrv = range(len(rv)) 87 # impose range constraints: first try bounce-back to maintain randomness 88 rv = [2*lb[i]-rv[i] if max(rv[i], lb[i]) == lb[i] else rv[i] for i in rrv] 89 rv = [2*ub[i]-rv[i] if min(rv[i], ub[i]) == ub[i] else rv[i] for i in rrv] 90 # if bounceback fails, then use a hard cutoff #FIXME: breaks randomness 91 rv = [max(rv[i], lb[i]) for i in rrv] 92 rv = [min(rv[i], ub[i]) for i in rrv] 93 86 94 c = scenario() 87 95 c.load(rv, npts) … … 136 144 137 145 if MINMAX == 1: 138 print "func_minimum: %s" % func_max# inf146 tag = 'minimum' # inf 139 147 else: 140 print "func_maximum: %s" % func_max # sup 148 tag = 'maximum' # sup 149 print "func_%s: %s" % (tag,func_max) 141 150 print "func_evals: %s" % func_evals 142 151 -
branches/UQ/math/legacy/MM_OUQ_StAlData.py
r575 r585 92 92 # generate primary constraints function 93 93 def constraints(rv): 94 rrv = range(len(rv)) 95 # impose range constraints: first try bounce-back to maintain randomness 96 rv = [2*lb[i]-rv[i] if max(rv[i], lb[i]) == lb[i] else rv[i] for i in rrv] 97 rv = [2*ub[i]-rv[i] if min(rv[i], ub[i]) == ub[i] else rv[i] for i in rrv] 98 # if bounceback fails, then use a hard cutoff #FIXME: breaks randomness 99 rv = [max(rv[i], lb[i]) for i in rrv] 100 rv = [min(rv[i], ub[i]) for i in rrv] 101 94 102 c = scenario() 95 103 c.load(rv, npts) … … 160 168 161 169 if MINMAX == 1: 162 print "func_minimum: %s" % func_max# inf170 tag = 'minimum' # inf 163 171 else: 164 print "func_maximum: %s" % func_max # sup 172 tag = 'maximum' # sup 173 print "func_%s: %s" % (tag,func_max) 165 174 print "func_evals: %s" % func_evals 166 175 -
branches/UQ/math/legacy/TEST_OUQ_1dData.py
r582 r585 88 88 # generate primary constraints function 89 89 def constraints(rv): 90 rrv = range(len(rv)) 91 # impose range constraints: first try bounce-back to maintain randomness 92 rv = [2*lb[i]-rv[i] if max(rv[i], lb[i]) == lb[i] else rv[i] for i in rrv] 93 rv = [2*ub[i]-rv[i] if min(rv[i], ub[i]) == ub[i] else rv[i] for i in rrv] 94 # if bounceback fails, then use a hard cutoff #FIXME: breaks randomness 95 rv = [max(rv[i], lb[i]) for i in rrv] 96 rv = [min(rv[i], ub[i]) for i in rrv] 97 90 98 c = scenario() 91 99 c.load(rv, npts) … … 156 164 157 165 if MINMAX == 1: 158 print "func_minimum: %s" % func_max# inf166 tag = 'minimum' # inf 159 167 else: 160 print "func_maximum: %s" % func_max # sup 168 tag = 'maximum' # sup 169 print "func_%s: %s" % (tag,func_max) 161 170 print "func_evals: %s" % func_evals 162 171 … … 193 202 w_split = [0.5] 194 203 195 #XXX XXX: EDITED TO USE w_split *AND* npts=(2,1,1) *AND*FIX Y1 == Y_lower204 #XXX XXX: EDITED TO USE w_split *AND* FIX Y1 == Y_lower 196 205 lower_bounds = (w_lower) + (w_split) + (nx * h_lower) \ 197 206 + (ny * w_upper) + (ny * a_lower) \ -
branches/UQ/math/legacy/TEST_OUQ_1dSurr_CxCy.py
r582 r585 87 87 # generate primary constraints function 88 88 def constraints(rv): 89 rrv = range(len(rv)) 90 # impose range constraints: first try bounce-back to maintain randomness 91 rv = [2*lb[i]-rv[i] if max(rv[i], lb[i]) == lb[i] else rv[i] for i in rrv] 92 rv = [2*ub[i]-rv[i] if min(rv[i], ub[i]) == ub[i] else rv[i] for i in rrv] 93 # if bounceback fails, then use a hard cutoff #FIXME: breaks randomness 94 rv = [max(rv[i], lb[i]) for i in rrv] 95 rv = [min(rv[i], ub[i]) for i in rrv] 96 89 97 c = scenario() 90 98 c.load(rv, npts) … … 109 117 # then test if valid... then impose model validity on product measure 110 118 if not c.valid_wrt_model(model, ytol=target[2], xtol=target[3], \ 111 imax=target[4]):119 imax=target[4],hausdorff=target[5]): 112 120 c.set_valid(model, cutoff=target[2], bounds=bounds, tol=error[2], \ 113 114 maxiter=error[3], imax=error[4])121 constraints=constrain, xtol=target[3], \ 122 maxiter=error[3], imax=error[4], hausdorff=target[5]) 115 123 ###################### more function-specific ##################### 116 124 if debug: 117 125 if not c.valid_wrt_model(model, ytol=target[2], xtol=target[3], \ 118 imax=target[4]):126 imax=target[4], hausdorff=target[5]): 119 127 print "valid_wrt_model: False" 120 128 if not [sum(w) for w in c.wts] == [1.0] * len(c.wts): … … 143 151 144 152 if not c.valid_wrt_model(model, ytol=target[2], xtol=target[3], \ 145 imax=target[4]):153 imax=target[4], hausdorff=target[5]): 146 154 if debug: print "skipping model-invalidity" 147 155 return inf #XXX: FORCE TO SATISFY E CONSTRAINTS … … 153 161 154 162 if MINMAX == 1: 155 print "func_minimum: %s" % func_max# inf163 tag = 'minimum' # inf 156 164 else: 157 print "func_maximum: %s" % func_max # sup 165 tag = 'maximum' # sup 166 print "func_%s: %s" % (tag,func_max) 158 167 print "func_evals: %s" % func_evals 159 168 … … 173 182 Cy = 0.1 #NOTE: SET THE 'cutoff' HERE! 174 183 Cx = (2.0,0.0,0.0) #NOTE: SET THE 'wiggle' HERE! 184 hausdorff = (1.0,0.0,0.0) #NOTE: SET THE 'hausdorff normalization' HERE! 175 185 valid_tol = 0.0 #NOTE: SET THE 'model tolerance' HERE! 176 186 imax_c = 200 #NOTE: SET THE 'max iterations to check valid' HERE! 177 187 imax_i = 10 #NOTE: SET THE 'max inner iterations to set valid' HERE! 178 188 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 )189 target = (y_mean,theta,Cy,Cx,imax_c,hausdorff) 190 error = (y_mean_error,None,valid_tol,imax_o,imax_i,None) 181 191 pars = (target,error) 182 192 … … 194 204 h_upper = [1.0]; a_upper = [0.0]; v_upper = [0.0] 195 205 196 #XXX XXX: EDITED TO USE npts=(2,1,1) *AND*FIX Y1 == Y_lower206 #XXX XXX: EDITED TO FIX Y1 == Y_lower 197 207 lower_bounds = (nx * w_lower) + (nx * h_lower) \ 198 208 + (ny * w_lower) + (ny * a_lower) \ … … 258 268 259 269 print "fails valid wrt model:\n%s" % \ 260 c.valid_wrt_model(model, xtol=Cx, ytol=Cy, blamelist=True, imax=imax_c) 270 c.valid_wrt_model(model, xtol=Cx, ytol=Cy, blamelist=True, \ 271 imax=imax_c, hausdorff=hausdorff) 261 272 print "mean(y): %s >= %s" % (str( c.get_mean_value() ), y_mean - y_mean_error) 262 273 print "sum_wts: %s == 1.0" % [sum(w) for w in c.wts] 263 274 275 try: _Cx = max(Cx) 276 except TypeError: _Cx = Cx 264 277 from mystic.math.paramtrans import graphical_distance 265 Ry = graphical_distance(model, c, ytol=Cy, xtol=Cx, cutoff=0.0, imax=0) 266 print "vertical_distance: %s <= %s" % (Ry, Cy + max(Cx)) 267 Rv = graphical_distance(model, c, ytol=Cy, xtol=Cx, cutoff=0.0, imax=imax_c) 278 Ry = graphical_distance(model, c, ytol=Cy, xtol=Cx, cutoff=0.0, 279 imax=0, hausdorff=hausdorff) 280 print "vertical_distance: %s <= %s" % (Ry, Cy + _Cx) 281 Rv = graphical_distance(model, c, ytol=Cy, xtol=Cx, cutoff=0.0, 282 imax=imax_c, hausdorff=hausdorff) 268 283 print "graphical_distance: %s <= %s" % (Rv, Cy) 269 284 -
branches/UQ/math/legacy/TEST_OUQ_1dSurr_Cy.py
r582 r585 87 87 # generate primary constraints function 88 88 def constraints(rv): 89 rrv = range(len(rv)) 90 # impose range constraints: first try bounce-back to maintain randomness 91 rv = [2*lb[i]-rv[i] if max(rv[i], lb[i]) == lb[i] else rv[i] for i in rrv] 92 rv = [2*ub[i]-rv[i] if min(rv[i], ub[i]) == ub[i] else rv[i] for i in rrv] 93 # if bounceback fails, then use a hard cutoff #FIXME: breaks randomness 94 rv = [max(rv[i], lb[i]) for i in rrv] 95 rv = [min(rv[i], ub[i]) for i in rrv] 96 89 97 c = scenario() 90 98 c.load(rv, npts) … … 153 161 154 162 if MINMAX == 1: 155 print "func_minimum: %s" % func_max# inf163 tag = 'minimum' # inf 156 164 else: 157 print "func_maximum: %s" % func_max # sup 165 tag = 'maximum' # sup 166 print "func_%s: %s" % (tag,func_max) 158 167 print "func_evals: %s" % func_evals 159 168 … … 194 203 h_upper = [1.0]; a_upper = [0.0]; v_upper = [0.0] 195 204 196 #XXX XXX: EDITED TO USE npts=(2,1,1) *AND*FIX Y1 == Y_lower205 #XXX XXX: EDITED TO FIX Y1 == Y_lower 197 206 lower_bounds = (nx * w_lower) + (nx * h_lower) \ 198 207 + (ny * w_lower) + (ny * a_lower) \ … … 262 271 print "sum_wts: %s == 1.0" % [sum(w) for w in c.wts] 263 272 273 try: _Cx = max(Cx) 274 except TypeError: _Cx = Cx 264 275 from mystic.math.paramtrans import graphical_distance 265 276 Ry = graphical_distance(model, c, ytol=Cy, xtol=Cx, cutoff=0.0, imax=0) 266 print "vertical_distance: %s <= %s" % (Ry, Cy + max(Cx))277 print "vertical_distance: %s <= %s" % (Ry, Cy + _Cx) 267 278 Rv = graphical_distance(model, c, ytol=Cy, xtol=Cx, cutoff=0.0, imax=imax_c) 268 279 print "graphical_distance: %s <= %s" % (Rv, Cy) -
branches/UQ/math/legacy/TEST_OUQ_StAlData.py
r575 r585 88 88 # generate primary constraints function 89 89 def constraints(rv): 90 rrv = range(len(rv)) 91 # impose range constraints: first try bounce-back to maintain randomness 92 rv = [2*lb[i]-rv[i] if max(rv[i], lb[i]) == lb[i] else rv[i] for i in rrv] 93 rv = [2*ub[i]-rv[i] if min(rv[i], ub[i]) == ub[i] else rv[i] for i in rrv] 94 # if bounceback fails, then use a hard cutoff #FIXME: breaks randomness 95 rv = [max(rv[i], lb[i]) for i in rrv] 96 rv = [min(rv[i], ub[i]) for i in rrv] 97 90 98 c = scenario() 91 99 c.load(rv, npts) … … 157 165 158 166 if MINMAX == 1: 159 print "func_minimum: %s" % func_max# inf167 tag = 'minimum' # inf 160 168 else: 161 print "func_maximum: %s" % func_max # sup 169 tag = 'maximum' # sup 170 print "func_%s: %s" % (tag,func_max) 162 171 print "func_evals: %s" % func_evals 163 172 -
branches/UQ/math/legacy/TEST_OUQ_StStSurr_Cy.py
r582 r585 87 87 # generate primary constraints function 88 88 def constraints(rv): 89 rrv = range(len(rv)) 90 # impose range constraints: first try bounce-back to maintain randomness 91 rv = [2*lb[i]-rv[i] if max(rv[i], lb[i]) == lb[i] else rv[i] for i in rrv] 92 rv = [2*ub[i]-rv[i] if min(rv[i], ub[i]) == ub[i] else rv[i] for i in rrv] 93 # if bounceback fails, then use a hard cutoff #FIXME: breaks randomness 94 rv = [max(rv[i], lb[i]) for i in rrv] 95 rv = [min(rv[i], ub[i]) for i in rrv] 96 89 97 c = scenario() 90 98 c.load(rv, npts) … … 153 161 154 162 if MINMAX == 1: 155 print "func_minimum: %s" % func_max# inf163 tag = 'minimum' # inf 156 164 else: 157 print "func_maximum: %s" % func_max # sup 165 tag = 'maximum' # sup 166 print "func_%s: %s" % (tag,func_max) 158 167 print "func_evals: %s" % func_evals 159 168 … … 194 203 h_upper = [105.0]; a_upper = [30.0]; v_upper = [2.8] 195 204 196 #XXX XXX: EDITED TO USE npts=(2,1,1) *AND*FIX Y1 == Y_lower205 #XXX XXX: EDITED TO FIX Y1 == Y_lower 197 206 lower_bounds = (nx * w_lower) + (nx * h_lower) \ 198 207 + (ny * w_lower) + (ny * a_lower) \ … … 262 271 print "sum_wts: %s == 1.0" % [sum(w) for w in c.wts] 263 272 273 try: _Cx = max(Cx) 274 except TypeError: _Cx = Cx 264 275 from mystic.math.paramtrans import graphical_distance 265 276 Ry = graphical_distance(model, c, ytol=Cy, xtol=Cx, cutoff=0.0, imax=0) 266 print "vertical_distance: %s <= %s" % (Ry, Cy + max(Cx))277 print "vertical_distance: %s <= %s" % (Ry, Cy + _Cx) 267 278 Rv = graphical_distance(model, c, ytol=Cy, xtol=Cx, cutoff=0.0, imax=imax_c) 268 279 print "graphical_distance: %s <= %s" % (Rv, Cy)
Note: See TracChangeset
for help on using the changeset viewer.