1 简介

无人机成本低,部署灵活,执行任务能力强,因此将无人机应用于城市环境下的应急救灾前景广阔。由于城市环境复杂且存在多种突发事件,综合考虑无人机的能力进行任务分配能够显著提高无人机群协同执行任务的效能。本文针对城市环境下的多无人机应急救灾任务分配问题进行了研究。

2 部分代码


          
          
%% RequestZone object class
classdef RequestZone6 < handle
%RequestZone class to simulate requests for aid in the UAV simulation
% Stores location, probability of requests, probability of high/low
% priority, time needed to fulfill requests, etc.
% This version is a handle class.
properties
position % The location of the drop zone
activeList % List of the currently active requests in that zone
probX % Probability of the new A request
probY % Probability of a B request
expired % Number of expired requests
numUnassigned % Number of unassigned requests
completed % The number of completed requets
manager % The manager that assigns to the drone
exprTimeX % The average time at which A requests expire
exprTimeY % The average time at which B requests expire
waitTime % The amount of time requests have waited for aid (COMPLETED/EXPIRED ONLY)
waitTimeHi % The amount of time high priority requests have waited
priFac % The priority factor
timeFac % The time factor (how requests gain importance over time)
ID % The Request zone ID number, equals the zone's index in the manager's requestZones list
end
methods
% Constructor
% This tells what the position of the request is. It also tells
% what the probability of a new request is and what the probability
% of a high priority request is
function obj = RequestZone6(pos,probX,probY,exprTimeX, exprTimeY, ID)
obj.position = pos;
obj.probX = probX;
obj.probY = probY;
obj.activeList=Request6.empty;
obj.expired = 0;
obj.numUnassigned = 0;
obj.completed = 0;
obj.waitTime = 0;
obj.waitTimeHi = 0;
obj.manager=Manager6.empty;
obj.exprTimeX = exprTimeX;
obj.exprTimeY = exprTimeY;
obj.priFac = 1;
obj.timeFac = 1;
obj.ID = ID;
end
% Refresh function to be called every few hours
% The function randomly tests to see if the request is of high
% priority or low priority and adds it to the list
function refresh(obj,time)
x1=rand; % Random number for new A requests
y1=rand; % Random number for new B requests
% Generate a new request based on the probabilities of new
% requests and high priority requests
priority = obj.priFac;
newHi = 0;
% Determine the number of requests to add using random numbers
% and the probability of new requests
while(x1<obj.probX)
% Create an X request
exprTime = obj.getExpire('X');
if(exprTime <= 1)
newHi = 1;
end
newreq = Request6(time, obj.manager.priFac,obj.manager.timeFac, obj,exprTime,'X',length(obj.activeList)+1);
obj.activeList(newreq.index) = newreq;
x1=rand;
end
while(y1<obj.probY)
exprTime = obj.getExpire('Y');
if(exprTime <= 1)
newHi = 1;
end
newreq = Request6(time, obj.manager.priFac,obj.manager.timeFac, obj,exprTime,'Y',length(obj.activeList)+1);
obj.activeList(newreq.index) = newreq;
y1=rand;
end
obj.numUnassigned = obj.getUnassigned();
% Refresh the all active requests
p = 1;
n = length(obj.activeList);
while (p <= length(obj.activeList))
if(obj.activeList(p).status > 0)
obj.activeList(p).refresh(time);
else
disp('Old request found')
obj.remove(obj.activeList(p).index);
end
if (n == length(obj.activeList))
p = p + 1;
else
n = length(obj.activeList);
end
end
% Call the assign function if a new high priority request was
% generated
if newHi > 0
obj.manager.assign();
end
end
% Function to remove the request from the active list upon completion
% This is a homemade way of removing the request from the
% active list so it will not be attempted twice
function remove(obj, index)
n = length(obj.activeList);
% Check that the index is less than the list length and that
% the list has more than one value
if(n>index && n>1)
for c = index:n-1
obj.activeList(c) = obj.activeList(c+1);
obj.activeList(c).index = c;
end
obj.activeList = obj.activeList(1:n-1);
elseif(n<=1)
% Remove the only element in a list
obj.activeList = Request6.empty;
elseif(index == n)
% Remove the last element(if necessary)
obj.activeList=obj.activeList(1:n-1);
end
end
% Function to return the number of unassigned requests
function c = getUnassigned(obj)
c = 0;
for i = 1:length(obj.activeList)
if (obj.activeList(i).status == 2)
c = c+1;
end
end
end
% Function to reset the zone at the beginning of a simulation
function reset(obj)
obj.activeList=Request6.empty;
obj.expired = 0;
obj.numUnassigned = 0;
obj.manager=Manager6.empty;
end
%% This function is made to get the highest priority requests from
% the request zone. The number of requests returned equals the number of UAV's in the fleet
function requests = getHighest(obj, numUAV)
P = zeros(length(obj.activeList), 2); % Stores priority
sortedRequests=Request6.empty;
for j = 1:length(obj.activeList)
P(j, :) = [obj.activeList(j).priority, j];
end
sortedP = sortrows(P, 1);
for c = 1: length(obj.activeList)
sortedRequests(c) = obj.activeList(sortedP(c, 2));
if sortedRequests(c).status<2 || sortedRequests(c).index<1
disp('OLD REQUEST FOUND')
end
sortedRequests(c).index=c;
end
if isempty(sortedRequests)
requests=sortedRequests;
else
obj.activeList=sortedRequests;
if(numUAV<length(sortedRequests))
requests = sortedRequests(1:numUAV);
else
requests=sortedRequests;
end
end
end
%% Find the expiration time for a given request
function exprTime = getExpire(obj, type)
p=rand; % uniform random number (0-1)
% Type X requests
if(type == 'X')
exprTime = (obj.exprTimeX.*(p.^(1/4)))./((1-p).^(1/4));
else
% Type Y
exprTime = (obj.exprTimeY.*(p.^(1/4)))./((1-p).^(1/4));
end
end
end
end
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84.
  • 85.
  • 86.
  • 87.
  • 88.
  • 89.
  • 90.
  • 91.
  • 92.
  • 93.
  • 94.
  • 95.
  • 96.
  • 97.
  • 98.
  • 99.
  • 100.
  • 101.
  • 102.
  • 103.
  • 104.
  • 105.
  • 106.
  • 107.
  • 108.
  • 109.
  • 110.
  • 111.
  • 112.
  • 113.
  • 114.
  • 115.
  • 116.
  • 117.
  • 118.
  • 119.
  • 120.
  • 121.
  • 122.
  • 123.
  • 124.
  • 125.
  • 126.
  • 127.
  • 128.
  • 129.
  • 130.
  • 131.
  • 132.
  • 133.
  • 134.
  • 135.
  • 136.
  • 137.
  • 138.
  • 139.
  • 140.
  • 141.
  • 142.
  • 143.
  • 144.
  • 145.
  • 146.
  • 147.
  • 148.
  • 149.
  • 150.
  • 151.
  • 152.
  • 153.
  • 154.
  • 155.
  • 156.
  • 157.
  • 158.
  • 159.
  • 160.
  • 161.
  • 162.
  • 163.
  • 164.
  • 165.
  • 166.
  • 167.
  • 168.
  • 169.
  • 170.
  • 171.
  • 172.
  • 173.
  • 174.
  • 175.
  • 176.

3 仿真结果

【无人机分配】救灾无人机机队任务分配问题研究附matlab代码_无人机

4 参考文献

[1]丁臻极. 城市环境下多无人机应急救灾任务分配技术研究[D]. 南京航空航天大学.

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

部分理论引用网络文献,若有侵权联系博主删除。

【无人机分配】救灾无人机机队任务分配问题研究附matlab代码_任务分配_02