资源简介
侵入性杂草优化(IWO)是自然启发式的元启发式方法,受杂草的传播策略启发,由Alireza Mehrabian和Caro Lucas于2006年提出。在本文中,我们将与您分享MATLAB中侵入性杂草优化(IWO)的结构化开源实现。
代码片段和文件信息
clc;
clear;
close all;
%% Problem Definition
CostFunction = @(x) Sphere(x); % objective Function
nVar = 5; % Number of Decision Variables
VarSize = [1 nVar]; % Decision Variables Matrix Size
VarMin = -10; % Lower Bound of Decision Variables
VarMax = 10; % Upper Bound of Decision Variables
%% IWO Parameters
MaxIt = 200; % Maximum Number of Iterations
nPop0 = 10; % Initial Population Size
nPop = 25; % Maximum Population Size
Smin = 0; % Minimum Number of Seeds
Smax = 5; % Maximum Number of Seeds
Exponent = 2; % Variance Reduction Exponent
sigma_initial = 0.5; % Initial Value of Standard Deviation
sigma_final = 0.001; % Final Value of Standard Deviation
%% Initialization
% Empty Plant Structure
empty_plant.Position = [];
empty_plant.Cost = [];
pop = repmat(empty_plant nPop0 1); % Initial Population Array
for i = 1:numel(pop)
% Initialize Position
pop(i).Position = unifrnd(VarMin VarMax VarSize);
% Evaluation
pop(i).Cost = CostFunction(pop(i).Position);
end
% Initialize Best Cost History
BestCosts = zeros(MaxIt 1);
%% IWO Main Loop
for it = 1:MaxIt
% Update Standard Deviation
sigma = ((MaxIt - it)/(MaxIt - 1))^Exponent * (sigma_initial - sigma_final) + sigma_final;
% Get Best and Worst Cost Values
Costs = [pop.Cost];
BestCost = min(Costs);
WorstCost = max(Costs);
% Initialize Offsprings Population
newpop = [];
% Reproduction
for i = 1:numel(pop)
ratio = (pop(i).Cost - WorstCost)/(BestCost - WorstCost);
S = floor(Smin + (Smax - Smin)*ratio);
for j = 1:S
% Initialize Offspring
newsol = empty_plant;
% Generate Random Location
newsol.Position = pop(i).Position + sigma * randn(VarSize);
% Apply Lower/Upper Bounds
newsol.Position = max(newsol.Position VarMin);
newsol.Position = min(newsol.Position VarMax);
% Evaluate Offsring
newsol.Cost = CostFunction(newsol.Position);
% Add Offpsring to the Population
newpop = [newpop
newsol]; %#ok
end
end
% Merge Populations
pop = [pop
newpop];
% Sort Population
[~ SortOrder]=sort([pop.Cost]);
pop = pop(SortOrder);
% Competitive Exclusion (Delete Extra Members)
if numel(pop)>nPop
pop = pop(1:nPop);
end
% Store Best Solution Ever Found
BestSol = pop(1);
% Store Best Cost History
BestCosts(it) = BestSol.Cost;
% Display Iteration Information
disp([‘Iteration ‘ num2str(it) ‘: Best Cost = ‘ num2str(BestCosts(it))]);
end
%% Results
f
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3132 2019-12-24 19:50 入侵杂草优化IWO\iwo.m
文件 10 2019-12-24 19:50 入侵杂草优化IWO\main.m
文件 55 2019-12-24 19:50 入侵杂草优化IWO\Sphere.m
目录 0 2019-12-24 19:49 入侵杂草优化IWO
----------- --------- ---------- ----- ----
3197 4
- 上一篇:混合蛙跳算法SFLA的matlab实现
- 下一篇:CMA-ES的matlab实现
相关资源
- CMA-ES的matlab实现
- 混合蛙跳算法SFLA的matlab实现
- 图像匹配matlab程序设计
- 天牛须智能算法(BAS)加模糊神经网
- MATLAB 费诺编码
- MatlabR2011b破解文件
- 基于Matlab2018b的SimMechanics工具箱建立的
- 粒子群算法matlab代码及使用
- 51622422POWER_SSSC_Ending.zip
- 直接序列扩频通信系统Matlab代码仿真
- 循环码matlab代码
- Matlab在结构动力学中的应用
- 基于灰度投影的图像配准MATLAB
- Matlab三维点云法向量与特征值的简易
- karman谱拟合
- 海浪模型MATLAB仿真代码
- 基于神经网络的自整定PID程序MATLAB
- PMX算法MATLAB实现
- 矩阵的QR分解基于施密特正交化
- 红外图像的处理及其MATLAB实现.zip
- 基于MATLAB的人脸识别源代码
- MATLAB最小错误率贝叶斯决策
- 水平集方法的matlab源代码
- 伪距差分定位MATLAB
- sigm激活函数
- 头部CTmatlab三维重建源代码.rar
- matlab中Copula理论及应用
- 矢量控制Matlab仿真图
- KPCA的MATLAB程序1
- 基于matlab的图像篡改检测2
评论
共有 条评论