made no plotting flag for better performance and unit testing

This commit is contained in:
2025-12-24 16:20:57 -08:00
parent 843e5ba574
commit 1d11ac4e90
6 changed files with 33 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
function obj = initialize(obj, domain, objective, agents, minAlt, timestep, partitoningFreq, maxIter, obstacles, makeVideo)
function obj = initialize(obj, domain, objective, agents, minAlt, timestep, partitoningFreq, maxIter, obstacles, makePlots, makeVideo)
arguments (Input)
obj (1, 1) {mustBeA(obj, 'miSim')};
domain (1, 1) {mustBeGeometry};
@@ -9,14 +9,23 @@ function obj = initialize(obj, domain, objective, agents, minAlt, timestep, part
partitoningFreq (:, 1) double = 0.25
maxIter (:, 1) double = 1000;
obstacles (:, 1) cell {mustBeGeometry} = cell(0, 1);
makePlots(1, 1) logical = true;
makeVideo (1, 1) logical = true;
end
arguments (Output)
obj (1, 1) {mustBeA(obj, 'miSim')};
end
% enable/disable video writer
% enable/disable plotting and video writer
obj.makePlots = makePlots;
if ~obj.makePlots
if makeVideo
warning("makeVideo set to true, but makePlots set to false. Setting makeVideo to false.");
makeVideo = false;
end
end
obj.makeVideo = makeVideo;
% Define simulation time parameters
obj.timestep = timestep;
@@ -51,7 +60,6 @@ function obj = initialize(obj, domain, objective, agents, minAlt, timestep, part
obj.partitioningTimes = obj.times(obj.partitioningFreq:obj.partitioningFreq:size(obj.times, 1));
% Prepare performance data store (at t = 0, all have 0 performance)
obj.fPerf = figure;
obj.perf = [zeros(size(obj.agents, 1) + 1, 1), NaN(size(obj.agents, 1) + 1, size(obj.partitioningTimes, 1) - 1)];
% Create initial partitioning

View File

@@ -28,8 +28,9 @@ classdef miSim
partitioningTimes;
% Plot objects
makePlots = true; % enable/disable simulation plotting (performance implications)
makeVideo = true; % enable/disable VideoWriter (performance implications)
f = firstPlotSetup(); % main plotting tiled layout figure
f; % main plotting tiled layout figure
connectionsPlot; % objects for lines connecting agents in spatial plots
graphPlot; % objects for abstract network graph plot
partitionPlot; % objects for partition plot

View File

@@ -5,6 +5,11 @@ function obj = plot(obj)
arguments (Output)
obj (1, 1) {mustBeA(obj, 'miSim')};
end
% fast exit when plotting is disabled
if ~obj.makePlots
return;
end
% Plot domain
[obj.domain, obj.f] = obj.domain.plotWireframe(obj.spatialPlotIndices);

View File

@@ -6,6 +6,13 @@ function obj = plotPerformance(obj)
obj (1, 1) {mustBeA(obj, 'miSim')};
end
% fast exit when plotting is disabled
if ~obj.makePlots
return;
end
obj.fPerf = figure;
axes(obj.fPerf);
title(obj.fPerf.Children(1), "Sensor Performance");
xlabel(obj.fPerf.Children(1), 'Time (s)');

View File

@@ -7,6 +7,11 @@ function [obj] = updatePlots(obj, updatePartitions)
obj (1, 1) {mustBeA(obj, 'miSim')};
end
% Fast exit when plotting is disabled
if ~obj.makePlots
return;
end
% Update agent positions, collision geometries
for ii = 1:size(obj.agents, 1)
obj.agents{ii}.updatePlots();