This commit is contained in:
2026-01-27 21:46:40 -08:00
parent a68690a5cf
commit 03fae7077c
58 changed files with 214 additions and 213 deletions

View File

@@ -1,6 +1,6 @@
function obj = initialize(obj, pos, collisionGeometry, sensorModel, comRange, maxIter, initialStepSize, label, plotCommsGeometry)
arguments (Input)
obj (1, 1) {mustBeA(obj, 'agent')};
obj (1, 1) {mustBeA(obj, "agent")};
pos (1, 3) double;
collisionGeometry (1, 1) {mustBeGeometry};
sensorModel (1, 1) {mustBeSensor};
@@ -11,7 +11,7 @@ function obj = initialize(obj, pos, collisionGeometry, sensorModel, comRange, ma
plotCommsGeometry (1, 1) logical = false;
end
arguments (Output)
obj (1, 1) {mustBeA(obj, 'agent')};
obj (1, 1) {mustBeA(obj, "agent")};
end
obj.pos = pos;

View File

@@ -1,8 +1,8 @@
function [partitioning] = partition(obj, agents, objective)
arguments (Input)
obj (1, 1) {mustBeA(obj, 'agent')};
agents (:, 1) {mustBeA(agents, 'cell')};
objective (1, 1) {mustBeA(objective, 'sensingObjective')};
obj (1, 1) {mustBeA(obj, "agent")};
agents (:, 1) {mustBeA(agents, "cell")};
objective (1, 1) {mustBeA(objective, "sensingObjective")};
end
arguments (Output)
partitioning (:, :) double;
@@ -10,7 +10,7 @@ function [partitioning] = partition(obj, agents, objective)
% Assess sensing performance of each agent at each sample point
% in the domain
agentPerformances = cellfun(@(x) reshape(x.sensorModel.sensorPerformance(x.pos, [objective.X(:), objective.Y(:), zeros(size(objective.X(:)))]), size(objective.X)), agents, 'UniformOutput', false);
agentPerformances = cellfun(@(x) reshape(x.sensorModel.sensorPerformance(x.pos, [objective.X(:), objective.Y(:), zeros(size(objective.X(:)))]), size(objective.X)), agents, "UniformOutput", false);
agentPerformances{end + 1} = objective.sensorPerformanceMinimum * ones(size(agentPerformances{end})); % add additional layer to represent the threshold that has to be cleared for assignment to any partiton
agentPerformances = cat(3, agentPerformances{:});
@@ -24,7 +24,7 @@ function [partitioning] = partition(obj, agents, objective)
agentInds = reshape(agentInds, [size(agents, 1), size(agentInds)]); % needed for cases with 1 agent where prior squeeze is too agressive
end
agentInds = num2cell(agentInds, 2:3);
agentInds = cellfun(@(x) squeeze(x), agentInds, 'UniformOutput', false);
agentInds = cellfun(@(x) squeeze(x), agentInds, "UniformOutput", false);
agentInds{end + 1} = zeros(size(agentInds{end})); % index for no assignment
agentInds = cat(3, agentInds{:});

View File

@@ -1,12 +1,12 @@
function [obj, f] = plot(obj, ind, f)
arguments (Input)
obj (1, 1) {mustBeA(obj, 'agent')};
obj (1, 1) {mustBeA(obj, "agent")};
ind (1, :) double = NaN;
f (1, 1) {mustBeA(f, 'matlab.ui.Figure')} = figure;
f (1, 1) {mustBeA(f, "matlab.ui.Figure")} = figure;
end
arguments (Output)
obj (1, 1) {mustBeA(obj, 'agent')};
f (1, 1) {mustBeA(f, 'matlab.ui.Figure')};
obj (1, 1) {mustBeA(obj, "agent")};
f (1, 1) {mustBeA(f, "matlab.ui.Figure")};
end
% Create axes if they don't already exist
@@ -14,11 +14,11 @@ function [obj, f] = plot(obj, ind, f)
% Plot points representing the agent position
hold(f.Children(1).Children(end), "on");
o = scatter3(f.Children(1).Children(end), obj.pos(1), obj.pos(2), obj.pos(3), 'filled', 'ko', 'SizeData', 25);
o = scatter3(f.Children(1).Children(end), obj.pos(1), obj.pos(2), obj.pos(3), "filled", "ko", "SizeData", 25);
hold(f.Children(1).Children(end), "off");
% Check if this is a tiled layout figure
if strcmp(f.Children(1).Type, 'tiledlayout')
if strcmp(f.Children(1).Type, "tiledlayout")
% Add to other perspectives
o = [o; copyobj(o(1), f.Children(1).Children(2))];
o = [o; copyobj(o(1), f.Children(1).Children(3))];

View File

@@ -1,14 +1,14 @@
function obj = run(obj, domain, partitioning, timestepIndex, index, agents)
arguments (Input)
obj (1, 1) {mustBeA(obj, 'agent')};
obj (1, 1) {mustBeA(obj, "agent")};
domain (1, 1) {mustBeGeometry};
partitioning (:, :) double;
timestepIndex (1, 1) double;
index (1, 1) double;
agents (:, 1) {mustBeA(agents, 'cell')};
agents (:, 1) {mustBeA(agents, "cell")};
end
arguments (Output)
obj (1, 1) {mustBeA(obj, 'agent')};
obj (1, 1) {mustBeA(obj, "agent")};
end
% Collect objective function values across partition
@@ -82,9 +82,9 @@ function obj = run(obj, domain, partitioning, timestepIndex, index, agents)
% Reinitialize collision geometry in the new position
d = obj.pos - obj.collisionGeometry.center;
if isa(obj.collisionGeometry, 'rectangularPrism')
if isa(obj.collisionGeometry, "rectangularPrism")
obj.collisionGeometry = obj.collisionGeometry.initialize([obj.collisionGeometry.minCorner; obj.collisionGeometry.maxCorner] + d, obj.collisionGeometry.tag, obj.collisionGeometry.label);
elseif isa(obj.collisionGeometry, 'spherical')
elseif isa(obj.collisionGeometry, "spherical")
obj.collisionGeometry = obj.collisionGeometry.initialize(obj.collisionGeometry.center + d, obj.collisionGeometry.radius, obj.collisionGeometry.tag, obj.collisionGeometry.label);
else
error("?");

View File

@@ -1,6 +1,6 @@
function updatePlots(obj)
arguments (Input)
obj (1, 1) {mustBeA(obj, 'agent')};
obj (1, 1) {mustBeA(obj, "agent")};
end
arguments (Output)
end