📄 工具箱psotb-beta-.3的说明.txt
字号:
推荐一下老外的工具箱psotb-beta-.3
我已开始还不会编pso程序时,就用这个工具箱,现在简单给大家介绍一下用法:
其实这个工具箱使用也很简单:
如果你是初学者,头一次用这个工具箱,你可以直接运行pso.m文件。这个程序会优化默认的函数DeJong即超球体函数。
[fxmin, xmin, Swarm, history] = PSO(psoOptions)这是pso.m文件的函数定义
psoOptions------是定义的参数,可以是自己的,也可以是别人的
fxmin, xmin------代表函数最优值机最优位置
如果想优化自己定义的函数,就照例子写适应度函数,改参数设置,参数设置可以在 get_psoOptions.m内改,此文件内定义了很多结构体,参数就在结构体内改,
比如先改目标结构体
'Obj', struct(...
'f2eval', 'DeJong', ...%Function/System to optimize这是适应度函数名,默认是'DeJong'
%可以改为自己定义的函数名
'GM', 0, ... %Value of Global Minima (Required if Error goal is a termination criteria).这个可以不管它
'lb', -100, ... %Lower bounds of Initialization,变量的下界,是一个标量,取各个变量下界值最小值
'ub', 200 ), ... %Upper bounds of Initialization变量的上界,是一个标量,取各个变量下界值最大值
... %Termination Options
再改改变量结构体
'Vars', struct(...
'SwarmSize', 20, ... %Swarm Size 种群大小
'Iterations', 1000,... %Maximum Iterations迭代代数
'ErrGoal', 1e-10, ... %Error goal可以不管
'Dim', 10 ), ... %Dimensions of the problem变量维数
'SParams', struct(...
'c1', 2, ... %Cognitive Acceleration
'c2', 2, ... %Social Acceleration
'c3', 1, ... %Neighborhood Acceleration
'w_start', 0.95, ... %Value of velocity Weight at the begining
'w_end', 0.4, ... %Value of velocity Weight at the end of the pso iterations
'w_varyfor',0.7,... %The fraction of maximum iterations, for which w is linearly varied
'Vmax', 100,... %Maximum velocity step最大速度
'Chi', 1, ... %Constriction factor
'Nhood', 1 ), ... %Neighborhood size (nhood=1 ==> 2 neighbors, one on each side)
改以上有中文注释的地方后就可以运行了
不好意思,内容有点乱
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -