Optimization of complex variables in matlab

1 visualizzazione (ultimi 30 giorni)
Gina
Gina il 8 Gen 2014
Commentato: Matt J il 8 Gen 2014

I am working with some optimization, I need to find the best $Lxp$ which is a control gain by minimizing the objective function $obj$ wich is the magnitude of the squares of the eigenvalues of phi_sol minus the values I enter $p1$ and $p2$. By programming in Matlab I have done this function.

function obj=objetivo(Lxp)%x,phi,gamma0,gamma1)
  global phi; %phi=[1 1;0 1]
  global gamma0; %  gamma0=[0.4900; 0.9900]
  global gamma1; %  gamma1=[0.0100; 0.0100]
  global p1
  global p2
  phi_sol= [1 0;0 1];
  for k=1:100
  phi_sol=phi+gamma0*Lxp+ gamma1*Lxp*inv(phi_sol);
  end
  E=vpa(eig(phi_sol))
  obj=abs((E(1)-p1)^2+(E(2)-p2)^2)

The optimization is done by using fminsearch so I do:

>>options = optimset('MaxFunEvals',10000,'TolFun',10^-11,'MaxIter',100000);
>>global p1; global p2; p1=0.7;p2=0.6;
>>[XOUT,FVAL,EXITFLAG]=fminsearch(@objetivo,[0.8 0.9],options)

It converges being $XOUT=[-0.1182 -0.6334]$ which is Lxp.

The problem comes when I need to find solution Lxp for complex $p1$ and $p2$, for example $p1=0.7+0.1*i$;$p2=0.6+0.05i$. My questions are: How should I work with complex variables in this particular optimization problem? How do I split them $p1$, $p2$ and E indeed, and calculate the objective function by using real and complex part?

  1 Commento
Matt J
Matt J il 8 Gen 2014
obj=abs((E(1)-p1)^2+(E(2)-p2)^2)
this looks like it should really be
obj=norm(sort(E)-sort([p1;p2])).^2

Accedi per commentare.

Risposte (1)

Matt J
Matt J il 8 Gen 2014
See here for the relevant technique
Also, I recommend you stop using global variables to pass fixed parameters to functions. There are better ways using anonymous and nested functions, discussed here

Community Treasure Hunt

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

Start Hunting!

Translated by