combine
Description
joins the parameter spaces sp_new = combine(sp1,sp2)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.
Examples
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";
open_system(mdl)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: {{1×5 cell} {1×3 cell} [1×1 prob.NormalDistribution] [1×1 prob.NormalDistribution]}
Notes: []
Spaces: {[1×1 sdo.GriddedSpace] [1×1 sdo.ParameterSpace]}
ParameterNames: {'A' 'h' 'FeedCon0' 'FeedTemp0'}
Options: [1×1 sdo.GriddingOptions]
The combined space is represented by an 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
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 withsdo.sampleinclude all possible combinations of values from each subspace.'sequential'or"sequential"— Samples drawn withsdo.sampleinclude 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
Combined parameter space, returned as an sdo.GriddedSpace object or
sdo.ParameterSpace object.
If
sp1andsp2are both random parameter spaces (sdo.ParameterSpace), thensp_newis ansdo.ParameterSpaceobject. Combining two random parameter spaces is equivalent to adding the parameters of one random space to the other usingaddParameter.If either
sp1orsp2is a gridded parameter space (sdo.GriddedSpace), thensp_newis a composite space. The composite space is returned as ansdo.GriddedSpaceobject that contains the combined spaces as subspaces in theSpacesproperty.You can think of a composite space as tree of spaces that contain subspaces. Use
combineto 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
See Also
sdo.ParameterSpace | sdo.GriddedSpace | sdo.sample | addParameter
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)