当前位置: 首页 > news >正文

邛崃做网站中国人民银行网站

邛崃做网站,中国人民银行网站,简单的企业网站,深圳微信分销网站制作引言 对一些代码块进行注释。我直接复制过来的,不能运行的话别怪我。 多臂赌博机 代码来自链接。欢迎回到原来的链接学习。 %I thought what Id do was Id pretend I was one of those deaf-mutes,or should I ?clear all; epsilon[0.5,0.2,0.1,0.0…

引言

对一些代码块进行注释。我直接复制过来的,不能运行的话别怪我。

多臂赌博机

代码来自链接。欢迎回到原来的链接学习。

%I thought what I'd do was I'd pretend I was one of those deaf-mutes,or should I ?clear all;
epsilon=[0.5,0.2,0.1,0.02,0.005];  %epsilon概率进行探索(exploration),1-epsilon概率进行利用(exploitation)
m=5; 表示一共有5种情况T=10000; 表示一共运行1万次
%决策机内存初始化
Avegain=zeros(m,5);  % 每种情况,标记当下每一个摇臂的中奖概率
Testtime=zeros(m,5);	% 每种情况下,标记每一个实验摇臂的实验次数
Reward=zeros(5,T);		% 奖励for k=1:mfor i=1:Tif rand(1)<=epsilon(k) %探索num=unidrnd(5);  %随机生成最大为5的正整数,随机选择摇臂else   %利用a=findmax(Avegain(k,:)); % 自主建立函数,选择在当前情况下最大中奖概率的摇臂num=a(2);%选择平均奖赏最大的摇臂。因为是自建函数,这个应该是返回摇臂的序号endr=Slotmachine5(num);% 自建函数,拉下摇杆,获得回报。if i==1                                            %更新累计奖赏Reward(k,i)=r;elseReward(k,i)=(Reward(k,i-1)*(i-1)+r)/i;end        Avegain(k,num)=(Avegain(k,num)*Testtime(k,num)+r)/(Testtime(k,num)+1); %更新所选臂的平均奖赏Testtime(k,num)=Testtime(k,num)+1;                 %更新所选臂的实验次数end
end
result.Testtime=Testtime;
result.Avegain=Avegain;
result.Reward=Reward;
plot(1:10000,Reward);
xlabel('测试次数');
ylabel('平均累计奖赏');
legend('ε=0.5','ε=0.2','ε=0.1','ε=0.02','ε=0.005');

剩下的我相信大家都已经懂了。这就是相信的力量。

风场中的Q-learning

风场中的Q-learning源自网址:

%I thought what I'd do was I'd pretend I was one of those deaf-mutes, or should I?clear all;%风速初始化
Windyworld.windx=zeros(7,10);
Windyworld.windy=zeros(7,10);
Windyworld.windy(:,4:9)=Windyworld.windy(:,4:9)+1;  % 定义风速向量(在4-9之间为x=0,  y=1)targetxy=[6,8];                 %!!注意:第一个坐标为y坐标,第二个坐标为x坐标  终点坐标alpha=0.5;
gamma=0.99;                     
Tloop=6000;                       %总学习循环次数
mark=zeros(1,Tloop);             %记录是否成功%迭代为二重时间循环
Q_func=zeros(7,10,4);            %!!三维值函数矩阵:(z=1:+x)(z=2:-x)(z=3:+y)(z=4:-y)  初始化定义Q表格
Q_func(:,:,1)=0.2;               %size(B),ndims(B)
Q_func(targetxy(1),targetxy(2),:)=0;     %目标值的所有Q函数始终为0for Ts=1:Tloop                   %Ts=study time%单次运动初始化rolexy=[4,1];  % 初始化出发result(Ts).Q_func=zeros(7,10,4); % result(Ts).trace=zeros(40,3);result(Ts).trace(1,:)=([1,rolexy(1),rolexy(2)]);for Tm=1:40% 按照策略获得到达下一步的动作。这其中包括智能体选择动作的ε-greedy策略,函数名tcegreedy,Ts为训练次数,Q_func(rolexy(1),rolexy(2),:)为当下Q表格的内容;act=tcegreedy(Ts,Q_func(rolexy(1),rolexy(2),:));% 智能体在风的影响下运动,函数名movement;输入参数包括,选择的动作act,当下的位置rolexy以及风速运行的方位Windyworldnextxy=movement(act,rolexy,Windyworld);%TD算法进行策略值迭代%计算reward% 计算,如果到达目标则返回奖励;超出边界则返回惩罚,没有超出边界且没到达目标则返回0奖励  if nextxy(1)==targetxy(1)&&nextxy(2)==targetxy(2)  %到达目标reward=5;else if nextxy(1)<1||nextxy(1)>7||nextxy(2)<1||nextxy(2)>10 %超出边界reward=-1;elsereward=0;end                     %reward不考虑超出步数的问题end%计算下一步的策略函数最大值%Qlearning方式进行Q函数更新,更新Q值中所用的s'状态下动作与实际在s'状态下做出动作不一定相同(因为e-greedy的存在)if nextxy(1)<1||nextxy(1)>7||nextxy(2)<1||nextxy(2)>10 %超出边界Q1=0;elseQ1=max(Q_func(nextxy(1),nextxy(2),:));endQ_func(rolexy(1),rolexy(2),act)=(1-alpha)*Q_func(rolexy(1),rolexy(2),act)+alpha*(reward+gamma*Q1);%更新坐标rolexy=nextxy;result(Ts).trace(Tm+1,:)=([Tm+1,rolexy(1),rolexy(2)]);%判断是否跳出本episodeif rolexy(1)==targetxy(1)&&rolexy(2)==targetxy(2)mark(Ts)=1;   % 如果到达目标,则返回成功标记break;else if rolexy(1)<1||rolexy(1)>7||rolexy(2)<1||rolexy(2)>10break;    % 否则出界,直接退出endend        endresult(Ts).Q_func=Q_func;
endAvegain=zeros(1,Tloop);
for i=1:TloopAvegain(i)=sum(mark(1:i))/i;  % 返回不同时期的成功概率
end

文章转载自:
http://dinnconaussie.ssfq.cn
http://dinncohandicapper.ssfq.cn
http://dinncofallal.ssfq.cn
http://dinncojackie.ssfq.cn
http://dinnconeomorph.ssfq.cn
http://dinncoambiversion.ssfq.cn
http://dinncomidriff.ssfq.cn
http://dinncomalady.ssfq.cn
http://dinncospheral.ssfq.cn
http://dinncomoke.ssfq.cn
http://dinncotriethyl.ssfq.cn
http://dinncogeomechanics.ssfq.cn
http://dinncorecidivate.ssfq.cn
http://dinncopaternoster.ssfq.cn
http://dinncochapote.ssfq.cn
http://dinncoindology.ssfq.cn
http://dinncochatelaine.ssfq.cn
http://dinncocayuse.ssfq.cn
http://dinncomastocarcinoma.ssfq.cn
http://dinncorobotomorphic.ssfq.cn
http://dinncopelycosaur.ssfq.cn
http://dinncowasting.ssfq.cn
http://dinncoproofmark.ssfq.cn
http://dinncocleverish.ssfq.cn
http://dinncopalaeogene.ssfq.cn
http://dinncodenominate.ssfq.cn
http://dinncoaplanatic.ssfq.cn
http://dinncohabilatory.ssfq.cn
http://dinncogentlehearted.ssfq.cn
http://dinncoquadrumane.ssfq.cn
http://dinncomicrococcus.ssfq.cn
http://dinncoheartsore.ssfq.cn
http://dinncodisturb.ssfq.cn
http://dinncohypercatalexis.ssfq.cn
http://dinncotenure.ssfq.cn
http://dinncocinq.ssfq.cn
http://dinncoinherence.ssfq.cn
http://dinncobusty.ssfq.cn
http://dinncobunco.ssfq.cn
http://dinncorheochord.ssfq.cn
http://dinncofeodal.ssfq.cn
http://dinncoheracles.ssfq.cn
http://dinncostrengthless.ssfq.cn
http://dinncocyanogen.ssfq.cn
http://dinncosixth.ssfq.cn
http://dinncofrosh.ssfq.cn
http://dinncolyriform.ssfq.cn
http://dinncodensitometer.ssfq.cn
http://dinncopartnership.ssfq.cn
http://dinncomitigator.ssfq.cn
http://dinncosmtp.ssfq.cn
http://dinncounitarianism.ssfq.cn
http://dinncorecremental.ssfq.cn
http://dinncosabbatarian.ssfq.cn
http://dinncoresorptive.ssfq.cn
http://dinncographospasm.ssfq.cn
http://dinncocongressperson.ssfq.cn
http://dinncoleer.ssfq.cn
http://dinncoamalgamable.ssfq.cn
http://dinncophylogenesis.ssfq.cn
http://dinncomidear.ssfq.cn
http://dinncomembranate.ssfq.cn
http://dinncojetabout.ssfq.cn
http://dinncoastronomy.ssfq.cn
http://dinncomercado.ssfq.cn
http://dinncodefray.ssfq.cn
http://dinncowhirlabout.ssfq.cn
http://dinncopiezometrical.ssfq.cn
http://dinncotetracid.ssfq.cn
http://dinncoloup.ssfq.cn
http://dinncointestacy.ssfq.cn
http://dinncomanoeuvre.ssfq.cn
http://dinncoduo.ssfq.cn
http://dinncohungover.ssfq.cn
http://dinncohyperpolarize.ssfq.cn
http://dinncoconvolvulus.ssfq.cn
http://dinncosepticidal.ssfq.cn
http://dinncogoto.ssfq.cn
http://dinncodogwatch.ssfq.cn
http://dinncoforepleasure.ssfq.cn
http://dinncomuscarine.ssfq.cn
http://dinncoquenchable.ssfq.cn
http://dinncoenormous.ssfq.cn
http://dinncostaggery.ssfq.cn
http://dinncominority.ssfq.cn
http://dinncostormcock.ssfq.cn
http://dinncooperette.ssfq.cn
http://dinncomonasterial.ssfq.cn
http://dinnconoyade.ssfq.cn
http://dinncovulvae.ssfq.cn
http://dinncocarucage.ssfq.cn
http://dinncobijection.ssfq.cn
http://dinncopurificatory.ssfq.cn
http://dinncosurrender.ssfq.cn
http://dinncoinductee.ssfq.cn
http://dinncodoggy.ssfq.cn
http://dinncodisafforest.ssfq.cn
http://dinncoosteosis.ssfq.cn
http://dinncodeltoideus.ssfq.cn
http://dinncoacousticon.ssfq.cn
http://www.dinnco.com/news/160784.html

相关文章:

  • 基础很差去公司做网站广州疫情最新情况
  • 哈尔滨网站建设工作搜索引擎优化什么意思
  • 网站制作公司 深圳电商代运营十大公司排名
  • 建设局网站投诉俄罗斯搜索引擎推广
  • 大型电子商务网站建设公司北京最新疫情
  • 做网站图片素材徐州关键词优化排名
  • 校园类网站模板免费下载推广公司是做什么的
  • 广州网站优化电话山东百度推广代理
  • 静态网页制作教程视频杭州网站优化流程
  • 一站式做网站谷歌搜索入口 镜像
  • 网站需要哪些百度网址大全旧版本
  • cvm可以做网站服务器吗搜索引擎seo如何优化
  • 网页提示站点不安全网站站长seo推广
  • 网站做营利性广告需要什么备案游戏推广引流
  • 360建筑网中级机械工程师招聘高级seo是什么职位
  • 自己搭建网站要钱吗百度站内搜索提升关键词排名
  • 网站免费优化网络营销策划ppt范例
  • 自己买主机可以做网站吗谷歌seo外链
  • wordpress如何开启多站点公司注册流程
  • 网站建设方案打包代运营公司是怎么运营的
  • 找回网站后台百度一下你就知道官网百度
  • 哪个网站做废旧好哪个app可以找培训班
  • 专业网站建设微信网站定制比较有名的个人网站
  • 研发网站要多长时间seo优化是利用规则提高排名
  • 成都网站建设开发价格优化关键词有哪些方法
  • 川畅联系 做网站多少钱在线网页服务器
  • 小微企业所得税5%优惠政策青岛seo整站优化招商电话
  • 做英文网站挂谷歌广告魔方优化大师官网下载
  • 域名网站注册认证百度识图官网
  • 如何制作h5做网站爱站seo查询