From c9ac9d7725be625870237367920c38940a57394c Mon Sep 17 00:00:00 2001 From: Kevin D Date: Sat, 15 Nov 2025 17:02:04 -0800 Subject: [PATCH] adjusted partitioning to allow non-assignment --- @miSim/miSim.m | 1 + @miSim/partition.m | 2 ++ sensingModels/@sigmoidSensor/sensorPerformance.m | 4 ++-- test/test_miSim.m | 8 +++++++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/@miSim/miSim.m b/@miSim/miSim.m index 552e771..dc5387e 100644 --- a/@miSim/miSim.m +++ b/@miSim/miSim.m @@ -11,6 +11,7 @@ classdef miSim obstacles = cell(0, 1); % geometries that define obstacles within the domain agents = cell(0, 1); % agents that move within the domain adjacency = NaN; % Adjacency matrix representing communications network graph + sensorPerformanceMinimum = 1e-6; % minimum sensor performance to allow assignment of a point in the domain to a partition partitioning = NaN; end diff --git a/@miSim/partition.m b/@miSim/partition.m index 9383ea9..6a2ac30 100644 --- a/@miSim/partition.m +++ b/@miSim/partition.m @@ -9,6 +9,7 @@ function obj = partition(obj) % Assess sensing performance of each agent at each sample point % in the domain agentPerformances = cellfun(@(x) reshape(x.sensorModel.sensorPerformance(x.pos, x.pan, x.tilt, [obj.objective.X(:), obj.objective.Y(:), zeros(size(obj.objective.X(:)))]), size(obj.objective.X)), obj.agents, 'UniformOutput', false); + agentPerformances{end + 1} = obj.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{:}); % Get highest performance value at each point @@ -16,6 +17,7 @@ function obj = partition(obj) % Collect agent indices in the same way 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 = cat(3, agentInds{:}); % Get highest performing agent's index diff --git a/sensingModels/@sigmoidSensor/sensorPerformance.m b/sensingModels/@sigmoidSensor/sensorPerformance.m index f82d344..f48ff99 100644 --- a/sensingModels/@sigmoidSensor/sensorPerformance.m +++ b/sensingModels/@sigmoidSensor/sensorPerformance.m @@ -17,7 +17,7 @@ function value = sensorPerformance(obj, agentPos, agentPan, agentTilt, targetPos % Membership functions mu_d = 1 - (1 ./ (1 + exp(-obj.betaDist .* (d - obj.alphaDist)))); % distance mu_p = 1; % pan - mu_t = (1 ./ (1 + exp(-obj.betaPan .* (tiltAngle + obj.alphaPan)))) - (1 ./ (1 + exp(-obj.betaPan .* (tiltAngle - obj.alphaPan)))); % tilt + mu_t = (1 ./ (1 + exp(-obj.betaTilt .* (tiltAngle + obj.alphaTilt)))) - (1 ./ (1 + exp(-obj.betaTilt .* (tiltAngle - obj.alphaTilt)))); % tilt - value = mu_d .* mu_p .* mu_t * 1e12; + value = mu_d .* mu_p .* mu_t; end \ No newline at end of file diff --git a/test/test_miSim.m b/test/test_miSim.m index fd26fe2..b553c19 100644 --- a/test/test_miSim.m +++ b/test/test_miSim.m @@ -411,7 +411,7 @@ classdef test_miSim < matlab.unittest.TestCase tc.domain = tc.domain.initialize([zeros(1, 3); 10 * ones(1, 3)], REGION_TYPE.DOMAIN, "Domain"); % make basic sensing objective - tc.domain.objective = tc.domain.objective.initialize(@(x, y) mvnpdf([x(:), y(:)], tc.domain.center(1:2), eye(2)), tc.domain.footprint, tc.domain.minCorner(3), tc.discretizationStep); + tc.domain.objective = tc.domain.objective.initialize(@(x, y) mvnpdf([x(:), y(:)], tc.domain.center(1:2)), tc.domain, tc.discretizationStep); % Initialize agent collision geometry geometry1 = rectangularPrism; @@ -428,6 +428,12 @@ classdef test_miSim < matlab.unittest.TestCase tc.agents{1} = tc.agents{1}.initialize(tc.domain.center + [d, 0, 0], zeros(1,3), 0, 0, geometry1, sensor, @gradientAscent, 3*d, 1, sprintf("Agent %d", 1)); tc.agents{2} = tc.agents{2}.initialize(tc.domain.center - [d, 0, 0], zeros(1,3), 0, 0, geometry2, sensor, @gradientAscent, 3*d, 2, sprintf("Agent %d", 2)); + % Optional third agent along the +Y axis + % geometry3 = rectangularPrism; + % geometry3 = geometry3.initialize([tc.domain.center - [0, d, 0] - tc.collisionRanges(1) * ones(1, 3); tc.domain.center - [0, d, 0] + tc.collisionRanges(1) * ones(1, 3)], REGION_TYPE.COLLISION, sprintf("Agent %d collision volume", 3)); + % tc.agents{3} = agent; + % tc.agents{3} = tc.agents{3}.initialize(tc.domain.center - [0, d, 0], zeros(1, 3), 0, 0, geometry3, sensor, @gradientAscent, 3*d, 3, sprintf("Agent %d", 3)); + % Initialize the simulation [tc.testClass, f] = tc.testClass.initialize(tc.domain, tc.domain.objective, tc.agents, tc.timestep, tc.partitoningFreq, tc.maxIter); end