I tried to solve
the joint optimization problem using the product manifold framework in manopt
toolbox. But result of ‘checkgradient’ function showed that the gradient is
wrong. So I tried to optimize each variable separately and check the gradient
separately with ‘checkgradient’ function. Using ‘matrix calculus’ website, I
worked out the gradient of alpha and ‘checkgradient’ function
demonstrated the correctness. However, gradients of and did not pass the
check.
Is anyone
interested in helping me.
clc; clear all; close all;
%% parameters
% user dependent parameters
M = 15; % total number of antenna
N = 10; % available number of antennas at a time
lambda = 300; % wavelength of radio wave in m
d = lambda/2; % inter-element spacing between two antennas
theta = -90 : 90; % directions of interest in degree
thetahat = [-50,0,50]; % special theta
deltheta = 20; % selected beam pattern in degree
c = M; % power of the symbols
ampw = 1; % amplitude of the beamforming weights in different angles
ampwc = 1; % amplitude of the beamforming weights in different crosscorrelation angles
L = 1;
m = 0 : (M-1);
% secondary parameters
K = length(theta); % number of angles
Kbar = length(thetahat); % number of angles we are interested in
w = ampw*ones(K,1); % weights of k-th angle
wc = ampwc; % weight of cross-correlation sidelobe
phi = zeros(K,1); % beam patterns
for k = 1:Kbar
phi ( theta >= thetahat(k) - floor(deltheta/2) & theta <= floor(thetahat(k)) + deltheta/2 ) = 1;
end
%% parameters structures
params.c = c; % power of the symbols
params.M = M; % total number of antenna
params.w = w; % weights of k-th angle
params.wc = wc; % weight of cross-correlation sidelobe
params.K = K; % number of angles
params.Kbar = Kbar; % number of angles we are interested in
params.phi = phi; % beam patterns
params.theta = theta; % directions of interest in degree
params.thetahat = thetahat; % special theta
params.L = L; % number of shot
%% functions and Initialization
aT = @(th) exp(1i*2*pi*m*d*sind(th)/lambda)'; % steering vector at theta = th
%% Initialization value of variables
alpha = rand(1,1);
S = rand(M,L)+1i*rand(M,L);
Y = ones(M,1);
options.maxiter = 100;
options.tolgradnorm = 1e-6; % tolerance on gradient norm
options.minstepsize = 1e-9;
%% optimize alpha
M1 = euclideanfactory(1, 1);
problem1.M = M1;
problem1.cost = @(alpha) IterCost (S, Y, alpha, params, aT);
problem1.grad = @(alpha) Gradf_alpha(S,Y,alpha, params, aT);
checkgradient(problem1);
[alpha, cost1, info1, options] = conjugategradient(problem1, [], options);
figure;semilogy([info1.iter]+1, abs([info1.cost]));grid on;
xlabel('迭代次数');ylabel('损失函数值');
figure;semilogy([info1.iter]+1, abs([info1.gradnorm])); grid on;
xlabel('迭代次数');ylabel('梯度范数值');
%% optimize Y
M2 = elliptopefactory(M, 1);
problem2.M = M2;
problem2.cost = @(Y) IterCost (S, Y, alpha, params, aT);
problem2.grad = @(Y) Gradf_Y(S,Y,alpha, params, aT);
checkgradient(problem2);
[Y, cost2, info2, options] = conjugategradient(problem2, [], options);
figure;semilogy([info2.iter]+1, abs([info2.cost]));grid on;
figure;semilogy([info2.iter]+1, abs([info2.gradnorm])); grid on;
%% optimize S
M3 = obliquecomplexfactory(M, L);
problem3.M = M3;
problem3.cost = @(S) IterCost (S, Y, alpha, params, aT);
problem3.grad = @(S) Gradf_Y(S,Y,alpha, params, aT);
checkgradient(problem3);
[S, cost3, info3, options] = conjugategradient(problem3, [], options);
figure;semilogy([info3.iter]+1, abs([info3.cost]));grid on;
figure;semilogy([info3.iter]+1, abs([info3.gradnorm])); grid on;