function [theta,x] =SPSA(x0,fun,a,c,alpha,gamma,A,n)
theta = x0;
p = length(x0);
for k = 0:n-1
ak = a/(k+1+A)^alpha;
ck = c/(k+1)^gamma;
delta = 2*round(rand(1,p))-1;
thetaplus = theta+ck*delta;
thetaminus = theta-ck*delta;
yplus = fun(thetaplus);
yminus = fun(thetaminus);
ghat = (yplus-yminus)./(2*ck*delta);
x(k+1,:) = theta';
theta = theta-ak*ghat;
end
%Notes:
%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);
%The MATLAB feval operation (not used above) is useful in
%yplus and yminus evaluations to allow for easy change of
%loss function.
%Algorithm initialization not shown above (see discussion
%in introduction to MATLAB code).
没有合适的资源?快使用搜索试试~ 我知道了~
SPSA Algorithm.rarSPSA Algorithm
共5个文件
m:5个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 1 下载量 174 浏览量
2022-04-11
21:11:48
上传
评论 1
收藏 2KB RAR 举报
温馨提示
提供了同步扰动随机近似优化算法(SPSA) 内部包含优化测试函数示例 可以直接点开运行,注释十分清晰
资源推荐
资源详情
资源评论
收起资源包目录
1096461.rar (5个子文件)
SPSA Algorithm
SPSA.m 906B
SPSAscript.m 895B
practice2.m 0B
fun.m 109B
practice.m 376B
新建文件夹
共 5 条
- 1
资源评论
- DDD汛2022-08-12资源内容详实,描述详尽,解决了我的问题,受益匪浅,学到了。
gu5218
- 粉丝: 31
- 资源: 259
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功