Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
6274787
Update README.md
hornel Oct 22, 2017
93a2070
Added research proposal
Oct 22, 2017
9b7f077
Added flash talk slide
Oct 22, 2017
aee4c25
06.11.17
johannahed Nov 6, 2017
f4a1864
Added some function skeletons
Nov 8, 2017
6cade8c
Performed basic initialization of the position matrix
Nov 8, 2017
a748bad
Added some comments on the structure of the position matrix
Nov 8, 2017
8d19c5d
More efficient initialization of ArrayLists
Nov 8, 2017
d22980d
Parallelized initialization of matrix
Nov 8, 2017
b4601fc
Added some notes about iterating through sectors
hornel Nov 9, 2017
5d3c9aa
Added some more general notes
hornel Nov 9, 2017
61ea163
Updated code to use LinkedList (more efficient removal)
Nov 9, 2017
5be3f5f
Initialized individuals with random coordinates
Nov 11, 2017
5ff4aa8
Implemented getNeighbors
Nov 11, 2017
dd3fb4e
"Updated skeleton to remove unnecessary functions"
Nov 11, 2017
23e4e0a
"Assigned random velocity to individuals"
Nov 11, 2017
dface21
"Run one timestep in test"
Nov 11, 2017
775aa16
"Created skeleton for running one timestep"
Nov 11, 2017
d52820c
Updated README
hornel Nov 11, 2017
af7751a
Added some comments
hornel Nov 11, 2017
bcad73d
Update runOneTimestep.m
johannahed Nov 12, 2017
d3fcbd2
Implemented new function from code.m. Iterating over neighbors using …
hornel Nov 12, 2017
c2da9cd
Added location of code skeleton
hornel Nov 12, 2017
3d6ab27
Changed parameters from paper into globals. Adjusted calculation of f…
Nov 13, 2017
80fb418
create plot
Nov 13, 2017
bb88073
a script to display the matrix
Nov 13, 2017
4db6d65
Created temporary plotting solution. Refined plotMatrix.
hornel Nov 14, 2017
818a3cd
Fixed bugs related to vector dimensions
Nov 15, 2017
2b54ea5
Fixed more bugs related to vector dimensions
hornel Nov 15, 2017
8c920bc
Fixed one more dimension-related bug
hornel Nov 15, 2017
4a40960
Removed debug output
hornel Nov 15, 2017
faa6f0f
Debugged calculation of forces
hornel Nov 15, 2017
0dea6ec
Started porting to Java
hornel Nov 16, 2017
7ed54fe
Implemented getNeighbors. Added comments for clarity.
hornel Nov 16, 2017
5ba5fb9
Added code skeleton to Simulation class
hornel Nov 16, 2017
db8e889
Created README.md
hornel Nov 17, 2017
70b4c89
Implemented runOneTimestep. Added code for testing & timing.
hornel Nov 17, 2017
ca0d2aa
Added graphics. Fixed bugs in runOneTimestep.
hornel Nov 18, 2017
1260e11
Added code for coloring individual according to isParticipating
hornel Nov 20, 2017
d0bcc5f
Added code for coloring individual according to isParticipating
hornel Nov 22, 2017
64dffab
Fixed bug where window was not repainted on Windows and Linux
hornel Nov 22, 2017
8369089
Update Simulation.java
johannahed Nov 22, 2017
210b9fc
Update Individual.java
johannahed Nov 22, 2017
5968933
Update Simulation.java
johannahed Nov 22, 2017
2396e0a
added GUI controls
Nov 22, 2017
f0015b3
added GUI controls
Nov 22, 2017
95cf565
Reinstated Test.java
hornel Nov 23, 2017
062ec9b
Cleaned up GUI code
hornel Nov 23, 2017
cf921e9
Added new folder
hornel Nov 26, 2017
4730c7b
implemented a basic isPartecipating algorithm
mrPaga Nov 26, 2017
335ef8d
Delete deletethis.txt
mrPaga Nov 26, 2017
4ac0e67
Cleaned up code & merged into src. Added propulsion and controls for µ.
hornel Nov 27, 2017
3a3d603
Implemented various enhancements and changes, including:
hornel Nov 27, 2017
5b246fc
Added new controls to ControlPanel
hornel Nov 30, 2017
ab5772f
Update README.md
hornel Nov 30, 2017
dd31dcd
Added code for isParticipating
hornel Dec 2, 2017
20a2e68
Added danger level
Dec 2, 2017
f3cf89f
Formatting fixes
Dec 2, 2017
9504f6d
Cleaned up code for danger level
hornel Dec 2, 2017
4155cc4
added force level
Dec 2, 2017
f110ffa
Added policemen
hornel Dec 2, 2017
4c024f2
Added white circle for non-participating individuals
hornel Dec 2, 2017
dac236c
modified controlPanel, SimulationGUI
Dec 2, 2017
435ec13
added participating button
Dec 2, 2017
68e83ce
Added export function
hornel Dec 2, 2017
f629113
definition of danger levels based on density and forces
johannahed Dec 2, 2017
08beb12
Added export function
hornel Dec 2, 2017
d546ee1
johannahed Dec 2, 2017
86b7789
added force/density effects
Dec 2, 2017
1fb6929
Added button for exporting data
hornel Dec 2, 2017
42eab5b
fixed color of danger levels
johannahed Dec 2, 2017
b471c76
improved danger level limits
johannahed Dec 2, 2017
bfa7de2
Added new export data
hornel Dec 2, 2017
43bb023
Merge remote-tracking branch 'origin/master'
hornel Dec 2, 2017
8782ece
Added new export data
hornel Dec 2, 2017
7701369
Added average danger indicator
mrPaga Dec 2, 2017
317f036
Merged PoliceSimulation and Simulation
hornel Dec 2, 2017
d7c9818
Merge remote-tracking branch 'origin/master'
hornel Dec 2, 2017
d666cc8
Test
Dec 2, 2017
5ffde81
Update SimulationPanel.java
Dec 2, 2017
0551f8f
adde policeman
Dec 2, 2017
a2a59f3
Added method to add policemen by clicking
hornel Dec 2, 2017
d1cd7e3
Adjusted Main's values
mrPaga Dec 2, 2017
b3b045d
Exported to Python file
hornel Dec 2, 2017
b37b413
Merge remote-tracking branch 'origin/master'
hornel Dec 2, 2017
70a9961
Create Data_Analysis
johannahed Dec 2, 2017
f6a1ec6
Various formatting & minor bug fixes
hornel Dec 2, 2017
695d6e4
Initialization from random seed and support for multiple output files
hornel Dec 8, 2017
716ccc5
Create data_analysis.py
hornel Dec 8, 2017
b996efb
Delete Data_Analysis
hornel Dec 8, 2017
a600b0b
Update data_analysis.py
johannahed Dec 8, 2017
942e580
Fixed bugs in data_analysis
hornel Dec 8, 2017
fd83b1b
Update data_analysis.py
johannahed Dec 8, 2017
90b2af1
Dec 8, 2017
bb0ad84
Added code for telling Python how many simulations were executed
hornel Dec 8, 2017
3052ed3
johannahed Dec 8, 2017
7b1ad99
fixed bug in data_analysis
johannahed Dec 8, 2017
4500d9b
Added automatic data collector
hornel Dec 8, 2017
8619c9e
Made data collection deterministic
hornel Dec 8, 2017
3bd96df
added phase diagram
mrPaga Dec 8, 2017
e7021f2
Moved counter.py to test set
hornel Dec 8, 2017
7904c05
Merge remote-tracking branch 'origin/master'
hornel Dec 8, 2017
d541a31
Added automatic simulation & data collection based on config files
hornel Dec 9, 2017
74a6d35
Delete data_analysis2.py
mrPaga Dec 9, 2017
774767b
phase diagram for single out.py file
mrPaga Dec 9, 2017
dd618c9
Delete phase_diagram.py
mrPaga Dec 9, 2017
96e90f0
phase diagram for analysis of single out.py file
mrPaga Dec 9, 2017
991ab17
Added comments & cleaned up code. DataCollector now creates __init__.py.
hornel Dec 9, 2017
8e7c78e
phase diagram for multiple 'out%s.py' files
mrPaga Dec 10, 2017
64797fa
Create timeEvolution.py
johannahed Dec 11, 2017
e503de6
Rename timeEvolution.py to java_code/timeEvolution.py
johannahed Dec 11, 2017
c45989c
Fixed bug in DataCollector & enabled importing from different folders
hornel Dec 11, 2017
6f3b4c2
uploaded some new config files
johannahed Dec 11, 2017
f6a31ab
Removed print statements from timeEvolution and DataCollector
hornel Dec 11, 2017
ec33ae3
change graph ouput format to png
Dec 11, 2017
9784b90
Added compatibility with Java 5
hornel Dec 11, 2017
cce3397
modifid the scirpts to call multiple graphs
Dec 11, 2017
938aa3b
added some new configs
johannahed Dec 11, 2017
08a3007
Changed config parameters to be uniform for data collection
hornel Dec 11, 2017
611c320
Increased compatibility with Java 5. Fixed bugs in config files.
hornel Dec 11, 2017
39d8ae3
Now outputting continuous danger levels and median danger level
hornel Dec 12, 2017
ac18dda
timeEvolution plots median instead of average
johannahed Dec 12, 2017
6a6d808
new version
johannahed Dec 15, 2017
7078bf7
modify phase_diagram_multi
Dec 15, 2017
e1a115c
density and forces to continuousDangerLevel phase diagram
mrPaga Dec 15, 2017
bae01b0
Updated configGuide to match the report
hornel Dec 16, 2017
41e511a
Merge remote-tracking branch 'origin/master'
hornel Dec 16, 2017
2e00eff
Cleaned up code to wrap to 80 columns (to fit in report)
hornel Dec 16, 2017
3d83bf4
Hopefully fixed bug due to encoding of Greek letters
hornel Dec 16, 2017
a56422e
Update timeEvolution.py
johannahed Dec 17, 2017
4faecf3
Update timeEvolution.py
johannahed Dec 17, 2017
bba9ba7
Update timeEvolution.py
johannahed Dec 17, 2017
88bb0c5
Update timeEvolution.py
johannahed Dec 17, 2017
9605dc4
Cleaned up Python code
hornel Dec 17, 2017
71ce571
Added report
hornel Dec 17, 2017
be40464
New version of report
hornel Dec 17, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# MATLAB Fall 2014 – Research Plan (Template)
# MATLAB Fall 2017 – Research Plan (Template)
(text between brackets to be removed)

