Why does 'paretosearch' function show an error here?

2 ビュー (過去 30 日間)
kefeng sens
kefeng sens 2022 年 1 月 26 日
編集済み: ag 2024 年 1 月 9 日
I am getting an error : Unrecognized field name "nArchiveSize" , and I do not know how to fix it.
The 'optimoptions' is from plot-3-d-pareto-set.
'N3(x)' and 'N4(x)' are familer with 'N2(x)'.
function fa = N2(x)
u0=4*pi*1e-7;
eps0=1e-9/(36*pi);
fre = 0.9e9;
w = 2*pi*fre;
lamda = 3e8/fre;
k0 = w*sqrt(eps0*u0);
gamma1 = 0.63117783 - 1i*0.043092759;
gamma2 = gamma1*exp(2*1i*k0*lamda/4);
Zin1 = 376.99*(1 + gamma2)/(1 - gamma2);
x(:,6)=0;
d1 = x(:,1);
d2 = x(:,2);
d3 = x(:,3);
eps_r1 = x(:,4);
eps_r2 = x(:,5);
eps_r3 = x(:,6);
eps1 = eps_r1.*eps0;
eps2 = eps_r2.*eps0;
eps3 = eps_r3.*eps0;
k1 = w.*sqrt(eps1.*u0);
k2 = w.*sqrt(eps2.*u0);
k3 = w.*sqrt(eps3.*u0);
Z01 = sqrt(u0./eps1);
Z02 = sqrt(u0./eps2);
Z03 = sqrt(u0./eps3);
Zin2 = Z01.*(Zin1 + 1i.*Z01.*tan(k1.*d1))./(Z01 + 1i.*Zin1.*tan(k1.*d1));
Zin3 = Z02.*(Zin2 + 1i.*Z02.*tan(k2.*d2))./(Z02 + 1i.*Zin2.*tan(k2.*d2));
Zin4 = Z03.*(Zin3 + 1i.*Z03.*tan(k3.*d3))./(Z03 + 1i.*Zin3.*tan(k3.*d3));
gamma3 = (Zin4-377)./(Zin4+377);
aa = abs(imag(gamma3));
bb = abs(real(gamma3));
fa = aa+bb;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function F=fun(~)
F(1) = N2;
F(2) = N3;
F(3) = N4;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear
clc
fitnessfcn=@fun;
nvars=6;
lb=[0 0 0 1 1 1];
ub=[0.02 0.02 0.02 50 50 50];
A = [];
b = [];
Aeq=[];
beq=[];
options = optimoptions('paretosearch','UseVectorized',true,'ParetoSetSize',1,'PlotFcn','psplotparetof');
rng default
[x,fval]=paretosearch(fitnessfcn,nvars,A,b,Aeq,beq,lb,ub,[],options);
  1 件のコメント
PaulS
PaulS 2022 年 9 月 5 日
編集済み: PaulS 2022 年 9 月 5 日
Hi. Did you find the cause of this error? I'm getting the same error.

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

回答 (1 件)

ag
ag 2024 年 1 月 9 日
編集済み: ag 2024 年 1 月 9 日
Hi Kefeng,
I understand that you are facing the error "Unrecognized field name: nArchiveSize" while using the "paretosearch" function.
Upon debugging your code, I found that the objective function "N2", returns "NaN" value, which causes the function "initialize"(called through "paretosearch") to exit early, without initializing all the required variables. Therreafter, when the "nArchiveSize" is being accessed inside "driver"(called through "paretosearch"), which was never initialized, it throws the error.
The below lines from the function "N2", are producing "NaN" values, because of the "divide by zero" problem.
Z01 = sqrt(u0./eps1);
Z02 = sqrt(u0./eps2);
Z03 = sqrt(u0./eps3);
Zin2 = Z01.*(Zin1 + 1i.*Z01.*tan(k1.*d1))./(Z01 + 1i.*Zin1.*tan(k1.*d1));
Zin3 = Z02.*(Zin2 + 1i.*Z02.*tan(k2.*d2))./(Z02 + 1i.*Zin2.*tan(k2.*d2));
Zin4 = Z03.*(Zin3 + 1i.*Z03.*tan(k3.*d3))./(Z03 + 1i.*Zin3.*tan(k3.*d3));
To fix this, modify the logic for "N2", to get rid of the "divide by zero" scenario.
Please refer to the following documentation, for more details on creating an objective function:
Hope this helps!
Best Regards,
Aryan Gupta

カテゴリ

Help Center および File ExchangeMultiobjective Optimization についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by