【发布时间】:2020-03-03 18:25:49
【问题描述】:
我有一个矩阵 W,它是一个尺寸为 2*4 的块对角矩阵,它的两个块对角线中的每一个都是 1*2 向量。我想找到其条目的值,以最小化以下函数之间的差异: (F = BH-AW) 其中:W是需要优化的块对角矩阵,B是2*2矩阵,H是给定的2*4矩阵,A是2*2矩阵。 A 和 B 使用附加代码中使用的函数计算。 我尝试了这个附加代码,但我认为它现在处于无限循环中,我不知道该怎么办?
%% My code is:
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 maybe not the same.
w2=randn(1,2);
% generate the second block diagonal vector with dimensions 1*2.
W=blkdiag(w1,w2);
% build the block diagonal matrix that I want to optimize with dimensions 2*4.
R=sqrtm(W*inv(inv(P)+(H'*inv(eye(2)+D)*H))*W');
% R is a 2*2 matrix that will be used to calculate matrix A using the 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
【问题讨论】:
-
“函数”
F是 2x4 矩阵。你在什么意义上试图最小化F?您可以最小化其 2 范数、Frobenius 范数、元素绝对值之和等。 -
我没有试图理解你的循环体,但是循环测试
while ((B*H)-(A*W)~=zeros(2,4))永远不会满足于常规浮点,即使你有一个最佳A的公式和B以精确的算术实现该结果。你应该改用监视器norm((B*H)-(A*W))之类的方法,并在它变得足够小时停止。 -
所以,你认为如果我使用 ``` while (norm((BH)-(AW))~=0) ``` 而不是使用``` while ((BH)-(AW)~=zeros(2,4)) ``` 这样能解决问题吗?
-
我尝试使用while (norm((BH)-(AW))~=0),但到现在还没有任何输出,似乎进入了无限循环。有没有其他方法可以优化矩阵W?
-
@bg2b 建议类似
while norm((B*H)-(A*W))>tol,其中tol是您的容忍度,例如10^-5.
标签: matlab matrix optimization linear-algebra