started plot3 work
This commit is contained in:
29
plot1.m
29
plot1.m
@@ -38,11 +38,20 @@ for ii = 1:length(simHists)
|
|||||||
assert(hist.out.agent(jj).commsRadius == commsRadius(ii));
|
assert(hist.out.agent(jj).commsRadius == commsRadius(ii));
|
||||||
assert(hist.out.agent(jj).collisionRadius == collisionRadius(ii));
|
assert(hist.out.agent(jj).collisionRadius == collisionRadius(ii));
|
||||||
end
|
end
|
||||||
|
|
||||||
|
alphaDist2 = unique(alphaDist);
|
||||||
|
if length(alphaDist2) > 1
|
||||||
|
alphaDist2 = alphaDist2(1);
|
||||||
|
end
|
||||||
|
if doubleIntegrator(ii) && unique(alphaDist(:, ii)) == alphaDist2 && numObjective(ii) == 1
|
||||||
|
a2betaIdx = ii;
|
||||||
|
a2beta = struct("init", init, "hist", hist.out);
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
commsRadius = unique(commsRadius); assert(isscalar(commsRadius));
|
commsRadius = unique(commsRadius); assert(isscalar(commsRadius));
|
||||||
collisionRadius = unique(collisionRadius); assert(isscalar(collisionRadius));
|
collisionRadius = unique(collisionRadius); assert(isscalar(collisionRadius));
|
||||||
sensors = unique(alphaDist(1, :));
|
sensors = flip(unique(alphaDist(1, :)));
|
||||||
|
|
||||||
config = [];
|
config = [];
|
||||||
for ii = 1:length(simHists)
|
for ii = 1:length(simHists)
|
||||||
@@ -72,6 +81,7 @@ for ii = 1:length(simHists)
|
|||||||
config = [config; s];
|
config = [config; s];
|
||||||
end
|
end
|
||||||
|
|
||||||
|
%%
|
||||||
close all;
|
close all;
|
||||||
f1 = figure;
|
f1 = figure;
|
||||||
x1 = axes;
|
x1 = axes;
|
||||||
@@ -91,6 +101,7 @@ legend(["$AI\alpha$"; "$AI\beta$"; "$AII\alpha$"; "$BI\beta$"], "Interpreter", "
|
|||||||
grid("on");
|
grid("on");
|
||||||
ylim([0, 1]);
|
ylim([0, 1]);
|
||||||
|
|
||||||
|
%%
|
||||||
f2 = figure;
|
f2 = figure;
|
||||||
x2 = axes;
|
x2 = axes;
|
||||||
|
|
||||||
@@ -154,4 +165,18 @@ grid(x2, "on");
|
|||||||
yline(collisionRadius, 'r--', "Label", "Collision Radius", "LabelHorizontalAlignment", "left", "HandleVisibility", "off");
|
yline(collisionRadius, 'r--', "Label", "Collision Radius", "LabelHorizontalAlignment", "left", "HandleVisibility", "off");
|
||||||
yline(commsRadius, 'r--', "Label", "Communications Radius", "LabelHorizontalAlignment", "left", "HandleVisibility", "off");
|
yline(commsRadius, 'r--', "Label", "Communications Radius", "LabelHorizontalAlignment", "left", "HandleVisibility", "off");
|
||||||
|
|
||||||
ylim([0, inf]);
|
ylim([0, inf]);
|
||||||
|
|
||||||
|
f3 = figure;
|
||||||
|
x3 = axes;
|
||||||
|
assert(size(a2beta.init.objectivePos, 1) == 1)
|
||||||
|
assert(a2beta.hist.useDoubleIntegrator);
|
||||||
|
assert(a2beta.hist.agent(1).sensor.alphaDist == sensors(2))
|
||||||
|
|
||||||
|
plot(a2beta.hist.perf./a2beta.init.objectiveIntegral);
|
||||||
|
hold("on");
|
||||||
|
for ii = 1:length(a2beta.hist.agent)
|
||||||
|
plot(a2beta.hist.agent(ii).perf./a2beta.init.objectiveIntegral);
|
||||||
|
end
|
||||||
|
grid("on");
|
||||||
|
xlabel("Performance");
|
||||||
@@ -266,8 +266,52 @@ classdef results < matlab.unittest.TestCase
|
|||||||
close all;
|
close all;
|
||||||
end
|
end
|
||||||
function AIIbeta_plots_3_4(tc)
|
function AIIbeta_plots_3_4(tc)
|
||||||
|
% test-specific parameters
|
||||||
|
maxIters = 400;
|
||||||
|
|
||||||
configs = results.makeConfigs();
|
configs = results.makeConfigs();
|
||||||
config = configs.A_2_alpha;
|
c = configs.A_2_alpha;
|
||||||
|
|
||||||
|
% Set up fixed-size domain
|
||||||
|
minAlt = tc.domainSize(3)/10 + rand * 1/10 * tc.domainSize(3);
|
||||||
|
tc.testClass.domain = tc.testClass.domain.initialize([zeros(1, 3); tc.domainSize], REGION_TYPE.DOMAIN, "Domain");
|
||||||
|
|
||||||
|
% Set objective
|
||||||
|
objectiveMu = [tc.domainSize(1) * 2 / 3, tc.domainSize(2) * 3 / 4];
|
||||||
|
objectiveSigma = reshape([215, 100; 100, 175], [1, 2, 2]);
|
||||||
|
tc.testClass.domain.objective = tc.testClass.domain.objective.initialize(objectiveFunctionWrapper(objectiveMu, objectiveSigma), tc.testClass.domain, tc.discretizationStep, tc.protectedRange, tc.sensorPerformanceMinimum, objectiveMu, objectiveSigma);
|
||||||
|
|
||||||
|
% Set agent initial states (fully connected network of 4)
|
||||||
|
centerPos = [tc.domainSize(1) / 4, tc.domainSize(2) / 4];
|
||||||
|
d = tc.collisionRadius + (tc.comRange - tc.collisionRadius) / 4;
|
||||||
|
agentsPos = centerPos + [1, 1; 1, -1; -1, -1; -1, 1] / sqrt(2) * d;
|
||||||
|
agentAlt = minAlt * 1.5;
|
||||||
|
agentsPos = [agentsPos, agentAlt * ones(4, 1) + rand * 5 - 2.5];
|
||||||
|
|
||||||
|
agents = {agent, agent, agent, agent};
|
||||||
|
cg = spherical;
|
||||||
|
sensorModel = sigmoidSensor;
|
||||||
|
sensorModel = sensorModel.initialize(c.sensor.alphaDist, c.sensor.betaDist, c.sensor.alphaTilt, c.sensor.betaTilt);
|
||||||
|
agents{1} = agents{1}.initialize(agentsPos(1, :), cg.initialize(agentsPos(1, :), tc.collisionRadius, REGION_TYPE.COLLISION, "Agent 1 Collision Geometry"), sensorModel, tc.comRange, maxIters, tc.initialStepSize, "Agent 1", false);
|
||||||
|
agents{2} = agents{2}.initialize(agentsPos(2, :), cg.initialize(agentsPos(2, :), tc.collisionRadius, REGION_TYPE.COLLISION, "Agent 2 Collision Geometry"), sensorModel, tc.comRange, maxIters, tc.initialStepSize, "Agent 2", false);
|
||||||
|
agents{3} = agents{3}.initialize(agentsPos(3, :), cg.initialize(agentsPos(3, :), tc.collisionRadius, REGION_TYPE.COLLISION, "Agent 3 Collision Geometry"), sensorModel, tc.comRange, maxIters, tc.initialStepSize, "Agent 3", false);
|
||||||
|
agents{4} = agents{4}.initialize(agentsPos(4, :), cg.initialize(agentsPos(4, :), tc.collisionRadius, REGION_TYPE.COLLISION, "Agent 4 Collision Geometry"), sensorModel, tc.comRange, maxIters, tc.initialStepSize, "Agent 4", false);
|
||||||
|
|
||||||
|
obstacles = cell(1, 1);
|
||||||
|
obstacles{1} = rectangularPrism;
|
||||||
|
obstacles{1} = obstacles{1}.initialize([0, tc.domainSize(2)/2, 0; tc.domainSize(1) * 0.4, tc.domainSize(2), 40],REGION_TYPE.OBSTACLE, "Obstacle 1");
|
||||||
|
|
||||||
|
% Set up simulation
|
||||||
|
tc.testClass = tc.testClass.initialize(tc.testClass.domain, agents, tc.barrierGain, tc.barrierExponent, minAlt, tc.timestep, maxIters, obstacles, tc.makePlots, tc.makeVideo, c.doubleIntegrator, tc.dampingCoeff, tc.useFixedTopology);
|
||||||
|
|
||||||
|
% Save simulation parameters to output file
|
||||||
|
tc.testClass.writeInits();
|
||||||
|
|
||||||
|
% Run
|
||||||
|
tc.testClass = tc.testClass.run();
|
||||||
|
|
||||||
|
% Cleanup
|
||||||
|
tc.testClass = tc.testClass.teardown();
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user