Coding help needed to optimize my 3*3 Diagonal matrix with GA.

3 ビュー (過去 30 日間)
guru
guru 2016 年 3 月 27 日
コメント済み: guru 2016 年 9 月 14 日
Hi. I am working on antenna design and for optimization of reactive elements or we can say to find the best parasitic reactance, I am using GA in Matlab. I looked at various resources but my problem is little different and haven't addressed earlier. I have tried below to explain my algorithm with the use of Matlab code it self.
clc;
clear all;
j = sqrt(-1);
c = 3*10^8;
f = 10^9;
lambda = c/f;
d = lambda/2;
h = lambda/2;
display(c);
display(f);
display(lambda);
display(d);
display(h);
z11 = 78.1+(j*35.5);
z12 = 96.8+(j*66.139);
z13 = 60.0824+(j*42.95);
Z_A = [z11 z12 z13; z12 z11 z12; z13 z12 z11]; % Antenna Impedance
display(Z_A);
Z_L = [j*x_1 0 0; 0 50+j*x_2 0; 0 0 j*x_3]; % Load Impedance
display(Z_L);
Z_T = [Z_A] + Z_L;
V = [0;
1;
0];
I = inv(Z_T)*V;
display(I);
display(fval);
In this code I am trying to find the minimum I by optimizing x1,x2 and x3. What I am trying is somehow I can generate x1, x2, x3 and then run GA over and over again on the same program until I get minimum I with my fitness function being
y = -((abs(I(1)-I(2))^2) + (abs(I(3)-I(2))^2));
If anyone has done something related to it or willing to help. your help would be much appreciated and If I write a paper I will surely acknowledge them.
  7 件のコメント
Walter Roberson
Walter Roberson 2016 年 9 月 14 日
Instead of (for example)
x(1).^2 - 3 * x(2)
where x(1) is complex, you would break it up into two variables
(x(1)+1i*x(3)).^2 - 3 * x(2)
Depending on the expression, you might be able to simplify the calculation after you do that; for example if there is a imag(x(1)) sub-expression in the original, you could replace that with x(3) directly instead of with imag(x(1)+1i*x(3))
guru
guru 2016 年 9 月 14 日
So what could be the right code here? if my values are imaginary.
function best_imp = determine_impedence
c = 3*10^8;
f = 10^9;
lambda = c/f;
d = lambda/2;
h = lambda/2;
z11 = 78.1+(1j*35.5);
z12 = 96.8+(1j*66.139);
z13 = 60.0824+(1j*42.95);
Z_A = [z11 z12 z13; z12 z11 z12; z13 z12 z11]; % Antenna Impedance
nvar = 3;
A = [];
b = [];
Aeq = [];
beq = [];
lb = -300 * ones(nvar, 1);
ub = -50 * ones(nvar, 1);
best_imp = ga(@(x) obj(x, Z_A), nvar, A, b, Aeq, beq, lb, ub);
function y = obj(x, Z_A)
Z_L = [1j*x(1), 0, 0; 0, 50+1j*x(2), 0; 0, 0, 1j*x(3)]; % Load Impedance
Z_T = Z_A + Z_L;
V = [0; 1; 0];
I = Z_T \ V;
y = -((abs(I(1)-I(2))^2) + (abs(I(3)-I(2))^2));
end

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

採用された回答

Walter Roberson
Walter Roberson 2016 年 3 月 29 日
function best_imp = determine_impedence
c = 3*10^8;
f = 10^9;
lambda = c/f;
d = lambda/2;
h = lambda/2;
z11 = 78.1+(1j*35.5);
z12 = 96.8+(1j*66.139);
z13 = 60.0824+(1j*42.95);
Z_A = [z11 z12 z13; z12 z11 z12; z13 z12 z11]; % Antenna Impedance
nvar = 3;
A = [];
b = [];
Aeq = [];
beq = [];
lb = -300 * ones(nvar, 1);
ub = -50 * ones(nvar, 1);
best_imp = ga(@(x) obj(x, Z_A), nvar, A, b, Aeq, beq, lb, ub);
function y = obj(x, Z_A)
Z_L = [1j*x(1), 0, 0; 0, 50+1j*x(2), 0; 0, 0, 1j*x(3)]; % Load Impedance
Z_T = Z_A + Z_L;
V = [0; 1; 0];
I = Z_T \ V;
y = -((abs(I(1)-I(2))^2) + (abs(I(3)-I(2))^2));
  8 件のコメント