> * Group Name: (be creative!)
Expand Down
100 changes: 100 additions & 0 deletions code.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
%{
GENERAL NOTES
=============

Each function should be defined in a separate file according
to MATLAB requirements. Upload these files to the code folder
in the repository.
When iterating over the matrix, if possible, parallelize the
accesses using parfor to increase efficiency. To iterate over
the people inside of one sector, use the following piece of
code:

itr = matrix(i, j).iterator();

while itr.hasNext()
person = itr.next();
% Do something with that person
end

Inside the matrix, the position of the individual is represented in
absolute terms (i.e. relative to the entire matrix, not the sector). For
precision reasons, the coordinates range from 0 to 10 * resolution (for
now, we can always make it finer-grained by changing the SECTOR_SIZE
global).

To convert coordinates to a sector, use the function
sectorForCoords(individual). You can also pass pure coordinates to this
function.

Define all globals in the runSimulation.m file. This way, the parameters of
the simulation are easy to find and change.

=============
%}

% Definition of individual

%{
An individual is a vector with
- positionX
- positionY
- velocityX
- velocityY
- isParticipating in moshpit
%}

%{
Initializes the position matrix. The ground covered by the people
attending the concert is divided into sectors. The people in
each sector are represented with a java.util.LinkedList.
The coordinates of each person are given as absolute coordinates,
i.e. not relative to the sector, but to the entire matrix.
%}
function initializeMatrix()
end

