# Optimization with GA (genetic algorithm)

I want to optimize the below function with GA(genetic algorithm): $$\min_{l_{x_1},l_{x_2},l_d}||S_QS(z)||_2$$

$$S_Q$$ and S(z) are defined as: $$S_Q=\Biggm[\matrix{6.6549 &-0.806&6.883\cr -0.806 &12.146 &6.818\cr 6.883 &6.818 &29.071}\Biggm]$$ $$S(z)=\Biggm[\matrix{z-1-l{x_1}&-0.05&-1 \cr -l{x_2}&z-1&-1\cr -l_d &0 &z-1}\Biggm]^{-1}$$ where z is the z-transform variable

I write below code and using optimization toolbox in MATLAB

function z=objective_function(o)
lx1=o(1);
lx2=o(2);
ld=o(3);
Sq=[6.6549,-0.806,6.883;
-0.806,12.146,6.818;
6.883, 6.818,29.071]
z=tf('z')
s=[z-lx1-1,-0.05,-1;-lx2,z-1,-1;-ld,0,z-1]
z=norm(Sq*inv(s));
end


but do not work and give me that error (The "norm" command cannot compute the H2 norm of improper discrete-time models)

• Hi welcome to engineering. This looks like homework. Please show your efforts to solve this. – NMech Mar 11 at 9:46
• I added the code I wrote and this problem relates to my Thesis. I appreciate it if you help me. – user212662 Mar 11 at 12:29
• Not an answer, but in matlab it is better to use backslash instead of calculating the inverse separately, so Sq / s instead of Sq*in(s). Is should be faster and more accurate. – fibonatic Mar 11 at 13:11
• Your optimization problem also seems to be note well enough defined, since $z$ seems to still be a free variable and thus the objective function can't be evaluated numerically. – fibonatic Mar 11 at 13:14

This page even shows an example in discrete time. However, what I think is missing in your example is that you should provide a sampling time. As the norm is calculated for every value of $$z$$ (I believe it is something like the integral of the trace of the absolute value of the system for every $$e^{jw}$$), the sampling time should be included. I'd recommend first testing if z=tf('z', -1); works, but otherwise specify a generic sampling rate.