Using fmincon to maximize a complex scalar function

7 ビュー (過去 30 日間)
Shankul Saini
Shankul Saini 2022 年 10 月 14 日
コメント済み: Shankul Saini 2022 年 10 月 14 日
N = 1;
h = sqrt(0.5)*(randn(1,N)+1i*randn(1,N));
g = sqrt(0.5)*(randn(N,1)+1i*randn(N,1));
phi0 = zeros(N,1);
lb = zeros(N,1);
ub = 2*pi*ones(N,1);
obj = @(phi)-((h*diag(exp(1i*phi))*g));
[sol,fval] = fmincon(obj,phi0,[],[],[],[],lb,ub)
Error using barrier
Objective function is undefined at initial point. Fmincon cannot continue.

Error in fmincon (line 886)
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = barrier(funfcn,X,A,B,Aeq,Beq,l,u,confcn,options.HessFcn, ...
phi1 = -(angle(h)+angle(g.'));
If in the above code i am trying to maximize ((h*diag(exp(1i*phi))*g)) where all h,g are complex scalar. Why matlab is giving such error, is it because objective function is complex, or some other reason?

採用された回答

Walter Roberson
Walter Roberson 2022 年 10 月 14 日
編集済み: Walter Roberson 2022 年 10 月 14 日
Function to minimize, specified as a function handle or function name. fun is a function that accepts a vector or array x and returns a real scalar f, the objective function evaluated at x.
So, yes, the fact that the objective function is complex is a problem. The maximum of complex numbers is not mathematically defined.
Are you trying to find something like the vector that is "most orthagonal" to the inputs ? If so then you should consider the square of the norm.
  1 件のコメント
Shankul Saini
Shankul Saini 2022 年 10 月 14 日
Thank you @walter this cleared the doubt

サインインしてコメントする。

その他の回答 (1 件)

Matt J
Matt J 2022 年 10 月 14 日
It is because your objective is returning a complex value at phi0.
>> obj(phi0)
ans =
1.3978 + 1.8395i
  1 件のコメント
Shankul Saini
Shankul Saini 2022 年 10 月 14 日
Ok yeah thanks @Matt J for the insight 🙌👍.

サインインしてコメントする。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by