Exemplo n.º 1
0
 def __init__(self, mode):
     self.mode = mode
     if self.mode == "random":
         pass
     elif self.mode == "sobol":
         self.rand_gen = SobolGenerator(2)
     elif self.mode == "halton":
         self.rand_gen = Halton(2)
         self.rand_gen_1 = Halton(1)
Exemplo n.º 2
0
def get_design_sites(dim, n_sample, x_lb, x_ub, sampling_method='lhs'):

    x_lb = atleast_2d(x_lb)
    x_ub = atleast_2d(x_ub)

    x_lb = x_lb.T if size(x_lb, 0) != 1 else x_lb
    x_ub = x_ub.T if size(x_ub, 0) != 1 else x_ub

    if sampling_method == 'lhs':
        # Latin Hyper Cube Sampling: Get evenly distributed sampling in R^dim
        samples = lhs(dim, samples=n_sample) * (x_ub - x_lb) + x_lb

    elif sampling_method == 'uniform':
        samples = np.random.rand(n_sample, dim) * (x_ub - x_lb) + x_lb

    elif sampling_method == 'sobol':
        seed = mod(int(time.time()) + os.getpid(), int(1e6))
        samples = np.zeros((n_sample, dim))
        for i in range(n_sample):
            samples[i, :], seed = i4_sobol(dim, seed)
        samples = samples * (x_ub - x_lb) + x_lb

    elif sampling_method == 'halton':
        sequencer = Halton(dim)
        samples = sequencer.get(n_sample) * (x_ub - x_lb) + x_lb

    return samples
Exemplo n.º 3
0
    def __init__(self, n, shape='col'):

        if not halton_available:
            raise ImportError("Package 'ghalton' not found, QuasiGaussianHaltonSampling not available.")
        self.n = n
        self.shape = (n,1) if shape == 'col' else (1,n)
        self.halton = Halton(n)
Exemplo n.º 4
0
    def __init__(self,
                 param_distributions,
                 n_iter,
                 random_state=None,
                 method='Halton'):
        self.param_distributions = param_distributions
        self.n_iter = n_iter
        self.random_state = random_state
        self.method = method

        if method == 'Halton':
            self.Halton = Halton(len(self.param_distributions.keys()))