필터 지우기
필터 지우기

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

커뮤니티

더 많은 답변 보기:  Power Electronics Community

카테고리

Help CenterFile Exchange에서 Genetic Algorithm에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by