使用Manopt工具箱适合优化最小化问题,如果你的优化问题是最大化问题,那么需要将其转换为最小化问题然后使用Manopt工具箱求解。
具体安装过程
Matlab添加Manopt - 知乎 (zhihu.com)
clc,clear;
close all;
s=rng(1);%rand seed
N=10;
GR_num=1e3;% number, should be large enough
A = rand(N)+1i*rand(N);
A = (A*A'); % semidefinite matrix
% SDR
cvx_begin
variable X(N,N) hermitian semidefinite
minimize (real(trace(A*X)))
subject to
diag(X)==ones(N,1);
cvx_end
% gassian random
obj = zeros(GR_num,1);
v=zeros(N,GR_num);
[V1,D1]=eig(X);
for ii=1:GR_num
v(:,ii) = V1*D1^(1/2)*sqrt(1/2)*(randn(N,1) + 1i*randn(N,1));
v(:,ii) = exp(1i*angle(v(:,ii)