home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 2.ddi / MUTOOLS1.DI$ / HINFFI.M < prev    next >
Encoding:
Text File  |  1993-03-11  |  6.4 KB  |  244 lines

  1. % function [k,g,gfin,ax,hamx] = hinffi(p,ncon,gmin,gmax,tol,ricmethd,epr,epp) 
  2. %
  3. %  This function computes the FULL INFORMATION h-infinity n-state
  4. %  controller, using Glover's and Doyle's 1988 result,
  5. %  for a system P.  The solution assumes that all the states
  6. %  and disturbances can be measured. The P matrix has the form:
  7. %
  8. %       p  =  | ap  | b1   b2  |
  9. %             | c1  | d11  d12 |
  10. %
  11. %  Care must be taken by the user when closing the loop with the
  12. %  full information controller. For feedback the interconnection
  13. %  structure, P, must be augmented with state and disturbance 
  14. %  measurements.
  15. %  inputs:
  16. %      P      -   interconnection matrix for control design
  17. %      NCON   -   # controller outputs (nm2)
  18. %      GMIN   -   lower bound on gamma
  19. %      GMAX   -   upper bound on gamma
  20. %      TOL    -   relative difference between final gamma values
  21. %      RICMETHD - Ricatti solution via
  22. %                   1 - eigenvalue reduction 
  23. %                   2 - real schur decomposition   (default)
  24. %      EPR    -   measure of when real(eig) of Hamiltonian is zero
  25. %                  (default EPR = 1e-10)
  26. %      EPP    -   positive definite determination of xinf solution
  27. %                  (default EPP = 1e-6)
  28. %
  29. %  outputs:
  30. %      K      -   H-infinity FULL INFORMATION controller
  31. %      G      -   closed-loop system
  32. %      GFIN   -   final gamma value used in control design
  33. %      AX     -   Riccati solution as a VARYING matrix with independent
  34. %                  variable gamma (optional)
  35. %      HAMX   -   Hamiltonian matrix as a VARYING matrix with independent
  36. %                  variable gamma (optional)
  37.  
  38. function [k,g,gfin,ax,hamx] = hinffi(p,ncon,gmin,gmax,tol,imethd,epr,epp) 
  39.  
  40. %
  41. %   The following assumptions are made:
  42. %    (i)   (a,b2,c2) is stabilizable and detectable
  43. %    (ii)  d12 has full rank
  44. %   on return, the eigenvalues in egs must all be > 0 for the closed-
  45. %   loop system to be stable and to have inf-norm less than gam.
  46. %   this program provides a gamma iteration using a bisection method,
  47. %   it iterates on the value of gam to approach the h-inf optimal 
  48. %   full information controller.
  49. %                                    np  nm1  nm2
  50. %   The system p is partitioned:   | a   b1   b2   | np
  51. %                                  | c1  d11  d12  | np1
  52. %   Reference Paper:
  53. %    'State-space formulae for all stabilizing controllers
  54. %     that satisfy and h-infinity-norm bound and relations
  55. %     to risk sensitivity,' by keith glover and john doyle,
  56. %     systems & control letters 11, oct, 1988, pp 167-172.
  57. storxinf = [];
  58. storhx = [];
  59. gammavecxi = [];
  60. gammavechx = [];
  61.  
  62. if nargin == 0
  63.   disp('usage: [k,g,gfin,ax,hamx] = hinffi(p,ncon,gmin,gmax,tol,imethd,epr,epp)')
  64.   return
  65. end
  66. if nargin < 5
  67.   disp('usage: [k,g,gfin,ax,hamx]=hinffi(p,ncon,gmin,gmax,tol,imethd,epr,epp)')
  68.   error('incorrect number of input arguments')
  69.   return
  70. end
  71. % setup default cases
  72. if nargin == 5
  73.   imethd = 2;
  74.   epr = 1e-10;
  75.   epp = 1e-6;
  76. elseif nargin == 6
  77.   epr = 1e-10;
  78.   epp = 1e-6;
  79. else
  80.   epp = 1e-10;
  81. end
  82.   
  83. gam2=gmax;
  84. gam0=gmax;
  85. if gmin > gmax
  86.   error(' gamma min is greater than gamma max')
  87.   return
  88. end
  89. % save the input system to form the closed-loop system 
  90. pnom = p;
  91. niter = 1;
  92. npass = 0;
  93. first_it = 1;
  94. totaliter = 0;
  95. % fprintf('checking rank conditions: ');
  96.  [p,q12,r12,fail] = hinffi_t(p,ncon);
  97.  if fail == 1,
  98.     fprintf('\n')
  99.     return
  100.  end
  101.  
  102. %            gamma iteration
  103.  
  104. fprintf('Test bounds:  %10.4f <  gamma  <=  %10.4f\n\n',gmin,gmax)
  105. fprintf('   gamma      ham_eig     x_eig        pass/fail\n')
  106.  
  107.  while niter==1
  108.   totaliter = totaliter + 1;
  109.   if first_it ==1                  % first iteration checks gamma max
  110.     gam = gmax;
  111.   else
  112.     gam=((gam2+gam0)/2.);
  113.     gamall=[gam0 gam gam2];
  114.   end
  115.   fprintf(' %9.3f  ',gam)
  116.   [xinf,f,fail,hmx,hxmin] = hinffi_g(p,ncon,epr,gam,imethd);
  117.   if nargout >= 4
  118.     if isempty(xinf)
  119.       % don't update the matrix
  120.     else
  121.       gammavecxi = [gammavecxi ; gam];
  122.       storxinf = [storxinf ; xinf];
  123.     end
  124.     if nargout >= 5
  125.       if isempty(hmx)
  126.         % don't update the matrix
  127.       else
  128.         gammavechx = [gammavechx ; gam];
  129.         storhx = [storhx ; hmx];
  130.       end
  131.     end
  132.   end
  133. %
  134. % check the conditions for a solution to the FULL INFORMATION
  135. %  h-infinity control problem.
  136. %
  137.   if fail == 0
  138.     xe = eig(xinf);
  139.     xeig = min(real(xe));
  140.     index = find(real(xe)==xeig);
  141.     mprintf(hxmin,' %9.2e ',' ');
  142.     mprintf(real(xe(index(1))),' %9.2e',' ');
  143.     if xeig < -epp | xeig == nan;
  144.       npass=1;
  145.     end
  146.   else
  147.     mprintf(hxmin,' %9.2e ',' ');
  148.     fprintf('  ******** ')
  149.     npass = 1;
  150.   end 
  151.  
  152.   if npass == 1
  153.     fprintf('      fail \n')
  154.   else
  155.     fprintf('      pass \n')
  156.   end
  157. %
  158. % check the gamma iteration
  159. %
  160.  if first_it == 1;
  161.    if npass == 0;
  162.      gam0 = gmin; 
  163.      gam2 = gmax; 
  164.      xinffin = xinf; 
  165.      fsave = f;
  166.      gfin = gmax;
  167.      first_it = 0;
  168.      if gmin == gmax
  169.        niter = 0;           % stop since gmax = gmin
  170.      end
  171.    else
  172.      niter = 0;
  173.      fprintf('Gamma max, %10.4f, is too small !!\n',gmax);
  174.      if nargout >= 4
  175.        ax = vpck(storxinf,gammavecxi);
  176.        if nargout >= 5
  177.          hamx = vpck(storhx,gammavechx);
  178.        end
  179.      end
  180.         return
  181.       end    
  182.  else
  183.    if abs(gam - gam0) < tol
  184.      niter = 0;
  185.      if npass == 0
  186.        gfin = gam;
  187.        xinffin = xinf;
  188.        fsave = f;
  189.      else
  190.        gfin = gam2; 
  191.      end
  192.    else
  193.      if npass == 0;
  194.        gam2 = gam;
  195.        xinffin = xinf;
  196.        fsave = f;
  197.      else
  198.        gam0 = gam;
  199.      end
  200.    end
  201.    npass = 0;
  202.  end
  203. end
  204. xinf = xinffin;
  205.  
  206. %  finished with gamma iteration
  207.  
  208. fprintf('\n Gamma value achieved: %10.4f\n',gfin)
  209.  
  210. [k] = hinffi_c(p,ncon,fsave,r12);
  211. %
  212. % modify the interconnection structure to form the closed-loop plant
  213. %
  214. [ap,bp,cp,dp,b1,b2,c1,d11,d12,ndata] = hinffi_p(p,ncon);
  215.  np = max(size(ap));
  216.  c21 = eye(np);
  217.  [nr1,nc1] = size(b1);
  218.  c22 = zeros(nc1,np);
  219.  d211 = zeros(np,nc1);
  220.  d212 = eye(nc1);
  221.  [nr2,nc2] = size(b2);
  222.  d221 = zeros(np,nc2);
  223.  d222 = zeros(nc1,nc2);
  224.  
  225.  [a,b,c,d] = unpck(pnom);
  226.  c = [c; c21; c22];
  227.  d = [d; d211 d221; d212 d222];
  228.  p_fi = pck(a,b,c,d);
  229. %
  230. % form closed-loop system
  231. %
  232.  [g] = starp(p_fi,k,np+nc1,ncon);
  233.   if nargout >= 4
  234.     ax = vpck(storxinf,gammavecxi);
  235.     if nargout >= 5
  236.       hamx = vpck(storhx,gammavechx);
  237.     end
  238.   end
  239. %
  240. % Copyright MUSYN INC 1991,  All Rights Reserved
  241.