フィルターのクリア

Calculation in inter dependency matrix

1 回表示 (過去 30 日間)
Santhosh Chandrasekar
Santhosh Chandrasekar 2018 年 2 月 20 日
Can someone help me to solve the below-mentioned calculation? i have vectors
A1(221X1), D1(221X1) and P(221X1) and my formula to calculate utility is Utility= (((1-P(1,1))*(D(1,1)/(D(1,1)+A1(1,1)))* V)-C + (((1-P(2,1))*(D(2,1)/(D(2,1)+A1(2,1)))* V)-C +.........till (((1-P(221,1))*(D(221,1)/(D(221,1)+A1(221,1)))* V)-C
My requirement is:
For iteration 1:
% A1= (221X1) random values
% X1= (221X1) calculated values
% D1= (221X1) random values
% utility1= (((1-P(1,1))*(D(1,1)/(D(1,1)+A1(1,1)))* V)-C + (((1-P(2,1))*(D(2,1)/(D(2,1)+A1(2,1)))* V)-C +.........till (((1-P(221,1))*(D(221,1)/(D(221,1)+A1(221,1)))* V)-C%
% store the calculated utilty1 value %
% store the generated A1 vector used in the iteration1 utility calculation %
% store the generated D1 vector used in the iteration1 utility calculation %
% store the calculated P vector used in the iteration1 utility calculation %
start the iteration 2
% Do the same as iteration1 and save all newly generated D1, A1, and P %
%Repeat for 1000 iteration and store the newly generated A1, D1, P vector of size (221X1) and utility of size (1) for 1000 iterations %
%Find the maximum utility of 1000 iteration and show the corresponding D1, P and A1 vectors used in the calculation of that maximum utility%
V= 0.2;
C=0.2;
I= eye(221);
s = string({'CR';'E';'R';'S';'SR'})
s1 = s([2,5])' + (1:20)'
s1 = [s([2,3,2,4]) + [101;1;106;1];s1(:)] + (0:4)
d = {tril(ones(44,4),-1),diag(ones(20,1),-24)}
d{2} = d{2}(:,1:end-4)
dd = repmat({[d{:}]},1,5)
str = cellstr([s(1);s1(:)])
out = [{nan},str(:)';str, num2cell([zeros(1,221);[ones(220,1),blkdiag(dd{:})]]) ];
A= out(2:end,2:end);
for i=1:1000
A1= ( randn(221,1) * 0.1 ) + 0.45;
X11= cell2mat(A)*A1;
P= zeros(221,1);
P(:)= X11(:)/sum(X11)
D1= ( randn(221,1) * 0.1 ) + 0.45;
% Utility= (((1-P(1,1))*(D(1,1)/(D(1,1)+A1(1,1)))* V)-C + (((1-P(2,1))*(D(2,1)/(D(2,1)+A1(2,1)))* V)-C +.........till (((1-P(221,1))*(D(221,1)/(D(221,1)+A1(221,1)))* V)-C
end %

採用された回答

Basil C.
Basil C. 2018 年 2 月 20 日
編集済み: Basil C. 2018 年 2 月 20 日
You could use a 3D matrix to store the new values of A1, D1, P and Utility
result=zeros(221,4,1000);
for (i=1:1000)
A1= ( randn(221,1) * 0.1 ) + 0.45;
X11= cell2mat(A)*A1;
P= zeros(221,1);
P(:)= X11(:)/sum(X11)
D1= ( randn(221,1) * 0.1 ) + 0.45;
Utility=0;
for(j=1:221)
Utility= (((1-P(j))*(D(j)/(D(j)+A1(j)))* V)-C +Utility;
end
result(:,1,i)=A1;
result(:,2,i)=D1;
result(:,3,i)=P;
result(1,4,i)=Utility;
end
  • To find the maximum Utility use:
[Utility_max,index_max]=max(result(1,4,:));
A1_max=result(:,1,index_max);
D1_max=result(:,2,index_max);
P_max=result(:,3,index_max);
where A1_max, D1_max, P_max are the values of A1, D1, P at maximum Utility
  1 件のコメント
Santhosh Chandrasekar
Santhosh Chandrasekar 2018 年 2 月 20 日
Thank you very much, sir! This is what I required.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSmoothing についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by