# Particle Swarm Optimization
This directory contains a simple implementation of particle swarm optimization (PSO.m), as well as scripts that use it to solve standard optimization test problems (TEST_PSO_*.m).
This implementation of PSO is designed for solving a bounded non-linear paramter optimization problem, with an initial guess. It is fully vectorized.
There are a variety of options that can be set by the user, but will be initialized to a default value if ommitted.
The output of the solver contains a full history of the optimization, which can be plotted using plotPsoHistory.m. Additionally, the user can define a plotting function to be called on each iteration.Both of these features are demonstrated in the TEST_PSO_*.m scripts.
The code supports both vectorized and non-vectorized objective function. If the objective function is vectorized, then the global best is updated synchronously, once per generation. If the objective function is not vectorized, then the optimization uses an asynchronous update, updating the global best after every particle update.
## Test Functions:
- TEST_PSO_1.m --> 2-D Sphere Function
- TEST_PSO_2.m --> Himmelblau's function
- TEST_PSO_3.m --> Goldstein-Price function
- TEST_PSO_4.m --> 2-D Styblinski-Tang function
- TEST_PSO_5.m --> N-D Styblinski-Tang function
## Help file for PSO.m
[xBest, fBest, info, dataLog] = PSO(objFun, x0, xLow, xUpp, options)
Particle Swarm Optimization
This function minimizes OBJFUN using a variant of particle swarm
optimization. The optimization uses an initial guess X0, and searches
over a search space bounded by XLOW and XUPP.
INPUTS:
objFun = objective function handle:
f = objFun(x)
x = [n, m] = search point in n-dimensional space (for m points)
f = [1, m] = objective function value, for each of m points
x0 = [n, 1] = initial search location
--> Optional input. Set x0 = [] to ignore.
xLow = [n, 1] = lower bounds on search space
xUpp = [n, 1] = upper bounds on search space
options = option struct. All fields are optional, with defaults:
.alpha = 0.6 = search weight on current search direction
.beta = 0.9 = search weight on global best
.gamma = 0.9 = search weight on local best
.nPopulation = m = 3*n = population count
.maxIter = 100 = maximum number of generations
.tolFun = 1e-6 = exit when variance in objective is < tolFun
.tolX = 1e-10 = exit when norm of variance in state < tolX
.flagVectorize = false = is the objective function vectorized?
.flagMinimize = true = minimize objective
--> Set to false to maximize objective
.flagWarmStart = false = directly use initial guess?
--> true: first particle starts at x0
--> false: all particles are randomly selected
.guessWeight = 0.2; trade-off for initialization; range [0, 0.9)
--> 0.0 ignore x0; use random initialization [xLow, xUpp]
--> 0.9 heavy weight on initial guess (x0)
.plotFun = function handle for plotting progress
plotFun( dataLog(iter), iter )
--> See OUTPUTS for details about dataLog
--> Leave empty to omit plotting (faster)
.display = 'iter';
--> 'iter' = print out info for each iteration
--> 'final' = print out some info on exit
--> 'off' = disable printing
.printMod = 1 (only used if display == 'iter')
OUTPUTS:
xBest = [n, 1] = best point ever found
fBest = [1, 1] = value of best point found
info = output struct with solver info
.input = copy of solver inputs:
.objFun
.x0
.xLow
.xUpp
.options
.exitFlag = how did optimization finish
0 = objective variance < tolFun
1 = reached max iteration count
2 = norm of state variance < tolX
.fEvalCount = how many calls to the objective function?
.X_Global = [n,iter] = best point in each generation
.F_Global = [1,iter] = value of the best point ever
.I_Global = [1,iter] = index of the best point ever
.X_Best_Var = [n,iter] = variance in best point along each dim
.X_Var = [n,iter] = variance in current search along each dim
.X_Best_Mean = [n,iter] = mean in best point along each dim
.X_Mean = [n,iter] = mean in current search along each dim
.F_Best_Var = [1,iter] = variance in the best val at each gen
.F_Var = [1,iter] = variance in the current val at each gen
.F_Best_Mean = [1,iter] = mean of the population best value
.F_Mean = [1,iter] = mean of the current population value
dataLog(iter) = struct array with data from each iteration
.X = [n,m] = current position of each particle
.V = [n,m] = current "velocity" of each particle
.F = [1,m] = value of each particle
.X_Best = [n,m] = best point for each particle
.F_Best = [1,m] = value of the best point for each particle
.X_Global = [n,1] = best point ever (over all particles)
.F_Global = [1,1] = value of the best point ever
.I_Global = [1,1] = index of the best point ever
NOTES:
This function uses a slightly different algorithm based on whether or
not the objective function is vectorized. If the objective is
vectorized, then the new global best point is only computed once per
iteration (generation). If the objective is not vectorized, then the
global best is updated after each particle is updated.
DEPENDENCIES
--> mergeOptions()
--> makeStruct()
REFERENCES:
http://www.scholarpedia.org/article/Particle_swarm_optimization
Clerc and Kennedy (2002)
没有合适的资源?快使用搜索试试~ 我知道了~
Matlab实现粒子 群 优化_有很好的例子记录_MATLAB_代码_下载
共23个文件
m:19个
gitignore:1个
md:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 24 浏览量
2022-06-20
15:26:33
上传
评论
收藏 161KB ZIP 举报
温馨提示
粒子群优化 该目录包含粒子群优化 (PSO.m) 的简单实现,以及使用它解决标准优化测试问题的脚本 (TEST_PSO_*.m)。 PSO 的这种实现是为解决有界非线性参数优化问题而设计的,具有初始猜测。它是完全矢量化的。 用户可以设置多种选项,但如果省略,将初始化为默认值。 求解器的输出包含完整的优化历史,可以使用 plotPsoHistory.m 绘制。此外,用户可以定义在每次迭代时调用的绘图函数。这两个功能都在 TEST_PSO_*.m 脚本中进行了演示。 该代码支持矢量化和非矢量化目标函数。如果目标函数是矢量化的,那么全局最佳值会同步更新,每代一次。如果目标函数未矢量化,则优化使用异步更新,在每次粒子更新后更新全局最佳值。 更多详情、使用方法,请下载后阅读README.md文件
资源推荐
资源详情
资源评论
收起资源包目录
ParticleSwarmOptimiaster.zip (23个子文件)
ParticleSwarmOptimizaaster
GoldsteinPrice.m 614B
.gitignore 42B
license.txt 1KB
PSO_Image.png 141KB
README.md 6KB
plotPsoHistory.m 2KB
TEST_PSO_2.m 937B
TEST_PSO_5.m 1KB
StyblinskiTang.m 460B
plotGoldsteinPrice.m 3KB
mergeOptions.m 2KB
TEST_PSO_4.m 821B
plotStyblinskiTang.m 3KB
TEST_PSO_7.m 1KB
Himmelblau.m 635B
StyblinskiTangNoise.m 551B
TEST_PSO_6.m 4KB
plotBowl.m 2KB
plotHimmelblau.m 4KB
TEST_PSO_1.m 767B
PSO.m 14KB
makeStruct.m 531B
TEST_PSO_3.m 945B
共 23 条
- 1
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9153
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功