source: issm/oecreview/Archive/24307-24683/ISSM-24536-24537.diff

Last change on this file was 24684, checked in by Mathieu Morlighem, 5 years ago

CHG: added new review

File size: 11.3 KB
RevLine 
[24684]1Index: ../trunk-jpl/src/m/classes/qmu/response_function.m
2===================================================================
3--- ../trunk-jpl/src/m/classes/qmu/response_function.m (revision 24536)
4+++ ../trunk-jpl/src/m/classes/qmu/response_function.m (revision 24537)
5@@ -42,12 +42,10 @@
6
7 switch nargin
8
9-% create a default object
10-
11+ % create a default object
12 case 0
13
14-% copy the object or create the object from the input
15-
16+ % copy the object or create the object from the input
17 otherwise
18 if (nargin == 1) && isa(varargin{1},'response_function')
19 rf=varargin{1};
20@@ -169,24 +167,20 @@
21 methods (Static)
22 function [rdesc]=dakota_write(fidi,dresp,rdesc)
23
24-% collect only the responses of the appropriate class
25-
26+ % collect only the responses of the appropriate class
27 rf=struc_class(dresp,'response_function');
28
29-% write responses
30+ % write responses
31+ [rdesc]=rlist_write(fidi,'response_functions','response_function',rf,rdesc);
32+ end
33
34- [rdesc]=rlist_write(fidi,'response_functions','response_function',rf,rdesc);
35- end
36+ function []=dakota_rlev_write(fidi,dresp,params)
37
38- function []=dakota_rlev_write(fidi,dresp,params)
39+ % collect only the responses of the appropriate class
40+ rf=struc_class(dresp,'response_function');
41
42-% collect only the responses of the appropriate class
43-
44- rf=struc_class(dresp,'response_function');
45-
46-% write response levels
47-
48- rlev_write(fidi,rf,params);
49+ % write response levels
50+ rlev_write(fidi,rf,params);
51 end
52 end
53 end
54Index: ../trunk-jpl/src/m/classes/qmu/dakota_method/dakota_method.m
55===================================================================
56--- ../trunk-jpl/src/m/classes/qmu/dakota_method/dakota_method.m (revision 24536)
57+++ ../trunk-jpl/src/m/classes/qmu/dakota_method/dakota_method.m (revision 24537)
58@@ -61,47 +61,48 @@
59 dm=method;
60 else
61 mlist={...
62- 'dot_bfgs',...
63- 'dot_frcg',...
64- 'dot_mmfd',...
65- 'dot_slp',...
66- 'dot_sqp',...
67- 'npsol_sqp',...
68- 'conmin_frcg',...
69- 'conmin_mfd',...
70- 'optpp_cg',...
71- 'optpp_q_newton',...
72- 'optpp_fd_newton',...
73- 'optpp_newton',...
74- 'optpp_pds',...
75- 'asynch_pattern_search',...
76- 'coliny_cobyla',...
77- 'coliny_direct',...
78- 'coliny_ea',...
79- 'coliny_pattern_search',...
80- 'coliny_solis_wets',...
81- 'ncsu_direct',...
82- 'surrogate_based_local',...
83- 'surrogate_based_global',...
84- 'moga',...
85- 'soga',...
86- 'nl2sol',...
87- 'nlssol_sqp',...
88- 'optpp_g_newton',...
89- 'nond_sampling',...
90- 'nond_local_reliability',...
91- 'nond_global_reliability',...
92- 'nond_polynomial_chaos',...
93- 'nond_stoch_collocation',...
94- 'nond_evidence',...
95- 'dace',...
96- 'fsu_quasi_mc',...
97- 'fsu_cvt',...
98- 'vector_parameter_study',...
99- 'list_parameter_study',...
100- 'centered_parameter_study',...
101- 'multidim_parameter_study',...
102- 'bayes_calibration',...
103+ 'dot_bfgs',...
104+ 'dot_frcg',...
105+ 'dot_mmfd',...
106+ 'dot_slp',...
107+ 'dot_sqp',...
108+ 'npsol_sqp',...
109+ 'conmin_frcg',...
110+ 'conmin_mfd',...
111+ 'optpp_cg',...
112+ 'optpp_q_newton',...
113+ 'optpp_fd_newton',...
114+ 'optpp_newton',...
115+ 'optpp_pds',...
116+ 'asynch_pattern_search',...
117+ 'coliny_cobyla',...
118+ 'coliny_direct',...
119+ 'coliny_ea',...
120+ 'coliny_pattern_search',...
121+ 'coliny_solis_wets',...
122+ 'ncsu_direct',...
123+ 'surrogate_based_local',...
124+ 'surrogate_based_global',...
125+ 'moga',...
126+ 'soga',...
127+ 'nl2sol',...
128+ 'nlssol_sqp',...
129+ 'optpp_g_newton',...
130+ 'nond_sampling',...
131+ 'nond_local_reliability',...
132+ 'nond_global_reliability',...
133+ 'nond_polynomial_chaos',...
134+ 'nond_stoch_collocation',...
135+ 'nond_evidence',...
136+ 'dace',...
137+ 'fsu_quasi_mc',...
138+ 'fsu_cvt',...
139+ 'vector_parameter_study',...
140+ 'list_parameter_study',...
141+ 'centered_parameter_study',...
142+ 'multidim_parameter_study',...
143+ 'bayes_calibration',...
144+ 'polynomial_chaos',...
145 };
146
147 mlist2={};
148@@ -111,12 +112,10 @@
149 end
150 end
151
152-% check for a unique match in the list of methods
153-
154+ % check for a unique match in the list of methods
155 switch length(mlist2)
156 case 0
157- error('Unrecognized method: ''%s''.',...
158- method);
159+ error(['Unrecognized method: ''' method '''']);
160 case 1
161 dm.method=mlist2{1};
162 otherwise
163@@ -124,11 +123,9 @@
164 method,string_cell(mlist2));
165 end
166
167-% assign the default values for the method
168-
169+ % assign the default values for the method
170 switch dm.method
171- case {'dot_bfgs',...
172- 'dot_frcg'}
173+ case {'dot_bfgs','dot_frcg'}
174 dm.type ='dot';
175 dm.variables={'continuous_design',...
176 'continuous_state'};
177@@ -841,8 +838,16 @@
178 dm.params.proposal_covariance=false;
179 dm.params.diagonal=false;
180 dm.params.values=[];
181-
182-
183+ case {'polynomial_chaos'}
184+ dm.type ='polynomial_chaos';
185+ dm.params.sparse_grid_level = 3;
186+ dm.params.dimension_adaptive = 'whoops';
187+ dm.responses={'objective_function',...
188+ 'response_function',...
189+ 'calibration_function'};
190+ dm.variables={'normal_uncertain',...
191+ 'uniform_uncertain',...
192+ 'continuous_state'};
193 otherwise
194 error('Unimplemented method: ''%s''.',dm.method);
195 end
196Index: ../trunk-jpl/src/m/classes/qmu/dakota_method/dmeth_params_write.m
197===================================================================
198--- ../trunk-jpl/src/m/classes/qmu/dakota_method/dmeth_params_write.m (revision 24536)
199+++ ../trunk-jpl/src/m/classes/qmu/dakota_method/dmeth_params_write.m (revision 24537)
200@@ -1,9 +1,9 @@
201+function dmeth_params_write(dm,fid,sbeg)
202+%DMETH_PARAMS_WRITE - write the parameters from a dakota_method object
203 %
204-% write the parameters from a dakota_method object.
205+% Usage:
206+% dmeth_params_write(dm,fid,sbeg)
207 %
208-% []=dmeth_params_write(dm,fid,sbeg)
209-%
210-function []=dmeth_params_write(dm,fid,sbeg)
211
212 if ~isa(dm,'dakota_method')
213 error('Object ''%s'' is a ''%s'' class object, not ''%s''.',...
214@@ -541,6 +541,15 @@
215 param_write(fid,sbeg,'values',' = ','\n',dm.params);
216 end
217
218+ case {'polynomial_chaos'}
219+ switch dm.method
220+ case {'polynomial_chaos'}
221+ param_write(fid,sbeg,'sparse_grid_level',' = ','\n',dm.params);
222+ fprintf(fid,'\t dimension_adaptive p_refinement sobol\n');
223+ fprintf(fid,'\t \tmax_iterations = 3\n');
224+ fprintf(fid,'\t \tconvergence_tol = 1.e-1\n');
225+ end
226+
227 otherwise
228 error('Unrecognized method type: ''%s''.',dm.type);
229 end
230@@ -547,57 +556,48 @@
231
232 end
233
234-%% function to write a structure of parameters
235+function param_struc_write(fidi,sbeg,smid,send,params) % {{{
236+ %% function to write a structure of parameters
237
238-function []=param_struc_write(fidi,sbeg,smid,send,params)
239+ % loop through each parameter field in the structure
240
241-% loop through each parameter field in the structure
242+ fnames=fieldnames(params);
243
244-fnames=fieldnames(params);
245+ for i=1:numel(fnames)
246+ param_write(fidi,sbeg,fnames{i},smid,send,params);
247+ end
248
249-for i=1:numel(fnames)
250- param_write(fidi,sbeg,fnames{i},smid,send,params);
251-end
252-
253-end
254-
255+end %}}}
256+function param_write(fidi,sbeg,pname,smid,send,params) % {{{
257 %% function to write a parameter
258
259-function []=param_write(fidi,sbeg,pname,smid,send,params)
260+ % check for errors
261
262-% check for errors
263+ if ~isfield(params,pname)
264+ warning('param_write:param_not_found','Parameter ''%s'' not found in ''%s''.',pname,inputname(6));
265+ return
266+ elseif islogical(params.(pname)) && ~params.(pname)
267+ return
268+ elseif isempty(params.(pname))
269+ warning('param_write:param_empty','Parameter ''%s'' requires input of type ''%s''.',...
270+ pname,class(params.(pname)));
271+ return
272+ end
273
274-if ~isfield(params,pname)
275- warning('param_write:param_not_found',...
276- 'Parameter ''%s'' not found in ''%s''.',...
277- pname,inputname(6));
278- return
279-elseif islogical(params.(pname)) && ~params.(pname)
280- return
281-elseif isempty(params.(pname))
282- warning('param_write:param_empty',...
283- 'Parameter ''%s'' requires input of type ''%s''.',...
284- pname,class(params.(pname)));
285- return
286-end
287+ % construct the parameter string based on type
288+ if islogical(params.(pname))
289+ fprintf(fidi,[sbeg '%s' send],pname);
290+ elseif isnumeric(params.(pname))
291+ fprintf(fidi,[sbeg '%s' smid '%g'],pname,params.(pname)(1));
292+ for i=2:numel(params.(pname))
293+ fprintf(fidi,[' %g'],params.(pname)(i));
294+ end
295+ fprintf(fidi,[send]);
296+ elseif ischar (params.(pname))
297+ fprintf(fidi,[sbeg '%s' smid '%s' send],pname,params.(pname));
298+ else
299+ warning('param_write:param_unrecog','Parameter ''%s'' is of unrecognized type ''%s''.',pname,class(params.(pname)));
300+ return
301+ end
302
303-% construct the parameter string based on type
304-
305-if islogical(params.(pname))
306- fprintf(fidi,[sbeg '%s' send],pname);
307-elseif isnumeric(params.(pname))
308- fprintf(fidi,[sbeg '%s' smid '%g'],pname,params.(pname)(1));
309- for i=2:numel(params.(pname))
310- fprintf(fidi,[' %g'],params.(pname)(i));
311- end
312- fprintf(fidi,[send]);
313-elseif ischar (params.(pname))
314- fprintf(fidi,[sbeg '%s' smid '%s' send],pname,params.(pname));
315-else
316- warning('param_write:param_unrecog',...
317- 'Parameter ''%s'' is of unrecognized type ''%s''.',...
318- pname,class(params.(pname)));
319- return
320-end
321-
322-end
323+end% }}}
Note: See TracBrowser for help on using the repository browser.