【WSN覆盖优化】基于改进花朵授粉算法实现带障碍物的异构无线传感器网络部署优化附Matlab代码

✅作者简介:热爱科研的Matlab仿真开发者,擅长数据处理、建模仿真、程序设计、完整代码获取、论文复现及科研仿真。

🍎个人主页:Matlab科研工作室

🍊个人信条:格物致知,完整Matlab代码及仿真咨询内容私信。

🌿 往期回顾可以关注主页,点击搜索

🔥 内容介绍

针对监测区域内含有障碍物的无线传感器网络(Wireless Sensor Networks,WSNs)异构节点部署优化问题,在花朵授粉算法(Flower Pollination Algorithm,FPA)的基础之上,提出了一种改进的花朵授粉算法(Improved Flower Pollination Algorithm,FPA)用于改善原有算法收敛速度慢、精度不够高的不足.设计非线性收敛因子以约束原有的缩放因子,采用Tent映射以维持迭代后期种群的多样性,而贪心交叉策略则是以较优的个体辅助较差个体搜索.基准函数实验验证了IFPA具有较好的收敛性能,而WSN部署的仿真实验表明IFPA可得到较高的覆盖率,可节约网络部署成本.    

📣 部分代码

function [rowsol,cost,v,u,costMat] = lapjv(costMat,resolution)% LAPJV  Jonker-Volgenant Algorithm for Linear Assignment Problem.%% [ROWSOL,COST,v,u,rMat] = LAPJV(COSTMAT, resolution) returns the optimal column indices,% ROWSOL, assigned to row in solution, and the minimum COST based on the% assignment problem represented by the COSTMAT, where the (i,j)th element% represents the cost to assign the jth job to the ith worker.% The second optional input can be used to define data resolution to% accelerate speed.% Other output arguments are:% v: dual variables, column reduction numbers.% u: dual variables, row reduction numbers.% rMat: the reduced cost matrix.%% For a rectangular (nonsquare) costMat, rowsol is the index vector of the% larger dimension assigned to the smaller dimension.%% [ROWSOL,COST,v,u,rMat] = LAPJV(COSTMAT,resolution) accepts the second% input argument as the minimum resolution to differentiate costs between% assignments. The default is eps.%% Known problems: The original algorithm was developed for integer costs.% When it is used for real (floating point) costs, sometime the algorithm% will take an extreamly long time. In this case, using a reasonable large% resolution as the second arguments can significantly increase the% solution speed.%% See also munkres, Hungarian% version 1.0 by Yi Cao at Cranfield University on 3rd March 2010% version 1.1 by Yi Cao at Cranfield University on 19th July 2010% version 1.2 by Yi Cao at Cranfield University on 22nd July 2010% version 2.0 by Yi Cao at Cranfield University on 28th July 2010% version 2.1 by Yi Cao at Cranfield University on 13th August 2010% version 2.2 by Yi Cao at Cranfield University on 17th August 2010% version 3.0 by Yi Cao at Cranfield University on 10th April 2013% This Matlab version is developed based on the orginal C++ version coded% by Roy Jonker @ MagicLogic Optimization Inc on 4 September 1996.% Reference:% R. Jonker and A. Volgenant, "A shortest augmenting path algorithm for% dense and spare linear assignment problems", Computing, Vol. 38, pp.% 325-340, 1987.%% Examples% Example 1: a 5 x 5 example%{[rowsol,cost] = lapjv(magic(5));disp(rowsol); % 3 2 1 5 4disp(cost);   %15%}% Example 2: 1000 x 1000 random data%{n=1000;A=randn(n)./rand(n);tic[a,b]=lapjv(A);toc                 % about 0.5 seconds %}% Example 3: nonsquare test%{n=100;A=1./randn(n);tic[a,b]=lapjv(A);toc % about 0.2 secA1=[A zeros(n,1)+max(max(A))];tic[a1,b1]=lapjv(A1);toc % about 0.01 sec. The nonsquare one can be done faster!%check resultsdisp(norm(a-a1))disp(b-b)%}if nargin<2    maxcost=min(1e16,max(max(costMat)));    resolution=eps(maxcost);end% Prepare working data[rdim,cdim] = size(costMat);M=min(min(costMat));if rdim>cdim    costMat = costMat';    [rdim,cdim] = size(costMat);    swapf=true;else    swapf=false;enddim=cdim;costMat = [costMat;2*M+zeros(cdim-rdim,cdim)];costMat(costMat~=costMat)=Inf;maxcost=max(costMat(costMat<Inf))*dim+1;if isempty(maxcost)    maxcost = Inf;endcostMat(costMat==Inf)=maxcost;% free = zeros(dim,1);      % list of unssigned rows% colist = 1:dim;         % list of columns to be scaed in various ways% d = zeros(1,dim);       % 'cost-distance' in augmenting path calculation.% pred = zeros(dim,1);    % row-predecessor of column in augumenting/alternating path.v = zeros(1,dim);         % dual variables, column reduction numbers.rowsol = zeros(1,dim)-1;  % column assigned to row in solutioncolsol = zeros(dim,1)-1;  % row assigned to column in solutionnumfree=0;free = zeros(dim,1);      % list of unssigned rowsmatches = zeros(dim,1);   % counts how many times a row could be assigned.% The Initilization Phase% column reductionfor j=dim:-1:1 % reverse order gives better results    % find minimum cost over rows    [v(j), imin] = min(costMat(:,j));    if ~matches(imin)        % init assignement if minimum row assigned for first time        rowsol(imin)=j;        colsol(j)=imin;    elseif v(j)<v(rowsol(imin))        j1=rowsol(imin);        rowsol(imin)=j;        colsol(j)=imin;        colsol(j1)=-1;    else        colsol(j)=-1; % row already assigned, column not assigned.    end    matches(imin)=matches(imin)+1;end% Reduction transfer from unassigned to assigned rowsfor i=1:dim    if ~matches(i)      % fill list of unaasigned 'free' rows.        numfree=numfree+1;        free(numfree)=i;    else        if matches(i) == 1 % transfer reduction from rows that are assigned once.            j1 = rowsol(i);            x = costMat(i,:)-v;            x(j1) = maxcost;            v(j1) = v(j1) - min(x);        end    endend% Augmenting reduction of unassigned rowsloopcnt = 0;while loopcnt < 2    loopcnt = loopcnt + 1;    % scan all free rows    % in some cases, a free row may be replaced with another one to be scaed next    k = 0;    prvnumfree = numfree;    numfree = 0;    % start list of rows still free after augmenting row reduction.    while k < prvnumfree        k = k+1;        i = free(k);        % find minimum and second minimum reduced cost over columns        x = costMat(i,:) - v;        [umin, j1] = min(x);        x(j1) = maxcost;        [usubmin, j2] = min(x);        i0 = colsol(j1);        if usubmin - umin > resolution             % change the reduction of the minmum column to increase the            % minimum reduced cost in the row to the subminimum.            v(j1) = v(j1) - (usubmin - umin);        else % minimum and subminimum equal.            if i0 > 0 % minimum column j1 is assigned.                % swap columns j1 and j2, as j2 may be unassigned.                j1 = j2;                i0 = colsol(j2);            end        end        % reassign i to j1, possibly de-assigning an i0.        rowsol(i) = j1;        colsol(j1) = i;        if i0 > 0 % ,inimum column j1 assigned easier            if usubmin - umin > resolution                % put in current k, and go back to that k.                % continue augmenting path i - j1 with i0.                free(k)=i0;                k=k-1;            else                % no further augmenting reduction possible                % store i0 in list of free rows for next phase.                numfree = numfree + 1;                free(numfree) = i0;            end        end    endend% Augmentation Phase% augment solution for each free rowsfor f=1:numfree    freerow = free(f); % start row of augmenting path    % Dijkstra shortest path algorithm.    % runs until unassigned column added to shortest path tree.    d = costMat(freerow,:) - v;    pred = freerow(1,ones(1,dim));    collist = 1:dim;    low = 1; % columns in 1...low-1 are ready, now none.    up = 1; % columns in low...up-1 are to be scaed for current minimum, now none.    % columns in up+1...dim are to be considered later to find new minimum,    % at this stage the list simply contains all columns.    unassignedfound = false;    while ~unassignedfound        if up == low    % no more columns to be scaned for current minimum.            last = low-1;            % scan columns for up...dim to find all indices for which new minimum occurs.             % store these indices between low+1...up (increasing up).            minh = d(collist(up));            up = up + 1;            for k=up:dim                j = collist(k);                h = d(j);                if h<=minh                    if h<minh                        up = low;                        minh = h;                    end                    % new index with same minimum, put on index up, and extend list.                    collist(k) = collist(up);                    collist(up) = j;                    up = up +1;                end            end            % check if any of the minimum columns happens to be unassigned.            % if so, we have an augmenting path right away.            for k=low:up-1                if colsol(collist(k)) < 0                    endofpath = collist(k);                     unassignedfound = true;                    break                end            end        end        if ~unassignedfound            % update 'distances' between freerow and all unscanned columns,            % via next scanned column.            j1 = collist(low);            low=low+1;            i = colsol(j1); %line 215            x = costMat(i,:)-v;            h = x(j1) - minh;            xh = x-h;            k=up:dim;            j=collist(k);            vf0 = xh<d;            vf = vf0(j);            vj = j(vf);            vk = k(vf);            pred(vj)=i;            v2 = xh(vj);            d(vj)=v2;            vf = v2 == minh; % new column found at same minimum value            j2 = vj(vf);            k2 = vk(vf);            cf = colsol(j2)<0;             if any(cf) % unassigned, shortest augmenting path is complete.                i2 = find(cf,1);                                endofpath = j2(i2);                unassignedfound = true;            else                 i2 = numel(cf)+1;            end            % add to list to be scaned right away            for k=1:i2-1                collist(k2(k)) = collist(up);                collist(up) = j2(k);                up = up + 1;            end        end    end    % update column prices    j1=collist(1:last+1);    v(j1) = v(j1) + d(j1) - minh;    % reset row and column assignments along the alternating path    while 1        i=pred(endofpath);        colsol(endofpath)=i;        j1=endofpath;        endofpath=rowsol(i);        rowsol(i)=j1;        if (i==freerow)            break        end    endendrowsol = rowsol(1:rdim);u=diag(costMat(:,rowsol))-v(rowsol)';u=u(1:rdim);v=v(1:cdim);cost = sum(u)+sum(v(rowsol));costMat=costMat(1:rdim,1:cdim);costMat = costMat - u(:,ones(1,cdim)) - v(ones(rdim,1),:);if swapf    costMat = costMat';    t=u';    u=v';    v=t;endif cost>maxcost    cost=Inf;end

