Matlab - GlobalSearch 函数 - 得到非预期的结果

问题描述

我已经在这里尝试了其他解决方案来解决我的问题( common eigen vectorsstudy of commutator to get common eigen vectors ),但从物理角度来看,结果不是预期的。 我的项目的目标是构建不同特征向量的矩阵组合,以这种方式共享公共特征值(见下文 D=D1+D2)。

我现在在这里尝试求解一个矩阵方程组,我想在其中找到 2 个 7x7 的矩阵(所以我正在使用 (1x98) 向量)。

我想使用 GlobalSearch Matlab 函数时遇到问题。这是我的代码

clear
clc

N = 7;
Nsq2 = 2*N*N;

% Load
FISH_GCsp = load('Fisher_GCsp_flat');
FISH_XC = load('Fisher_XC_GCph_WL_flat');
% Marginalizing over uncommon parameters between the two matrices
COV_GCsp_first = inv(FISH_GCsp);
COV_XC_first = inv(FISH_XC);
COV_GCsp = COV_GCsp_first(1:7,1:7);
COV_XC = COV_XC_first(1:7,1:7);
% Invert to get Fisher matrix
FISH_sp = inv(COV_GCsp);
FISH_xc = inv(COV_XC);
% Get eigen values (marginalized error since we handle Covariance error)
% and eigen vectors giving matrix "P" with convention : F = P D P^-1
[eigenv_sp,eigen_sp] = eig(COV_GCsp);
[eigenv_xc,eigen_xc] = eig(COV_XC);

% Fisher eigen scalar vectors
FISH_eigen_sp = inv(eigen_sp);
FISH_eigen_xc = inv(eigen_xc);

% Eigen sum for  Fisher matrices
FISH_eigen_sum = FISH_eigen_sp + FISH_eigen_xc;

% Fisher matrices
F1 = FISH_sp;
F2 = FISH_xc;

P1 = eigenv_sp;
P2 = eigenv_xc;

D1 = FISH_eigen_sp;
D2 = FISH_eigen_xc;

%% unkNown variables
a = sym('a_',[7,7]);
b = sym('b_',7]);

%% generate function from equations    
D = D1 + D2;
Eq1 = (P1.')*(a.')*a*P1 + (P1.')*(a.')*b*P2 + (P2.')*(b.')*a*P1 + (P2.')*(b.')*b*P2 - eye(N);
Eq2 = F1*a*P1 + F1*b*P2 + F2*a*P1 + F2*b*P2 - (a*P1 + b*P2)*D;
Eqs = reshape([Eq1,Eq2],98,[]);

% Solution
Eqs_vars = {[a(:); b(:)].'};
objective = sum(Eqs .* conj(Eqs));
F = matlabFunction(objective,'var',Eqs_vars);
x0 =  ones(1,Nsq2);
options = optimoptions('fmincon','Algorithm','interior-point',...
    'UseParallel',true,'display','off','MaxFunctionEvaluations',100000,'TolCon',1e-6,'TolFun',1e-6);
problem = createOptimProblem('fmincon',...
    'objective',F,...
    'x0',x0,...
    'lb',-1e10*ones(1,Nsq2),...
    'ub',1e10*ones(1,...
    'options',options);

gs = GlobalSearch;
[x,fval] = run(gs,problem);

% output
a = zeros(N,N);
b = zeros(N,N);
for ii=1:N
    a(ii,:) = x(1+N*(ii-1):N*ii);
    b(ii,:) = x(N*N+1+N*(ii-1):N*N+N*ii);
end

% Sum of passing matrix P = aX + bY with X = eigenv_sp,Y = eigenv_xc 
% a and b to infer
eigenv_final = a*eigenv_sp + b*eigenv_xc

% Fisher final
FISH_final = eigenv_final*FISH_eigen_sum*(eigenv_final.');

% Save Fisher_final
dlmwrite('Fisher_final.txt',FISH_final,'delimiter',' ')

我正在尝试使用 GlobalSearch,因为目前,通过使用经典的 fsolve 函数,我对提供的初始猜测太不稳定:似乎存在不同的局部最小值等我想知道全局最小值是否可以解决这种初始猜测的敏感性。

难点是解 2 个 7x7 矩阵,所以总共有 98 个元素,因为这是一个矩阵方程。

如果你们中的一些人想执行上面的代码或做简单的测试,我在这里提供 2 个输入矩阵:

Fisher_GCsp_flat

Fisher_XC_GCph_WL_flat

由于某些原因我忽略了,几分钟后,出现以下消息:

Starting parallel pool (parpool) using the 'local' profile ...
Connected to the parallel pool (number of workers: 8).

GlobalSearch stopped because it analyzed all the trial points.

1 out of 2 local solver runs converged with a positive local solver exit flag.

eigenv_final =

     0     0     0     0     0     0     0
     0     0     0     0     0     0     0
     0     0     0     0     0     0     0
     0     0     0     0     0     0     0
     0     0     0     0     0     0     0
     0     0     0     0     0     0     0
     0     0     0     0     0     0     0

并且矩阵“a”和“b”的元素都等于0,因此2个想要的解都是空矩阵。

你怎么看这个问题?以及如何获得与空矩阵不同的矩阵?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)