Download - 第六章 控制系统参数优化及仿真
-
Matlab
-
6.1 ,.
(1) (2) (3)
-
6.1 (1) J, B(R,L,C)()X
-
6.1 (2) ()()(KCLKVL)
-
6.1
-
6.1 (3)
-
6.1 -
-
6.1 (6.1.1)
-
6.1 (1)(2)(3)(4)(5)
-
6.1 (1) 6.1.1 6.1.1
-
6.1 (6.1.2)
-
6.1 q p ()
(2)
-
6.1 q p m
-
6.1 (1)
-
6.1 J (2) ()
-
6.2
-
6.2 6.2.1 ( ) 6.2.1(a) ( ) n
-
6.2 6.2.1(b)6.2.1
-
6.2 , (6.2.2)
: , ,
= (6.2.3) =0.6180339
-
6.2 6.2.2
-
6.2 6.2.1 A B E C
#include math.h #include stdio.h main( )
-
6.2 {float x0, x1, x2, x3, x4, e1, e2, q1, q2, q3, q4, q5, m, h0, h, c1, c2;int n;printf(intput x0, H0,E1, E2, M);scanf(%f, %f, %f, %f, %f ,&x0, &h0, &e1, &e2, &m ); x1=x0, q1=x1 *x1-10x1+36;p2: n=0; h=h0; x2=x1+h;q2=x2*x2-10x2+36;if(q1>q2) {h=h+h; n=n+1;}else {h= -h;x3=x1;q3=q1;
-
6.2 p1: x1=x2; q1=q2; x2=x3; q2=q3;} x3=x2+h; q3=x3*x3 -10x3+36; if(q2>q3) {h=h+h; n=n+1; go to p1;} else {if(n>0){x4=0.5*(x2+x3); q4=x4*x4 10*x4+36;if(q4>q2) {x3=x4; q3=q4;}else{x1=x2; q1=q2; x2=x4; q2=q4;}} c1=(q3-q1)/(x3-x1) c2=((q2-q1)/(x2-x1)-c1)/(x2-x3);
-
6.2 if(fabs(c2)q2) {x1=x2; q1=q2;} else{x1=x4; q1=q4;} h0=m*h0; go to p2;}
-
6.2 printf(OPTIM X=%f\n,x4); printf(OBJ.FUNC=%f,q4); }}} Q=11, x1=5.000 67, A=5.007 5, B=5.000 63
-
6.2 6.2.2 1 (6.2.4) (6.2.5)
-
6.2 (6.2.4) (6.2.6) (6.2.7) (6.2.7)a1a2 (6.2.5) (6.2.8)
-
6.2
(6.2.8) (6.2.9)
(6.2.10)
-
6.2 2. , ,, ,, , ,6.2.3(a)
-
6.2 , , , ,.2.3(b) , (6.2.11)
6.2.3
-
6.2 k+1
(6.2.12) , ,; ,
-
6.2 36.2.46.2.4(a)6.2.4(b)6.2.4(c) 6.2.4(a)(b)6.2.2 C #include math.h #include stdio.h
-
6.2 main( ) {float x0, x1, x2, x3, x4, e1, e2, q1, q2, q3, q4, q5, m, h0, h, c1, c2;int n;printf(input x0, H0, E1, E2, M)scanf(%f, %f, %f, %f, %f,&x0, &h0, &e1, &e2, &m);x1=x0; q1=x1*x1-10*x1+36;p2: n=0; h=h0; x2=x1+h; q2=x2*x2-10*x2+36; if(q1>q2) {h=h+h; n=n+1;} else {h= -h;x3=x1;q3=q1;
-
6.2 p1: x1=x2; q1+q2; x2=x3; q2=q3;} x3=x2+h; q3=x3*x3-10*x3+36; if(q2>q3) {h=h+h; n=n+1; go to p1;}else {if(n>0) {x4=0.5*(x2+x3); q4=x4*x4-10*x4+36; if(q4>q2) {x3=x4; q3=q4;}else{x1=x2; q1=q2; x2=x4;q2=q4;} } c1=(q3-q1)/(x3-x1); c2=((q2-q1)/(x2-x1)-c1)/(x2-x3
- 6.2 if(fabs(c2)
-
6.2 if(fabs((q4-q2)/q5>=e1) {if(q4>q2) {x1=x2; q1=q2}; else{x1=x4;q1=q4;} h0=m*h0; go to p2;} printf(OPTIM X=%f\n, x4); printf(OBJ.FUNC=%f ,q4); } }}
-
6.2.4 x0=0.5, h0=1, 0, e1=0.001, e2=1, m=0.1 optim x=5.0, obj.fucn=11.0
-
6.3
-
6.3 .3.1
-
6.3 (6.3.1) (6.3.2)
-
6.3 (6.3.3) (6.3.4) (6.3.5)
-
6.3 (6.3.6)(6.3.5) (6.3.7) (6.3.7)(6.3.2)
-
6.3 (6.3.9)
(6.3.10)(6.3.10)(6.3.7) (6.3.11) (6.3.12)
-
6.3 (6.3.12)(6.3.8)(6.3.7) (6.3.13)(6.3.5)
(6.3.14)
-
6.3 (6.3.6) (6.3.5) (6.3.5) (6.3.10)(6.3.6) (6.3.5)
-
6.3 (6.3.15) , (6.3.16)
- 6.3
-
6.3 6.3.1
6.3.1
- 6.3 CR P h f #include math.h#include stdio.h float x[10], y[10], p[10], f, h; int n; vod fun( ) {int i; for(i=1, i
-
6.3 f=x[1]*x[1]+x[2]*x[2]-x[1]*x[2]-10*x[1]-4*x[2];f=f+60;return;}main( ){float g[10], d[10], q, r, e, h1, h2, h3, h4, t, t0, c1, c2, f1, f2, f3, f4, f5, v;int i, k, u;printf(input n, e\n);scanf(%d, %f, &n, &e);
- 6.3 x[1]=0; x[2]=0;p4: g[1]=2*x[1]-x[2]-10;g[2]=2*x[2]-x[1]-4;q=0;for(i=1; i
-
6.3 {t0=1; v=0.1; h1=0; h=h1 fun( ); f1=f; p2: u=0;t=t0; h2=h1+t; h=h2; fun( ); f2=f; if(f1>f2) {t=t+t; u=u+1; else{t=-t; h3=h1; f3=f1; h1=h2;f1=f2;h2=h3;f2=f3; p1: h3=h2+t; h=h3; fun( );f3=f;
-
6.3 if(f2>f3) {t=t+t; u=u+1;h1=h2;f1=f2;h2=h3;f2=f3;goto p1;} else{if(u>0){h4=0.5*(h2+h3); h=h4; fun( ); f4=f; if(f4>f2) {h3=h4; f3=f4;} else{h1=h2; f1=f2; h2=h4; f2=f4;}} c1=(f3-f1)/(h3-h1);c2=((f2-f1)/(h2-h1)-c1)/(h2-h3);
- 6.3 if(fabs(c2)
- 6.3 else {if(f4>f2) {h1=h2;f1=f2;} else {h1=h4;f1=f4;} t0=v*t0; goto p2; }}} }p3: h=0; fun( );printf(OBJ.FUNC F=%f\n, f);for(i=1; i
-
6.3 {printf(X(%d, I);printf()=%f\n, x[i]);} } 6.3.2
-
6.3
6.3.2
-
6.3
-
6.3 6.3.2
-
6.3
(6.3.18)
: (6.3.19)
-
6.3 (6.3.20) (6.3.20)(6.3.18)
-
6.3 (6.3.21)
(6.3.22)
-
6.3 2 6.3.3(a) 0 0
6.3.3
-
6.3 6.3.3(b) (6.3.23) (6.3.24)
:
-
6.3 , (6.3.25) 6.3.4
-
6.3 ,Q(x*)=0,
-
6.3
,.
-
6.3 (6.3.26) = (6.3.27) (6.3.28)
-
6.3
6.3.5 6.3.4 6.3.5
-
6.3 ,
(6.3.29)
(6.3.28)(6.3.29)
(6.3.30)
, (6.3.31) Q(x)
-
6.3 6.3.1 C=[10 4]TA= E , (6.3.32)
-
6.3 (6.3.31) (6.3.33)(6.3.33) (6.3.34)
-
6.3 (6.3.35)
(6.3.36)
(6.3.35)(6.3.36)
-
6.3 (6.3.37)
(6.3.37) (6.3.38)(6.3.38) (6.3.39)
-
6.3
8 6 ()
-
6.3 (6.3.40) n (6.3.41) (6.3.42) (6.3.43)
-
6.3 (6.3.44)(6.3.44)(6.3.41)(6.3.42) (6.3.45) (6.3.46)(6.3.45)(6.3.46) (6.3.47)(6.3.47)A
-
6.3 (6.3.48) , (6.3.49) ,
-
6.3 , (6.3.51) (6.3.47) (6.3.52)(6.3.50)(6.3.51)(6.3.52)
-
6.3 = (6.3.53)
(6.3.53)(6.3.51)
(6.3.54)
. (6.3.55)
(6.3.56)
-
6.3 (6.3.55)(6.3.56)6.3.6 6.3.6
-
6.3 6.3.2
-
6.3
- 6.3 C #include math.h #include stdio.hfloat x[10],y[10],p[10],f,h;int n;void fun(){int i; for(I=1;I
- 6.3 main(){float g[10],q1,q0,e,h1,h2,h3,h4,t,t0,c1,c2,f1,f2,f3,f4,f5,v;int I,k,u;printf(INPUT N,E\n); scanf(%d,%d,&n,&e);for (I=1;I
- 6.3 for(i=1;I
-
6.3 p1: h3=h2+t;=h3; fun( );f3=f; if(f2>f3) {t=t+t;u=u+1;h1=h2;f1=f2;h2=h3;f2=f3;goto p1;} else {if(u>0){h4=0.5*(h2+h3);h=h4; fun( );f4=f; if(f4>f2) {h3=h4;f3=f4;} else{h1=h2;f1=f2;h2=h4;f2=f4;} } c1=(f3-f1)/(h3-h1); c2=((f2-f1)/(h2-h1)-c1)/(h2-h3);
- 6.3 if((f2
- 6.3 goto p4;p3: h=0;fun( );printf(OBJ.FUNC F=%f\n,f);for(I=1;I
-
6.3 6.3.3
-
6.3 6.3.7 123() 114 225345
-
6.3 n ( ) n ( )()( )(4)n
-
6.3 n n (6.3.57) (6.3.58) 10
-
6.3 6.3.86.3.7 6.3.8
-
6.3
(6.3.59)
(6.3.60)
(n) , (6.3.61):
-
6.3 (n1) ( ) ( ) ( ) () (6.3.62)
-
6.3 (6.3.61) () (6.3.63) 01 ( ) ( ) (6.3.64)
-
6.3 K6.3.97(1)(2)(3) (4) 1
-
6.3 (5)(6)(3)(4)(7)(4)
-
6.3 6.3.9
-
6.4 ()
-
6.4
-
6.4 ()n , (6.4.1) , , :
-
6.4 :
(6.4.2) (6.4.2)
-
6.4 (1) (5)
(2) (6.4.3)
11
-
6.4 3) (6.4.4)
C2~3 , (4)
-
6.4 (1) 4(56) T (2) () ( )
-
6.4 (3) 1/5 (4)
-
6.4 6.4.16.4.1
-
6.4 ( ) .
-
6.4 6.4.26.4.2
-
6.4 ( )
-
6.4 (1) () (2)
(6.4.5)
(3) 1 1
-
65 65 2 (6.5.1)
-
65 (6.5.1) (1) (2) (3) (2)
-
65
-
65 (6.5.2)
(6.5.3)
(6.5.4)
-
65
(6.5.5)
(6.5.6)
-
65 (1) (2) (3)
-
65
-
6.6 (6.6.1) (6.6.2) (6.6.3) (6.6.4)
-
6.6 , ,
-
6.6 (6.6.4)
(6.6.5)
(6.6.6)(6.6.5) (6.6.7)
-
6.6 ,(6.6.7)
(6.6.8)
(6.6.8) 6.6.1
-
6.6 6.6.1
-
6.6
6.6.1
-
6.6
, .
-
6.6 (1) , (2) (3) (6.6.2) (4) (6.6.4) (5)
(6) ,
-
6.6 (7)
(8)
(9) ,
(10) , , (2)
-
6.7 Matlab6.7.1 Matlab Matlab(Optimization Toolbox)Matlab
-
6.7 Matlab MatlabOptimization Toolbox
-
6.7 Matlab116.7.1
X=lp(f,A,b)X=qp(H,c,A,b)X=nnls(A,b)X=fmin(f,x)
-
6.7 Matlab
-
6.7 MatlabNelder-MeadBFGS(quasi-Newton)Gauss-NewtonLevenberg-Marquardt
-
6.7 MatlabMatlab6.7.2
x = fzero(@myfun,x0) x = fsolve(@myfun,x0)
-
6.7 MatlabMatlab6.7.3
x = lsqnonneg(C,d,x0)x =lsqlin(C,d,A,b,Aeq,beq,lb,ub,x0)
-
6.7 Matlab
x = lsqnonlin(fun,x0,lb,ub)x = lsqcurvefit(fun,x0, xdata,ydata,lb,ub)
-
6.7 Matlab.7.2 MatlabMatlaboptdemoMMatlab6.7.1 x0 = [-5 -5]m
-
6.7 Matlab function F = myfun(x)F = [2*x(1) - x(2) - exp(-x(1)); -x(1) + 2*x(2) - exp(-x(2))];x0 = [-5; -5]; % Make a starting guess at the solutionoptions=optimset('Display','iter'); % Option to display output[x,fval] = fsolve(@myfun,x0,options) % Call optimizer
-
6.7 MatlabIteration Func-count f(x) step optimality radius 0 3 23535.6 2.29e+004 1 1 6 6001.72 1 5.75e+003 1 2 9 1573.51 1 1.47e+003 1 3 12 427.226 1 388 1 4 15 119.763 1 107 1 5 18 33.5206 1 30.8 1 6 21 8.35208 1 9.05 1 7 24 1.21394 1 2.26 1 8 27 0.016329 0.759511 0.206 2.5 9 30 3.51575e-006 0.111927 0.00294 2.5 10 33 1.64763e-013 0.00169132 6.36e-007 2.5
-
6.7 MatlabOptimization terminated successfully: First-order optimality is less than options.TolFunx = 0.5671 0.5671fval = 1.0e-006 * -0.4059 -0.4059Matlab
-
6.7 Matlab 6.7.2Matlab
-
6.7 Matlab f=[-2 -1.3 -5] A=[1 2 4 -1; 2 3 -1 1; 1 0 1 1; -1 0 0 0; 0 -1 0 0; 0 0 -1 0; 0 0 0 -1] b=[6 12 4 0 0 0 0] X=lp(f,A,b) X = 0 2.6667 0 4.0000f'*Xans = -22.6667lp( )Matlabhelp lp
-
6.7 Matlab6.7.3MatlabM,fun.m function f=fun(x) f=exp(x(1))*(4*x(1)^2+2*x(2)^2+4*x(1)*x(2)+2*x(2)+1); x0=[-1 1]; options=[]; [x,options]=fminu('fun',x0,options)x = 0.5000 -1.0000options =[0 0.0001 0.0001 0.0000 0 0 0 0.0000 0 36.00000 0 0 200.0000 0 0.0000 0.1000 1.0000]
-
6.7 Matlaboptions18lpoptions(8)options(10)fun x0=[-1 1]; options=[];[x,options]=fminu('exp(x(1))*(4*x(1)^2+2*x(2)^2+4*x(1)*x(2)+2*x(2)+1)',x0,options)
-
6.7 Matlab6.7.4Matlab x0 = [-1 1]; options = []; [x,options] = constr('fun',x0,options) x = -9.5474 1.0474 options(8) ans0.0236
-
6.7 Matlab6.7.5lsqcurvefitxdataydata10xdata = [3.6 7.7 9.3 4.1 8.6 2.8 1.3 7.9 10.0 5.4];ydata = [16.5 150.6 263.1 24.7 208.5 9.9 2.7 163.9 325.0 54.3];
-
6.7 Matlab F(x,xdata) = x(1)*xdata.^2 + x(2)*sin(xdata) + x(3)*xdata.^3x0 = [0.3, 0.4, 0.1]MF() function F = myfun(x,xdata)F = x(1)*xdata.^2 + x(2)*sin(xdata) + x(3)*xdata.^3; % Assume you determined xdata and ydata experimentallyxdata = [3.6 7.7 9.3 4.1 8.6 2.8 1.3 7.9 10.0 5.4];ydata = [16.5 150.6 263.1 24.7 208.5 9.9 2.7 163.9 325.0 54.3];x0 = [10, 10, 10] % Starting guess[x,resnorm] = lsqcurvefit(@myfun,x0,xdata,ydata)
-
6.7 Matlabx = 0.2269 0.3385 0.3021% residual or sum of squaresresnorm = 6.2950
-
6-16-2 =0.000 01
-
6-3 (1) (2)
-
6-4PDI618PDI
-
PDI 6-5