# Optimization problem with complex number in patternsearch command

2 views (last 30 days)
Seyoung Jung on 24 Apr 2021
Commented: Seyoung Jung on 26 Apr 2021
clc; clear;
%% Model
% Prameters
N = 64; % #of antenna element
angle = -pi/2:0.005:pi/2; % Define angle within visible region (rad)
u=sin(angle); % Define u space
% Arrayfactor without weights (d=0.5lambda)
n=(1:N)';
steeringangle=60;
us=0;
% us=sind(steeringangle);
arrayfactor=exp(-i*(-(N+1)/2+n)*pi*u); % For objfun
% Desired pattern for beam1
Beam_left=-pi/4;
Beam_right=pi/4;
for num = 1:size(angle,2)
if ( (angle(num) >= Beam_left) & (angle(num) <= Beam_right) )
Beam_d(num)=1;
else Beam_d(num)=0;
end
end
%% Optimization for beam
p=4;
objfun = @(w)(2/length(u)*sum(abs(abs(w'*arrayfactor)-Beam_d).^p)).^(1/p); % Objective functin
weights_i = [ones(N,1),i*ones(N,1)]; % Initial setting for w
weights_o = patternsearch(objfun,weights_i,[],[],[],[],[],[ones(N,1),ones(N,1)]);
Hello,
I am trying to write code to synthesis antenna array with optimization command.
However, I could not get complex optimization values.
And can I give constraint like 'abs[weights_i(complex number)] <= 1' as a upper bound?
Thank you so much.

Alan Weiss on 25 Apr 2021
Global Optimization Toolbox solvers such as patternsearch require real numbers only as control variables. It is fine to calculate with complex values in the objective and nonlinear constraint functions; however, the results of such calculations must be real-valued. So it is fine that your arrayfactor is complex, as long as your results are purely real.
If you want to work with complex outputs, rewrite your functions to have twice as many real outputs, one representing the real part, one representing the complex part. For an example, see Split Real and Imaginary Parts.
For a Global Optimization Toolbox example of an antenna design problem, see Surrogate Optimization of Six-Element Yagi-Uda Antenna.
Alan Weiss
MATLAB mathematical toolbox documentation
Seyoung Jung on 26 Apr 2021