Beispiel #1
0
    def build_map(self, GP):

        self.update_bounds(GP)

        y_mean, y_var = self.GenGrid(GP)
        self.mean.set_values(y_mean)

        if self.var_map == "pca":
            G = np.prod(y_var.shape[:-1])
            full_rank = np.min((G, y_var.shape[-1]))

            if self.svd_rank == "auto":
                self.var = PCASplines(
                    self.bounds[0],
                    self.bounds[1],
                    orders=self.grid_num,
                    svd_rank=full_rank,
                )
            else:
                assert isinstance(self.svd_rank, int), "Please set svd_rank to int or 'auto'"
                assert self.svd_rank <= full_rank, f"svd_rank={self.svd_rank} exceeds full_rank={full_rank}"
                self.var = PCASplines(
                    self.bounds[0],
                    self.bounds[1],
                    orders=self.grid_num,
                    svd_rank=self.svd_rank,
                )


        if self.var_map is not None:
            self.var.set_values(y_var)

        self.hyps_mask = deepcopy(GP.hyps_mask)
Beispiel #2
0
    def build_map_container(self):
        """
        build 1-d spline function for mean, 2-d for var
        """
        if np.any(np.array(self.bounds[1]) <= 0.0):
            bounds = [
                np.zeros_like(self.bounds[0]),
                np.ones_like(self.bounds[1])
            ]
        else:
            bounds = self.bounds

        self.mean = CubicSpline(bounds[0], bounds[1], orders=self.grid_num)

        if self.var_map == "pca":
            if self.svd_rank == "auto":
                warnings.warn(
                    "The containers for variance are not built because svd_rank='auto'"
                )

            elif isinstance(self.svd_rank, int):
                self.var = PCASplines(
                    bounds[0],
                    bounds[1],
                    orders=self.grid_num,
                    svd_rank=self.svd_rank,
                )

        if self.var_map == "simple":
            self.var = CubicSpline(bounds[0], bounds[1], orders=self.grid_num)
Beispiel #3
0
    def build_map(self, GP):

        self.update_bounds(GP)

        if not self.load_grid:
            y_mean, y_var = self.GenGrid(GP)
        else:
            if "mgp_grids" not in os.listdir(self.load_grid):
                raise FileNotFoundError(
                    "Please set 'load_grid' as the location of mgp_grids folder"
                )

            grid_path = f"{self.load_grid}/mgp_grids/{self.bodies}_{self.species_code}"
            y_mean = np.load(f"{grid_path}_mean.npy")
            y_var = np.load(f"{grid_path}_var.npy", allow_pickle=True)

        self.mean.set_values(y_mean)

        if self.var_map == "pca" and self.svd_rank == "auto":
            self.var = PCASplines(
                self.bounds[0],
                self.bounds[1],
                orders=self.grid_num,
                svd_rank=np.min(y_var.shape),
            )

        if self.var_map is not None:
            self.var.set_values(y_var)

        self.hyps_mask = deepcopy(GP.hyps_mask)
Beispiel #4
0
    def build_map_container(self):
        """
        build 1-d spline function for mean, 2-d for var
        """
        self.mean = CubicSpline(self.bounds[0],
                                self.bounds[1],
                                orders=self.grid_num)

        if self.var_map == "pca":
            if self.svd_rank == "auto":
                warnings.warn(
                    "The containers for variance are not built because svd_rank='auto'"
                )

            elif isinstance(self.svd_rank, int):
                self.var = PCASplines(
                    self.bounds[0],
                    self.bounds[1],
                    orders=self.grid_num,
                    svd_rank=self.svd_rank,
                )

        if self.var_map == "simple":
            self.var = CubicSpline(self.bounds[0],
                                   self.bounds[1],
                                   orders=self.grid_num)
Beispiel #5
0
    def build_map_container(self):
        self.mean = CubicSpline(self.l_bounds, self.u_bounds, 
                                orders=[self.grid_num])

        if not self.mean_only:
            self.var = PCASplines(self.l_bounds, self.u_bounds,
                                  orders=[self.grid_num],
                                  svd_rank=self.svd_rank)
Beispiel #6
0
    def build_map_container(self):
       # create spline interpolation class object
        self.mean = CubicSpline(self.l_bounds, self.u_bounds,
                                orders=self.grid_num)

        if not self.mean_only:
            self.var = PCASplines(self.l_bounds, self.u_bounds,
                                  orders=self.grid_num,
                                  svd_rank=self.svd_rank)
