Index: ../trunk-jpl/src/m/classes/qmu/response_function.m =================================================================== --- ../trunk-jpl/src/m/classes/qmu/response_function.m (revision 24536) +++ ../trunk-jpl/src/m/classes/qmu/response_function.m (revision 24537) @@ -42,12 +42,10 @@ switch nargin -% create a default object - + % create a default object case 0 -% copy the object or create the object from the input - + % copy the object or create the object from the input otherwise if (nargin == 1) && isa(varargin{1},'response_function') rf=varargin{1}; @@ -169,24 +167,20 @@ methods (Static) function [rdesc]=dakota_write(fidi,dresp,rdesc) -% collect only the responses of the appropriate class - + % collect only the responses of the appropriate class rf=struc_class(dresp,'response_function'); -% write responses + % write responses + [rdesc]=rlist_write(fidi,'response_functions','response_function',rf,rdesc); + end - [rdesc]=rlist_write(fidi,'response_functions','response_function',rf,rdesc); - end + function []=dakota_rlev_write(fidi,dresp,params) - function []=dakota_rlev_write(fidi,dresp,params) + % collect only the responses of the appropriate class + rf=struc_class(dresp,'response_function'); -% collect only the responses of the appropriate class - - rf=struc_class(dresp,'response_function'); - -% write response levels - - rlev_write(fidi,rf,params); + % write response levels + rlev_write(fidi,rf,params); end end end Index: ../trunk-jpl/src/m/classes/qmu/dakota_method/dakota_method.m =================================================================== --- ../trunk-jpl/src/m/classes/qmu/dakota_method/dakota_method.m (revision 24536) +++ ../trunk-jpl/src/m/classes/qmu/dakota_method/dakota_method.m (revision 24537) @@ -61,47 +61,48 @@ dm=method; else mlist={... - 'dot_bfgs',... - 'dot_frcg',... - 'dot_mmfd',... - 'dot_slp',... - 'dot_sqp',... - 'npsol_sqp',... - 'conmin_frcg',... - 'conmin_mfd',... - 'optpp_cg',... - 'optpp_q_newton',... - 'optpp_fd_newton',... - 'optpp_newton',... - 'optpp_pds',... - 'asynch_pattern_search',... - 'coliny_cobyla',... - 'coliny_direct',... - 'coliny_ea',... - 'coliny_pattern_search',... - 'coliny_solis_wets',... - 'ncsu_direct',... - 'surrogate_based_local',... - 'surrogate_based_global',... - 'moga',... - 'soga',... - 'nl2sol',... - 'nlssol_sqp',... - 'optpp_g_newton',... - 'nond_sampling',... - 'nond_local_reliability',... - 'nond_global_reliability',... - 'nond_polynomial_chaos',... - 'nond_stoch_collocation',... - 'nond_evidence',... - 'dace',... - 'fsu_quasi_mc',... - 'fsu_cvt',... - 'vector_parameter_study',... - 'list_parameter_study',... - 'centered_parameter_study',... - 'multidim_parameter_study',... - 'bayes_calibration',... + 'dot_bfgs',... + 'dot_frcg',... + 'dot_mmfd',... + 'dot_slp',... + 'dot_sqp',... + 'npsol_sqp',... + 'conmin_frcg',... + 'conmin_mfd',... + 'optpp_cg',... + 'optpp_q_newton',... + 'optpp_fd_newton',... + 'optpp_newton',... + 'optpp_pds',... + 'asynch_pattern_search',... + 'coliny_cobyla',... + 'coliny_direct',... + 'coliny_ea',... + 'coliny_pattern_search',... + 'coliny_solis_wets',... + 'ncsu_direct',... + 'surrogate_based_local',... + 'surrogate_based_global',... + 'moga',... + 'soga',... + 'nl2sol',... + 'nlssol_sqp',... + 'optpp_g_newton',... + 'nond_sampling',... + 'nond_local_reliability',... + 'nond_global_reliability',... + 'nond_polynomial_chaos',... + 'nond_stoch_collocation',... + 'nond_evidence',... + 'dace',... + 'fsu_quasi_mc',... + 'fsu_cvt',... + 'vector_parameter_study',... + 'list_parameter_study',... + 'centered_parameter_study',... + 'multidim_parameter_study',... + 'bayes_calibration',... + 'polynomial_chaos',... }; mlist2={}; @@ -111,12 +112,10 @@ end end -% check for a unique match in the list of methods - + % check for a unique match in the list of methods switch length(mlist2) case 0 - error('Unrecognized method: ''%s''.',... - method); + error(['Unrecognized method: ''' method '''']); case 1 dm.method=mlist2{1}; otherwise @@ -124,11 +123,9 @@ method,string_cell(mlist2)); end -% assign the default values for the method - + % assign the default values for the method switch dm.method - case {'dot_bfgs',... - 'dot_frcg'} + case {'dot_bfgs','dot_frcg'} dm.type ='dot'; dm.variables={'continuous_design',... 'continuous_state'}; @@ -841,8 +838,16 @@ dm.params.proposal_covariance=false; dm.params.diagonal=false; dm.params.values=[]; - - + case {'polynomial_chaos'} + dm.type ='polynomial_chaos'; + dm.params.sparse_grid_level = 3; + dm.params.dimension_adaptive = 'whoops'; + dm.responses={'objective_function',... + 'response_function',... + 'calibration_function'}; + dm.variables={'normal_uncertain',... + 'uniform_uncertain',... + 'continuous_state'}; otherwise error('Unimplemented method: ''%s''.',dm.method); end Index: ../trunk-jpl/src/m/classes/qmu/dakota_method/dmeth_params_write.m =================================================================== --- ../trunk-jpl/src/m/classes/qmu/dakota_method/dmeth_params_write.m (revision 24536) +++ ../trunk-jpl/src/m/classes/qmu/dakota_method/dmeth_params_write.m (revision 24537) @@ -1,9 +1,9 @@ +function dmeth_params_write(dm,fid,sbeg) +%DMETH_PARAMS_WRITE - write the parameters from a dakota_method object % -% write the parameters from a dakota_method object. +% Usage: +% dmeth_params_write(dm,fid,sbeg) % -% []=dmeth_params_write(dm,fid,sbeg) -% -function []=dmeth_params_write(dm,fid,sbeg) if ~isa(dm,'dakota_method') error('Object ''%s'' is a ''%s'' class object, not ''%s''.',... @@ -541,6 +541,15 @@ param_write(fid,sbeg,'values',' = ','\n',dm.params); end + case {'polynomial_chaos'} + switch dm.method + case {'polynomial_chaos'} + param_write(fid,sbeg,'sparse_grid_level',' = ','\n',dm.params); + fprintf(fid,'\t dimension_adaptive p_refinement sobol\n'); + fprintf(fid,'\t \tmax_iterations = 3\n'); + fprintf(fid,'\t \tconvergence_tol = 1.e-1\n'); + end + otherwise error('Unrecognized method type: ''%s''.',dm.type); end @@ -547,57 +556,48 @@ end -%% function to write a structure of parameters +function param_struc_write(fidi,sbeg,smid,send,params) % {{{ + %% function to write a structure of parameters -function []=param_struc_write(fidi,sbeg,smid,send,params) + % loop through each parameter field in the structure -% loop through each parameter field in the structure + fnames=fieldnames(params); -fnames=fieldnames(params); + for i=1:numel(fnames) + param_write(fidi,sbeg,fnames{i},smid,send,params); + end -for i=1:numel(fnames) - param_write(fidi,sbeg,fnames{i},smid,send,params); -end - -end - +end %}}} +function param_write(fidi,sbeg,pname,smid,send,params) % {{{ %% function to write a parameter -function []=param_write(fidi,sbeg,pname,smid,send,params) + % check for errors -% check for errors + if ~isfield(params,pname) + warning('param_write:param_not_found','Parameter ''%s'' not found in ''%s''.',pname,inputname(6)); + return + elseif islogical(params.(pname)) && ~params.(pname) + return + elseif isempty(params.(pname)) + warning('param_write:param_empty','Parameter ''%s'' requires input of type ''%s''.',... + pname,class(params.(pname))); + return + end -if ~isfield(params,pname) - warning('param_write:param_not_found',... - 'Parameter ''%s'' not found in ''%s''.',... - pname,inputname(6)); - return -elseif islogical(params.(pname)) && ~params.(pname) - return -elseif isempty(params.(pname)) - warning('param_write:param_empty',... - 'Parameter ''%s'' requires input of type ''%s''.',... - pname,class(params.(pname))); - return -end + % construct the parameter string based on type + if islogical(params.(pname)) + fprintf(fidi,[sbeg '%s' send],pname); + elseif isnumeric(params.(pname)) + fprintf(fidi,[sbeg '%s' smid '%g'],pname,params.(pname)(1)); + for i=2:numel(params.(pname)) + fprintf(fidi,[' %g'],params.(pname)(i)); + end + fprintf(fidi,[send]); + elseif ischar (params.(pname)) + fprintf(fidi,[sbeg '%s' smid '%s' send],pname,params.(pname)); + else + warning('param_write:param_unrecog','Parameter ''%s'' is of unrecognized type ''%s''.',pname,class(params.(pname))); + return + end -% construct the parameter string based on type - -if islogical(params.(pname)) - fprintf(fidi,[sbeg '%s' send],pname); -elseif isnumeric(params.(pname)) - fprintf(fidi,[sbeg '%s' smid '%g'],pname,params.(pname)(1)); - for i=2:numel(params.(pname)) - fprintf(fidi,[' %g'],params.(pname)(i)); - end - fprintf(fidi,[send]); -elseif ischar (params.(pname)) - fprintf(fidi,[sbeg '%s' smid '%s' send],pname,params.(pname)); -else - warning('param_write:param_unrecog',... - 'Parameter ''%s'' is of unrecognized type ''%s''.',... - pname,class(params.(pname))); - return -end - -end +end% }}}