- 积分
- 46
- 注册时间
- 2007-4-28
- 仿真币
-
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2010-9-11 09:50:48
|
显示全部楼层
来自 北京交通大学
17# shamohu
我用matlab的最优化方法去求解,但是算法容易陷入局部最小
-
- function y=myfun(x)
- n=3;
- b=n-1:-1:0;
- y=(sum(mod(floor(bsxfun(@rdivide,repmat(x,1,n),10.^fliplr(b))),10).^n,2)-x).^2;
复制代码
用下面的
-
- >> [x,y]=fminsearch(@myfun,400)
- x =
- 370
- y =
- 0
复制代码
针对多个局部极值,我用遗传工具箱,但是位数多的时候就不好用了
-
- function [x,fval,exitflag,output,population,score] = myfile(nvars,lb,ub,PopulationSize_Data)
- % This is an auto generated M-file from Optimization Tool.
- % Start with the default options
- options = gaoptimset;
- % Modify options setting
- options = gaoptimset(options,'PopulationSize', PopulationSize_Data);
- options = gaoptimset(options,'Display', 'off');
- [x,fval,exitflag,output,population,score] = ...
- ga(@myfun,nvars,[],[],[],[],lb,ub,[],options);
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
×
评分
-
1
查看全部评分
-
|