% Gets the position of the given individual
function [position] = getPosition(individual)
end

% Gets the velocity of the given individual
function [velocity] = getVelocity(individual)
end

% Returns true if the given individual is participating in the circle pit
function [isParticipating] = isParticipating(individual)
end

% Returns the distance between two individuals
function [distance] = distance(individual1, individual2)
end

%{
Returns the neighbors of the given individual as a matrix where each column
is an individual.
%}
function [neighbors] = getNeighbors(individual)
end

% TODO
%{
Main loop that iterates through the individuals and updates all their
positions, returning the modified main matrix.
%}
function runOneTimestep(matrix)
end

% TODO
%{
Runs the simulation.
%}
function runSimulation()
initializeMatrix();
for i = 1:MAX
runOneTimestep(matrix);
end
end



5 changes: 4 additions & 1 deletion code/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Code Folder

Your code goes here. You could also replace the content of this file with something more meaningful
Contains the code for the MATLAB implementation of the project.
The structure of the code is laid out in the `code.m` file in the root directory of the repository.

__WARNING__: The MATLAB version was retired on November 17, 2017 and is obsolete. We have moved to Java for speed reasons. See the `java_code` folder for the most recent version.
8 changes: 8 additions & 0 deletions code/createIndividual.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function [individual] = createIndividual(coordinates, velocity, isParticipating)
%CREATEINDIVIDUAL Creates a new individual
% Creates a new vector representing an individual with the specified
% properties.
individual = [coordinates(1); coordinates(2); velocity(1); velocity(2); isParticipating];

