how can i combine LQR with genetic algorithm

4 visualizzazioni (ultimi 30 giorni)
RAHWA ZESLUS
RAHWA ZESLUS il 30 Mar 2021
i face adifficulty in designing LQR by genetic algorithm of an inverted pendulum that have Xmax <= 1m and V=(-10 , 10)
function y=myga(x)
Q=[x(1) x(2) x(3) x(4);x(5) x(6) x(7) x(8);
x(9) x(10) x(11) x(12); x(13) x(14) x(15) x(16)];
R=x(17);
A=[0 1 0 0;0 -0.1818 2.6727 0;0 0 0 1;0 -0.4545 30.1818 0];
B=[0; 1.8182; 0; 4.5455];
k=lqr(A,B,Q,R);
sim('invpend','setparam','k');
sum=0;
for i=1:length(simout.time)
sum=sum+simout.signals.values(i,1)-1;
end
y=sum;
options=gaoptimset('PopInitRange',[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100]';
x=ga(@myga,17,[],[],[],[],[],[],[],optimset);

Risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by