フィルターのクリア

How to constrain genetic algorithm input u?

3 ビュー (過去 30 日間)
JAMES KEEN
JAMES KEEN 2021 年 2 月 23 日
回答済み: Ur rehman Waheed 2021 年 3 月 10 日
My real system (buck converter) can only take an input of 0 to 1 (duty ratio) and I need to constrain the system so the controller action does not go past this. How can I do this?
The code for the project is below, it is steve bruntons genetic algorithm coding. https://youtu.be/S5C_z1nVaSg?t=470
I assume the u variable is the duty ratio but I am not sure.
---------------------------------------------------- First live script with Ga cmd in it-------------------------------------
clear all, close all, clc
dt = 0.000001; % this is 10^-6
PopSize = 30 % was 500
MaxGenerations = 10; %was 1000
s = tf('s');
G = (1439928003.68621)/(s*s+5333.33333333333*s+95995200.2457475) % got this by doing feedback cmd
options = optimoptions(@ga,'PopulationSize',PopSize,'MaxGenerations',MaxGenerations,'OutputFcn',@myfun);
[x,fval] = ga(@(K)pidtest(G,dt,K),3,-eye(3),zeros(3,1),[],[],[],[],[],options);
function J = pidtest(G,dt,parms)
-----------------------------------------------in adjacent live script------------------------------------------------
s = tf('s');
K = parms(1)+ parms(2)/s + parms(3)*s/(1+0.000001*s)% this is 10^-6
Loop = series(K,G);
ClosedLoop = feedback(Loop,1);
t = 0:dt:0.05; % this indicates length of time to show
[y,t] = step(ClosedLoop,t);
CTRLtf = K/(1+K*G);
u = lsim(K,1-y,t); % not sure if this is what I should change
Q = [1]; % Q weighting (couldn't get it so it looked at inductor current also) effecfts response of system?
R = 0.005; % R weighting effects controller action
J = dt*sum(Q*(1-y(:)).^2 + R*u(:).^2) % LQR is my cost function
step(5*ClosedLoop,t)
h = findobj(gcf,'type','line');
set(h,'linewidth',2);
drawnow
---------------------------------------------------------------------------------------------------------------------------------
Thanks in advance, if anymore information is desired please ask away.

回答 (1 件)

Ur rehman Waheed
Ur rehman Waheed 2021 年 3 月 10 日
I have same question

コミュニティ

カテゴリ

Help Center および File ExchangeGenetic Algorithm についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by