Changeset 24537


Ignore:
Timestamp:
01/31/20 11:51:49 (5 years ago)
Author:
Mathieu Morlighem
Message:

CHG: minor estetics

Location:
issm/trunk-jpl/src/m/classes/qmu
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/classes/qmu/dakota_method/dakota_method.m

    r24532 r24537  
    6262                    else
    6363                        mlist={...
    64                             'dot_bfgs',...
    65                             'dot_frcg',...
    66                             'dot_mmfd',...
    67                             'dot_slp',...
    68                             'dot_sqp',...
    69                             'npsol_sqp',...
    70                             'conmin_frcg',...
    71                             'conmin_mfd',...
    72                             'optpp_cg',...
    73                             'optpp_q_newton',...
    74                             'optpp_fd_newton',...
    75                             'optpp_newton',...
    76                             'optpp_pds',...
    77                             'asynch_pattern_search',...
    78                             'coliny_cobyla',...
    79                             'coliny_direct',...
    80                             'coliny_ea',...
    81                             'coliny_pattern_search',...
    82                             'coliny_solis_wets',...
    83                             'ncsu_direct',...
    84                             'surrogate_based_local',...
    85                             'surrogate_based_global',...
    86                             'moga',...
    87                             'soga',...
    88                             'nl2sol',...
    89                             'nlssol_sqp',...
    90                             'optpp_g_newton',...
    91                             'nond_sampling',...
    92                             'nond_local_reliability',...
    93                             'nond_global_reliability',...
    94                             'nond_polynomial_chaos',...
    95                             'nond_stoch_collocation',...
    96                             'nond_evidence',...
    97                             'dace',...
    98                             'fsu_quasi_mc',...
    99                             'fsu_cvt',...
    100                             'vector_parameter_study',...
    101                             'list_parameter_study',...
    102                             'centered_parameter_study',...
    103                             'multidim_parameter_study',...
    104                                                                          'bayes_calibration',...
     64                                                                        'dot_bfgs',...
     65                                                                        'dot_frcg',...
     66                                                                        'dot_mmfd',...
     67                                                                        'dot_slp',...
     68                                                                        'dot_sqp',...
     69                                                                        'npsol_sqp',...
     70                                                                        'conmin_frcg',...
     71                                                                        'conmin_mfd',...
     72                                                                        'optpp_cg',...
     73                                                                        'optpp_q_newton',...
     74                                                                        'optpp_fd_newton',...
     75                                                                        'optpp_newton',...
     76                                                                        'optpp_pds',...
     77                                                                        'asynch_pattern_search',...
     78                                                                        'coliny_cobyla',...
     79                                                                        'coliny_direct',...
     80                                                                        'coliny_ea',...
     81                                                                        'coliny_pattern_search',...
     82                                                                        'coliny_solis_wets',...
     83                                                                        'ncsu_direct',...
     84                                                                        'surrogate_based_local',...
     85                                                                        'surrogate_based_global',...
     86                                                                        'moga',...
     87                                                                        'soga',...
     88                                                                        'nl2sol',...
     89                                                                        'nlssol_sqp',...
     90                                                                        'optpp_g_newton',...
     91                                                                        'nond_sampling',...
     92                                                                        'nond_local_reliability',...
     93                                                                        'nond_global_reliability',...
     94                                                                        'nond_polynomial_chaos',...
     95                                                                        'nond_stoch_collocation',...
     96                                                                        'nond_evidence',...
     97                                                                        'dace',...
     98                                                                        'fsu_quasi_mc',...
     99                                                                        'fsu_cvt',...
     100                                                                        'vector_parameter_study',...
     101                                                                        'list_parameter_study',...
     102                                                                        'centered_parameter_study',...
     103                                                                        'multidim_parameter_study',...
     104                                                                        'bayes_calibration',...
     105                                                                        'polynomial_chaos',...
    105106                            };
    106107
     
    112113                        end
    113114
    114 %  check for a unique match in the list of methods
    115 
     115                                                                %  check for a unique match in the list of methods
    116116                        switch length(mlist2)
    117117                            case 0
    118                                 error('Unrecognized method: ''%s''.',...
    119                                     method);
     118                                error(['Unrecognized method: ''' method '''']);
    120119                            case 1
    121120                                dm.method=mlist2{1};
     
    125124                        end
    126125
    127 %  assign the default values for the method
    128 
     126                                                                %  assign the default values for the method
    129127                        switch dm.method
    130                             case {'dot_bfgs',...
    131                                   'dot_frcg'}
     128                            case {'dot_bfgs','dot_frcg'}
    132129                                dm.type     ='dot';
    133130                                dm.variables={'continuous_design',...
     
    842839                                                                                  dm.params.diagonal=false;
    843840                                                                                  dm.params.values=[];
    844 
    845 
     841                                                                          case {'polynomial_chaos'}
     842                                                                                  dm.type     ='polynomial_chaos';
     843                                                                                  dm.params.sparse_grid_level = 3;
     844                                                                                  dm.params.dimension_adaptive = 'whoops';
     845                                                                                  dm.responses={'objective_function',...
     846                                                                                          'response_function',...
     847                                                                                          'calibration_function'};
     848                                                                                  dm.variables={'normal_uncertain',...
     849                                                                                          'uniform_uncertain',...
     850                                                                                          'continuous_state'};
    846851                            otherwise
    847852                                error('Unimplemented method: ''%s''.',dm.method);
  • issm/trunk-jpl/src/m/classes/qmu/dakota_method/dmeth_params_write.m

    r22175 r24537  
     1function dmeth_params_write(dm,fid,sbeg)
     2%DMETH_PARAMS_WRITE - write the parameters from a dakota_method object
    13%
    2 %  write the parameters from a dakota_method object.
     4%   Usage:
     5%      dmeth_params_write(dm,fid,sbeg)
    36%
    4 %  []=dmeth_params_write(dm,fid,sbeg)
    5 %
    6 function []=dmeth_params_write(dm,fid,sbeg)
    77
    88if ~isa(dm,'dakota_method')
     
    542542                end
    543543
     544        case {'polynomial_chaos'}
     545                switch dm.method
     546                                case {'polynomial_chaos'}
     547                                        param_write(fid,sbeg,'sparse_grid_level',' = ','\n',dm.params);
     548                                        fprintf(fid,'\t  dimension_adaptive p_refinement sobol\n');
     549                                        fprintf(fid,'\t  \tmax_iterations  = 3\n');
     550                                        fprintf(fid,'\t  \tconvergence_tol = 1.e-1\n');
     551                        end
     552
    544553    otherwise
    545554        error('Unrecognized method type: ''%s''.',dm.type);
     
    548557end
    549558
    550 %%  function to write a structure of parameters
    551 
    552 function []=param_struc_write(fidi,sbeg,smid,send,params)
    553 
    554 %  loop through each parameter field in the structure
    555 
    556 fnames=fieldnames(params);
    557 
    558 for i=1:numel(fnames)
    559     param_write(fidi,sbeg,fnames{i},smid,send,params);
    560 end
    561 
    562 end
    563 
     559function param_struc_write(fidi,sbeg,smid,send,params) % {{{
     560        %%  function to write a structure of parameters
     561
     562        %  loop through each parameter field in the structure
     563
     564        fnames=fieldnames(params);
     565
     566        for i=1:numel(fnames)
     567                param_write(fidi,sbeg,fnames{i},smid,send,params);
     568        end
     569
     570end %}}}
     571function param_write(fidi,sbeg,pname,smid,send,params) % {{{
    564572%%  function to write a parameter
    565573
    566 function []=param_write(fidi,sbeg,pname,smid,send,params)
    567 
    568 %  check for errors
    569 
    570 if ~isfield(params,pname)
    571     warning('param_write:param_not_found',...
    572         'Parameter ''%s'' not found in ''%s''.',...
    573         pname,inputname(6));
    574     return
    575 elseif islogical(params.(pname)) && ~params.(pname)
    576     return
    577 elseif isempty(params.(pname))
    578     warning('param_write:param_empty',...
    579         'Parameter ''%s'' requires input of type ''%s''.',...
    580         pname,class(params.(pname)));
    581     return
    582 end
    583 
    584 %  construct the parameter string based on type
    585 
    586 if     islogical(params.(pname))
    587     fprintf(fidi,[sbeg '%s' send],pname);
    588 elseif isnumeric(params.(pname))
    589     fprintf(fidi,[sbeg '%s' smid '%g'],pname,params.(pname)(1));
    590     for i=2:numel(params.(pname))
    591         fprintf(fidi,[' %g'],params.(pname)(i));
    592     end
    593     fprintf(fidi,[send]);
    594 elseif ischar   (params.(pname))
    595     fprintf(fidi,[sbeg '%s' smid '%s' send],pname,params.(pname));
    596 else
    597     warning('param_write:param_unrecog',...
    598         'Parameter ''%s'' is of unrecognized type ''%s''.',...
    599         pname,class(params.(pname)));
    600     return
    601 end
    602 
    603 end
     574        %  check for errors
     575
     576        if ~isfield(params,pname)
     577                warning('param_write:param_not_found','Parameter ''%s'' not found in ''%s''.',pname,inputname(6));
     578                return
     579        elseif islogical(params.(pname)) && ~params.(pname)
     580                return
     581        elseif isempty(params.(pname))
     582                warning('param_write:param_empty','Parameter ''%s'' requires input of type ''%s''.',...
     583                        pname,class(params.(pname)));
     584                return
     585        end
     586
     587        %  construct the parameter string based on type
     588        if islogical(params.(pname))
     589                fprintf(fidi,[sbeg '%s' send],pname);
     590        elseif isnumeric(params.(pname))
     591                fprintf(fidi,[sbeg '%s' smid '%g'],pname,params.(pname)(1));
     592                for i=2:numel(params.(pname))
     593                        fprintf(fidi,[' %g'],params.(pname)(i));
     594                end
     595                fprintf(fidi,[send]);
     596        elseif ischar   (params.(pname))
     597                fprintf(fidi,[sbeg '%s' smid '%s' send],pname,params.(pname));
     598        else
     599                warning('param_write:param_unrecog','Parameter ''%s'' is of unrecognized type ''%s''.',pname,class(params.(pname)));
     600                return
     601        end
     602
     603end% }}}
  • issm/trunk-jpl/src/m/classes/qmu/response_function.m

    r13646 r24537  
    4343            switch nargin
    4444
    45 %  create a default object
    46 
     45                                        %  create a default object
    4746                case 0
    4847
    49 %  copy the object or create the object from the input
    50 
     48                                                 %  copy the object or create the object from the input
    5149                otherwise
    5250                    if  (nargin == 1) && isa(varargin{1},'response_function')
     
    170168        function [rdesc]=dakota_write(fidi,dresp,rdesc)
    171169
    172 %  collect only the responses of the appropriate class
    173 
     170                          %  collect only the responses of the appropriate class
    174171            rf=struc_class(dresp,'response_function');
    175172
    176 %  write responses
     173                                %  write responses
     174                                [rdesc]=rlist_write(fidi,'response_functions','response_function',rf,rdesc);
     175                        end
    177176
    178             [rdesc]=rlist_write(fidi,'response_functions','response_function',rf,rdesc);
    179         end
     177                        function []=dakota_rlev_write(fidi,dresp,params)
    180178
    181         function []=dakota_rlev_write(fidi,dresp,params)
     179                                %  collect only the responses of the appropriate class
     180                                rf=struc_class(dresp,'response_function');
    182181
    183 %  collect only the responses of the appropriate class
    184 
    185             rf=struc_class(dresp,'response_function');
    186 
    187 %  write response levels
    188 
    189             rlev_write(fidi,rf,params);
     182                                %  write response levels
     183                                rlev_write(fidi,rf,params);
    190184        end
    191185    end
Note: See TracChangeset for help on using the changeset viewer.