| Description of edl_batchexp |
edl_batchexp
PURPOSE 
EDL_BATCHEXP Performs Batch experiments according to scheme
SYNOPSIS 
function edl_batchexp(expfun, scrpath, env, logger, filter, runopt)
DESCRIPTION 
CROSS-REFERENCE INFORMATION 
This function calls:
- edl_readctrlfile EDL_READCTRLFILE Reads in a control file
- edl_readscript EDL_READSCRIPT Reads in a EDL script
- edl_updatectrlfile EDL_UPDATECTRLFILE Updates the status in a control file
- incindent INCINDENT Increases the indent by a specified amount
- sllog SLLOG Constructs a logger
- write WRITE Writes message to a logger
- writeblank WRITEBLANK Writes a blank line to log
- writeinfo WRITEINFO Writes information to logger without time-stamp
- slfilepart SLFILEPARTS Extracts a specified part of a file path string
- raise_lackinput RAISE_LACKINPUT Raises an error indicating lack of input argument
- sladdpath SLADDPATH Adds dirpath to precede the filenames
This function is called by:
- edl_go EDL_GO The Top interface for doing experiments in EDL
SUBFUNCTIONS 
- function [copts, sch] = prepare_configuration(scrpath, logger, filter, runopt)
- function sch = filter_sch(sch, filter)
- function sch = filter_sch_runopt(sch, ctrlpath)
- function do_experiments(expfun, copts, sch, env, logger)
SOURCE CODE 
0001 function edl_batchexp(expfun, scrpath, env, logger, filter, runopt)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039 if nargin < 3
0040 raise_lackinput('edl_batchexp', 3);
0041 end
0042
0043 if nargin < 4 || isempty(logger)
0044 logger = sllog();
0045 end
0046
0047 if nargin < 5
0048 filter = [];
0049 end
0050
0051 if nargin < 6 || isempty(runopt)
0052 runopt = 'restart';
0053 end
0054
0055
0056
0057
0058
0059
0060 [copts, sch] = prepare_configuration(scrpath, logger, filter, runopt);
0061
0062
0063 do_experiments(expfun, copts, sch, env, logger);
0064
0065
0066 write(logger, 'Experiments completed.');
0067
0068
0069
0070
0071 function [copts, sch] = prepare_configuration(scrpath, logger, filter, runopt)
0072
0073 switch runopt
0074 case 'restart'
0075 is_resume = false;
0076 case 'resume'
0077 is_resume = true;
0078 otherwise
0079 error('edl:interperror', ...
0080 'Invalid running option %s', runopt);
0081 end
0082
0083
0084 write(logger, 'Prepare experiment configurations');
0085
0086 script = edl_readscript(scrpath);
0087 scrparent = slfilepart(scrpath, 'parent');
0088
0089 copts.guid = script.attribs.guid;
0090 copts.workdir = script.attribs.workdir;
0091 copts.ctrlpath = sladdpath(script.attribs.ctrlpath, scrparent);
0092
0093 logger = incindent(logger, 1);
0094 writeinfo(logger, 'GUID = %s', copts.guid);
0095 writeinfo(logger, 'workdir root = %s', copts.workdir);
0096 writeinfo(logger, 'control path = %s', copts.ctrlpath);
0097
0098 sch = script.entries;
0099
0100 if ~isempty(filter)
0101 writeinfo(logger, 'filtered scheme = true');
0102 sch = filter_sch(sch, filter);
0103 end
0104
0105 writeinfo(logger, 'running mode = %s', runopt);
0106 if is_resume
0107 sch = filter_sch_runopt(sch, copts.ctrlpath);
0108 end
0109
0110 writeinfo(logger, 'number of experiments: %d', length(sch));
0111 writeblank(logger);
0112
0113
0114 function sch = filter_sch(sch, filter)
0115
0116 n = length(sch);
0117
0118 is_selected = false(n, 1);
0119
0120 if isnumeric(filter)
0121 is_selected(filter) = true;
0122 else
0123 for i = 1 : n
0124 is_selected(i) = feval(filter, sch(i));
0125 end
0126 end
0127
0128 if ~all(is_selected)
0129 sch = sch(is_selected);
0130 end
0131
0132 function sch = filter_sch_runopt(sch, ctrlpath)
0133
0134 n = length(sch);
0135
0136 if n > 0
0137 C = edl_readctrlfile(ctrlpath);
0138 is_disabled = false(n, 1);
0139
0140 for i = 1 : n
0141 idx = sch(i).internal_index;
0142 if strcmpi(C.status{idx}, 'succeed')
0143 is_disabled(i) = true;
0144 end
0145 end
0146 end
0147
0148
0149 if any(is_disabled)
0150 sch = sch(~is_disabled);
0151 end
0152
0153
0154
0155 function do_experiments(expfun, copts, sch, env, logger)
0156
0157 n = length(sch);
0158
0159 for i = 1 : n
0160
0161 cursch = sch(i);
0162 internal_index = cursch.internal_index;
0163
0164 write(logger, 'Enter experiment %d / %d (internal index = %d)', i, n, internal_index);
0165
0166 try
0167 feval(expfun, ...
0168 cursch, ...
0169 env, ...
0170 incindent(logger, 1));
0171
0172 edl_updatectrlfile(copts.guid, copts.ctrlpath, internal_index, 'succeed');
0173 write(logger, 'experiment succeeded');
0174 writeblank(logger);
0175
0176 catch
0177 write(logger, 'experiment failed');
0178 writeblank(logger);
0179 edl_updatectrlfile(copts.guid, copts.ctrlpath, internal_index, 'failed');
0180
0181 rethrow(lasterror);
0182 end
0183
0184 end
0185
0186
Generated on Wed 20-Sep-2006 12:43:11 by m2html © 2003
|
|