Contents Functions PDF Index |

- Build R,stra
- DirScan
- fname ,LabCell,Labdef]
- GeneLoop
- labFcn
- Loop
- Res
- Sel
- Stats
- Simple
- UI Tree
- Val
- ValCell
- Vect

Purpose

fe_range commands are used to manipulate experiment (series of design points) specifications.

Description

A range is the description of a set of experiments through a data structure with fields

- .val numeric array containing one design point per row and one design parameter per column.
- .lab cell array of strings giving a parameter label for each column. These labels should be acceptable fieldnames (no spaces, braces, ...)
- .param optional structure with fields associated with parameter labels used for formatting and analysis. Accepted values are detailed below. It is not necessary to define a .param field for each design parameter.
param.MainFcn={FcnHandle,'command'} can be used specify the user handling function in fe_range Loop.

- .edge optional connectivity matrix used to define lines connecting different design points of the experiment

- .FileName optional cell array of strings used to build file names associated with each experiment with command fe_range fname.

.param fields must match string values in .lab. Each field is a struct with possible fields

- .type a string. Typically double or pop.
- .choices, for .type='pop', contains a cell array of strings. The parameter value then gives the index within .choices.
- .data possible cell array containing data associated with the .choices field.
- .LabFcn a command to be evaluated with st1=eval(r2.LabFcn) to generate the proper label. For example 'sprintf(”%.1f ms”,val/1000)' is used to generate a label in a different unit. For choices, the default is r2.choices{val};.
- .Xlab long name to be used to fill Xlab when generating curve data structures.
- .level is an integer specifying the computational step at which a given parameter can be modified. This is used to generate tree type experiments.
- .uProp is a cell array giving a coefficient to go from value to engineering unit and a string for the unit. Or a structure with fields .coef multiplicative coefficient to go from storage value in val to display value. .coef can be a callback string based on the assumption that the value is in a val variable. .Xlab to be used for display after unit conversion, .unit string for unit of storage value. .fmt java formatting for display in tables.
- .SetFcn={fun,command} provides the callback used in fe_range Loop to execute parameter setting.
- .RepList={tokenString,subsasgn} optionally provides the mechanism to aggregate parameter modifications in a Loop step.

Commands

Build commands handle generation of the Range structure.

Range=fe_range('Buildstra',par);

Range is defined by a grid of all the parameter values defined in par.

par is expected to be either