⛳️ 运行结果

🔗 参考文献

本程序参考以下中文EI期刊,程序注释清晰,干货满满。

[1]王振东,谢华茂,胡中栋,et al.改进花朵授粉算法的无线传感器网络部署优化[J].系统仿真学报, 2021.DOI:10.16182/j.issn1004731x.joss.19-0580.

🎈 部分理论引用网络文献,若有侵权联系博主删除
🎁  关注我领取海量matlab电子书和数学建模资料

👇  私信完整代码、论文复现、期刊合作、论文辅导及科研仿真定制

1 各类智能优化算法改进及应用
生产调度、经济调度、装配线调度、充电优化、车间调度、发车优化、水库调度、三维装箱、物流选址、货位优化、公交排班优化、充电桩布局优化、车间布局优化、集装箱船配载优化、水泵组合优化、解医疗资源分配优化、设施布局优化、可视域基站和无人机选址优化
2 机器学习和深度学习方面
卷积神经网络(CNN)、LSTM、支持向量机(SVM)、最小二乘支持向量机(LSSVM)、极限学习机(ELM)、核极限学习机(KELM)、BP、RBF、宽度学习、DBN、RF、RBF、DELM、XGBOOST、TCN实现风电预测、光伏预测、电池寿命预测、辐射源识别、交通流预测、负荷预测、股价预测、PM2.5浓度预测、电池健康状态预测、水体光学参数反演、NLOS信号识别、地铁停车精准预测、变压器故障诊断
2.图像处理方面
图像识别、图像分割、图像检测、图像隐藏、图像配准、图像拼接、图像融合、图像增强、图像压缩感知
3 路径规划方面
旅行商问题(TSP)、车辆路径问题(VRP、MVRP、CVRP、VRPTW等)、无人机三维路径规划、无人机协同、无人机编队、机器人路径规划、栅格地图路径规划、多式联运运输问题、车辆协同无人机路径规划、天线线性阵列分布优化、车间布局优化
4 无人机应用方面
无人机路径规划、无人机控制、无人机编队、无人机协同、无人机任务分配、无人机安全通信轨迹在线优化
5 无线传感器定位及布局方面
传感器部署优化、通信协议优化、路由优化、目标定位优化、Dv-Hop定位优化、Leach协议优化、WSN覆盖优化、组播优化、RSSI定位优化
6 信号处理方面
信号识别、信号加密、信号去噪、信号增强、雷达信号处理、信号水印嵌入提取、肌电信号、脑电信号、信号配时优化
7 电力系统方面
微电网优化、无功优化、配电网重构、储能配置
8 元胞自动机方面
交通流 人群疏散 病毒扩散 晶体生长
9 雷达方面
卡尔曼滤波跟踪、航迹关联、航迹融合

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

天天Matlab科研工作室

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值