Changeset 27750
- Timestamp:
- 05/12/23 23:08:06 (23 months ago)
- Location:
- issm/branches/trunk-larour-SLPS2022/src/m
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/branches/trunk-larour-SLPS2022/src/m/classes/qmu.m
r26339 r27750 226 226 return; 227 227 end 228 WriteData(fid,prefix,'data',self.method.params.samples,'name','md.qmu.method.params.samples','format','Integer'); 228 if strcmpi(self.method.method,'nond_sampling'), 229 WriteData(fid,prefix,'data',self.method.params.samples,'name','md.qmu.method.params.samples','format','Integer'); 230 end 229 231 WriteData(fid,prefix,'object',self,'fieldname','numberofresponses','format','Integer'); 230 232 WriteData(fid,prefix,'object',self,'fieldname','variabledescriptors','format','StringArray'); -
issm/branches/trunk-larour-SLPS2022/src/m/classes/qmu/continuous_design.m
r24820 r27750 38 38 scale_type='none'; 39 39 scale = 1.; 40 partition = []; 41 nsteps = 0; 40 42 end 41 43 42 44 methods 43 function [cdv]=continuous_design(varargin) 44 45 switch nargin 46 47 % create a default object 48 49 case 0 50 51 % copy the object 52 53 case 1 54 if isa(varargin{1},'continuous_design') 55 cdv=varargin{1}; 56 else 57 error('Object ''%s'' is a ''%s'' class object, not ''%s''.',... 58 inputname(1),class(varargin{1}),'continuous_design'); 59 end 60 61 % create the object from the input 62 63 otherwise 64 asizec=num2cell(array_size(varargin{1:min(nargin,6)})); 65 cdv(asizec{:})=continuous_design; 66 clear asizec 67 68 if ischar(varargin{1}) 69 varargin{1}=cellstr(varargin{1}); 70 end 71 for i=1:numel(cdv) 72 if (numel(varargin{1}) > 1) 73 cdv(i).descriptor=varargin{1}{i}; 74 else 75 cdv(i).descriptor=[char(varargin{1}) string_dim(cdv,i,'vector')]; 76 end 77 end 78 79 if (nargin >= 2) 80 for i=1:numel(cdv) 81 if (numel(varargin{2}) > 1) 82 cdv(i).initpt =varargin{2}(i); 83 else 84 cdv(i).initpt =varargin{2}; 85 end 86 end 87 if (nargin >= 3) 88 for i=1:numel(cdv) 89 if (numel(varargin{3}) > 1) 90 cdv(i).lower =varargin{3}(i); 91 else 92 cdv(i).lower =varargin{3}; 93 end 94 end 95 if (nargin >= 4) 96 for i=1:numel(cdv) 97 if (numel(varargin{4}) > 1) 98 cdv(i).upper =varargin{4}(i); 99 else 100 cdv(i).upper =varargin{4}; 101 end 102 end 103 if (nargin >= 5) 104 if ischar(varargin{5}) 105 varargin{5}=cellstr(varargin{5}); 106 end 107 for i=1:numel(cdv) 108 if (numel(varargin{5}) > 1) 109 cdv(i).scale_type=varargin{5}{i}; 110 else 111 cdv(i).scale_type=char(varargin{5}); 112 end 113 end 114 if (nargin >= 6) 115 for i=1:numel(cdv) 116 if (numel(varargin{6}) > 1) 117 cdv(i).scale =varargin{6}(i); 118 else 119 cdv(i).scale =varargin{6}; 120 end 121 end 122 if (nargin > 6) 123 warning('continuous_design:extra_arg',... 124 'Extra arguments for object of class ''%s''.',... 125 class(cdv)); 126 end 127 end 128 end 129 end 130 end 131 end 132 end 133 134 end 135 136 function []=disp(cdv) 137 138 % display the object 139 140 disp(sprintf('\n')); 141 for i=1:numel(cdv) 142 disp(sprintf('class ''%s'' object ''%s%s'' = \n',... 143 class(cdv),inputname(1),string_dim(cdv,i))); 144 disp(sprintf(' descriptor: ''%s''' ,cdv(i).descriptor)); 145 disp(sprintf(' initpt: %g' ,cdv(i).initpt)); 146 disp(sprintf(' lower: %g' ,cdv(i).lower)); 147 disp(sprintf(' upper: %g' ,cdv(i).upper)); 148 disp(sprintf(' scale_type: ''%s''' ,cdv(i).scale_type)); 149 disp(sprintf(' scale: %g\n' ,cdv(i).scale)); 150 end 151 152 end 153 154 function [desc] =prop_desc(cdv,dstr) 45 function self=continuous_design(varargin) % {{{ 46 47 %recover options: 48 options=pairoptions(varargin{:}); 49 50 %initialize fields: 51 self.descriptor=getfieldvalue(options,'descriptor'); 52 self.initpt=getfieldvalue(options,'initpt'); 53 self.lower=getfieldvalue(options,'lower'); 54 self.upper=getfieldvalue(options,'upper'); 55 self.scale_type=getfieldvalue(options,'scale_type','none'); 56 self.scale=getfieldvalue(options,'scale',1.); 57 58 %if the variable is scaled, a partition vector should have been 59 %supplied, and that partition vector should have as many partitions 60 %as the upper and lower vectors: 61 if self.isscaled() | self.isdistributed(), 62 self.partition=getfieldvalue(options,'partition'); 63 self.nsteps=getfieldvalue(options,'nsteps',1); 64 npart=qmupart2npart(self.partition); 65 if npart~=size(self.upper,1), 66 error(['continuous_design constructor: for the scaled variable ' self.descriptor ' the row size of the upper field should be identical to the number of partitions']); 67 end 68 if npart~=size(self.lower,1), 69 error(['continuous_design constructor: for the scaled variable ' self.descriptor ' the row size of the lower field should be identical to the number of partitions']); 70 end 71 if self.nsteps~=size(self.upper,2), 72 error(['continuous_design constructor: for the scaled variable ' self.descriptor ' the col size of the upper field should be identical to the number of time steps']); 73 end 74 if self.nsteps~=size(self.lower,2), 75 error(['continuous_design constructor: for the scaled variable ' self.descriptor ' the col size of the lower field should be identical to the number of time steps']); 76 end 77 78 end 79 80 81 82 end % }}} 83 function disp(self) % {{{ 84 85 disp(sprintf(' continuous design variable: ')); 86 fielddisplay(self,'descriptor','name tag'); 87 fielddisplay(self,'initpt','initial point'); 88 fielddisplay(self,'lower','lower values'); 89 fielddisplay(self,'upper','upper values'); 90 fielddisplay(self,'scale_type','scale type'); 91 fielddisplay(self,'scale','scale'); 92 93 end % }}} 94 function md=checkconsistency(self,md,solution,analyses) % {{{ 95 96 md = checkfield(md,'field',self.upper,'fieldname','continuous_design.upper','NaN',1,'Inf',1,'>=',0); 97 md = checkfield(md,'field',self.lower,'fieldname','continuous_design.lower','NaN',1,'Inf',1,'>=',0); 98 if self.isscaled(), 99 if isempty(self.partition), 100 error('continuous_design is a scaled variable, but it''s missing a partition vector'); 101 end 102 %better have a partition vector that has as many partitions as loer's size: 103 if size(self.lower,1)~=partition_npart(self.partition), 104 error('continuous_design error message: row size of lower and partition size should be identical'); 105 end 106 if size(self.upper,1)~=partition_npart(self.partition), 107 error('continuous_design error message: row size of upper and partition size should be identical'); 108 end 109 %we need as steps in lower and upper as there are time steps: 110 if size(self.lower,2)~=self.nsteps, 111 error('continuous_design error message: col size of lower and number of time steps should be identical'); 112 end 113 if size(self.upper,2)~=self.nsteps, 114 error('continuous_design error message: col size of upper and number of time steps should be identical'); 115 end 116 117 md = checkfield(md,'field',self.partition,'fieldname','continuous_design.partition','NaN',1,'Inf',1,'>=',-1,'numel',[md.mesh.numberofvertices,md.mesh.numberofelements]); 118 if size(self.partition,2)>1, 119 error('continuous_design error message: partition should be a column vector'); 120 end 121 partcheck=unique(self.partition); 122 partmin=min(partcheck); 123 partmax=max(partcheck); 124 if partmax<-1, 125 error('continuous_design error message: partition vector''s min value should be -1 (for no partition), or start at 0'); 126 end 127 nmax=max(md.mesh.numberofelements,md.mesh.numberofvertices); 128 if partmax>nmax, 129 error('continuous_design error message: partition vector''s values cannot go over the number of vertices or elements'); 130 end 131 end 132 end % }}} 133 function [desc] =prop_desc(cdv,dstr) % {{{ 155 134 desc=cell(1,numel(cdv)); 156 135 for i=1:numel(cdv) … … 166 145 end 167 146 desc=allempty(desc); 168 end 169 function [initpt]=prop_initpt(cdv) 147 end % }}} 148 function [initpt]=prop_initpt(cdv) % {{{ 170 149 initpt=zeros(1,numel(cdv)); 171 150 for i=1:numel(cdv) … … 173 152 end 174 153 initpt=allequal(initpt,0.); 175 end 176 function [lower] =prop_lower(cdv) 154 end % }}} 155 function [lower] =prop_lower(cdv) % {{{ 177 156 lower=zeros(1,numel(cdv)); 178 157 for i=1:numel(cdv) … … 180 159 end 181 160 lower=allequal(lower,-Inf); 182 end 183 function [upper] =prop_upper(cdv) 161 end % }}} 162 function [upper] =prop_upper(cdv) % {{{ 184 163 upper=zeros(1,numel(cdv)); 185 164 for i=1:numel(cdv) … … 187 166 end 188 167 upper=allequal(upper, Inf); 189 end 190 function [mean] =prop_mean(cdv) 168 end % }}} 169 function [mean] =prop_mean(cdv) % {{{ 191 170 mean=[]; 192 end 193 function [stddev]=prop_stddev(cdv) 171 end % }}} 172 function [stddev]=prop_stddev(cdv) % {{{ 194 173 stddev=[]; 195 end 196 function [initst]=prop_initst(cdv) 174 end % }}} 175 function [initst]=prop_initst(cdv) % {{{ 197 176 initst=[]; 198 end 199 function [stype] =prop_stype(cdv) 177 end % }}} 178 function [stype] =prop_stype(cdv) % {{{ 200 179 stype=cell(1,numel(cdv)); 201 180 for i=1:numel(cdv) … … 203 182 end 204 183 stype=allequal(stype,'none'); 205 end 206 function [scale] =prop_scale(cdv) 184 end % }}} 185 function [scale] =prop_scale(cdv) % {{{ 207 186 scale=zeros(1,numel(cdv)); 208 187 for i=1:numel(cdv) … … 210 189 end 211 190 scale=allequal(scale,1.); 212 end 191 end % }}} 213 192 function [abscissas] =prop_abscissas(hbu) % {{{ 214 193 abscissas=[]; … … 220 199 pairs_per_variable=[]; 221 200 end % }}} 222 function checkconsistency(self,md,solution,analyses) % {{{ 223 end % }}} 224 201 %new methods: 202 function distributed=isdistributed(self) % {{{ 203 if strncmp(self.descriptor,'distributed_',12), 204 distributed=1; 205 else 206 distributed=0; 207 end 208 end % }}} 209 function scaled=isscaled(self) % {{{ 210 if strncmp(self.descriptor,'scaled_',7), 211 scaled=1; 212 else 213 scaled=0; 214 end 215 end % }}} 225 216 end 226 217 227 218 methods (Static) 228 function []=dakota_write(fidi,dvar) 229 219 function []=dakota_write(fidi,dvar) % {{{ 230 220 % collect only the variables of the appropriate class 231 232 221 cdv=struc_class(dvar,'continuous_design'); 233 234 222 % write variables 235 236 223 vlist_write(fidi,'continuous_design','cdv',cdv); 237 end 224 end % }}} 238 225 end 239 226 end -
issm/branches/trunk-larour-SLPS2022/src/m/classes/qmu/normal_uncertain.m
r25688 r27750 34 34 %supplied, and that partition vector should have as many partitions 35 35 %as the mean and stddev vectors: 36 if self.isscaled() ,36 if self.isscaled() | self.isdistributed(), 37 37 self.partition=getfieldvalue(options,'partition'); 38 38 self.nsteps=getfieldvalue(options,'nsteps',1); -
issm/branches/trunk-larour-SLPS2022/src/m/qmu/dakota_m_write.m
r25726 r27750 155 155 156 156 function [ixc]=vsets_write(fidm,ixc,dvar,variables,params,varargin) 157 158 157 for i=1:length(variables) 159 158 if isfield(dvar,variables{i}) -
issm/branches/trunk-larour-SLPS2022/src/m/qmu/postqmu.m
r25806 r27750 47 47 end 48 48 end 49 if strcmpi(md.qmu.method.method,'list_parameter_study'), 50 dakotaresults.modelresults={}; 51 md2=md; 52 md2.qmu.isdakota=0; 53 for i=md.qmu.method.params.list_of_points, 54 disp(['Reading qmu file ' md2.miscellaneous.name '.outbin.' num2str(i)]); 55 md2=loadresultsfromdisk(md2,[md2.miscellaneous.name '.outbin.' num2str(i)]); 56 dakotaresults.modelresults{end+1}=md2.results; 57 end 58 end 59 49 60 end 50 61 if ~strcmpi(md.qmu.statistics.method(1).name,'None'), -
issm/branches/trunk-larour-SLPS2022/src/m/qmu/preqmu.m
r25688 r27750 23 23 24 24 %retrieve variables and resposnes for this particular analysis. 25 variables=md.qmu.variables(ivar) ;25 variables=md.qmu.variables(ivar) 26 26 responses=md.qmu.responses(iresp); 27 27 -
issm/branches/trunk-larour-SLPS2022/src/m/qmu/setupdesign/QmuSetupVariables.m
r25223 r27750 38 38 error('QmuSetupVariables error message: stddev and mean fields should have the same number of cols as the number of time steps'); 39 39 end 40 40 elseif isa(variables,'continuous_design'), 41 nupper=size(variables.upper,1); 42 nlower=size(variables.lower,1); 43 if (nupper ~= npart || nlower ~=npart), 44 error('QmuSetupVariables error message: upper and lower fields should have the same number of rows as the number of partitions'); 45 end 46 nupper=size(variables.upper,2); 47 nlower=size(variables.lower,2); 48 if (nupper ~= nt || nlower ~=nt), 49 error('QmuSetupVariables error message: upper and lower fields should have the same number of cols as the number of time steps'); 50 end 41 51 end 42 52 … … 53 63 dvar(end ).stddev=variables.stddev(j); 54 64 dvar(end ).mean=variables.mean(j); 65 elseif isa(variables,'continuous_design'), 66 dvar(end ).upper=variables.upper(j); 67 dvar(end ).lower=variables.lower(j); 68 dvar(end ).initpt=variables.initpt(j); 55 69 end 56 70 end … … 66 80 dvar(end ).stddev=variables.stddev(j,k); 67 81 dvar(end ).mean=variables.mean(j,k); 82 elseif isa(variables,'continuous_design'), 83 dvar(end ).upper=variables.upper(j,k); 84 dvar(end ).lower=variables.lower(j,k); 85 dvar(end ).initpt=variables.initpt(j,k); 68 86 end 69 87 end … … 90 108 if (nstddev ~= npart || nmean ~=npart), 91 109 error('QmuSetupVariables error message: stddev and mean fields should have the same number of rows as the number of partitions'); 110 end 111 elseif isa(variables,'continuous_design'), 112 nupper=size(variables.upper,1); 113 nlower=size(variables.lower,1); 114 if (nupper ~= npart || nlower ~=npart), 115 error('QmuSetupVariables error message: upper and lower fields should have the same number of rows as the number of partitions'); 92 116 end 93 117 elseif isa(variables,'histogram_bin_uncertain'), … … 119 143 dvar(end ).mean=variables.mean(j); 120 144 dvar(end ).partition=[]; 145 elseif isa(variables,'continuous_design'), 146 dvar(end ).upper=variables.upper(j); 147 dvar(end ).lower=variables.lower(j); 148 dvar(end ).initpt=variables.initpt(j); 149 dvar(end ).partition=[]; 121 150 elseif isa(variables,'histogram_bin_uncertain'), 122 151 dvar(end).pairs_per_variable=variables.pairs_per_variable(j); -
issm/branches/trunk-larour-SLPS2022/src/m/qmu/vlist_write.m
r24870 r27750 3 3 % 4 4 function []=vlist_write(fidi,cstring,cstring2,dvar) 5 6 5 if isempty(dvar) 7 6 return; -
issm/branches/trunk-larour-SLPS2022/src/m/solve/loadresultsfromcluster.m
r26630 r27750 35 35 if strcmpi(md.qmu.method.method,'nond_sampling'), 36 36 for i=1:md.qmu.method.params.samples 37 filelist{end+1}=[md.miscellaneous.name '.outbin.' num2str(i)]; 38 end 39 end 40 if strcmpi(md.qmu.method.method,'list_parameter_study'), 41 for i=md.qmu.method.params.list_of_points, 37 42 filelist{end+1}=[md.miscellaneous.name '.outbin.' num2str(i)]; 38 43 end
Note:
See TracChangeset
for help on using the changeset viewer.