1 | function factors=importancefactors(md,variablename,responsename)
|
---|
2 | %IMPORTANCEFACTORS - compute importance factors for a certain variable and response.
|
---|
3 | %
|
---|
4 | % Usage:
|
---|
5 | % factors=importancefactors(md,variablename,responsename)
|
---|
6 | %
|
---|
7 | %
|
---|
8 | % Example: factors=importancefactors(md,'drag','max_vel');
|
---|
9 | %
|
---|
10 |
|
---|
11 |
|
---|
12 | variablenamelength=length(variablename);
|
---|
13 |
|
---|
14 | %go through all response functions and find the one corresponding to the correct responsename
|
---|
15 | responsefunctions=md.dakotaresults.dresp_out;
|
---|
16 | found=0;
|
---|
17 | for i=1:length(responsefunctions),
|
---|
18 | if strcmpi(responsefunctions(i).descriptor,responsename),
|
---|
19 | found=i;
|
---|
20 | break;
|
---|
21 | end
|
---|
22 | end
|
---|
23 | if ~found,
|
---|
24 | error('importancefactors error message: could not find correct response function');
|
---|
25 | end
|
---|
26 | responsefunctions=responsefunctions(found);
|
---|
27 | nfun=size(responsefunctions.var,1);
|
---|
28 |
|
---|
29 | %Now recover response to the correct design variable
|
---|
30 | importancefactors=zeros(1,0);
|
---|
31 | count=0;
|
---|
32 | for i=1:nfun,
|
---|
33 | desvar=responsefunctions.var{i};
|
---|
34 | if strncmpi(desvar,variablename,variablenamelength),
|
---|
35 | importancefactors(end+1)=responsefunctions.impfac(i);
|
---|
36 | count=count+1;
|
---|
37 | end
|
---|
38 | end
|
---|
39 |
|
---|
40 | if count==0,
|
---|
41 | error('importancefactors error message: could not find to response functions with corresponding design variable');
|
---|
42 | end
|
---|
43 |
|
---|
44 | if count==1, %we have scalar
|
---|
45 | factors=importancefactors;
|
---|
46 | return;
|
---|
47 | else
|
---|
48 | %distribute importance factor
|
---|
49 | factors=importancefactors(md.part'+1); %md.part was created to index "c" style
|
---|
50 | end
|
---|
51 |
|
---|
52 | %weight importancefactors by area
|
---|
53 | %if numel(factors)==md.numberofgrids,
|
---|
54 | % %get areas for each vertex.
|
---|
55 | % aire=GetAreas(md.elements,md.x,md.y);
|
---|
56 | % num_elements_by_node=md.nodeconnectivity(:,end);
|
---|
57 | % grid_aire=zeros(md.numberofgrids,1);
|
---|
58 | % for i=1:md.numberofgrids,
|
---|
59 | % for j=1:num_elements_by_node(i),
|
---|
60 | % grid_aire(i)=grid_aire(i)+aire(md.nodeconnectivity(i,j));
|
---|
61 | % end
|
---|
62 | % end
|
---|
63 | % factors=factors./grid_aire;
|
---|
64 | %end
|
---|