home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 4.ddi / OPTIM.DI$ / GOALDEMO.M < prev    next >
Encoding:
Text File  |  1993-03-11  |  2.5 KB  |  95 lines

  1. %GOALDEMO Demonstration of the goal-attainment method.
  2. clc
  3. echo on
  4. %   We demonstrate here the use of the Goal Attainment method
  5. %   for pole-placement. It follows the example in the reference manual. 
  6. %   Consider here a 2-input 2-output  unstable plant.
  7. pause % Strike any key to enter plant state-space matrices
  8.  
  9. A =  [ -0.5   0   0    
  10.         0    -2  10
  11.         0     1  -2];
  12.  
  13. B =  [  1  0
  14.        -2  2
  15.         0  1];
  16.  
  17. C =  [  1  0  0
  18.         0  0  1];
  19.  
  20. %  Suppose we wish to design an output feedback controller(X) to have poles
  21. %  to the left of the location [-5,-3,-1] in the complex plane.
  22. %  The controller must not have any gain element exceeding an absolute
  23. %  value of 4.
  24.  
  25. pause % Strike any key to enter goal pole locations
  26.  
  27. GOAL=[-5,-3,-1]
  28.  
  29. % Set the weights equal to the goals to ensure same percentage 
  30. % under- or over-attainment in the goals.
  31.  
  32. pause % Strike any key to enter weights 
  33.  
  34. W=abs(GOAL)
  35.  
  36. % Initialize output feedback controller
  37.  
  38. X = zeros(2,2); 
  39.  
  40. pause % Strike any key to set upper and lower bounds for X
  41.  
  42. VUB =  4*ones(2,2)
  43. VLB = -4*ones(2,2)
  44.  
  45. pause % Strike any key to initialize optimization parameters 
  46.  
  47. OPTIONS = 0;         % Use default termination and other criteria
  48.  
  49. pause % An M-file to return eigenvalues of closed loop system:
  50.  
  51. type eigfun
  52.  
  53. pause % Set optimization display parameter to give tabular display:
  54.  
  55. OPTIONS(1) = 1;
  56.  
  57. pause % Strike any key to start optimization
  58.  
  59. [X,OPTIONS] = attgoal('eigfun',X,GOAL,W,OPTIONS,VLB,VUB,[],A,B,C); 
  60.  
  61. pause % Strike any key to see results
  62.  
  63. %  The value of the control parameters at the solution is as follows:
  64. X
  65. %  The eigenvalues of the closed loop system are as follows:
  66. eigfun(X,A,B,C)
  67. %  The attainment factor (OPTIONS(8)) is as follows:
  68. OPTIONS(8)
  69. %  This indicates that the objectives have been over-achieved by 38.63%.
  70.   
  71. pause % Strike any key for next problem
  72. clc
  73.  
  74. % Suppose we require the eigenvalues to be as near as possible
  75. % to the goal values, [-5, -3, -1]. 
  76.  
  77. % Set OPTIONS(15) to the number of objectives that should be as near as possible
  78. % to the goals:
  79.  
  80. OPTIONS(15) = 3;
  81.  
  82. pause % Strike any key to start optimization
  83.  
  84. [X,OPTIONS] = attgoal('eigfun',X,GOAL,W,OPTIONS,VLB,VUB,[],A,B,C); 
  85.  
  86. pause % Strike any key to see results
  87.  
  88. %  This time the eigenvalues of the closed loop system are as follows:
  89. eigfun(X,A,B,C)
  90. %  The attainment factor (OPTIONS(8)) is as follows:
  91. OPTIONS(8)
  92. % which indicates that the eigenvalues have almost exactly met the goals.
  93.  
  94. pause % Strike any key to return 
  95.