candexch
R2026bD-optimal design from candidate set using row exchanges
Description
Examples
Define a candidate set with a restriction.
F = (fullfact([5 5 5])-1)/4; % Factor settings in a unit cube T = sum(F,2)<=1.51; % Find rows matching a restriction F = F(T,:); % Take only those rows C = [ones(size(F,1),1) F F.^2];
Calculate model terms including a constant and all squared terms. Because the candidate set has a restriction, use the candexch function instead of the rowexch function.
R = candexch(C,12); % Find a D-optimal 12-run subset X = F(R,:); % Get factor settings
Input Arguments
Candidate set, specified as a matrix of size
N-by-P. The
candidate set contains the values of P model
terms at each of N runs.
Desired number of rows in the design, specified as a positive integer.
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN, where Name is
the argument name and Value is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name in quotes.
Example: rlist = candexch(C,nrows,MaxIterations=7)
specifies the maximum number of iterations as
7.
Flag for candexch to avoid
calculating duplicate rows, specified as a numeric or
logical 1 (true) or
0 (false). If
AvoidDuplicates is
true and
candexch is able to
calculate non-duplicate runs, the rows of
rlist are unique. When
AvoidDuplicates is
false, the function does not
avoid calculating duplicate rows.
Example: AvoidDuplicates=true
Data Types: single | double | logical
Display the iteration number, specified as
"on" or "off".
By default, the candexch function
displays the iteration number, except when the
UseParallel field of the
Options name-value argument is
"on" or "auto".
Maximum number of iterations, specified as a positive integer.
Options for computing in parallel and setting random streams, specified as a
structure. Create the Options structure using statset. This table lists the option fields and their
values.
| Field Name | Value | Default |
|---|---|---|
UseParallel | Set this value to | "off" |
UseSubstreams | Set this value to To compute
reproducibly, set | false |
Streams | Specify this value as a RandStream object or
cell array of such objects. Use a single object except when the
UseParallel value is "on"
or "auto" and the
UseSubstreams value is
false. In that case, use a cell array that
has the same size as the parallel pool. | If you do not specify Streams, then
candexch uses the default stream or
streams. |
Note
You need Parallel Computing Toolbox™ to run computations in parallel.
Before R2026b: To run computations in parallel, set
UseParallel to true.
Example: Options=statset(UseParallel="auto",UseSubstreams=true,Streams=RandStream("mlfg6331_64"))
Data Types: struct
Number of tries to generate a design from a new starting point, specified as a positive integer. The algorithm uses random points for each try, except possibly the first.
Output Arguments
Selected rows, returned as a vector of length
nrows.
Algorithms
candexch selects a starting design X at
random, and uses a row-exchange algorithm to iteratively replace rows of
X by rows of C in an attempt to
improve the determinant of X'*X.
Alternatives
The rowexch function also generates
D-optimal designs using a row-exchange algorithm, but it automatically generates a
candidate set that is appropriate for a specified model.
The daugment function augments a
set of fixed design runs using a coordinate-exchange algorithm; the FixedRows name-value
argument provides the same functionality using the row exchange algorithm.
Extended Capabilities
The candexch function has automatic parallel support. To run
computations in parallel, specify the Options name-value argument and set
the UseParallel field of the options structure to
"on" or "auto" using
statset:
Options=statset(UseParallel="auto")
For more information, see Run MATLAB Functions with Automatic Parallel Support (Parallel Computing Toolbox).
Version History
Introduced before R2006aThe UseParallel field of the Options name-value
argument now accepts "off", "auto", or
"on" values instead of true or
false. This change gives you more control over when to use a parallel
pool for parallel execution. Specifying the UseParallel field as
true or false is not recommended.
This table shows how to update your code depending on your goal.
| Goal | Not Recommended | Recommended |
|---|---|---|
Write code that runs on the MATLAB client. |
Options=statset(UseParallel=false)
|
Options=statset(UseParallel="off")
|
| Write portable code that runs on a parallel pool and, if a pool is not available, runs on the MATLAB client. |
Options=statset(UseParallel=true)
|
Options=statset(UseParallel="auto")
|
| Write code that runs on a parallel pool and errors if a pool is not available. | N/A |
Options=statset(UseParallel="on")
|
There are no plans to remove support for the true or
false values.
You can specify whether to avoid duplicate rows when using candexch to
augment a D-optimal design. Use the AvoidDuplicates name-value
argument to avoid duplicate rows in the additional runs, when possible.
candexch has updated name-value argument names. These more intuitive
names are now supported:
BoundsCategoricalVariablesNumLevels
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.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)