Beispiel #7
0
    def build_map_container(self):
        '''
        build 1-d spline function for mean, 2-d for var
        '''
        self.mean = CubicSpline(self.bounds[0],
                                self.bounds[1],
                                orders=[self.grid_num])

        if not self.mean_only:
            self.var = PCASplines(self.bounds[0],
                                  self.bounds[1],
                                  orders=[self.grid_num],
                                  svd_rank=self.svd_rank)
Beispiel #8
0
    def build_map_container(self):
        '''
        build 3-d spline function for mean,
        3-d for the low rank approximation of L^{-1}k*
        '''

        # create spline interpolation class object
        self.mean = CubicSpline(self.bounds[0],
                                self.bounds[1],
                                orders=self.grid_num)

        if not self.mean_only:
            self.var = PCASplines(self.bounds[0],
                                  self.bounds[1],
                                  orders=self.grid_num,
                                  svd_rank=self.svd_rank)
Beispiel #9
0
    def build_map(self, y_mean, y_var):

        '''
        build 1-d spline function for mean, 2-d for var
        '''

        self.mean = \
            SplinesInterpolation(y_mean, u_bounds=np.array(self.u_bound),
                                 l_bounds=np.array(self.l_bound),
                                 orders=np.array([self.grid_num]))

        if not self.mean_only:
            self.var = \
                PCASplines(y_var, u_bounds=np.array(self.u_bound),
                           l_bounds=np.array(self.l_bound),
                           orders=np.array([self.grid_num]),
                           svd_rank=self.svd_rank)
Beispiel #10
0
    def build_map(self, y_mean, y_var, svd_rank, load_svd):
        '''
        build 3-d spline function for mean, 
        3-d for the low rank approximation of L^{-1}k*
        '''
        nop = self.grid_num[0]
        noa = self.grid_num[2]
        self.mean = SplinesInterpolation(y_mean,
                                         u_bounds=self.u_bound,
                                         l_bounds=self.l_bound,
                                         orders=np.array([nop, nop, noa]))

        self.var = PCASplines(y_var,
                              u_bounds=self.u_bound,
                              l_bounds=self.l_bound,
                              orders=np.array([nop, nop, noa]),
                              svd_rank=svd_rank,
                              load_svd=load_svd)
Beispiel #11
0
    def build_map_container(self):
        '''
        build 3-d spline function for mean,
        3-d for the low rank approximation of L^{-1}k*
        '''

        # create spline interpolation class object
        nop = self.grid_num[0]
        noa = self.grid_num[2]
        self.mean = CubicSpline(self.l_bounds,
                                self.u_bounds,
                                orders=[nop, nop, noa])

        if not self.mean_only:
            self.var = PCASplines(self.l_bounds,
                                  self.u_bounds,
                                  orders=[nop, nop, noa],
                                  svd_rank=self.svd_rank)
Beispiel #12
0
    def build_map(self, GP):

        self.update_bounds(GP)

        y_mean, y_var = self.GenGrid(GP)
        self.mean.set_values(y_mean)

        if self.var_map == "pca" and self.svd_rank == "auto":
            self.var = PCASplines(
                self.bounds[0],
                self.bounds[1],
                orders=self.grid_num,
                svd_rank=np.min(y_var.shape),
            )

        if self.var_map is not None:
            self.var.set_values(y_var)

        self.hyps_mask = deepcopy(GP.hyps_mask)
Beispiel #13
0
    def build_map(self, y_mean, y_var):
        '''
        build 1-d spline function for mean, 2-d for var
        '''

        self.mean = SplinesInterpolation(y_mean,
                                         u_bounds=np.array(self.u_bound),
                                         l_bounds=np.array(self.l_bound),
                                         orders=np.array([self.grid_num]))
        if self.bodies == '2':
            self.var = SplinesInterpolation(
                y_var,
                u_bounds=np.array([self.u_bound, self.u_bound]),
                l_bounds=np.array([self.l_bound, self.l_bound]),
                orders=np.array([self.grid_num, self.grid_num]))
        elif self.bodies == '2+3':
            self.var = PCASplines(y_var,
                                  u_bounds=np.array(self.u_bound),
                                  l_bounds=np.array(self.l_bound),
                                  orders=np.array([self.grid_num]),
                                  svd_rank=self.svd_rank,
                                  load_svd=None)