end

12 changes: 12 additions & 0 deletions code/distance.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function distance = distance(individual1, individual2)
%DISTANCE Gets the distance between two individuals.
x1 = individual1(1);
y1 = individual1(2);
x2 = individual2(1);
y2 = individual2(2);

dx = x1 - x2;
dy = y1 - y2;

distance = sqrt(dx*dx + dy*dy);
end
69 changes: 69 additions & 0 deletions code/getNeighbors.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
function [individuals] = getNeighbors(individual, radius)
%GETNEIGHBORS Gets the neighbors of the given individual
% Gets the neighbors of an individual in the radius specified by the
% NEIGHBOR_SEARCH_RADIUS global. Returns these individuals as columns in
% a matrix.

individuals = [];

global matrix;

% Get location of the individual
coords = getPosition(individual);
sector = sectorForCoords(coords);

% Get the sectors where we need to search
sectorsToSearch = sector;
northSector = sectorForCoords(coords - [0; radius]);
if ~isequal(northSector, sector)
sectorsToSearch = [sectorsToSearch, northSector];
end

southSector = sectorForCoords(coords + [0; radius]);
if ~isequal(southSector, sector)
sectorsToSearch = [sectorsToSearch, southSector];
end

westSector = sectorForCoords(coords - [radius; 0]);
if ~isequal(westSector, sector)
sectorsToSearch = [sectorsToSearch, westSector];
end

eastSector = sectorForCoords(coords + [radius; 0]);
if ~isequal(eastSector, sector)
sectorsToSearch = [sectorsToSearch, eastSector];
end

northEastSector = sectorForCoords(coords + [radius; -radius]);
if ~isequal(northEastSector, sector)
sectorsToSearch = [sectorsToSearch, northEastSector];
end

northWestSector = sectorForCoords(coords + [-radius; -radius]);
if ~isequal(northWestSector, sector)
sectorsToSearch = [sectorsToSearch, northWestSector];
end

southEastSector = sectorForCoords(coords + [radius; radius]);
if ~isequal(southEastSector, sector)
sectorsToSearch = [sectorsToSearch, southEastSector];
end

southWestSector = sectorForCoords(coords + [-radius; radius]);
if ~isequal(southWestSector, sector)
sectorsToSearch = [sectorsToSearch, southWestSector];
end

% Search over those vectors
for k = 1:size(sectorsToSearch, 2)
i = sectorsToSearch(1, k);
j = sectorsToSearch(2, k);
itr = matrix(i, j).iterator();
while itr.hasNext()
person = itr.next();
if distance(individual, person) < radius
individuals = [individuals, person];
end
end
end
end
5 changes: 5 additions & 0 deletions code/getPosition.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function [position] = getPosition(individual)
%GETPOSITION Gets the position of the given individual.
position = [individual(1); individual(2)];
end

