added sensor performance metric
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
classdef agent
|
classdef agent
|
||||||
|
properties (Access = public)
|
||||||
|
performance = NaN; % current individual sensor performance on partition
|
||||||
|
end
|
||||||
properties (SetAccess = private, GetAccess = public)
|
properties (SetAccess = private, GetAccess = public)
|
||||||
% Identifiers
|
% Identifiers
|
||||||
index = NaN;
|
index = NaN;
|
||||||
|
|||||||
@@ -15,10 +15,7 @@ function obj = partition(obj)
|
|||||||
% Get highest performance value at each point
|
% Get highest performance value at each point
|
||||||
[~, idx] = max(agentPerformances, [], 3);
|
[~, idx] = max(agentPerformances, [], 3);
|
||||||
|
|
||||||
% Current total performance
|
% Collect agent indices in the same way as performance
|
||||||
obj.performance = sum(max(agentPerformances(:, :, 1:(end - 1)), [], 3), 'all');
|
|
||||||
|
|
||||||
% Collect agent indices in the same way
|
|
||||||
agentInds = cellfun(@(x) x.index * ones(size(obj.objective.X)), obj.agents, 'UniformOutput', false);
|
agentInds = cellfun(@(x) x.index * ones(size(obj.objective.X)), obj.agents, 'UniformOutput', false);
|
||||||
agentInds{end + 1} = zeros(size(agentInds{end})); % index for no assignment
|
agentInds{end + 1} = zeros(size(agentInds{end})); % index for no assignment
|
||||||
agentInds = cat(3, agentInds{:});
|
agentInds = cat(3, agentInds{:});
|
||||||
@@ -27,4 +24,13 @@ function obj = partition(obj)
|
|||||||
[m,n,~] = size(agentInds);
|
[m,n,~] = size(agentInds);
|
||||||
[i,j] = ndgrid(1:m, 1:n);
|
[i,j] = ndgrid(1:m, 1:n);
|
||||||
obj.partitioning = agentInds(sub2ind(size(agentInds), i, j, idx));
|
obj.partitioning = agentInds(sub2ind(size(agentInds), i, j, idx));
|
||||||
|
|
||||||
|
% Get individual agent sensor performance
|
||||||
|
for ii = 1:size(obj.agents, 1)
|
||||||
|
obj.agents{ii}.performance = sum(agentPerformances(sub2ind(size(agentInds), i, j, idx)), 'all');
|
||||||
|
end
|
||||||
|
|
||||||
|
% Current total performance
|
||||||
|
sum(arrayfun(@(x) x.performance, [obj.agents{:}]))
|
||||||
|
obj.performance = sum(max(agentPerformances(:, :, 1:(end - 1)), [], 3), 'all'); % do not count final "non-assignment" layer in computing cumulative performance
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user