Ignore:
Timestamp:
05/29/09 16:01:19 (16 years ago)
Author:
jschierm
Message:

Revision to make parsing of Dakota output data content-driven rather than method-driven.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/m/solutions/dakota/dakota_out_parse.m

    r642 r646  
    1616fidi=fopen(sprintf('%s',filei),'r');
    1717if (fidi < 0)
    18     error('%s could not be opened.',filei);
     18    error('''%s'' could not be opened.',filei);
    1919end
    2020
     
    2525if ~ischar(fline)
    2626    ieof=1;
    27     error('File %s is empty.',filei);
     27    error('File ''%s'' is empty.',filei);
    2828end
    2929
     
    4242    return
    4343end
     44% display(['  ' deblank(fline)]);
    4445
    4546[ntokens,tokens]=fltokens(fline);
     
    4748display(sprintf('Dakota method=%s.',method));
    4849
     50dresp=struct([]);
    4951scm =struct([]);
    5052pcm =struct([]);
     
    5254prcm=struct([]);
    5355
    54 %%  switch according to the Dakota method
    55 
    56 switch lower(method)
    57 %     case {'dot_bfgs','dot_frcg','dot_mmfd','dot_slp','dot_sqp'}
    58 %     case {'npsol_sqp'}
    59     case {'conmin_frcg','conmin_mfd'}
    60         [dresp]=opt_any(fidi);
    61 %     case {'optpp_cg','optpp_q_newton','optpp_fd_newton',...
    62 %             'optpp_newton','optpp_pds'}
    63 %     case {'asynch_pattern_search'}
    64 %     case {'coliny_cobyla','coliny_direct','coliny_ea',...
    65 %             'coliny_pattern_search','coliny_solis_wets'}
    66 %     case {'ncsu_direct'}
    67 %     case {'moga','soga'}
    68 %     case {'nl2sol','nlssol_sqp','optpp_g_newton'}
    69     case {'nond_sampling'}
    70         [dresp,scm,pcm,srcm,prcm]=nond_samp(fidi);
    71     case {'nond_local_reliability'}
    72         [dresp]=nond_locrel(fidi);
    73      case {'dace','fsu_quasi_mc','fsu_cvt'}
    74         [dresp]=param_any(fidi);
    75      case {'vector_parameter_study','list_parameter_study',...
    76              'centered_parameter_study','multidim_parameter_study'}
    77         [dresp]=param_any(fidi);
    78     otherwise
    79         error('Unrecognized  method ''%s'' in file %s.',...
    80             method,filei);
     56%%  loop through the file to find the iterator completion
     57
     58[fline]=findline(fidi,['<<<<< Iterator ' method ' completed.']);
     59if ~ischar(fline)
     60    return
     61end
     62% display(['  ' deblank(fline)]);
     63
     64fline=fgetl(fidi);
     65
     66%%  process each results section based on content of the file
     67
     68while ischar(fline)
     69%     ipos=ftell(fidi);
     70    if     strncmp(fline,'<<<<< Function evaluation summary',33)
     71        [nfeval]=nfeval_read(fidi,fline);
     72    elseif strncmp(fline,'Statistics based on ',20)
     73        [nsamp]=nsamp_read(fidi,fline);
     74    elseif strncmp(fline,'Moments for each response function',34)
     75        [dresp]=moments_read(fidi,dresp,fline);
     76    elseif strncmp(fline,'95% confidence intervals for each response function',51)
     77        [dresp]=cis_read(fidi,dresp,fline);
     78    elseif strncmp(fline,'Probabilities for each response function',40)
     79        [dresp]=cdfs_read(fidi,dresp,fline);
     80    elseif strncmp(fline,'Simple Correlation Matrix',25)
     81        [scm]=corrmat_read(fidi,'Simple Correlation Matrix',fline);
     82    elseif strncmp(fline,'Partial Correlation Matrix',26)
     83        [pcm]=corrmat_read(fidi,'Partial Correlation Matrix',fline);
     84    elseif strncmp(fline,'Simple Rank Correlation Matrix',30)
     85        [srcm]=corrmat_read(fidi,'Simple Rank Correlation Matrix',fline);
     86    elseif strncmp(fline,'Partial Rank Correlation Matrix',31)
     87        [prcm]=corrmat_read(fidi,'Partial Rank Correlation Matrix',fline);
     88    elseif strncmp(fline,'MV Statistics for ',18)
     89        [dresp]=mvstats_read(fidi,dresp,fline);
     90    elseif strncmp(fline,'<<<<< Best ',11)
     91        [dresp]=best_read(fidi,dresp,fline);
     92    elseif strncmp(fline,'The following lists volumetric uniformity measures',50)
     93        [dresp]=vum_read(fidi,dresp,fline);
     94    elseif strncmp(fline,'-----',5)
     95    elseif isempty(fline)
     96    else
     97        display(['Unexpected line: ' deblank(fline)]);
     98        fline=fgetl(fidi);
     99    end
     100    fline=fgetl(fidi);
     101%     fseek(fidi,ipos,'bof');
    81102end
    82103
     
    173194end
    174195
    175 %%  function to parse the nond_sampling output file
    176 
    177 function [dresp,scm,pcm,srcm,prcm]=nond_samp(fidi)
    178 
    179 %  loop through the file to find the number of function evaluations
    180 
    181 [nfeval]=nfeval_read(fidi);
    182 
    183 %  loop through the file to find the number of samples
    184 
    185 [nsamp]=nsamp_read(fidi);
    186 
    187 %  loop through the file to find the moments
    188 
    189 [dresp]=moments_read(fidi,struct([]));
    190 
    191 %  loop through the file to find the confidence intervals
    192 
    193 [dresp]=cis_read(fidi,dresp);
    194 
    195 %  loop through the file to find the probabilities
    196 
    197 [dresp]=cdfs_read(fidi,dresp);
    198 
    199 %  loop through the file to find the scm
    200 
    201 [scm]=corrmat_read(fidi,'Simple Correlation Matrix');
    202 
    203 %  loop through the file to find the pcm
    204 
    205 [pcm]=corrmat_read(fidi,'Partial Correlation Matrix');
    206 
    207 %  loop through the file to find the srcm
    208 
    209 [srcm]=corrmat_read(fidi,'Simple Rank Correlation Matrix');
    210 
    211 %  loop through the file to find the prcm
    212 
    213 [prcm]=corrmat_read(fidi,'Partial Rank Correlation Matrix');
     196%%  function to find and read the number of function evaluations
     197
     198function [nfeval]=nfeval_read(fidi,fline)
     199
     200if ~exist('fline','var') || isempty(fline) || ~ischar(fline)
     201    [fline]=findline(fidi,'<<<<< Function evaluation summary');
     202    if ~ischar(fline)
     203        return
     204    end
     205end
     206
     207[ntokens,tokens]=fltokens(fline);
     208nfeval=tokens{1}{5};
     209display(sprintf('  Dakota function evaluations=%d.',nfeval));
    214210
    215211end
     
    217213%%  function to find and read the number of samples
    218214
    219 function [nsamp]=nsamp_read(fidi)
    220 
    221 [fline]=findline(fidi,'Statistics based on ');
    222 if ~ischar(fline)
    223     return
     215function [nsamp]=nsamp_read(fidi,fline)
     216
     217if ~exist('fline','var') || isempty(fline) || ~ischar(fline)
     218    [fline]=findline(fidi,'Statistics based on ');
     219    if ~ischar(fline)
     220        return
     221    end
    224222end
    225223
     
    232230%%  function to find and read the moments
    233231
    234 function [dresp]=moments_read(fidi,dresp)
    235 
    236 [fline]=findline(fidi,'Moments for each response function');
    237 if ~ischar(fline)
    238     return
     232function [dresp]=moments_read(fidi,dresp,fline)
     233
     234if ~exist('fline','var') || isempty(fline) || ~ischar(fline)
     235    [fline]=findline(fidi,'Moments for each response function');
     236    if ~ischar(fline)
     237        return
     238    end
    239239end
    240240
     
    264264%%  function to find and read the confidence intervals
    265265
    266 function [dresp]=cis_read(fidi,dresp)
    267 
    268 [fline]=findline(fidi,...
    269     '95% confidence intervals for each response function');
    270 if ~ischar(fline)
    271     return
     266function [dresp]=cis_read(fidi,dresp,fline)
     267
     268if ~exist('fline','var') || isempty(fline) || ~ischar(fline)
     269    [fline]=findline(fidi,...
     270        '95% confidence intervals for each response function');
     271    if ~ischar(fline)
     272        return
     273    end
    272274end
    273275
     
    311313%%  function to find and read the cdf's
    312314
    313 function [dresp]=cdfs_read(fidi,dresp)
    314 
    315 [fline]=findline(fidi,'Probabilities for each response function');
    316 if ~ischar(fline)
    317     return
     315function [dresp]=cdfs_read(fidi,dresp,fline)
     316
     317if ~exist('fline','var') || isempty(fline) || ~ischar(fline)
     318    [fline]=findline(fidi,'Probabilities for each response function');
     319    if ~ischar(fline)
     320        return
     321    end
    318322end
    319323
     
    380384%%  function to find and read a correlation matrix
    381385
    382 function [cmat]=corrmat_read(fidi,cmstr)
    383 
    384 [fline]=findline(fidi,cmstr);
    385 if ~ischar(fline)
    386     cmat=struct([]);
    387     return
     386function [cmat]=corrmat_read(fidi,cmstr,fline)
     387
     388if ~exist('fline','var') || isempty(fline) || ~ischar(fline)
     389    [fline]=findline(fidi,cmstr);
     390    if ~ischar(fline)
     391        cmat=struct([]);
     392        return
     393    end
    388394end
    389395
     
    434440end
    435441
    436 %%  function to parse the nond_local_reliability output file
    437 
    438 function [dresp]=nond_locrel(fidi)
    439 
    440 %  loop through the file to find the number of function evaluations
    441 
    442 [nfeval]=nfeval_read(fidi);
    443 
    444 %  loop through the file to find the statistics
    445 
    446 [dresp]=mvstats_read(fidi,struct([]));
    447 
    448 end
    449 
    450 %%  function to find and read the number of function evaluations
    451 
    452 function [nfeval]=nfeval_read(fidi)
    453 
    454 [fline]=findline(fidi,'<<<<< Function evaluation summary');
    455 if ~ischar(fline)
    456     return
    457 end
    458 
    459 [ntokens,tokens]=fltokens(fline);
    460 nfeval=tokens{1}{5};
    461 display(sprintf('  Dakota function evaluations=%d.',nfeval));
    462 
    463 end
    464 
    465442%%  function to find and read the MV statistics
    466443
    467 function [dresp]=mvstats_read(fidi,dresp)
     444function [dresp]=mvstats_read(fidi,dresp,fline)
     445
     446if ~exist('fline','var') || isempty(fline) || ~ischar(fline)
     447    [fline]=findline(fidi,'MV Statistics for ');
     448    if ~ischar(fline)
     449        return
     450    end
     451end
    468452
    469453ieof=0;
    470 
    471 [fline]=findline(fidi,'MV Statistics for ');
    472 if ~ischar(fline)
    473     return
    474 end
    475 
    476454display('Reading MV statistics for response functions:');
    477455ndresp=0;
     
    605583end
    606584
    607 %%  function to parse any optimization output file
    608 
    609 function [dresp]=opt_any(fidi)
    610 
    611 %%  search through the file to find the Dakota output data
    612 
    613 [fline]=findline(fidi,'<<<<< Iterator');
    614 if ~ischar(fline)
    615     return
    616 end
    617 display(['  ' deblank(fline)]);
    618 
    619 %  loop through the file to find the number of function evaluations
    620 
    621 [nfeval]=nfeval_read(fidi);
    622 
    623 %  loop through the file to find the best evaluation
    624 
    625 [dresp]=best_read(fidi,struct([]));
    626 
    627 end
    628 
    629585%%  function to find and read the best evaluation
    630586
    631 function [dresp]=best_read(fidi,dresp)
    632 
    633 [fline]=findline(fidi,'<<<<< Best ');
    634 if ~ischar(fline)
    635     return
    636 end
    637 dresp(end+1).best=[];
    638 
     587function [dresp]=best_read(fidi,dresp,fline)
     588
     589if ~exist('fline','var') || isempty(fline) || ~ischar(fline)
     590    [fline]=findline(fidi,'<<<<< Best ');
     591    if ~ischar(fline)
     592        return
     593    end
     594end
     595
     596if isempty(dresp)
     597    dresp(end+1).best=[];
     598end
    639599display('Reading values for best function evaluation:');
    640600
     
    737697end
    738698
    739 %%  function to parse any parameter study output file
    740 
    741 function [dresp]=param_any(fidi)
    742 
    743 %%  search through the file to find the Dakota output data
    744 
    745 [fline]=findline(fidi,'<<<<< Iterator');
    746 if ~ischar(fline)
    747     return
    748 end
    749 display(['  ' deblank(fline)]);
    750 
    751 %  loop through the file to find the number of function evaluations
    752 
    753 [nfeval]=nfeval_read(fidi);
    754 
    755 %  loop through the file to find the volumetric uniformity measures
    756 
    757 [dresp]=vum_read(fidi,struct([]));
    758 
    759 end
    760 
    761699%%  function to find and read the volumetric uniformity measures
    762700
    763 function [dresp]=vum_read(fidi,dresp)
    764 
    765 [fline]=findline(fidi,'The following lists volumetric uniformity measures');
    766 if ~ischar(fline)
    767     return
    768 end
    769 dresp(end+1).vum=[];
    770 
     701function [dresp]=vum_read(fidi,dresp,fline)
     702
     703if ~exist('fline','var') || isempty(fline) || ~ischar(fline)
     704    [fline]=findline(fidi,'The following lists volumetric uniformity measures');
     705    if ~ischar(fline)
     706        return
     707    end
     708end
     709
     710if isempty(dresp)
     711    dresp(end+1).vum=[];
     712end
    771713display('Reading measures for volumetric uniformity.');
    772714
Note: See TracChangeset for help on using the changeset viewer.