def search_lower_bound(self, GP): """ If the lower bound is set to be 'auto', search the minimal interatomic distances in the training set of GP. """ upper_bound = Parameters.get_cutoff(self.kernel_name, self.species, GP.hyps_mask) lower_bound = np.min(upper_bound) training_data = _global_training_data[GP.name] for env in training_data: if len(env.bond_array_2) == 0: continue min_dist = env.bond_array_2[0][0] if min_dist < lower_bound: lower_bound = min_dist training_struc = _global_training_structures[GP.name] for struc in training_struc: for env in struc: if len(env.bond_array_2) == 0: continue min_dist = env.bond_array_2[0][0] if min_dist < lower_bound: lower_bound = min_dist return lower_bound
def update_bounds(self, GP): rebuild_container = False # double check the container and the GP is consistent if not Parameters.compare_dict(GP.hyps_mask, self.hyps_mask): rebuild_container = True lower_bound = self.bounds[0] min_dist = self.search_lower_bound(GP) # change lower bound only when there appears a smaller distance if lower_bound is None or min_dist < np.max(lower_bound): lower_bound = np.max((min_dist - self.lower_bound_relax, 0.0)) rebuild_container = True warnings.warn( "The minimal distance in training data is lower than " f"the current lower bound, will reset lower bound to {lower_bound}" ) upper_bound = self.bounds[1] if self.auto_upper or upper_bound is None: gp_cutoffs = Parameters.get_cutoff(self.kernel_name, self.species, GP.hyps_mask) if upper_bound is None or np.any(gp_cutoffs > upper_bound): upper_bound = gp_cutoffs rebuild_container = True if rebuild_container: self.set_bounds(lower_bound, upper_bound) self.build_map_container()