資源簡介
matlab中平衡桿問題的強化學習代碼,包含Q學習、Sarsa學習的實現。

代碼片段和文件信息
%??Cart_Pole:?實施動作,通過估計τ秒后的狀態更新其值
function?[xx_dotthetatheta_dot]=Cart_Pole(actionxx_dotthetatheta_dot)
%?仿真參數
g=9.8;??????????????%重力
Mass_Cart=1.0;??????%車的質量
Mass_Pole=0.1;??????%桿的質量
Total_Mass=Mass_Cart+Mass_Pole;
Length=0.5;?????????%桿的一半的長度
PoleMass_Length=Mass_Pole*Length;
Force_Mag=10.0;
Tau=0.02;???????????%更新值的時間間隔
Fourthirds=1.3333333;
if?action>0
????force=Force_Mag;
else
????force=-Force_Mag;
end
temp?=?(force?+?PoleMass_Length?*theta_dot?*?theta_dot?*?sin(theta))/?Total_Mass;
thetaacc?=?(g?*?sin(theta)?-?cos(theta)*?temp)/?(Length?*?(Fourthirds?-?Mass_Pole?*?cos(theta)?*?cos(theta)?/?Total_Mass));
xacc??=?temp?-?PoleMass_Length?*?thetaacc*?cos(theta)?/?Total_Mass;
?
%?更新狀態值
x=x+Tau*x_dot;
x_dot=x_dot+Tau*xacc;
theta=theta+Tau*theta_dot;
theta_dot=theta_dot+Tau*thetaacc;
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-05-15?17:11??☆cartpole\
?????文件?????????897??2016-12-28?14:50??☆cartpole\Cart_Pole.m
?????文件????????1624??2016-12-28?14:26??☆cartpole\get_box.m
?????文件????????2919??2017-01-05?19:21??☆cartpole\main.asv
?????文件?????????134??2004-02-26?08:24??☆cartpole\plotcircle.m
?????文件?????????437??2005-03-09?02:26??☆cartpole\plot_Cart_Pole.m
?????文件??????????84??2005-03-08?23:39??☆cartpole\prob_push_right.m
?????文件????????2329??2017-01-05?19:56??☆cartpole\Q.asv
?????文件????????2406??2017-01-05?20:07??☆cartpole\Q.m
?????文件????????2535??2017-01-05?19:49??☆cartpole\Ql.m
?????文件??????????65??2005-03-09?01:08??☆cartpole\Random_Pole_Cart.m
?????文件????????2565??2017-01-05?19:30??☆cartpole\Sarsa.m
- 上一篇:matlab_基于QPSK的ML檢測算法
- 下一篇:用脈沖函數求傳遞函數
評論
共有 條評論