-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsocialdistancing.m
55 lines (50 loc) · 1.13 KB
/
socialdistancing.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
%% Determines the best starting configuration
% Justin Stevens
% June 1st, 2020
%% preliminary
close all
clear
clc
%% length of the bar
long=25;
gap=6;
% best length found so far
bestL=0;
bestF=0;
bestIC=[];
colorD=distinguishable_colors(long);
%% iterate over all the possible seats
for i=1:long
IC=[i];
bestV=gap;
while(bestV>=gap)
[bestI, bestV]=gen_move(IC, long);
if(bestI && bestV>=gap)
IC=[IC, bestI];
end
end
%% find length of best iteration
L=length(IC);
%% scatter y-coordinates
vec=zeros(L, 1);
positions=[1:L];
vec(positions)=i;
sz=linspace(125, 25, L);
scatter(IC(1:L), vec, sz, colorD(i, :), 'filled');
hold on;
%% update if it's better
if(L>bestL)
bestL=L;
bestF=i;
bestIC=IC;
end
end
vec=zeros(bestL, 1);
positions=[1:bestL];
vec(positions)=bestF;
sz2=linspace(225, 125, bestL);
scatter(bestIC(1:bestL), vec, sz2, colorD(bestF, :), 'p');
str=sprintf('Plot of Seating Configurations for a Table of Length %d and Gap %d', long, gap);
title(str);
xlabel("Seat Configuration");
ylabel("Location of First Person");