Walter Roberson
Walter Roberson 2016 年 3 月 30 日
The false premise implies all premises. When you use code to do something it is not intended to do, then it may return any result, including working the way you "want" until the time your Senior Vice President is watching you demonstrate it, at which time it could instead decide to say out loud "The boss is a fat-head!" and send an email message to your mother that says "Please wash the elephant with ice cubes and haggis!"
Walter Roberson
Walter Roberson 2016 年 3 月 30 日
編集済み: Walter Roberson 2016 年 3 月 30 日
My tests appear to indicate that the zeros of obj occur when x1 = x3, with x2 irrelevant. I am having difficulty interpreting some of my findings, but it appears there might be a small set of values that x1 and x3 must be chosen from, and that y becomes 0 in those cases, no matter what the value of x2.
The formula for y is
- 10000 * ((156250000000000 * x1^2 * x3^2 + 11093750000000000 * x1^2 * x3 + 31762187500000000 * x1 * x3^2 + 1149978125000000000 * x1^2 + 3736521112425000000 * x1 * x3 + 6393827550156250000 * x3^2 - 38063162015837500000 * x1 - 121983908458654175000 * x3 + 4521408223111359099409)^2 / (1562500000000000000 * x1^2 * x2^2 * x3^2 + 110937500000000000000 * x1^2 * x2^2 * x3 + 110937500000000000000 * x1^2 * x2 * x3^2 + 110937500000000000000 * x1 * x2^2 * x3^2 + 11499781250000000000000 * x1^2 * x2^2 + 23488664621875000000000 * x1^2 * x2 * x3 + 27609156250000000000000 * x1^2 * x3^2 + 13392788405500000000000 * x1 * x2^2 * x3 + 23488664621875000000000 * x1 * x2 * x3^2 + 11499781250000000000000 * x2^2 * x3^2 - 1754386725423437500000000 * x1^2 * x2 - 2611325850423437500000000 * x1^2 * x3 - 247315150029750000000000 * x1 * x2^2 - 2981558817028312500000000 * x1 * x2 * x3 - 2611325850423437500000000 * x1 * x3^2 - 247315150029750000000000 * x2^2 * x3 - 1754386725423437500000000 * x2 * x3^2 + 68952991611446745376562500 * x1^2 + 52512019412360693584500000 * x1 * x2 + 159527293499906478503125000 * x1 * x3 + 14996843569186297188840000 * x2^2 + 52512019412360693584500000 * x2 * x3 + 68952991611446745376562500 * x3^2 - 2518083174982482155091812500 * x1 - 2207798895986669961611370000 * x2 - 2518083174982482155091812500 * x3 + 81824373462710400660974340041)^2)^(1 / 2) - 10000 * ((156250000000000 * x1^2 * x3^2 + 31762187500000000 * x1^2 * x3 + 11093750000000000 * x1 * x3^2 + 6393827550156250000 * x1^2 + 3736521112425000000 * x1 * x3 + 1149978125000000000 * x3^2 - 121983908458654175000 * x1 - 38063162015837500000 * x3 + 4521408223111359099409)^2 / (1562500000000000000 * x1^2 * x2^2 * x3^2 + 110937500000000000000 * x1^2 * x2^2 * x3 + 110937500000000000000 * x1^2 * x2 * x3^2 + 110937500000000000000 * x1 * x2^2 * x3^2 + 11499781250000000000000 * x1^2 * x2^2 + 23488664621875000000000 * x1^2 * x2 * x3 + 27609156250000000000000 * x1^2 * x3^2 + 13392788405500000000000 * x1 * x2^2 * x3 + 23488664621875000000000 * x1 * x2 * x3^2 + 11499781250000000000000 * x2^2 * x3^2 - 1754386725423437500000000 * x1^2 * x2 - 2611325850423437500000000 * x1^2 * x3 - 247315150029750000000000 * x1 * x2^2 - 2981558817028312500000000 * x1 * x2 * x3 - 2611325850423437500000000 * x1 * x3^2 - 247315150029750000000000 * x2^2 * x3 - 1754386725423437500000000 * x2 * x3^2 + 68952991611446745376562500 * x1^2 + 52512019412360693584500000 * x1 * x2 + 159527293499906478503125000 * x1 * x3 + 14996843569186297188840000 * x2^2 + 52512019412360693584500000 * x2 * x3 + 68952991611446745376562500 * x3^2 - 2518083174982482155091812500 * x1 - 2207798895986669961611370000 * x2 - 2518083174982482155091812500 * x3 + 81824373462710400660974340041)^2)^(1 / 2)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDesign, Analysis, Benchmarking, and Verification についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by