Main Content


Combine parameter spaces defined for sensitivity analysis

Since R2023a



    sp_new = combine(sp1,sp2) joins the parameter spaces sp1 and sp2 into a composite parameter space that contains sp1 and sp2 as subspaces. You can combine gridded parameter spaces, random parameter spaces, or both. You can use composite parameter spaces to generate sample sets containing both gridded and randomly sampled parameters.

    sp_new = combine(sp1,sp2,method) combines the parameter spaces and sets the sampling method.


    collapse all

    If your model contains some parameters you want to sample across a grid and others from which you want to draw random samples, you can combine gridded and random parameter spaces.

    This example uses the sdoCSTR model discussed in detail in Design Exploration Using Parameter Sampling (Code). Open the model.

    mdl = "sdoCSTR";

    Among the parameters in this model are the reactor cylinder area A, height h, and the feed temperature and concentration, FeedCon0 and FeedTemp0. Suppose that you want to explore the sensitivity of your design constraint to these four parameters, sampling across a grid of A and h values while drawing FeedCon0 and FeedTemp0 from random distributions.

    First, define a gridded parameter space for A and h. Use sdo.getParameterFromModel to create an array of param.Continuous objects representing A and h. Then, specify values for the grid, and create the parameter space.

    pg = sdo.getParameterFromModel(mdl,{'A','h'});
    Avals = {0.2 0.6 1.0 1.4 1.8};
    hvals = {0.5 1.5 2.5};
    gspace = sdo.GriddedSpace(pg,{Avals,hvals});

    Next, define a random parameter space for FeedCon0 and FeedTemp0. Create an array of param.Continuous objects and specify the probability distributions for each parameter. For this example, assign both variables a normal distribution where the mean is the current parameter value in the model and the variance is 5% of the mean. Then, create the parameter space.

    pr = sdo.getParameterFromModel(mdl,{'FeedCon0','FeedTemp0'});
    distCon  = makedist('normal',pr(1).Value,0.05*pr(1).Value); 
    distTemp = makedist('normal',pr(2).Value,0.05*pr(2).Value);
    rspace = sdo.ParameterSpace(pr);
    rspace = setDistribution(rspace,'FeedCon0',distCon);
    rspace = setDistribution(rspace,'FeedTemp0',distTemp);

    Finally, combine the two parameter spaces into a new parameter space.

    cspace = combine(gspace,rspace)
    cspace = 
      GriddedSpace with properties:
        ParameterValues: {{1x5 cell}  {1x3 cell}  [1x1 prob.NormalDistribution]  [1x1 prob.NormalDistribution]}
                  Notes: []
                 Spaces: {[1x1 sdo.GriddedSpace]  [1x1 sdo.ParameterSpace]}
         ParameterNames: {'A'  'h'  'FeedCon0'  'FeedTemp0'}
                Options: [1x1 sdo.GriddingOptions]

    The combined space is represented by a sdo.GriddedSpace object. The property cspace.Spaces shows that cspace contains the two subspaces, one gridded space and one random parameter space. The property cspace.ParameterValues shows that the space includes the finite grid for A and H, and the probability distributions for the random variables FeedCon0 and FeedTemp0.

    You can now use sdo.sample to draw sets of sampled values from the combined space. By default, the samples are exhaustive over the grid, meaning every possible combination of grid values is included in the sampled set. Suppose that for each combination, you want to sample the random parameters ten times. Provide that value to sdo.sample in the NumSample argument.

    cspace.Options.Method = 'exhaustive';
    NumSample = 10;
    evalues = sdo.sample(cspace,NumSample)
    evalues=150×4 table
         A      h     FeedCon0    FeedTemp0
        ___    ___    ________    _________
        0.2    0.5     10.269      275.09  
        0.6    0.5     10.269      275.09  
          1    0.5     10.269      275.09  
        1.4    0.5     10.269      275.09  
        1.8    0.5     10.269      275.09  
        0.2    1.5     10.269      275.09  
        0.6    1.5     10.269      275.09  
          1    1.5     10.269      275.09  
        1.4    1.5     10.269      275.09  
        1.8    1.5     10.269      275.09  
        0.2    2.5     10.269      275.09  
        0.6    2.5     10.269      275.09  
          1    2.5     10.269      275.09  
        1.4    2.5     10.269      275.09  
        1.8    2.5     10.269      275.09  
        0.2    0.5     10.917      339.77  

    Here, for each of the fifteen combinations of (A, h) values, sdo.sample assigns ten random values for (Feedcon0, FeedTemp0), resulting in 150 sets of (A, h, FeedCon0, FeedTemp0) samples.

    You can also have sdo.sample choose only one random (FeedCon0,FeedTemp0) value for each (A,h) pair. To do so, set the sampling method of cspace to sequential. Note that in this case, you created cspace using a gridded space gspace that had gspace.Options.Method = 'exhaustive'. Thus, when you sample cspace, the (A,h) pairs are still exhaustive.

    cspace.Options.Method = 'sequential';
    svalues = sdo.sample(cspace)
    svalues=15×4 table
         A      h     FeedCon0    FeedTemp0
        ___    ___    ________    _________
        0.2    0.5     9.5682      296.27  
        0.6    0.5     10.039         273  
          1    0.5     9.3929      284.05  
        1.4    0.5     9.4432      279.34  
        1.8    0.5     9.9966      329.67  
        0.2    1.5     10.766      285.92  
        0.6    1.5     9.6152      306.03  
          1    1.5     10.186      292.16  
        1.4    1.5     9.8872      308.11  
        1.8    1.5     10.559      283.72  
        0.2    2.5     9.4555      274.32  
        0.6    2.5     10.016      274.02  
          1    2.5     10.276       302.2  
        1.4    2.5      10.55      292.38  
        1.8    2.5     10.772      292.11  

    Use values with sdo.evalute to evaluate your design objectives at each of the sampled parameter values. For instance, if you have defined a cost function design, you can use values in a call to sdo.evluate as follows.

    [yR,infoR] = sdo.evaluate(@design,p,values);

    Input Arguments

    collapse all

    Parameter spaces to combine, specified as sdo.ParameterSpace objects, sdo.GriddedSpace objects, or one of each.

    Sampling method of the combined space, specified as one of the following:

    • 'exhaustive' or "exhaustive" — Samples drawn with sdo.sample include all possible combinations of values from each subspace.

    • 'sequential' or "sequential" — Samples drawn with sdo.sample include pairwise combinations of values from each subspace.

    The method argument sets the method property of the composite space, sp_new.Option.Method. If both sp1 and sp2 are random parameter spaces (sdo.ParameterSpace), then method is ignored.

    Output Arguments

    collapse all

    Combined parameter space, returned as an sdo.GriddedSpace object or sdo.ParameterSpace object.

    • If sp1 and sp2 are both random parameter spaces (sdo.ParameterSpace), then sp_new is an sdo.ParameterSpace object. Combining two random parameter spaces is equivalent to adding the parameters of one random space to the other using addParameter.

    • If either sp1 or sp2 is a gridded parameter space (sdo.GriddedSpace), then sp_new is a composite space. The composite space is returned as an sdo.GriddedSpace object that contains the combined spaces as subspaces in the Spaces property.

      You can think of a composite space as tree of spaces that contain subspaces. Use combine to construct the tree one space at a time. A composite gridded parameter space contains at most one random parameter space at the top level of the composite space. When you combine a composite parameter space that has a random parameter subspace with another random parameter space, the random parameter spaces are combined into a single parameter space at the top level of the composite space.

    Version History

    Introduced in R2023a