Commit 814213e3 by Kristian Soltesz

### cleaned up pidIAE

parent 8a45acaf
 % This example demonstrates how to invoke the scripts for obtaining % This example demonstrates how to invoke the scripts for obtaining %IE-optimal and IAE optimal (with or without LP filter) PID controllers. % IE-optimal and IAE optimal (with or without LP filter) PID controllers. % % % Downloaded from git@gitlab.control.lth.se:kristian/PIDopt.git % Downloaded from git@gitlab.control.lth.se:kristian/PIDopt.git % See the git repo for further documentation. % See the git repo for further documentation. ... ...
 function [K,p,w] =pidIAE(P,Ms,Mt,Mks,p,w) function [K,p,w] = pidIAE(P,Ms,Mt,Mks,p,w) % Computes PID controller that maximizes the integral gain subject to % Computes PID controller that maximizes the integral gain subject to % constraints on the magnitude of the sensitivity, complementary % constraints on the magnitude of the sensitivity, complementary % sensitivity and noise sensitivity fu nctions. % sensitivity and noise sensitivity fu nctions. ... @@ -54,7 +54,7 @@ cfg = optimset('algorithm','active-set','GradConstr','on','GradObj','on',... ... @@ -54,7 +54,7 @@ cfg = optimset('algorithm','active-set','GradConstr','on','GradObj','on',... p = p*k0; p = p*k0; K = K(p); K = K(p); % Objective and gradient % Objective and gradient function [J,J_p] = J(p) function [J,J_p] = J(p) % Objective % Objective [e,t] = step(P*S(p)); [e,t] = step(P*S(p)); ... @@ -66,30 +66,47 @@ K = K(p); ... @@ -66,30 +66,47 @@ K = K(p); J_p = trapz(t,mdot(sign(e),e_p)); J_p = trapz(t,mdot(sign(e),e_p)); end end % Constraints and gradients % Constraints and gradients function [c,cEq,c_p,cEq_p]=cNL(p) function [c,cEq,c_p,cEq_p]=cNL(p) % Ms % Sensitivity Sw = fr(S(p)); if Ms < inf Sm = abs(Sw); Sw = fr(S(p)); Sm = abs(Sw); cS = Sm-Ms; Sm_p = -mdot(Sm,real(mdot(Sw.*Pw,K_pw))); else cS = []; Sm_p = []; end % Mt % Complementary sensitivity Tw = 1-Sw; if Mt < inf Tm = abs(Tw); Tw = 1-Sw; Tm = abs(Tw); cT = Tm-Mt; Tm_p = mdot(Tm,real(mdot(Sw.^2.*Pw./Tw,K_pw))); else cT = []; Tm_p = []; end % Mks % Noise sensitivity Kw = fr(K(p)); if Mks < inf Km = abs(Kw); Kw = fr(K(p)); KSm = Km.*Sm*k0; % Undo regularization Km = abs(Kw); KSm = Km.*Sm*k0; % Undo regularization cKS = KSm-Mks; KSm_p = mdot(Sm./Km,real(mdot(conj(Kw).*Sw,K_pw))); else cKS = []; KSm_p = []; end % Constraints % Constraints c = [Sm-Ms,Tm-Mt,KSm-Mks]; c = [cS cT cKS]; cEq = []; cEq = []; % Gradients % Gradients SPdotK_pw = fr(P*S(p)*K_p); Sm_p = -mdot(Sm,real(mdot(Sw.*Pw,K_pw))); Tm_p = mdot(Tm,real(mdot(Sw.^2.*Pw./Tw,K_pw))); KSm_p = mdot(Sm./Km,real(mdot(conj(Kw).*Sw,K_pw))); c_p = [Sm_p;Tm_p;KSm_p].'; c_p = [Sm_p;Tm_p;KSm_p].'; cEq_p = []; cEq_p = []; end end ... ...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!