Changeset 646
- Timestamp:
- 05/29/09 16:01:19 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/m/solutions/dakota/dakota_out_parse.m
r642 r646 16 16 fidi=fopen(sprintf('%s',filei),'r'); 17 17 if (fidi < 0) 18 error(' %scould not be opened.',filei);18 error('''%s'' could not be opened.',filei); 19 19 end 20 20 … … 25 25 if ~ischar(fline) 26 26 ieof=1; 27 error('File %sis empty.',filei);27 error('File ''%s'' is empty.',filei); 28 28 end 29 29 … … 42 42 return 43 43 end 44 % display([' ' deblank(fline)]); 44 45 45 46 [ntokens,tokens]=fltokens(fline); … … 47 48 display(sprintf('Dakota method=%s.',method)); 48 49 50 dresp=struct([]); 49 51 scm =struct([]); 50 52 pcm =struct([]); … … 52 54 prcm=struct([]); 53 55 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.']); 59 if ~ischar(fline) 60 return 61 end 62 % display([' ' deblank(fline)]); 63 64 fline=fgetl(fidi); 65 66 %% process each results section based on content of the file 67 68 while 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'); 81 102 end 82 103 … … 173 194 end 174 195 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 198 function [nfeval]=nfeval_read(fidi,fline) 199 200 if ~exist('fline','var') || isempty(fline) || ~ischar(fline) 201 [fline]=findline(fidi,'<<<<< Function evaluation summary'); 202 if ~ischar(fline) 203 return 204 end 205 end 206 207 [ntokens,tokens]=fltokens(fline); 208 nfeval=tokens{1}{5}; 209 display(sprintf(' Dakota function evaluations=%d.',nfeval)); 214 210 215 211 end … … 217 213 %% function to find and read the number of samples 218 214 219 function [nsamp]=nsamp_read(fidi) 220 221 [fline]=findline(fidi,'Statistics based on '); 222 if ~ischar(fline) 223 return 215 function [nsamp]=nsamp_read(fidi,fline) 216 217 if ~exist('fline','var') || isempty(fline) || ~ischar(fline) 218 [fline]=findline(fidi,'Statistics based on '); 219 if ~ischar(fline) 220 return 221 end 224 222 end 225 223 … … 232 230 %% function to find and read the moments 233 231 234 function [dresp]=moments_read(fidi,dresp) 235 236 [fline]=findline(fidi,'Moments for each response function'); 237 if ~ischar(fline) 238 return 232 function [dresp]=moments_read(fidi,dresp,fline) 233 234 if ~exist('fline','var') || isempty(fline) || ~ischar(fline) 235 [fline]=findline(fidi,'Moments for each response function'); 236 if ~ischar(fline) 237 return 238 end 239 239 end 240 240 … … 264 264 %% function to find and read the confidence intervals 265 265 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 266 function [dresp]=cis_read(fidi,dresp,fline) 267 268 if ~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 272 274 end 273 275 … … 311 313 %% function to find and read the cdf's 312 314 313 function [dresp]=cdfs_read(fidi,dresp) 314 315 [fline]=findline(fidi,'Probabilities for each response function'); 316 if ~ischar(fline) 317 return 315 function [dresp]=cdfs_read(fidi,dresp,fline) 316 317 if ~exist('fline','var') || isempty(fline) || ~ischar(fline) 318 [fline]=findline(fidi,'Probabilities for each response function'); 319 if ~ischar(fline) 320 return 321 end 318 322 end 319 323 … … 380 384 %% function to find and read a correlation matrix 381 385 382 function [cmat]=corrmat_read(fidi,cmstr) 383 384 [fline]=findline(fidi,cmstr); 385 if ~ischar(fline) 386 cmat=struct([]); 387 return 386 function [cmat]=corrmat_read(fidi,cmstr,fline) 387 388 if ~exist('fline','var') || isempty(fline) || ~ischar(fline) 389 [fline]=findline(fidi,cmstr); 390 if ~ischar(fline) 391 cmat=struct([]); 392 return 393 end 388 394 end 389 395 … … 434 440 end 435 441 436 %% function to parse the nond_local_reliability output file437 438 function [dresp]=nond_locrel(fidi)439 440 % loop through the file to find the number of function evaluations441 442 [nfeval]=nfeval_read(fidi);443 444 % loop through the file to find the statistics445 446 [dresp]=mvstats_read(fidi,struct([]));447 448 end449 450 %% function to find and read the number of function evaluations451 452 function [nfeval]=nfeval_read(fidi)453 454 [fline]=findline(fidi,'<<<<< Function evaluation summary');455 if ~ischar(fline)456 return457 end458 459 [ntokens,tokens]=fltokens(fline);460 nfeval=tokens{1}{5};461 display(sprintf(' Dakota function evaluations=%d.',nfeval));462 463 end464 465 442 %% function to find and read the MV statistics 466 443 467 function [dresp]=mvstats_read(fidi,dresp) 444 function [dresp]=mvstats_read(fidi,dresp,fline) 445 446 if ~exist('fline','var') || isempty(fline) || ~ischar(fline) 447 [fline]=findline(fidi,'MV Statistics for '); 448 if ~ischar(fline) 449 return 450 end 451 end 468 452 469 453 ieof=0; 470 471 [fline]=findline(fidi,'MV Statistics for ');472 if ~ischar(fline)473 return474 end475 476 454 display('Reading MV statistics for response functions:'); 477 455 ndresp=0; … … 605 583 end 606 584 607 %% function to parse any optimization output file608 609 function [dresp]=opt_any(fidi)610 611 %% search through the file to find the Dakota output data612 613 [fline]=findline(fidi,'<<<<< Iterator');614 if ~ischar(fline)615 return616 end617 display([' ' deblank(fline)]);618 619 % loop through the file to find the number of function evaluations620 621 [nfeval]=nfeval_read(fidi);622 623 % loop through the file to find the best evaluation624 625 [dresp]=best_read(fidi,struct([]));626 627 end628 629 585 %% function to find and read the best evaluation 630 586 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 587 function [dresp]=best_read(fidi,dresp,fline) 588 589 if ~exist('fline','var') || isempty(fline) || ~ischar(fline) 590 [fline]=findline(fidi,'<<<<< Best '); 591 if ~ischar(fline) 592 return 593 end 594 end 595 596 if isempty(dresp) 597 dresp(end+1).best=[]; 598 end 639 599 display('Reading values for best function evaluation:'); 640 600 … … 737 697 end 738 698 739 %% function to parse any parameter study output file740 741 function [dresp]=param_any(fidi)742 743 %% search through the file to find the Dakota output data744 745 [fline]=findline(fidi,'<<<<< Iterator');746 if ~ischar(fline)747 return748 end749 display([' ' deblank(fline)]);750 751 % loop through the file to find the number of function evaluations752 753 [nfeval]=nfeval_read(fidi);754 755 % loop through the file to find the volumetric uniformity measures756 757 [dresp]=vum_read(fidi,struct([]));758 759 end760 761 699 %% function to find and read the volumetric uniformity measures 762 700 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 701 function [dresp]=vum_read(fidi,dresp,fline) 702 703 if ~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 708 end 709 710 if isempty(dresp) 711 dresp(end+1).vum=[]; 712 end 771 713 display('Reading measures for volumetric uniformity.'); 772 714
Note:
See TracChangeset
for help on using the changeset viewer.