made no plotting flag for better performance and unit testing
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)');
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -5,6 +5,7 @@ classdef test_miSim < matlab.unittest.TestCase
|
||||
|
||||
% Debug
|
||||
makeVideo = true; % disable video writing for big performance increase
|
||||
makePlots = true; % disable plotting for big performance increase (also disables video)
|
||||
|
||||
% Sim
|
||||
maxIter = 250;
|
||||
@@ -528,7 +529,6 @@ classdef test_miSim < matlab.unittest.TestCase
|
||||
% Run the simulation
|
||||
tc.testClass.run();
|
||||
end
|
||||
|
||||
function test_obstacle_blocks_comms_LOS(tc)
|
||||
% Fixed single obstacle
|
||||
% Fixed two agents initial conditions
|
||||
@@ -565,8 +565,8 @@ classdef test_miSim < matlab.unittest.TestCase
|
||||
tc.obstacles{1} = tc.obstacles{1}.initialize([tc.domain.center(1:2) - obstacleLength, 0; tc.domain.center(1:2) + obstacleLength, tc.domain.maxCorner(3)], REGION_TYPE.OBSTACLE, "Obstacle 1");
|
||||
|
||||
% Initialize the simulation
|
||||
tc.testClass = tc.testClass.initialize(tc.domain, tc.domain.objective, tc.agents, 0, tc.timestep, tc.partitoningFreq, 125, tc.obstacles, tc.makeVideo);
|
||||
|
||||
tc.testClass = tc.testClass.initialize(tc.domain, tc.domain.objective, tc.agents, 0, tc.timestep, tc.partitoningFreq, 125, tc.obstacles, false, false);
|
||||
|
||||
% No communications link should be established
|
||||
tc.assertEqual(tc.testClass.adjacency, logical(eye(2)));
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user