分离 fmincon 的实部和虚部的问题(约束 MATLAB 优化)。如何正确编程?

Problem with separating Real and Imaginary parts for fmincon (constrained MATLAB optimization). How to program it correctly?

我正在尝试用 fmincon 函数在 MATLAB 中解决这个优化问题:

其中H均为复数矩阵,g、Pdes为复数列向量,D0、E0为数。

我希望得到 g 的复数列向量(一般来说它应该是复数),所以我把问题分成两个部分:real 和 imag,但它不起作用,MATLAB 给我回了一条消息:

Not enough input arguments.

Error in temp>nonlincon (line 17)
c(1) = norm ( H_d*([g(1)+1i*g(4); g(2)+1i*g(5); g(3)+1i*g(6)]) )^2 - D_0;

Error in temp (line 12)
        = fmincon(objective,x0,[],[],[],[],[],[],nonlincon);

我哪里错了?

总的来说,我按以下方式写给定问题是否正确:?

% For example:
D_0 = 2*10^(-5)*10^(60/10);
E_0 = 50;
H_b = rand(15,3) + 1i*rand(15,3);
P_des = rand(15,1) + 1i*rand(15,1);
H_d = rand(10,3) + 1i*rand(10,3);

    objective = @(g) (norm ( H_b*([g(1)+1i*g(4); g(2)+1i*g(5); g(3)+1i*g(6)]) - P_des ))^2;                        
x0 = ones(1,3*2)';
options = optimoptions('fmincon','MaxFunctionEvaluations',10e3);
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN]...
        = fmincon(objective,x0,[],[],[],[],[],[],nonlincon);

% So I expect to get a column vector g: 1st 3 elements - Real part, next 3 - Imag

function [c,ceq] = nonlincon(g, H_d, E_0, D_0)
c(1) = (norm ( H_d*([g(1)+1i*g(4); g(2)+1i*g(5); g(3)+1i*g(6)]) ))^2 - D_0;                        
c(2) = (norm ([g(1)+1i*g(4); g(2)+1i*g(5); g(3)+1i*g(6)]))^2 - E_0;
ceq = [];
end

只需要在调用fmincon

时指定nonlincon是变量g的函数即可

代码如下

[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN]...
        = fmincon(objective,x0,[],[],[],[],[],[],@(g)nonlincon(g, H_d, E_0, D_0));

解决方案 X

X = [0.2982; 0.1427; 0.3597; -0.0729; -0.1187; 0.2090]