Preliminary Heat Exchanger Control Design Study Steve Rogers 9 April 2011
Table of Contents Preliminary Heat Exchanger Control Design Study......................................................................................1 Table of Contents........................................................................................................................................1 Introduction.............................................................................................................................................1 Operating Conditions...............................................................................................................................2 Model Linearization.................................................................................................................................2 Simulink Dynamic Model.........................................................................................................................3 Pole Placement Method..........................................................................................................................4 LQR Method...........................................................................................................................................11 Optimization Using LQR.........................................................................................................................15 Conclusions............................................................................................................................................16 Appendix................................................................................................................................................17 Appendix – operating condition 1..........................................................................................................17 Appendix – operating condition 2..........................................................................................................19 Appendix – operating condition 3..........................................................................................................20 Appendix – operating condition 4..........................................................................................................21 Appendix – Genetic Algorithm Optimizer..............................................................................................22
Introduction Air bleed control systems for jet engines involve pressure, flow, and temperature regulation. Heat exchangers, control valves, and sensor suites are components of the system to be regulated. Ordinarily a cascade control system is used, with flow/pressure on the inner loop and temperature on the outer loop. The classical approach is to close one loop at a time starting with the inner loop. This study shows how a modern approach will close both loops simultaneously. We will show 4 different operating conditions. Solutions will be by pole placement and LQR (modern methods). In order to speed up development, optimization may be used to determine the weighting for the control laws. In this case we chose the LQR for optimization. We limited the parameter optimization to 11
1
variables, which include 6 state weights for the state estimator and the control gain, 4 input weights for the state estimator, and 1 input weight for the control gain.
Operating Conditions The following simulink model is intended to represent an air flow loop through a heat exchanger. The simulink model below is used to extract linear models at varying operating conditions which are used for control design. The various operating conditions are listed below. The operating conditions are contrived and are shown merely for the purpose of illustrating the control development concept. Fkw = [1.5 2 3 5]+0.5; ts_Q = [0.5 1 1.5 2]; ts_Fkw = [20 30 40 60]; Cp = [0.2 0.22 0.24 0.28]; Cv = Cp; rho = [0.1 0.09 0.08 0.06]; Tin = [20 60 80 110];
The above are inserted into the linearization model for each design. Example matlab code for inserting the operating variables follows. set_param('HX_lin_Mdl/In_Fkw','Value',num2str(Fkw(i))) set_param('HX_lin_Mdl/Cp','Value',num2str(Cp(i)))
Model Linearization Modern, as well as classical approaches require linear models. The linearization is performed by the following matlab code. The 2nd line establishes the input nominal value, along with the command limits. op=operspec('HX_lin_Mdl'); op.Inputs(1).u = 1;op.Inputs(1).Min = 0.5;op.Inputs(1).Max = 20; op.Outputs.Min(1) = op.Inputs(1).Min; op=findop('HX_lin_Mdl',op); lin_sys{i} = linearize('HX_lin_Mdl',op,io); A = lin_sys{i}.a;B = lin_sys{i}.b;C = lin_sys{i}.c;D = lin_sys{i}.d; sys = ss(A,B,C,D);
There is a single input and 4 outputs for the linearized model. The 4 outputs are: 1) Q measurement, 2) T measurement, 3) T error, and 4) T integral error. The input is Q commanded. Adding outputs for T error and T integral error provide additional setpoint error states that are input into the linearized model. Thus, any control law (pole placement, LQR, Hinf, etc.) that utilizes the following model construction will have a PI (proportional integral) control law as a component. In order to emulate failed sensors, the linearization model will be updated to eliminate them as outputs. The physical model is not altered, just the output vector. The output model is in the Appendix. A comparison of the eigenvalues of the original system and the controlled system is: [eig(A),eig(syscon3)] 0
-2.0000 2
-0.2000
-1.0000
0
-0.3000
-1.0000
-0.0900 + 0.1500i
-0.3333
-0.0900 - 0.1500i
-2.0000
-0.2000
The 1st column is the uncontrolled system, while the 2 nd column is the controlled system. The 2 integrators have been replaced with a complex stable pole. Note that the specified poles will be the same for all operating conditions. 1
2 In_Fkw 1 0.5s+1 Qlag
20s+1 HX_dist 1 1
1 s
3s+1 s+1 Valve Qsensor
10
Cp 1 In_Q
T
V
0.2
0.1 20
rho
Tin 0.20 Cv 30 Tsp 1
4
1 5s+1 Temp_sensor
Out_y 1 s T_err_int
Simulink Dynamic Model The simulink model below is nearly the same as the linearization model, with the additions of control algorithm and observer. The simulink diagram is for the 1 st operating condition: Fkw = 1.5 ts_Q = 0.5 ts_Fkw = 20 Cp = 0.2 Cv = 0.2; rho = 0.1 Tin = 20 Note that Fkw is the heat load, ts_Q is the time constant for the flow loop, ts_Fkw is the time constant for the heat load, and Tin is the inlet temperature.
3
1
2
10s+1 HX_dist 1 1
Fkw 1 0.5s+1 Qlag
1 s
3s+1 s+1 Valve Qsensor
10
T
V
0.2
0.1
Cp
20 rho
Tin
0.20 Cv Qsat
30 Q Saturation
Terr 4
syscon3
v ar 4
Tsp Tmeas
1
5s+1 Temp_sensor
Controller
1 s
2 Q
4 3
T_err_int Scope Terr Tmeas
AW
20
AW&err 3
Taw
Pole Placement Method The 1st controller shown is a pole placement state space method. Pole placement attempts to place the controlled system poles at specified locations by calculating control matrix gains. The development code is shown below. [a,b,c,d] = ssdata(sys); a1 = -0.05;b1 = 0.4i; pc = [a1+b1,a1-b1,-0.2,-0.08,-0.3,-1.2]; po = pc - 3; Lobs = place(a',c',po).';[nr,ncd]=size(Lobs); Lcon = place(a,b,pc);[nr,nc]=size(Lcon); syscon3 = ss(a-Lobs*c,Lobs,Lcon,zeros(nr,ncd));
The pole-zero maps display the poles/zeros for each of the 4 outputs SISO systems. All are stable with reasonable time constants and damping coefficients. The observer poles are in red & the controlled system poles are in blue. Note that there are right-half-plane zeros in 3 of the observers.
4
Pole-Zero Map
Pole-Zero Map 0.5 Imaginary Axis
Imaginary Axis
0.5
0
-0.5 -5
0
0
-0.5 -6
5
-4
-2
Real Axis Pole-Zero Map
Pole-Zero Map 0.4 Imaginary Axis
Imaginary Axis
2
Real Axis
0.5
0
-0.5 -6
0
-4
-2 Real Axis
0
2
0.2 0 -0.2 -0.4 -6
-4
-2
0
Real Axis
The 4 impulse responses are below. They are indicators of disturbance rejection capabilities of the control system. The top 3 are of most interest since the bottom is the integral of the 3 rd. The Q measurement (top) is the most important since it has the fastest dynamics and determines the overall system response. Within 50 seconds the disturbance has damped out. Also, the magnitude of response is relatively small, which keeps the other responses bounded as well.
5
Impulse Response From: Q cmd
To: T meas
0 -1 50 0 -50 50
To: T err
Amplitude
To: Q meas
1
0
To: T err int
-50 200 0 -200
0
20
40
60
80
100
120
Time (sec)
The step response is the integral of the impulse response and also is an indicator of the disturbance sensitivity of the control system.
6
Step Response From: Q cmd
To: T meas
0 -2 200 0
-200 200 To: T err
Amplitude
To: Q meas
2
0
To: T err int
-200 0 -2000 -4000
0
20
40
60
80
100
120
Time (sec)
The preceding plots were the output of linear model control analyses. The following shows the simulation plots of the simulink diagram with both plant and controller operating. The key plot is the bottom right, which is the deviation from setpoint (temperature error). The bottom left is the temperature measurement.
7
poleplace MV - HX System output variables 500 1.5 0
1
-500 0.5
-1000 -1500
0
200
400
600
0
60
40
40
20
20
0
0
0
200
400
600
-20
0
200
400
600
0
200 400 time (sec)
600
The next plot is from the 2nd operating condition & shows the same type of response as the 1 st. This is due to the consistency of the pole-placement approach. The key plot is the bottom right, which is the deviation from setpoint (temperature error). The bottom left is the temperature measurement.
8
poleplace MV - HX System output variables 1000 1.5 0
1
-1000 0.5
-2000 -3000
0
200
400
600
100
0
0
200
400
600
0
200 400 time (sec)
600
100
50 50 0
0
0
200
400
600
-50
The next plot is from the 3rd operating condition. The same kind of response is evident for all operating conditions. The key plot is the bottom right, which is the deviation from setpoint (temperature error). The bottom left is the temperature measurement.
9
poleplace MV - HX System output variables 1000 1.5 0
1
-1000 0.5
-2000 -3000
0
200
400
600
0
150
100
100
50
50
0
0
0
200
400
600
-50
0
200
400
600
0
200 400 time (sec)
600
The next plot is from the 4th operating condition. The same kind of response is evident for all operating conditions. The key plot is the bottom right, which is the deviation from setpoint (temperature error). The bottom left is the temperature measurement.
10
poleplace MV - HX System output variables 1000 1.5 0
1
-1000 0.5
-2000 -3000
0
200
400
600
150
0
0
200
400
600
0
200 400 time (sec)
600
150 100
100
50 50
0
0
0
200
400
600
-50
LQR Method The 2nd controller shown is a linear quadratic regulator (LQR) state space method. Pole placement attempts to place the controlled system poles at specified locations by calculating control matrix gains. LQR weights the states & inputs to generate control matrix gains. The development code is shown below. [a,b,c,d] = ssdata(sys); Q = eye(size(a))*1;%R = b(:,1:2)'*b(:,1:2)*1; R = c*c';R = eye(size(R))*1e2; Lobs = lqr(a',c',Q,R).';[nr,ncd]=size(Lobs); Q = eye(size(a))*1;R = b'*b*1e6; Lcon = lqr(a,b,Q,R);[nr,nc]=size(Lcon); syscon3 = ss(a-Lobs*c,Lobs,Lcon,zeros(nr,ncd));
The LQR weighting is accomplished via the Q & R matrices. One set of weights generates the observer gain matrix (Lobs) and another generates the control gain matrix (Lcon). The pole-zero maps display the poles/zeros for each of the 4 outputs SISO systems. All are stable with reasonable time constants and damping coefficients. The observer poles are in red & the controlled system poles are in blue. Note that there are right-half-plane zeros in only the last of the observers. In the case of the pole placement there were right-half-plane zeros in 3 of the 4 conditions.
11
Pole-Zero Map 1
0.5
0.5
Imaginary Axis
Imaginary Axis
Pole-Zero Map 1
0 -0.5 -1 -3
-2
-1
0 -0.5 -1 -3
0
-2
Real Axis
0.5
0.5
0 -0.5
-2
-1 Real Axis
0
Pole-Zero Map 1 Imaginary Axis
Imaginary Axis
Pole-Zero Map 1
-1 -3
-1 Real Axis
0
0 -0.5 -1 -3
-2
-1
0
1
Real Axis
The 4 impulse responses are below. They are indicators of disturbance rejection capabilities of the control system. The top 3 are of most interest since the bottom is the integral of the 3 rd. The Q measurement (top) is the most important since it has the fastest dynamics and determines the overall system response. Within 40 seconds the disturbance has damped out. Also, the magnitude of response is relatively small, which keeps the other responses bounded as well. The magnitude of the response is similar to that of the pole placement, but it is much less oscillatory. This corresponds with the pole-zero maps above.
12
Impulse Response From: Q cmd
To: T meas
0 -0.2 10 0 -10 10
To: T err
Amplitude
To: Q meas
0.2
0
To: T err int
-10 100 0 -100
0
10
20
30
40
50
60
70
80
90
Time (sec)
The step response is the integral of the impulse response and also is an indicator of the disturbance sensitivity of the control system. Again, the response appears less oscillatory than that of the pole placement.
13
Step Response From: Q cmd
To: T meas
0 -0.5 100 0 -100 100
To: T err
Amplitude
To: Q meas
0.5
0
To: T err int
-100 0 -1000 -2000
0
10
20
30
40
50
60
70
80
90
Time (sec)
The preceding plots were the output of linear model control analyses. The following shows the simulation plots of the simulink diagram with both plant and controller operating. The 1 st operating condition plot is shown next. The key plot is the bottom right, which is the deviation from setpoint (temperature error). The bottom left is the temperature measurement. Only one operating condition is shown as the procedure is the same as in the preceding section. The next section will deal with optimization, which is more important.
14
lqr MV - HX System output variables 200 0
1.5
1
-200 0.5
-400 -600
0
200
400
600
0
40
30
30
20
20
10
10
0
0
0
200
400
600
-10
0
200
400
600
0
200 400 time (sec)
600
Optimization Using LQR If there is multiple operating conditions that have significantly varying characteristics they usually require different control law gains for useful performance. An optimization program was set up to converge on 11 lqr control parameters as shown in the matlab code snippet below. [a,b,c,d] = ssdata(sys{i}); Q = diag(in(1:6)); R = diag(in(7:10)); Lobs = lqr(a',c',Q,R).';[nr,ncd]=size(Lobs); R = diag(in(11)); Lcon = lqr(a,b,Q,R);[nr,nc]=size(Lcon); syscon3 = ss(a-Lobs*c,Lobs,Lcon,zeros(nr,ncd));
The differing operating conditions shown previously serve as motivation for an optimization problem. The linearized plant models for each operating condition are shown in the Appendix. The optimizer should have a reasonably well thought out performance index to direct it. In this case it is a combination of deviation from setpoint and smoothness of transition, that is, there should be minimal change in measurements from one sampling instant to the next. The following plot was generated by optimizing over a series of operating conditions with changing setpoints and kw inputs, which provided disturbances to the system. There is still some oscillation or 15
‘buzz’ at the initial portion of the simulation for the 1 st operating condition, but the others have become smooth. lqr MV - HX System output variables 1000
5 4
500
3 2
0
1 -500
0
500
1000
1500
0
0
500
1000
1500
0
500 1000 time (sec)
1500
150 5 100 0 50 -5 0
0
500
1000
1500
The optimizer is a genetic algorithm as written by the author and the matlab code is shown in the Appendix.
Conclusions A continuous simulink model of a flow controlled heat exchanger was modeled. Four operating conditions were examined. Linear models of each were generated & are given in the Appendix. Two modern control methods were investigated as a means of tying together the inner and outer control loops simultaneously. The control solutions include an observer design and a control design. The observer generates an estimated, smooth state vector, while the control design uses the state estimates to track to a temperature setpoint. An optimization approach was also developed to speed up the control design over multiple operating conditions. Ordinarily, the development of a control law for a single operating condition will proceed manually to determine a feasible optimization process. Then, other operating conditions are included as the optimization process is evaluated. As experience and confidence in the optimization process is gained the entire suite of operating conditions are included. Failed sensor scenarios may also be included, or handled separately, as needed. 16
Any ‘modern’ control law (pole placement, LQR, Hinf, etc.) that utilizes the above model construction will have a PI (proportional integral) control law as a component. Since it has more states involved in the feedback controller than the classical PI controller it can be made more robust to disturbances. In order to emulate failed sensors, the linearization model can be updated to eliminate the failed sensors as outputs. The observer gain matrix Lobs produced by the LQR method for all operating conditions seem more uniformly spread over the input measurements. This is desirable from a robustness point of view. The pole placement Lobs set most of the column corresponding to the temperature error integral to zero. The LQR temperature response appeared to give less overshoot than the pole placement method. The impulse response of the LQR design was less oscillatory; therefore, it is likely to be more robust to disturbances. If gain scheduling for various operating conditions is required, please note that more parameters are required for each operating condition than the typical PI controller. Future activities include: 1) generate a better, more representative dynamic model, including realistic operating conditions, 2) controller discretization at proper sampling rates, 3) investigation of various sensor failures which may point to use of LQR output feedback, 4) gain scheduling for the various operating conditions, & 5) test plan (considering failures, changes in operating conditions, & interactions to the control loops) for control system verification/validation.
Appendix Appendix – operating condition 1 Linearized model – operating condition 1 a= x1
x2
x3
x4
x5
x6 0
x1
-2
0
0
0
0
x2
0
-1
0
0
0 0.3333
x3
0
20
0
0
0
0
x4
0
0
0
0
-0.2
0
x5
0
0
1
0
-0.2
0
x6
2
0
0
0
0 -0.3333
b= 17
u1 x1 1 x2 0 x3 0 x4 0 x5 0 x6 0
c= x1 x2 x3 x4 x5 x6 y1
0
1
0
0
0
y2
0
0
0
0 0.2
0
y3
0
0
0
0 -0.2
0
y4
0
0
0
1
0
0
0
d= u1 y1 0 y2 0 y3 0 y4 0
The observer gain matrix Pole placement Lobs = 2.2622 0.3577 -0.3577
0
5.9687 0.1545 -0.1545
0
18
19.6757 25.3964 -25.3964
0
0 -0.5000 0.5000 4.2000 -0.1010 15.4449 -15.4449 36.1821 1.9436 -1.9436
0 0
The observer gain matrix LQR Lobs = 0.0002 0.0001 -0.0001 -0.0000 0.0068 0.0163 -0.0163 -0.0045 0.1355 1.5313 -1.5313 -0.8492 -0.0045 -0.3411 0.3411 0.6779 0.0817 2.0404 -2.0404 -1.7056 0.0063 0.0225 -0.0225 -0.0071 The controller gain matrix Pole placement Lcon = -1.6533 0.3196 0.0061 -0.0004 0.0004 0.0025 The controller gain matrix Pole placement Lcon = 0.1947 0.2615 0.0141 -0.0010 0.0010 0.2041
Appendix – operating condition 2 Linearized model – operating condition 2 a= -1.0000
0
0
0
0
0 -1.0000
0
0
0 0.3333
0 61.2245
0
0
0
0
0 -0.2000
0
0
0
0
0 1.0000
1.0000
0
0
0
0 -0.2000 0
0
0
0 -0.3333
Matrices b, c, & d are the same for all operating conditions. Pole placement Lobs = 19
28.8890 -0.5032 0.5032
0
6.9738 0.0022 -0.0022
0
61.1681 25.3529 -25.3529
0
0 -0.5000 0.5000 4.2000 -0.0167 15.4322 -15.4322 54.1833 -0.2378 0.2378
0 0
LQR Lobs = 0.0006 0.0016 -0.0016 -0.0002 0.0062 0.0237 -0.0237 -0.0033 0.2797 4.0393 -4.0393 -1.2465 -0.0033 -0.4160 0.4160 0.7042 0.1183 3.7757 -3.7757 -2.0799 0.0052 0.0290 -0.0290 -0.0048 Pole placement Lcon = -0.6533 0.6392 0.0040 -0.0002 0.0002 0.0049 LQR Lcon = 0.3280 0.5504 0.0100 -0.0010 0.0010 0.3819
Appendix – operating condition 3 Linearized model – operating condition 3 a= -0.6667
0
0
0
0
0 -1.0000
0
0
0 0.3333
0 83.3333
0
0
0
0
0 -0.2000
0
0
0
0
0 1.0000
0.6667
0
0
0
0 -0.2000 0
0
0
0 -0.3333 20
Matrices b, c, & d are the same for all operating conditions. Pole Placement Lobs = 66.6056 -2.6625 2.6625
0
7.3012 -0.1076 0.1076
0
83.1563 25.4074 -25.4074
0
0 -0.5000 0.5000 4.2000 -0.0553 15.4471 -15.4471 61.3978 -1.5995 1.5995
0 0
LQR Lobs = 0.0008 0.0036 -0.0036 -0.0004 0.0059 0.0255 -0.0255 -0.0029 0.3339 5.1829 -5.1829 -1.3491 -0.0029 -0.4309 0.4309 0.7074 0.1274 4.3827 -4.3827 -2.1543 0.0047 0.0296 -0.0296 -0.0041 Pole Placement Lcon = -0.3200 0.9587 0.0044 -0.0003 0.0003 0.0074 LQR Lcon = 0.3742 0.7070 0.0095 -0.0010 0.0010 0.4792
Appendix – operating condition 4 Linearized model – operating condition 4 a= -0.5000
0
0
0
0
0 -1.0000
0
0
0 0.3333
0 117.0213 0
0
0 0
0
0
0 -0.2000
0
0 0 21
0 0.5000
0 1.0000 0
0
0 -0.2000 0
0
0 -0.3333
Matrices b, c, & d are the same for all operating conditions. Pole Placement Lobs = 108.0312 -5.6919 5.6919 7.4691 -0.1486 0.1486
0 0
116.8411 25.3984 -25.3984
0
0 -0.5000 0.5000 4.2000 -0.0563 15.4438 -15.4438 65.3202 -2.3030 2.3030
0 0
LQR Lobs = 0.0010 0.0057 -0.0057 -0.0005 0.0056 0.0276 -0.0276 -0.0024 0.4057 6.8067 -6.8067 -1.4573 -0.0024 -0.4449 0.4449 0.7099 0.1380 5.1396 -5.1396 -2.2243 0.0043 0.0298 -0.0298 -0.0034 Pole Placement Lcon = -0.1533 1.2783 0.0041 -0.0002 0.0002 0.0099 LQR Lcon = 0.4296 0.9308 0.0090 -0.0010 0.0010 0.6141
Appendix – Genetic Algorithm Optimizer % GA_scr_v1.m % Solution of improving edge detection of tracker by % genetic algorithm optimization.
22
% preliminaries clear all close all clc warning off dbstop if error if exist('GA_lqr_param.mat','file')==2,load GA_lqr_param, end num_elements = 15; % number of elements evaluated each generation MAXGEN = 50; % maximum number of generations (iterations) num_xovers = 3; % number of cross overs nvar = 11; % number of variables (see next line) filtr_pole = 0.9; % field_max_vec = [5*ones(1,6),1000*ones(1,4),2000,1000*ones(1,4),1200]; field_max_vec = [5*ones(1,6),1500*ones(1,4),3000]; GA_field_max(:,1) = field_max_vec(1)*ones(num_elements,1); %state wt1 GA_field_max(:,2) = field_max_vec(2)*ones(num_elements,1); %state wt2 GA_field_max(:,3) = field_max_vec(3)*ones(num_elements,1); %state wt3 GA_field_max(:,4) = field_max_vec(4)*ones(num_elements,1); %state wt4 GA_field_max(:,5) = field_max_vec(5)*ones(num_elements,1); %state wt5 GA_field_max(:,6) = field_max_vec(6)*ones(num_elements,1); %state wt6 GA_field_max(:,7) = field_max_vec(7)*ones(num_elements,1); %control wt1 GA_field_max(:,8) = field_max_vec(8)*ones(num_elements,1); %control wt2 GA_field_max(:,9) = field_max_vec(9)*ones(num_elements,1); %control wt3 GA_field_max(:,10) = field_max_vec(10)*ones(num_elements,1); %control wt4 GA_field_max(:,11) = field_max_vec(11)*ones(num_elements,1); %control wt5 % GA_field_max(:,12) = field_max_vec(12)*ones(num_elements,1); %control wt1 % GA_field_max(:,13) = field_max_vec(13)*ones(num_elements,1); %control wt2 % GA_field_max(:,14) = field_max_vec(14)*ones(num_elements,1); %control wt3 % GA_field_max(:,15) = field_max_vec(15)*ones(num_elements,1); %control wt4 % GA_field_max(:,16) = field_max_vec(16)*ones(num_elements,1); %control wt5 % field_min_vec = [zeros(1,6),2*ones(1,4),200,2*ones(1,4),200]; field_min_vec = [zeros(1,6),2*ones(1,4),200]; GA_field_min(:,1) = field_min_vec(1)*ones(num_elements,1); %state wt1 GA_field_min(:,2) = field_min_vec(2)*ones(num_elements,1); %state wt2 GA_field_min(:,3) = field_min_vec(3)*ones(num_elements,1); %state wt3 GA_field_min(:,4) = field_min_vec(4)*ones(num_elements,1); %state wt4 GA_field_min(:,5) = field_min_vec(5)*ones(num_elements,1); %state wt5 GA_field_min(:,6) = field_min_vec(6)*ones(num_elements,1); %state wt6 GA_field_min(:,7) = field_min_vec(7)*ones(num_elements,1); %control wt1 GA_field_min(:,8) = field_min_vec(8)*ones(num_elements,1); %control wt2 GA_field_min(:,9) = field_min_vec(9)*ones(num_elements,1); %control wt3 GA_field_min(:,10) = field_min_vec(10)*ones(num_elements,1); %control wt4 GA_field_min(:,11) = field_min_vec(11)*ones(num_elements,1); %control wt5 % GA_field_min(:,12) = field_min_vec(12)*ones(num_elements,1); %control wt1 % GA_field_min(:,13) = field_min_vec(13)*ones(num_elements,1); %control wt2 % GA_field_min(:,14) = field_min_vec(14)*ones(num_elements,1); %control wt3 % GA_field_min(:,15) = field_min_vec(15)*ones(num_elements,1); %control wt4 % GA_field_min(:,16) = field_min_vec(16)*ones(num_elements,1); %control wt5 GA_field = GA_field_min + (GA_field_max GA_field_min).*rand(size(GA_field_min)); if exist('global_best','var'), GA_field = [GA_field(1:end-1,:);global_best(1,:)]; end if exist('global_2nd_best','var'),
23
GA_field = [GA_field(2:end,:);global_2nd_best(1,:)]; end GA_best = GA_field; GA_best_cum = GA_field; perf_index_vec = contr_opt(GA_field); % [perf_index_vec,edge_PI_vec] = get_GA_optim(GA_field); [PImin,ind_PImin] = min(perf_index_vec); glob_best = ones(num_elements,1)*GA_field(ind_PImin,:); xcum = GA_field; perf_index_cum = perf_index_vec; [val ncp] = min(perf_index_cum,[],2); [val1 ncg] = min(val); [temp,nc2b] = sort(val); global_2nd_best = GA_best(nc2b(2),:); glob_best_filt = glob_best(1,:); for gen = 1:MAXGEN temp1 = [glob_best(1,:);glob_best_filt]; temp1 = [temp1;(randn(1,nvar)/15+1).*global_2nd_best(1,:)]; glob_best_mute = ceil(num_elements/2); for k = 1:glob_best_mute-num_xovers-1 % mutation computations temp = (randn(1,nvar)/15+1).*glob_best(1,:); temp1 = [temp1;temp]; end for k = 1:num_xovers-1 % crossover computation temp = randi(nvar,[1,5]);% select from 5 variables to get better spread minx = min(temp); maxx = max(temp); temp = GA_field(randi([2 num_elements],1),:); temp(minx:maxx) = glob_best(1,minx:maxx); temp1 = [temp1;temp]; end [nr,nc] = size(temp1); chromo_mute = randi(num_elements,[num_elements-nr,1]); temp2 = []; for k = 1:num_elements-nr % mutation computations temp = (randn(1,nvar)/15+1).*GA_field(chromo_mute(k),:); temp2 = [temp2;temp]; end GA_field = [temp1;temp2]; GA_field = min(GA_field,GA_field_max); % upper constraint GA_field = max(GA_field,GA_field_min); % lower constraint xcum = [xcum,GA_field]; perf_index_vec = contr_opt(GA_field); %[perf_index_vec,edge_PI_vec] = get_GA_optim(GA_field); perf_index_cum = [perf_index_cum perf_index_vec]; [val ncp] = min(perf_index_cum,[],2); for j = 1:length(ncp) GA_best(j,:) = xcum(j,... [nvar*(ncp(j)-1)+1:nvar*(ncp(j)-1)+nvar]); end GA_best_cum = [GA_best_cum,GA_best]; [temp,nc2b] = sort(val); glob_best = ones(num_elements,1)*GA_best(nc2b(1),:); global_2nd_best = GA_best(nc2b(2),:); glob_best_filt = filtr_pole*glob_best_filt + (1filtr_pole)*global_2nd_best;
24
%[val nedge_best] = min(sum(edge_PI_vec,2)); %edge_glob_best = edge_PI_vec(nedge_best,:); %save GA_lqr_param perf_index_cum glob_best GA_best_cum xcum global_2nd_best edge_glob_best save GA_lqr_param perf_index_cum glob_best GA_best_cum xcum global_2nd_best glob_best(1,:),perf_index_vec',%edge_glob_best end
25