章玉的博客分享 http://blog.sciencenet.cn/u/aspic 致力于交通运输经济与政策研究!

博文

SPSA算法的核心代码

已有 7206 次阅读 2010-10-11 10:27 |个人分类:交通|系统分类:科研笔记|关键词:学者

for k=0:n-1
ak=a/(k+1+A)^alpha;
ck=c/(k+1)^gamma;
delta=2*round(rand(p,1))-1;
thetaplus=theta+ck*delta;
thetaminus=theta-ck*delta;
yplus=loss(thetaplus);
yminus=loss(thetaminus);
ghat=(yplus-yminus)./(2*ck*delta);
theta=theta-ak*ghat;
end
theta
If maximum and minimum values on the values of
theta can be specified, say thetamax and
thetamin, then the following two lines can be
added below the theta update line to impose the
constraints
theta=min(theta,thetamax);
theta=max(theta,thetamin);

对于学习SPSA算法的初学者来讲非常有用。



https://m.sciencenet.cn/blog-456139-372056.html

上一篇:《交通规划模型——TransCAD的操作与应用》
下一篇:城市公共交通票制票价优化与财政补贴机制研究出版

1 杨华磊

发表评论 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-5-19 12:58

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部