4 changes: 4 additions & 0 deletions code/getVelocity.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function [velocity] = getVelocity(individual)
%GETVELOCITY Gets the velocity of the given individual.
velocity = [individual(3); individual(4)];
end
29 changes: 29 additions & 0 deletions code/getXY.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
function [X, Y] = getXY()
%GETXY Gets the x and y coordinates of all the individuals for plotting.
% Stores the x coordinates of all the individuals in X and the
% corresponding y coordinates in Y.
% TODO: Find a way to separate the people based on isParticipating

global matrix;
global NUMBER_OF_PEOPLE;

X = zeros(NUMBER_OF_PEOPLE, 1);
Y = zeros(NUMBER_OF_PEOPLE, 1);

k = 1;

for i = 1:matrix.length
for j = 1:matrix(i).length
itr = matrix(i, j).iterator();
while itr.hasNext()
individual = itr.next();
position = getPosition(individual);
X(k) = position(1);
Y(k) = position(2);
k = k + 1;
end
end
end

end

46 changes: 46 additions & 0 deletions code/initializeMatrix.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

function [matrix] = initializeMatrix(resolution, numberOfPeople)
%INITIALIZEMATRIX Initializes the position matrix used by the simulation.
% The matrix is a low-resolution representation of the people at the
% concert and is divided into "sectors". Each sector can contain several
% people (whose position is defined by their x and y coordinates). The
% matrix initially contains numberOfPeople people. Each sector is a
% reference to a java.util.ArrayList which contains a list of the people
% currently in that sector.

% Initialize a matrix of the proper size
width = resolution(1);
height = resolution(2);

global SECTOR_SIZE;

% We have to use a Java array because MATLAB matrices cannot store Java
% objects
matrix = javaArray('java.util.LinkedList', width, height);

for i = 1:width
for j = 1:height
matrix(i, j) = javaObject('java.util.LinkedList');
end
end

for i = 1:numberOfPeople
% Generate random coordinates
coords(1) = rand() * width * SECTOR_SIZE;
coords(2) = rand() * height * SECTOR_SIZE;

% Generate random velocity
% TODO: Generate more sensible velocity
velocity = [rand() - 0.5; rand() - 0.5];

% TODO: Decide whether individual is participating
isParticipating = false;

individual = createIndividual(coords, velocity, isParticipating);

% Add individual to appropriate sector
sector = sectorForCoords(coords);
matrix(sector(1), sector(2)).add(individual);
end

return;
6 changes: 6 additions & 0 deletions code/isParticipating.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function [isParticipating] = isParticipating(individual)
%ISPARTICIPATING Returns true if the given individual is participating in
%the cirle pit.
isParticipating = individual(5);
end

39 changes: 39 additions & 0 deletions code/plotMatrix.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
global matrix;
global INDIVIDUAL_RADIUS;
global SECTOR_SIZE;
global MATRIX_SIZE;

% try
close all
hfig = figure('NumberTitle','off','name','Moshpit simulation','MenuBar','none');
axis([0, SECTOR_SIZE * MATRIX_SIZE, 0, SECTOR_SIZE * MATRIX_SIZE]);
axis off %do not show the coordinator

% while 1
for i = 1:matrix.length
for j = 1:matrix(i).length
disp('Position: ');
disp([i, j]);
list = matrix(i, j);
itr = list.iterator();
while itr.hasNext()
individual = itr.next();
position = getPosition(individual);
x0 = position(1);
y0 = position(2);
if(isParticipating(individual))
%erase mode, if the individual is participating, then
%we draw a red dot, otherwise it's black
head = line(x0, y0, 'color', 'r', 'Marker', '.', 'erasemode', 'xor', 'markersize', INDIVIDUAL_RADIUS * 10);
else
head = line(x0, y0, 'color', 'k', 'Marker', '.', 'erasemode', 'xor', 'markersize', INDIVIDUAL_RADIUS * 10);
end
end
end
end
drawnow; %refresh the screen
% end

% catch
% return
% end
Loading