@@ -85,8 +85,8 @@ def __init__(self,configs):
8585 self .sampler_hook = None #bodge
8686
8787 self .t .add (samples = None ,point_selected = None ,boundary_points = [],
88- vols_poff = [],detected = [],vols_poff_axes = [],poff = [],
89- cand_v = [] ,all_v = [],vols_pinchoff = [],d_vec = [],poff_vec = [],meas_each_axis = [],vols_each_axis = [],extra_measure = [],
88+ vols_poff = [],detected = [],vols_poff_axes = [],poff = []
89+ ,all_v = [],vols_pinchoff = [],d_vec = [],poff_vec = [],meas_each_axis = [],vols_each_axis = [],extra_measure = [],
9090 vols_pinchoff_axes = [],vols_detected_axes = [],changed_origin = [],conditional_idx = [],r_vals = [])
9191
9292
@@ -120,7 +120,7 @@ def do_iter(self):
120120 do_gpr_p1 , do_gpc_p1 = (i - 1 > self .t ['gpr_start' ]) and self .t ['gpr_on' ], (i - 1 > self .t ['gpc_start' ]) and self .t ['gpc_on' ]
121121 print ("GPR:" ,do_gpr ,"GPC:" ,do_gpc ,"prune:" ,do_pruning ,"GPR1:" ,do_gpr_p1 ,"GPC1:" ,do_gpc_p1 ,"Optim:" ,do_optim )
122122 #pick a uvec and start sampling
123- u , r_est = select_point (self .gpr , self .gpc , * self .t .get ('origin' , 'cand_v ' , 'all_v ' , 'directions' ), do_gpr_p1 , do_gpc_p1 )
123+ u , r_est = select_point (self .gpr , self .gpc , * self .t .get ('origin' , 'boundary_points ' , 'vols_pinchoff ' , 'directions' ), do_gpr_p1 , do_gpc_p1 )
124124 self .timer .logtime ()
125125 self .sampler_hook = start_sampling (self .gpr , * self .t .get ('samples' , 'origin' , 'real_ub' , 'real_lb' ,
126126 'directions' , 'n_part' , 'sigma' , 'max_steps' ),sampler_hook = self .sampler_hook ) if do_gpr_p1 else None
@@ -161,9 +161,9 @@ def do_iter(self):
161161
162162 return self .t .getd (* self .t ['verbose' ])
163163
164- def select_point (hypersurface , selection_model , origin , cand_v , all_v , directions , use_selection = True , estimate_r = True ):
164+ def select_point (hypersurface , selection_model , origin , boundary_points , vols_pinchoff , directions , use_selection = True , estimate_r = True ):
165165 """selects a point to investigate using thompson sampling, uniform sampling or random angles
166- depending on use_selection flag or is no cand_v are present
166+ depending on use_selection flag or is no samples are present
167167 Args:
168168 hypersurface: model of the hypersurface
169169 selection_model: model of probability of observing desirable features
@@ -175,17 +175,23 @@ def select_point(hypersurface, selection_model, origin, cand_v, all_v, direction
175175 unit vector
176176 """
177177
178- if len (cand_v ) > 0 and use_selection :
179- points_candidate = rw .project_crosses_to_boundary (cand_v , hypersurface , origin )
180- v = choose_next (points_candidate , all_v , selection_model , d_tooclose = 20. )
181- elif len (cand_v ) != 0 :
182- v = rw .pick_from_boundary_points (cand_v )
178+ boundary_points = [] if boundary_points is None else boundary_points
179+
180+ if len (boundary_points ) > 0 and use_selection :
181+ points_candidate = rw .project_crosses_to_boundary (boundary_points , hypersurface , origin )
182+ v = choose_next (points_candidate , vols_pinchoff , selection_model , d_tooclose = 20. )
183+ elif len (boundary_points ) != 0 :
184+ v = rw .pick_from_boundary_points (boundary_points )
183185 else :
184186 print ('WARNING: no boundary point is sampled' )
185187 return random_angle_directions (len (origin ), 1 , np .array (directions ))[0 ], None
186188 v_origin = v - origin
187189 u = v_origin / np .sqrt (np .sum (np .square (v_origin )))
188- return u , hypersurface .predict (u ) if estimate_r else None
190+ r_est ,r_std = hypersurface .predict (u [np .newaxis ,:])
191+
192+ r_est = np .maximum (r_est - 1.0 * np .sqrt (r_std ), 0.0 )
193+
194+ return u .squeeze (), r_est .squeeze () if estimate_r else None
189195
190196
191197
@@ -236,6 +242,7 @@ def stop_sampling(sampler,stopper,listener):
236242 counter , samples , boundary_points = listener .recv ()
237243 sampler .join ()
238244 print ("STOP" )
245+ print (len (samples ),len (boundary_points ))
239246 return {'samples' :samples ,'boundary_points' :boundary_points }
240247
241248def project_samples_inside (hypersurface , samples , origin , ub , lb ):
@@ -283,14 +290,9 @@ def unpack(key,list_of_dict):
283290
284291def predict_probs (points , gpc_list ):
285292
286- probs = []
287- for gpc in gpc_list :
288- probs += [gpc .predict_prob (points )[:,0 ]]
289-
293+ total_probs = gpc_list .predict_comb_prob (points )
290294
291- total_prob = np .prod (probs , axis = 0 )
292- log_total_prob = np .sum (np .log (probs ), axis = 0 )
293- return total_prob , log_total_prob , probs
295+ return total_probs .squeeze (), None , None
294296
295297def choose_next (points_candidate , points_observed , gpc_dict , d_tooclose = 100. ):
296298 points_observed = np .array (points_observed )
0 commit comments