Exemplo n.º 1
0
    def generate_points(self):
        """Generate a matrix with the initial sample points,
        scaled to the unit hypercube

        :return: Box-Behnken design in the unit cube of size npts x dim
        :rtype: numpy.array
        """

        return 0.5*(1 + pydoe.bbdesign(self.dim, center=1))
Exemplo n.º 2
0
 def localInitialize(self):
     """
   Will perform all initialization specific to this Sampler. For instance,
   creating an empty container to hold the identified surface points, error
   checking the optionally provided solution export and other preset values,
   and initializing the limit surface Post-Processor used by this sampler.
   @ In, None
   @ Out, None
 """
     if self.respOpt['algorithmType'] == 'boxbehnken':
         self.designMatrix = doe.bbdesign(
             len(self.gridInfo.keys()),
             center=self.respOpt['options']['ncenters'])
     elif self.respOpt['algorithmType'] == 'centralcomposite':
         self.designMatrix = doe.ccdesign(
             len(self.gridInfo.keys()),
             center=self.respOpt['options']['centers'],
             alpha=self.respOpt['options']['alpha'],
             face=self.respOpt['options']['face'])
     gridInfo = self.gridEntity.returnParameter('gridInfo')
     stepLength = {}
     for cnt, varName in enumerate(self.axisName):
         self.mapping[varName] = np.unique(self.designMatrix[:,
                                                             cnt]).tolist()
         gridInfo[varName] = (gridInfo[varName][0], gridInfo[varName][1],
                              InterpolatedUnivariateSpline(
                                  np.array([
                                      min(self.mapping[varName]),
                                      max(self.mapping[varName])
                                  ]),
                                  np.array([
                                      min(gridInfo[varName][2]),
                                      max(gridInfo[varName][2])
                                  ]),
                                  k=1)(self.mapping[varName]).tolist())
         stepLength[varName] = [
             round(gridInfo[varName][-1][k + 1] - gridInfo[varName][-1][k],
                   14) for k in range(len(gridInfo[varName][-1]) - 1)
         ]
     self.gridEntity.updateParameter("stepLength", stepLength, False)
     self.gridEntity.updateParameter("gridInfo", gridInfo)
     Grid.localInitialize(self)
     self.limit = self.designMatrix.shape[0]
Exemplo n.º 3
0
 def bb_points(self):
     """Box-Behnken designs."""
     return (bbdesign(self.dim, 1) + 1) * 0.5
Exemplo n.º 4
0
 def __init__(self, dim):
     self.dim = dim
     self.npts = pydoe.bbdesign(self.dim, center=1).shape[0]
Exemplo n.º 5
0
    def _generate_doe_design(self):
        """
        This function is responsible for generating the matrix of operating
        conditions used in the design of experiments. It supports all of the
        design types implemented by pyDOE with the exception of general full
        factorials (including mixed level factorials). Full factorials are only
        permitted to have two levels at the moment.

        Parameters
        ----------
        None

        Returns
        -------
        None, but updates the self object to have the needed auxiliary data
        """

        # Unpack the dictionary of DOE design parameters
        doe_type = self.doe_design['doe_args']['type']
        kwargs = self.doe_design['doe_args']['args']

        # Get the list of parameters to iterate over
        try:
            param_list = self.doe_design['doe_params']
        except:
            self._generate_doe_param_list()
            param_list = self.doe_design['doe_params']
        n = len(param_list)

        # Create the design matrix in coded units
        if doe_type == 'full2':  # Two level general factorial
            coded_design_matrix = pyDOE.ff2n(n)
        elif doe_type == 'frac':  # Fractional factorial
            gen = kwargs.pop('gen', None)
            if gen is None:
                raise ValueError(
                    'No generator sequence specified for a fractional factorial design.'
                )
            coded_design_matrix = pyDOE.fracfact(gen)
        elif doe_type == 'pb':  # Plackett-Burman
            coded_design_matrix = pyDOE.pbdesign(n)
        elif doe_type == 'bb':  # Box-Behnken
            coded_design_matrix = pyDOE.bbdesign(n, **kwargs)
        elif doe_type == 'cc':  # Central composite
            coded_design_matrix = pyDOE.ccdesign(n, **kwargs)
        elif doe_type == 'lh':  # Latin hypercube
            coded_design_matrix = pyDOE.lhs(n, **kwargs)
        elif doe_type == 'sob':  # Sobol' Lp-tau low discrepancy sequence
            samples = kwargs.pop('samples')
            coded_design_matrix = sobol_seq.i4_sobol_generate(n, samples)
        else:
            raise ValueError('Unrecognized DOE design option ' + doe_type)

        # Convert the coded design matrix into an uncoded design matrix (i.e.,
        # in terms of the raw operating conditions). This takes the minimum and
        # maximum values from the distributions and places the points
        # accordingly.
        a_array = np.zeros(n)  # Minimum
        b_array = np.zeros(n)  # Maximum
        for i in range(n):
            pkey = param_list[i]
            a_array[i] = self.doe_design['doe_param_dist'][pkey].a
            b_array[i] = self.doe_design['doe_param_dist'][pkey].b
        r_array = b_array - a_array  # Ranges for each dimension
        if doe_type in ['pb', 'bb', 'cc', 'frac', 'full2']:
            # These designs all have points clustered around a distinct center.
            # The coded matrix is in terms of unit perturbations from the
            # center, so we can just scale them by the ranges before adding the
            # center value. For these designs, we actually want to use half the
            # range so that the points that are supposed to be at the min/max
            # values end up there.
            c_array = (a_array + b_array) / 2  # Center is average of min, max
            doe_op_conds = coded_design_matrix * r_array / 2 + c_array
        elif doe_type in ['lh', 'sob']:
            # The Latin hypercube and Sobol' sequences space points between a
            # range. This means the coded design matrix has all elements on
            # (0, 1). Since we don't have a center point, we place the operating
            # conditions with respect to the minimum values.
            doe_op_conds = coded_design_matrix * r_array + a_array
        self.doe_design['doe_op_conds'] = doe_op_conds
Exemplo n.º 6
0
 def generate_points(self):
     return 0.5*(1 + pydoe.bbdesign(self.dim, center=1))
Exemplo n.º 7
0
 def __init__(self, dim):
     self.dim = dim
     self.npts = pydoe.bbdesign(self.dim, center=1).shape[0]