Merge remote-tracking branch 'origin/ahmed' into lbaumberger

This commit is contained in:
lbaumberger
2026-04-27 14:54:27 +02:00
9 changed files with 36 additions and 1000011 deletions
+13
View File
@@ -0,0 +1,13 @@
# Build artifacts
*.o
*.out
sim
main
positions.csv
test.mp4
test_run_out.mp4
main_test_visualisation
# Editor files
.vscode/
.DS_Store
-5
View File
@@ -18,14 +18,9 @@ double g(double v_max_alpha, double w_alpha_norm) {
} }
// # 8 flops // # 8 flops
//
// $\vec{F}_\alpha(\vec{v}_\alpha, v^0_\alpha \vec{e}_\alpha) \vec{e}_\alpha(t) = \frac{1}{\tau_\alpha}(v^0_\alpha \vec{e}_\alpha - \vec{v}_\alpha)$
//
void compute_acceleration_term(Pedestrian *p) { void compute_acceleration_term(Pedestrian *p) {
// # 2 flops // # 2 flops
// $v_{\alpha}^{0}\vec{e}_{\alpha}$
Vector2d desired_velocity = p->e * p->desired_v0; Vector2d desired_velocity = p->e * p->desired_v0;
// $\vec{v}_{\alpha}(t)$
Vector2d actual_velocity = p->curr_vel; Vector2d actual_velocity = p->curr_vel;
// # 6 flops = 4 ADDs, 2 DIVs // # 6 flops = 4 ADDs, 2 DIVs
p->f_i += (desired_velocity - actual_velocity) / tau_alpha; p->f_i += (desired_velocity - actual_velocity) / tau_alpha;
BIN
View File
Binary file not shown.
+23 -5
View File
@@ -60,12 +60,30 @@ Pedestrian *init_pedestrians(int n_p) {
int main(int argc, const char *argv[]) { int main(int argc, const char *argv[]) {
Obstacle obs[] = {}; // Check command line arguments
Board board = Board(BOARD_LENGTH, BOARD_WIDTH, 0, obs); if (argc < 3) {
printf("Usage: ./sim <number_of_pedestrians> <number_of_iterations>\n");
printf(" number_of_iterations: each iteration = %.2f seconds of simulation time\n", dt);
return 1;
}
// Parse command line arguments
int n_p = atoi(argv[1]); int n_p = atoi(argv[1]);
int n_iter = atoi(argv[2]); int n_iter = atoi(argv[2]);
if (n_p <= 0) {
printf("Error: <number_of_pedestrians> must be a positive integer, got '%s'\n", argv[1]);
return 1;
}
if (n_iter <= 0) {
printf("Error: <number_of_iterations> must be a positive integer, got '%s'\n", argv[2]);
return 1;
}
Obstacle obs[] = {};
Board board = Board(BOARD_LENGTH, BOARD_WIDTH, 0, obs);
// Logic to get/dump the simulation data // Logic to get/dump the simulation data
const int dump_interval = 50; // dump every 5 iterations -> 20 fps (since dt = 0.01) const int dump_interval = 50; // dump every 5 iterations -> 20 fps (since dt = 0.01)
const char *dump_path = (argc >= 4) ? argv[3] : nullptr; const char *dump_path = (argc >= 4) ? argv[3] : nullptr;
@@ -123,6 +141,9 @@ int main(int argc, const char *argv[]) {
// //
p.curr_pos = p.curr_pos + p.curr_vel * dt; p.curr_pos = p.curr_pos + p.curr_vel * dt;
// # 10 flops = 5 ADDs, 2 DIVs, 1 SQRT, 2 MULTs
p.e = (p.destination - p.curr_pos) / (p.destination - p.curr_pos).norm();
// how to handle if a pedestrian reached the end of our simulation/end of the hallway // how to handle if a pedestrian reached the end of our simulation/end of the hallway
// The option we do here is to just "teleport" the person back to the beginning // The option we do here is to just "teleport" the person back to the beginning
// the good thing is we will have a constant flow of pedestrians and in the simulation we should see how lines build up // the good thing is we will have a constant flow of pedestrians and in the simulation we should see how lines build up
@@ -136,9 +157,6 @@ int main(int argc, const char *argv[]) {
// p.destination.y = p.curr_pos.y; // p.destination.y = p.curr_pos.y;
} }
// # 10 flops = 5 ADDs, 2 DIVs, 1 SQRT, 2 MULTs
p.e = (p.destination - p.curr_pos) / (p.destination - p.curr_pos).norm();
// if we have a dump path/file we wanna save the data for visualisation // if we have a dump path/file we wanna save the data for visualisation
if (dump_path && (t % dump_interval == 0)) { if (dump_path && (t % dump_interval == 0)) {
samples.emplace_back(t, i, p.curr_pos.x, p.curr_pos.y, p.color); samples.emplace_back(t, i, p.curr_pos.x, p.curr_pos.y, p.color);
Binary file not shown.
-1000001
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 MiB

BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.