Changeset 456
- Timestamp:
- 05/15/09 15:09:21 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/m/solutions/dakota/dakota_out_parse.m
r1 r456 47 47 display(sprintf('Dakota method=%s.',method)); 48 48 49 scm = [];50 pcm = [];51 srcm= [];52 prcm= [];49 scm =struct([]); 50 pcm =struct([]); 51 srcm=struct([]); 52 prcm=struct([]); 53 53 54 54 %% switch according to the Dakota method … … 175 175 function [dresp,scm,pcm,srcm,prcm]=nond_samp(fidi) 176 176 177 ieof=0; 178 179 %% loop through the file to find the Dakota statistics 177 % loop through the file to find the number of function evaluations 178 179 [nfeval]=nfeval_read(fidi); 180 181 % loop through the file to find the number of samples 182 183 [nsamp]=nsamp_read(fidi); 184 185 % loop through the file to find the moments 186 187 [dresp]=moments_read(fidi,struct([])); 188 189 % loop through the file to find the confidence intervals 190 191 [dresp]=cis_read(fidi,dresp); 192 193 % loop through the file to find the probabilities 194 195 [dresp]=cdfs_read(fidi,dresp); 196 197 % loop through the file to find the scm 198 199 [scm]=corrmat_read(fidi,'Simple Correlation Matrix'); 200 201 % loop through the file to find the pcm 202 203 [pcm]=corrmat_read(fidi,'Partial Correlation Matrix'); 204 205 % loop through the file to find the srcm 206 207 [srcm]=corrmat_read(fidi,'Simple Rank Correlation Matrix'); 208 209 % loop through the file to find the prcm 210 211 [prcm]=corrmat_read(fidi,'Partial Rank Correlation Matrix'); 212 213 end 214 215 %% function to find and read the number of samples 216 217 function [nsamp]=nsamp_read(fidi) 180 218 181 219 [fline]=findline(fidi,'Statistics based on '); … … 186 224 [ntokens,tokens]=fltokens(fline); 187 225 nsamp=tokens{1}{4}; 188 display(sprintf('Dakota samples=%d.',nsamp)); 189 190 %% loop through the file to find the moments 226 display(sprintf(' Dakota samples=%d.',nsamp)); 227 228 end 229 230 %% function to find and read the moments 231 232 function [dresp]=moments_read(fidi,dresp) 191 233 192 234 [fline]=findline(fidi,'Moments for each response function'); … … 195 237 end 196 238 197 display('Reading moments for each response function:'); 198 ndresp=0; 199 200 while ~ieof 239 display('Reading moments for response functions:'); 240 241 while 1 242 fline=fgetl(fidi); 243 if isempty(fline) 244 break; 245 end 246 [ntokens,tokens]=fltokens(fline); 247 248 % add new response function and moments 249 250 dresp(end+1).descriptor=tokens{1}{ 1}; 251 display(sprintf(' %s',dresp(end).descriptor)); 252 dresp(end ).mean =tokens{1}{ 4}; 253 dresp(end ).stddev =tokens{1}{ 8}; 254 dresp(end ).coefvar =tokens{1}{13}; 255 end 256 257 display(sprintf(' Number of Dakota response functions=%d.',... 258 length(dresp))); 259 260 end 261 262 %% function to find and read the confidence intervals 263 264 function [dresp]=cis_read(fidi,dresp) 265 266 [fline]=findline(fidi,... 267 '95% confidence intervals for each response function'); 268 if ~ischar(fline) 269 return 270 end 271 272 display('Reading 95% confidence intervals for response functions:'); 273 274 while 1 275 fline=fgetl(fidi); 276 if isempty(fline) 277 break; 278 end 279 [ntokens,tokens]=fltokens(fline); 280 281 % find response function associated with confidence intervals 282 283 idresp=0; 284 for i=1:length(dresp) 285 if strcmpi(tokens{1}{ 1},dresp(i).descriptor) 286 idresp=i; 287 break; 288 end 289 end 290 if ~idresp 291 idresp=length(dresp)+1; 292 dresp(idresp).descriptor=tokens{1}{ 1}; 293 display(sprintf(' %s',dresp(idresp).descriptor)); 294 end 295 296 % add confidence intervals to response functions 297 298 dresp(i).meanci (1,1)=tokens{1}{ 5}; 299 dresp(i).meanci (2,1)=tokens{1}{ 6}; 300 dresp(i).stddevci(1,1)=tokens{1}{12}; 301 dresp(i).stddevci(2,1)=tokens{1}{13}; 302 end 303 304 display(sprintf(' Number of Dakota response functions=%d.',... 305 length(dresp))); 306 307 end 308 309 %% function to find and read the cdf's 310 311 function [dresp]=cdfs_read(fidi,dresp) 312 313 [fline]=findline(fidi,'Probabilities for each response function'); 314 if ~ischar(fline) 315 return 316 end 317 318 display('Reading CDF''s for response functions:'); 319 320 while ~isempty(fline) 201 321 fline=fgetl(fidi); 202 322 if ~ischar(fline) 203 ieof=1;204 break;205 end206 if isempty(fline)207 break;208 end209 210 % add new response function and moments211 212 ndresp=ndresp+1;213 [ntokens,tokens]=fltokens(fline);214 dresp(ndresp).descriptor=tokens{1}{ 1};215 display(sprintf(' %s',dresp(ndresp).descriptor));216 dresp(ndresp).mean =tokens{1}{ 4};217 dresp(ndresp).stddev =tokens{1}{ 8};218 dresp(ndresp).coefvar =tokens{1}{13};219 end220 221 display(sprintf('Number of Dakota response functions=%d.',ndresp));222 223 %% loop through the file to find the confidence intervals224 225 [fline]=findline(fidi,...226 '95% confidence intervals for each response function');227 if ~ischar(fline)228 return229 end230 231 display('Reading 95% confidence intervals for each response function.');232 233 while ~ieof234 fline=fgetl(fidi);235 if ~ischar(fline)236 ieof=1;237 break;238 end239 if isempty(fline)240 break;241 end242 243 % add confidence intervals to response functions244 245 [ntokens,tokens]=fltokens(fline);246 for i=1:ndresp247 if strcmpi(tokens{1}{ 1},dresp(i).descriptor)248 dresp(i).meanci (1,1)=tokens{1}{ 5};249 dresp(i).meanci (2,1)=tokens{1}{ 6};250 dresp(i).stddevci(1,1)=tokens{1}{12};251 dresp(i).stddevci(2,1)=tokens{1}{13};252 break;253 end254 end255 end256 257 %% loop through the file to find the probabilities258 259 [fline]=findline(fidi,'Probabilities for each response function');260 if ~ischar(fline)261 return262 end263 264 display('Reading CDF''s for each response function.');265 266 while ~ieof && ~isempty(fline)267 fline=fgetl(fidi);268 if ~ischar(fline)269 ieof=1;270 323 break; 271 324 end … … 279 332 280 333 idresp=0; 281 for i=1: ndresp334 for i=1:length(dresp) 282 335 if strcmpi(tokens{1}{ 6},dresp(i).descriptor) 283 336 idresp=i; … … 285 338 end 286 339 end 287 340 if ~idresp 341 idresp=length(dresp)+1; 342 dresp(idresp).descriptor=tokens{1}{ 6}; 343 display(sprintf(' %s',dresp(idresp).descriptor)); 344 end 345 288 346 % skip column headings of cdf 289 347 … … 296 354 icdf=0; 297 355 while ~isempty(fline) && ... 298 356 ~strncmpi(fline,'Cumulative Distribution Function',32) 299 357 [ntokens,tokens]=fltokens(fline); 300 358 icdf=icdf+1; … … 313 371 end 314 372 315 %% loop through the file to find the scm 316 317 [fline]=findline(fidi,'Simple Correlation Matrix'); 318 if ~ischar(fline) 319 scm=[]; 320 return 321 end 322 323 display('Reading simple correlation matrix.'); 324 scm=corrmat(fidi,fline); 325 326 %% loop through the file to find the pcm 327 328 [fline]=findline(fidi,'Partial Correlation Matrix'); 329 if ~ischar(fline) 330 pcm=[]; 331 return 332 end 333 334 display('Reading partial correlation matrix.'); 335 pcm=corrmat(fidi,fline); 336 337 %% loop through the file to find the srcm 338 339 [fline]=findline(fidi,'Simple Rank Correlation Matrix'); 340 if ~ischar(fline) 341 srcm=[]; 342 return 343 end 344 345 display('Reading simple rank correlation matrix.'); 346 srcm=corrmat(fidi,fline); 347 348 %% loop through the file to find the prcm 349 350 [fline]=findline(fidi,'Partial Rank Correlation Matrix'); 351 if ~ischar(fline) 352 prcm=[]; 353 return 354 end 355 356 display('Reading partial rank correlation matrix.'); 357 prcm=corrmat(fidi,fline); 358 359 end 360 361 %% function to read a correlation matrix at current file position 362 363 function [cmat]=corrmat(fidi,fline) 364 365 ieof=0; 373 display(sprintf(' Number of Dakota response functions=%d.',... 374 length(dresp))); 375 376 end 377 378 %% function to find and read a correlation matrix 379 380 function [cmat]=corrmat_read(fidi,cmstr) 381 382 [fline]=findline(fidi,cmstr); 383 if ~ischar(fline) 384 cmat=struct([]); 385 return 386 end 387 388 display(['Reading ''' fline '''.']); 389 366 390 cmat.title=fline; 367 391 368 while ~i eof && ~isempty(fline)392 while ~isempty(fline) 369 393 fline=fgetl(fidi); 370 394 if ~ischar(fline) 371 ieof=1;372 395 break; 373 396 end … … 384 407 end 385 408 386 % process rows of matrix 409 % process rows of matrix, reading until blank line 387 410 388 411 nrow=0; 389 while ~ieof412 while 1 390 413 fline=fgetl(fidi); 391 414 if isempty(fline) … … 413 436 function [dresp]=nond_locrel(fidi) 414 437 438 % loop through the file to find the number of function evaluations 439 440 [nfeval]=nfeval_read(fidi); 441 442 % loop through the file to find the statistics 443 444 [dresp]=mvstats_read(fidi,struct([])); 445 446 end 447 448 %% function to find and read the number of function evaluations 449 450 function [nfeval]=nfeval_read(fidi) 451 452 [fline]=findline(fidi,'<<<<< Function evaluation summary'); 453 if ~ischar(fline) 454 return 455 end 456 457 [ntokens,tokens]=fltokens(fline); 458 nfeval=tokens{1}{5}; 459 display(sprintf(' Dakota function evaluations=%d.',nfeval)); 460 461 end 462 463 %% function to find and read the MV statistics 464 465 function [dresp]=mvstats_read(fidi,dresp) 466 415 467 ieof=0; 416 468 417 %% loop through the file to find the Dakota statistics418 419 [fline]=findline(fidi,'<<<<< Function evaluation summary');420 if ~ischar(fline)421 return422 end423 424 [ntokens,tokens]=fltokens(fline);425 nfunc=tokens{1}{5};426 display(sprintf('Dakota function evaluations=%d.',nfunc));427 428 %% loop through the file to find the statistics429 430 469 [fline]=findline(fidi,'MV Statistics for '); 431 470 if ~ischar(fline) … … 433 472 end 434 473 435 display('Reading MV statistics for each response function:');474 display('Reading MV statistics for response functions:'); 436 475 ndresp=0; 437 476 … … 441 480 % add new response function and moments 442 481 443 ndresp=ndresp+1;444 482 [ntokens,tokens]=fltokens(fline); 445 dresp( ndresp).descriptor=tokens{1}{4};446 display(sprintf(' %s',dresp(ndresp).descriptor));483 dresp(end+1).descriptor=tokens{1}{4}; 484 display(sprintf(' %s',dresp(end).descriptor)); 447 485 fline=fgetl(fidi); 448 486 [ntokens,tokens]=fltokens(fline); 449 dresp( ndresp).mean =tokens{1}{5};487 dresp(end ).mean =tokens{1}{5}; 450 488 fline=fgetl(fidi); 451 489 [ntokens,tokens]=fltokens(fline); 452 dresp( ndresp).stddev =tokens{1}{7};490 dresp(end ).stddev =tokens{1}{7}; 453 491 454 492 % read and add importance factors to response function … … 465 503 [ntokens,tokens]=fltokens(fline); 466 504 idvar=idvar+1; 467 dresp( ndresp).desvar(idvar,1)=cellstr(tokens{1}{5});468 dresp( ndresp).impfac(idvar,1)= tokens{1}{7};505 dresp(end).desvar(idvar,1)=cellstr(tokens{1}{5}); 506 dresp(end).impfac(idvar,1)= tokens{1}{7}; 469 507 470 508 fline=fgetl(fidi); … … 478 516 479 517 if ~idvar 480 display(' 481 dresp( ndresp).desvar={};482 dresp( ndresp).impfac=[];518 display(' Importance Factors not available.'); 519 dresp(end).desvar={}; 520 dresp(end).impfac=[]; 483 521 while ~ieof && ... 484 522 ~strncmpi(fline,'Cumulative Distribution Function',32) && ... … … 504 542 505 543 idresp=0; 506 for i=1: ndresp507 if strcmpi(tokens{1}{ 6},dresp(i).descriptor)544 for i=1:length(dresp) 545 if strcmpi(tokens{1}{ 6},dresp(i).descriptor) 508 546 idresp=i; 509 547 break; 510 548 end 549 end 550 if ~idresp 551 idresp=length(dresp)+1; 552 dresp(idresp).descriptor=tokens{1}{ 6}; 553 display(sprintf(' %s',dresp(idresp).descriptor)); 511 554 end 512 555 … … 540 583 541 584 if ~icdf 542 display(' 585 display(' Cumulative Distribution Function not available.'); 543 586 dresp(ndresp).cdf=[]; 544 587 while ~ieof && ... … … 555 598 end 556 599 557 display(sprintf('Number of Dakota response functions=%d.',ndresp)); 600 display(sprintf(' Number of Dakota response functions=%d.',... 601 length(dresp))); 558 602 559 603 end … … 571 615 display([' ' deblank(fline)]); 572 616 573 [fline]=findline(fidi,'<<<<< Function evaluation summary'); 574 if ~ischar(fline) 575 return 576 end 577 display([' ' deblank(fline)]); 578 579 [ntokens,tokens]=fltokens(fline); 580 nfunc=tokens{1}{5}; 581 % display(sprintf('Dakota function evaluations=%d.',nfunc)); 582 583 %% loop through the file to find the best evaluation 617 % loop through the file to find the number of function evaluations 618 619 [nfeval]=nfeval_read(fidi); 620 621 % loop through the file to find the best evaluation 622 623 [dresp]=best_read(fidi,struct([])); 624 625 end 626 627 %% function to find and read the best evaluation 628 629 function [dresp]=best_read(fidi,dresp) 584 630 585 631 [fline]=findline(fidi,'<<<<< Best '); … … 587 633 return 588 634 end 589 dresp .best=[];635 dresp(end+1).best=[]; 590 636 591 637 display('Reading values for best function evaluation:');
Note:
See TracChangeset
for help on using the changeset viewer.