- a structure where each field will be a parameter (for example struct('a',(1:3)','b',(1:2)'). For configurations, the field can contain a cell array with the configuration name and associated data (for example struct('MesCfg',{'a',data1;'b',data2}). To allow easier connection with graphical interfaces, the value can be replaced by a structure struct('a',struct('Eval','1:3')). Note that .param is a reserved field.
- a cell array defining parameters. Each cell can be
- a range data structure. This is for example used for visco parameter definitions (see fevisco Range for more details).
- (to be phased out) a string 'lab "label" min min max max cur cur scale "scale" NPoints NPoints'. "label" is the parameter name. Then the minimum, maximum and nominal values are defined. Scale can be "lin" for linear scale or "log" for logarithmic scale. NPoints defines the number of point for the parameter vector.
- (to be phased out) a numeric vector in the old upcom format [type cur min max scale] with type defining the matrix type (unused here), scale==2 indicates a logarithmic variation.

By default a grid type is generated. As an illustration, following example defines a grid 6x7 of 2 parameters named length and thickness

Range=fe_range('BuildGrid',struct('length',1:3, ... 'thickness',[1 2],'Name',{{'a','data_for_a';'b','data_for_b'}})) Range=fe_range('BuildGrid',Range); fe_range('Tree',Range); % XXXX VectFcn %Range=fe_range('BuildGrid',struct('length',struct('Eval','1:3'), ... % 'Name',{{'a';'b'}})) %Range=fe_range('BuildGrid',Range); % XXXX % String format (to be phased out) par={'lab "length" min 10 max 20 cur 10 scale "lin" NPoints 6',... 'lab "thickness" min 1e-3 max 2e-3 cur 0 scale "log" NPoints 7'}; Range=fe_range('BuildGrid',par); fe_range('Tree',Range);

A Range type must be defined by token stra. The following strategies are supported

- Grid Generates a grid type, with all possible parameter combinations.
- Vect generates a vector for a single parameter or a matrix with all parameters varying (the initial definition of each vector must have the same length).
- Simple Generates a sequential parameter combination. One parameter varies at a time, the others being kept at their nominal value.
- Rstra Generates reduced ranges spannix the parameters simplex. If ommitted this token is set to MinMax the available strategies are
- MinMax base point with all max, then successive set of one parameter to min.
- MinNom uses the first design point with the nominal values of each parameters, then variations with one parameter set to the minimum value while the other remain at their nominal value.
- NomMax uses the first design point with the maximum values of each parameters, then variations with one parameter set to the nominal value while the other remain at their maximum value.
- NomMin uses the first design point with the minimum values of each parameters, then variations with one parameter set to the nominal value while the other remain at their minimum value.
- MaxMin uses the first design point with the minimum values of each parameters, then variations with one parameter set to the maximum value while the other remain at their minimum value.
- MaxNom uses the first design point with the nominal values of each parameters, then variations with one parameter set to the maximum value while the other remain at their nominal value.
- Nom only uses the nominal value of each parameters.

- @cbk Allows customized defintion, using cbk as a function handle. Range is sequentially built with a expansion applied for each parameter. The typical call at the j1-th parameter is
Range.val=cbk(Range.val,par{j1}.val,i1,RO);

with Range.val the current Range before handling the j1-th parameter, par{j1}.val are the values considered for the j1-th parameter, i1 is the column index associated to the j1-th parameter in Range.val. RO is the current running option structure.

Accepted options are

- replace >0 keep first value. 3 Reuse parameters in range.
- level handles levels if present.
- FileName augments the Range.FileName field if present.
- diag in Grid type, takes the diagonal of the hypercube.

Scans a directory mat files and provides displayable information about property variations. It is assumed that files are saved with a variable RO (for Run Options) in struct format, each option considered as a field. Command DirScan will build a synthesis between constant and variable options, by providing in output a structure RB with fields

- wd the scanned directory.
- dirlist the file names scanned. (By default *.mat).
- RVar a structure that can be displayed by comstr -17 in Java tabs. In its basic version it contains fields table that list the differing options between each scanned file, one per line, and a field ColumName that provides the relative varying option fields. This list is handled by the flatParamFcn as explained below.
- RConstant a cell array with two columns providing the constant options for all scanned files. The first column contains the option fields and the second their value.

By default DirScan saves a file named RangeScan.mat in the scanned directory. This file contains the output to avoid scanning if possible. By default scanning is skipped if the file RangeScan.mat exists, refers to the same search in the dirlist field and if this file is more recent than all files to be scanned.

Options sorting is performed by the flatParamFcn. Typical options are hierarchically sorted in nested structure format that gather parameters of the same type, or belonging to a configuration set. To ensure a clean view of varying parameters, the hierarchical structure has to be flattened, that is to recursively flush back all nested structure fields to the root structure. The default flatParamFcn only performs this simple operation, one should not use identical parameter names in different locations.

For advanced applications it is recommended to add intelligence to the flatParamFcn to help sorting relevant parameters, possibly remove some irrelevant ones and to convert complex options into human readable format. The typical call to flatParamFcn is

r1=feval(flatParamFcn,fname,RO);

The output r1 is in the same format than output RConstant field, that is a two column cell array with fieldnames in first column defining found parameters and a second column containing current values for the currently scanned file.

Input fname is a structure with field fname providing the file name containing a parameter structure names RO. Input RO is a structure with fields wd providing the name of the scanned directory and Content, a cell array that will keep track of all parameter fieldnames encountered during scanning.

A sample call would be

% Example of flatParamFcn behavior % build a dummy result file with a parameter structure tname=nas2up('tempname_RES.mat'); % sample 2 level parameter structure RO=struct('MeshCfg',... struct('lc',4,'name','toto'),... 'SimuCfg',... struct('dt',1e-2','Tend',10)); % save RO in result file save(tname,'RO'); % Options to call flatParam R1=struct('flatParamFcn',fe_range('@flatParam'),'wd',pwd,'Content',{{}}); % call to flatParam [r1,RO]=feval(R1.flatParamFcn,struct('fname',tname),R1); delete(tname); % clean up example

Command DirScan takes a structure in input with fields

- wd the directory to scan.
- list the file names to scan. This allows restriction to filenames matching specific expressions. The default is *.mat.
- flatParamFcn. A function handle to sort the running options, by defaultset to fe_range('@flatParam').
- NoSave not to save the result in RangeScan.mat if set to one.

The following command options are accepted

- -reset to force a new scanning.
- -reload to force a reload of RangeScan.mat.

Range=fe_range('BuildGrid',struct('length',1:3, ... 'thickness',[1 2],'Name',{{'a','data_for_a';'b','data_for_b'}})) Range=fe_range('BuildGrid',Range); % Name built out of differnt labels Range.param.thickness.LabFcn='sprintf(''h=%.1f'',val)'; Range.param.thickness.ShortFmt=1; Range.FileName={'Root','@length','@thickness','@Name'}; fe_range('fname',Range)

Provides a genetic algorithm implementation inspired from the NSGA-II [50].

Command GeneLoop peforms the complete loop, taking into argument a set of parameters in a cell array, and a parameter structure with fields

- .PopSize the population size,
- .MatSize the mating group size,
- .NbTour the number of candidates to retain for a tournament round,
- .RatioMut the threshold ratio under which a gene mutation occurs when there is no crossover, between 0 (impossible) and 1 (always)
- .Optim the extremum to consider for the fitness function, min or max
- .RunExp the callback to the fitness function

The logic is to exploit a discretized pool gene based on a Range structure with available parameters. From a randomly chosen initial population using randi of size .PopSize, individuals are selected for mating, based on their fitness in a tournament phase. The tournament consists in running .MatSize tours in which the fittest individual is taken between .NbTour randomly picked candidates. The .MatSize selected individuals are then mated with a crossover and mutation strategy to produce a children gene pool of size PopSize. Crossover and mutation are sequential events. First, a crossover generates one child from two randomly picked parents in the mating pool (based on randperm) each gene is randomly picked from one or the other parent. Each gene can then mutate with a probability event driven by .RatioMut (based on rand threshold). In case of a mutation event, the gene will be forced to mutate by taking another available value in the gene pool. The children gene pool is forced to be gene combinations that have not been tested before. The parent and chidren populations are then combined, and only the .PopSize fittest individuals are kept for the next generation, ensuring elitism.

The output is a Range structure with field .val containing the current population, .Res the fitness values of the current population, .val0 the archive of all tested individuals, .Res0 the archive of fitness values of all tested individuals.

% define a set of parameters with discretized varying values par={'lab "p1" min 10 max 20 cur 10 scale "lin" NPoints 100',... 'lab "p2" min 1 max 100 cur 1 scale "lin" NPoints 100',... 'lab "p3" min 2 max 5 cur 100 scale "log" NPoints 100'}; % define a callback function updating Range.Res with fitness function based on Range.val RunExp=@(x,~)setfield(x,'Res',abs(sqrt(x.val(:,1)+x.val(:,2).^3)-x.val(:,3))); % Define genetic algorithm options RO=struct('MaxGen',100,'PopSize',25,'MatSize',10,'NbTour',4,... 'RatioMut',0.4,'RunExp',RunExp,'Optim','min'); % Run genetic algorithm Range=fe_range('GeneLoop',par,RO);

Loop the generic handler of parametric studies.

- The outer loop performs a loop on rows of Range.val (design points)
- For each design point, a loop on levels is performed. At a given level, an action is performed if .param.lab.SetFcn={'FcnName','Command'} is defined. When aggregating parameters of a given level (typically with a LabCfg parameter), it is expected that only the configuration parameter has a SetFcn and fe_range ValEvtMerge is called.
- Range.param.MainFcn={'FcnName','Command'} is used to implement standard methods.

Standard calls are:

fe_range('Loop',Range,RO) fe_range('Loop',Range,UI,RO)

RO is

- .restart do a restart.
- .StepStart defines the minimum step level to be computed. If omitted starts at 1.
- .nSteps defines the maximum step level to be computed. If omitted, all steps are computed.
- .Verbose define the verbosity level. 0 by default.
- .WaitAt can be used to generate wait files at a given step number. It is then possible to open MATLAB slaves that will consume waiting files present in a given directory by calling sdtjob('StudySlaveStart reset',pwd). This provides a simple mechanism for parallel exectution of a series of steps. It is however then expected that the step saves its results to a file that will not interact with other jobs.

R1=fe_range('Res',R1,Range);

This command reshapes the last dimension of the result curve R1 according to the Range. For a grid DOE last dimension is split in as many dimensions as parameters. For a vector DOE, last dimension is only redefined by a cell array of labels defining each design point.

This command allows selection of design points in a series of experiments described by a Range structure. The main output is the indices in Range.val rows corresponding to the sequential application of selection rules.

The selection rules a provided in a cell array of three columns and as many lines as rules to apply under the format

{param_name,'rule','crit';...}.

The following types of rules are supported, defined by a string,

- ismember applies selection by only taking the values specified using MATLAB ismember command. crit is then either a list of values (then corresponding to values appearing in the DOE table), or a cell array of values (then corresponding to the values in the DOE table where string values are used for pop style parameters. Regular expressions are supported for the pop entries, in which case the string must start by # followed by the regular expression to apply.
- <,>,<=,>=,== applies sampling by using the logical operator specified on the parameter values. crit is then a numerical value corresponding to the values appearing in the DOE table for all parameters.
- sort applies a sorting algorithm for a given parameter. crit is then either
- a string specifying an argument to the sort command of MATLAB, either ascend or descend. Support for pop types is provided based on alphabetical sorting.
- a function_handle to a sorting function that will be called with the val or choices field of the parameter and that will rethrow the sorted values and the corresponding index to the unsorted values.
- a cell array callback with first field a function_handle that will be called, the second entry will be replaced by the val or choices field of the parameter, and any further entries provided.

- sortrows will perform a post-treatment of the sampled Range to the selection applied and output a java compatible table.

Excepted for sortrows, other rules are sequentially applied to the current sampled Range. Sorting is thus only fully effective if last performed.

The optional .SortCol field can be used to specify a reformatting of the indices as a multi-dimensional grid.

fe_range('Stats',UI,sel,RA);

This command can be used to call a stack of post-treatments for a subpart of all computation results that have been priorly scanned through the DirScan command, and then displayed in the RVar tab. Results of the Stats command is a Stats tab in the UI.

UI is the interface data (where the Stats tab will be displayed), that can be obtained through the MainFcn('ParamUI') command. If it is left empty (UI=[]), sdtroot interface is implicitely defined.

sel is a selection cell array to select a sub set of results in all scanned results. See Sel for more details. If sel is empty (sel={}), all results are post-treated.

RA defines the post-treatments to be computed from selected results. It is a data structure with following fields:

- .SortCols defines a subset and the order of input parameters to consider for stats output or display. Parameters must be RVar parameters.
- .PostPar is a data structure with a .list field that defines the stack of post-treatments to be computed. PostPar.list is a cell array with as many rows as post-treatments to compute. Each row is of the form
'PostName' PostData. PostData is a cell array of the form {cbk data}.
- cbk is callback cell array of the form {FcnHandle Arg1 Arg2 ...}. The callback is called with [Full,Stat]=feval(cbk{1},obj0,evt0,cbk{2:end});. obj0 contains the results read in the current mat result file and evt0 is a structure with evt0.j1 containing the indice in the results stack. There are 2 output arguments Full that should contain a full signal (for example the observation of time deformation at sensors, ...) and Stats that should be a SDT curve table (1 or 2 dimensions) of scalar results (for example time statistics for time signals...).
- data is a cell array with as many rows as scalar results (1 by column in the Stats tab that will be displayed) to extract from the post-treatment result curve Stats. Each row is of the form i1 i2 CritFcn. i1 (resp. i2) can be either the row (resp column) indice of the scalar result in the Stats.Y table or the label of the row (resp column) in the Stat.X{1} abscissa (resp Stat.X{2}). CritFcn is the handle of a criterion function that can be used to colorate cell in the result tab (for example a threshold function) and also to display boundary lines in iiplot displays (needs critfcn doc and example).

Generates a set of experiments with sequential variation of each parameter, the other ones being fixed to their nominal value. par has the same format than for the fe_range BuildGrid input. They may feature a field nom providing a nominal value to each parameter, if this field is omitted the nominal value is considered to be the starting value of the parameter. In the case where par has been defined as a string input, field nom is taken to be the cur input value.

par={'lab "length" min 10 max 20 cur 10 scale "lin" NPoints 6',... 'lab "thickness" min 1e-3 max 2e-3 cur 0 scale "log" NPoints 7'}; Range=fe_range('Simple',par);

Basic display of an experiment design as a tree. See also the sdtroot version.

par={'lab "length" min 10 max 20 cur 10 scale "lin" NPoints 6',... 'lab "thickness" min 1e-3 max 2e-3 cur 0 scale "log" NPoints 7'}; Range=fe_range('Simple',par); fe_range('Tree',Range); sdtroot('setRange',Range); % Initialize range in PA.Range PA=sdtroot('PARAMVh');PA.Range sdtroot('InitRange'); % Initialize display

Val commands are used to ease range manipulations.

r2=fe_range('ValCell',Range);

This command can be used to convert a Range.Val as a cell array with as many rows as Range.val and each row of the form param1, val1, param2 val2, .... One can give ind as a 2nd argument, with the indices of rows to convert.

Range=fe_range('Vect',par);

Simply concatenate all parameter ranges (they must have the same length) into a functional Range. par has the same format than for the fe_range BuildGrid input. In addition, all par entries provided should have the same number of points.

Vect command is used to generate single par structures to feed Range.param entries.

par={'lab "length" min 10 max 20 cur 10 scale "lin" NPoints 7',... 'lab "thickness" min 1e-3 max 2e-3 cur 0 scale "log" NPoints 7'}; Range=fe_range('BuildVect',par);

©1991-2017 by SDTools