Revert "Merge branch 'smail' into lbaumberger"

This reverts commit 1cf29bfdd8, reversing
changes made to 1b79bd15f4.
This commit is contained in:
lbaumberger
2026-04-27 14:36:20 +02:00
parent d7a8154bbe
commit 5e738642fd
4 changed files with 58 additions and 25 deletions
+45 -16
View File
@@ -2,14 +2,15 @@
#include "forces.hpp"
#include "math.h"
#include "pedestrian.hpp"
#include "tsc_x86.h"
#include "vector2d.hpp"
#include <fstream>
#include <iostream>
#include <tuple>
#include <vector>
double g(double v_max_alpha, double w_alpha_norm) {
if (w_alpha_norm <= v_max_alpha) {
return 1;
}
return v_max_alpha / w_alpha_norm;
}
#define BOARD_WIDTH 10.0
#define BOARD_LENGTH 50.0
using namespace std;
@@ -23,20 +24,44 @@ using namespace std;
Pedestrian *init_pedestrians(int n_p) {
Pedestrian *P = new Pedestrian[n_p];
for (int i = 0; i < n_p; i++) {
P[i] = Pedestrian();
std::random_device rd; // use for truly random simulation
// std::mt19937 gen(rd()); // use rd instead of 42 as seed for real randomness
std::mt19937 gen(42); // use fixed seed for reproducibility
std::normal_distribution<double> velocity_gen(1.34, 0.26); // 1.34 and 0.26 are the mean and stdrd deviation used in paper
std::uniform_real_distribution<double> x_gen(2, BOARD_LENGTH - 2);
std::uniform_real_distribution<double> y_gen(2, BOARD_WIDTH - 2);
for (int i = 0; i < n_p / 2; i++) {
double y = y_gen(gen);
Vector2d start_pos = Vector2d(x_gen(gen), y);
Vector2d destination = Vector2d(BOARD_LENGTH + 300, BOARD_WIDTH / 2);
// double desired_v0 = velocity_gen(gen);
double desired_v0;
do {
desired_v0 = velocity_gen(gen);
} while (desired_v0 <= 0.1); // to avoid small values (Way below the social force -> that would make the walk backwards) (we discovered some weird stuff in the simulation)
double v_max = 1.3 * desired_v0;
P[i] = Pedestrian(WHITE, (destination - start_pos) / (destination - start_pos).norm() * desired_v0, start_pos, (destination - start_pos) / (destination - start_pos).norm(), v_max, desired_v0, destination, Vector2d());
}
for (int i = n_p / 2; i < n_p; i++) {
double y = y_gen(gen);
Vector2d start_pos = Vector2d(x_gen(gen), y);
Vector2d destination = Vector2d(-300, BOARD_WIDTH / 2);
// double desired_v0 = velocity_gen(gen);
double desired_v0;
do {
desired_v0 = velocity_gen(gen);
} while (desired_v0 <= 0.1);
double v_max = 1.3 * desired_v0;
P[i] = Pedestrian(BLACK, (destination - start_pos) / (destination - start_pos).norm() * desired_v0, start_pos, (destination - start_pos) / (destination - start_pos).norm(), v_max, desired_v0, destination, Vector2d(0, 0));
}
return P;
}
Board init_board(int width, int length) {
Vector2d obs[] = {Vector2d(2.0, 1.0), Vector2d(4.0, 1.0), Vector2d(6.0, 2.0), Vector2d(6.0, 4.0)};
return Board(width, length, 4, obs);
}
int main(int argc, const char *argv[]) {
Board B = init_board(10, 15);
Obstacle obs[] = {};
Board board = Board(BOARD_LENGTH, BOARD_WIDTH, 0, obs);
int n_p = atoi(argv[1]);
int n_iter = atoi(argv[2]);
@@ -51,13 +76,17 @@ int main(int argc, const char *argv[]) {
Pedestrian *pedestrians = init_pedestrians(n_p);
for (int t = 0; t < n_iter; t++) {
// # Start here or right after function signature
uint64_t start = start_tsc();
// # (8 + 55N - 55 + 192 + 4 + 8 + 4 + 10)*n_p*n_iter
for (int t = 0; t < n_iter; t++) {
// Pass1: conmpute all forces from the current state
for (int i = 0; i < n_p; i++) {
Pedestrian &p = pedestrians[i];
p.F_i.reset();
p.f_i.reset();
// # 8 flops
//