how to find the optimal value of a matrix that minimize a function?
20 次查看(过去 30 天)
显示 更早的评论
I have a matrix W which is a block diagonal matrix with dimensions
, and each of its two block diagonal is
vector. I want to find the values of its enteries that minimze the difference between the following function:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/274795/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/274796/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/274797/image.png)
Where: W is the required
block diagonal matrix to be optimized, B is a
matrix, H is a given
matrix, and A is a
matrix. A and B are calculated using the functions used in the attached code.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/274798/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/274799/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/274800/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/274801/image.png)
It tried this attached code, but I think it is now in infinte loop and I don't know what should I do?
while ((B*H)-(A*W)~=zeros(2,4))
w1=randn(1,2); % generate the first block diagonal vector with dimensions 1*2. The values of each entry of the block
% diagonal vector may be not the same.
w2=randn(1,2); % generate the second block diagonal vector with dimensions 1*2.
W=blkdiag(w1,w2); % bulid the block diagonal matrix that I want to optimize with dimmensions 2*4.
R=sqrtm(W*inv(inv(P)+(H'*inv(eye(2)+D)*H))*W'); % R is 2*2 matrix that will be used to calculate matrix A using LLL lattice
% reduction algorithm. The values of P (4*4 matrix), H (2*4 matrix) and D (2*2 matrix) are given. It's clear here that
% matrix R is a function of W.
A= LLL(R,3/4); % I use here LLL lattice reduction algorithm to obtain 2*2 matrix A which is function of R.
B=A'*W*P*H'*inv(eye(2)+D+H*P*H'); % B is 2*2 matrix which is function of A and W. The values of P (4*4 matrix),
% H (2*4 matrix) and D (2*2 matrix) are given.
end
2 个评论
采纳的回答
Fabio Freschi
2020-3-3
If I understand correctly the problem can be recast to the following
A*W = B*H = F;
[a11 a12; a21 a22]*[w1 w2 0 0; 0 0 w3 w4] = [f11 f12 f13 f14; f21 f22 f23 f24];
If so, it is possible to write it in terms of another linear system
A0*w0 = f0;
[A 0 0 0; 0 A 0 0; 0 0 A 0; 0 0 0 A]*[w1 0 w2 0 0 w3 0 w4]' = [f11 f21 f12 f22 f13 f23 f14 f24];
Where A0 is 8x8, w0 is 8x1 and f is 8x1.
This is actually a over determined system, because some of the unknowns (at positions 2 4 5 and 7) are actually zeros, so we can delete the corresponding cols of A0, having a 8x4 matrix. This can be solved with backslash, which gives the linear least squares solution. I don't have the actual matrices, so I play with dummy values
% this is your matrix A
A = eye(2)+rand(2);
% this is the result of the product of your matrices B*H
F = rand(2,4);
% create the 8x8 system
A0 = blkdiag(A,A,A,A);
% create the rhs
f = F(:);
% remove the 2 4 5 7 cols from A0
A0(:,[2 4 5 7]) = [];
% now get the least squares solution
w = A0\f
% result with your notation w1 and w2
w1 = [W(1) W(2)];
w2 = [W(3) W(4)];
hope it helps
6 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Operating on Diagonal Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!