Using the given code, how can I optimize a matrix to minimize a cost function?
24 views (last 30 days)
Show older comments
Given S1, (1,K) vector, I want to optimize B (N,M) matrix to minimize the following cost function:

Subject to:

Where:
S2 is (1,K) vector and a function of matrix B.
S2 can be calculated after optimizing matrix B using the following system parameters and equations:
clc;
clear;
% Given system parameters:
N = 2;
K = 4;
M=2;
C_l = 4;
H = [0.1185 0.2811; 0.3550 0.8224; 0.3260 0.9644; 0.5333 0.6083]; % 4*2 matrix
A = [-2 1; -1 1]; % 2*2 matrix
C = [7 -3; 7 -3; -2 1; -2 1]; % 4*2 matrix
P = [25000000 0; 0 25000000]; % 4*4 matrix
S1 = [3.1683 3.1686 1.8716 1.8898]; % 1*4 vector
S2 = zeros(1,K); % intial value
B = zeros(N,M); % intial value
% How can we optimize the value of B matrix to achieve our goal?
%calculate S2 from B and the other given inputs
for j=1:1:N
d(j) = (B(j,:)*P*B(j,:)')/((2^(2*C_l))-(norm(A(:,j))^2));
end
D_d = diag(d);
for i=1:1:K
V_d(i)=C(i,:)*P*B'*H(i,:)'*inv(1+H(i,:)*(A'*D_d*A+B*P*B')*H(i,:)');
sigma_d(i)=norm((V_d(i)*H(i,:)*B-C(i,:))*(P^(1/2)))^2+(V_d(i)^2)*(1+H(i,:)*A'*D_d*A*H(i,:)');
S2(i)=0.5*log2((P(1,1))/sigma_d(:,i));
end
Accepted Answer
Matt J
on 18 Nov 2020
Well, the way you would approach it is using fmincon as below. Using your initial guess of zeros(N,M), fmincon is unable to find a solution so, assuming a feasible solution does exist, you will need to choose a less arbitrary initial guess. I urge you to get familiar with the fmincon documentation.
B_Optimal=doOptimization
function B_Optimal=doOptimization
% Given system parameters:
N = 2;
K = 4;
M=2;
C_l = 4;
H = [0.1185 0.2811; 0.3550 0.8224; 0.3260 0.9644; 0.5333 0.6083]; % 4*2 matrix
A = [-2 1; -1 1]; % 2*2 matrix
C = [7 -3; 7 -3; -2 1; -2 1]; % 4*2 matrix
P = [25000000 0; 0 25000000]; % 4*4 matrix
S1 = [3.1683 3.1686 1.8716 1.8898]; % 1*4 vector
Binitial = zeros(N,M); % intial value
% How can we optimize the value of B matrix to achieve our goal?
B_Optimal=fmincon( @(B)norm( S2(B)-S1).^2, Binitial,[],[],[],[],[],[],@nlcon);
function [c,ceq]=nlcon(B)
ceq=[];
c=S1-S2(B);
end
function out=S2(B)
%calculate S2 from B and the other given inputs
for j=N:-1:1
d(j) = (B(j,:)*P*B(j,:)')/((2^(2*C_l))-(norm(A(:,j))^2));
end
D_d = diag(d);
for i=K:-1:1
V_d(i)=C(i,:)*P*B'*H(i,:)'*inv(1+H(i,:)*(A'*D_d*A+B*P*B')*H(i,:)');
sigma_d(i)=norm((V_d(i)*H(i,:)*B-C(i,:))*(P^(1/2)))^2+(V_d(i)^2)*(1+H(i,:)*A'*D_d*A*H(i,:)');
out(i)=0.5*log2((P(1,1))/sigma_d(:,i));
end
end
end
2 Comments
Rik
on 18 Nov 2020
How certain is it that such a B actually exists? It is not my field, so algebraically determining is such a matrix is possible in the first place is beyond my skills. However, I don't see anything to indicate that it would be impossible to find this out.
More Answers (0)
See Also
Categories
Find more on Surrogate Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!